Changes in / [8fdb18e:ef904895] in mainline
- Location:
- uspace
- Files:
-
- 2 deleted
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/dnsres/dnsres.c
r8fdb18e ref904895 34 34 35 35 #include <errno.h> 36 #include <inet/addr.h>37 36 #include <inet/dnsr.h> 38 37 #include <stdio.h> … … 44 43 { 45 44 printf("syntax: " NAME " <host-name>\n"); 45 } 46 47 static int addr_format(inet_addr_t *addr, char **bufp) 48 { 49 int rc; 50 51 rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24, 52 (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff, 53 addr->ipv4 & 0xff); 54 55 if (rc < 0) 56 return ENOMEM; 57 58 return EOK; 46 59 } 47 60 … … 63 76 } 64 77 65 rc = inet_addr_format(&hinfo->addr, &saddr);78 rc = addr_format(&hinfo->addr, &saddr); 66 79 if (rc != EOK) { 67 80 dnsr_hostinfo_destroy(hinfo); -
uspace/app/inet/inet.c
r8fdb18e ref904895 1 1 /* 2 * Copyright (c) 201 3Jiri Svoboda2 * Copyright (c) 2012 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 37 37 #include <errno.h> 38 #include <inet/addr.h>39 38 #include <inet/inetcfg.h> 40 39 #include <loc.h> … … 55 54 } 56 55 56 static int naddr_parse(const char *text, inet_naddr_t *naddr) 57 { 58 unsigned long a[4], bits; 59 char *cp = (char *)text; 60 int i; 61 62 for (i = 0; i < 3; i++) { 63 a[i] = strtoul(cp, &cp, 10); 64 if (*cp != '.') 65 return EINVAL; 66 ++cp; 67 } 68 69 a[3] = strtoul(cp, &cp, 10); 70 if (*cp != '/') 71 return EINVAL; 72 ++cp; 73 74 bits = strtoul(cp, &cp, 10); 75 if (*cp != '\0') 76 return EINVAL; 77 78 naddr->ipv4 = 0; 79 for (i = 0; i < 4; i++) { 80 if (a[i] > 255) 81 return EINVAL; 82 naddr->ipv4 = (naddr->ipv4 << 8) | a[i]; 83 } 84 85 if (bits > 31) 86 return EINVAL; 87 88 naddr->bits = bits; 89 return EOK; 90 } 91 92 static int addr_parse(const char *text, inet_addr_t *addr) 93 { 94 unsigned long a[4]; 95 char *cp = (char *)text; 96 int i; 97 98 for (i = 0; i < 3; i++) { 99 a[i] = strtoul(cp, &cp, 10); 100 if (*cp != '.') 101 return EINVAL; 102 ++cp; 103 } 104 105 a[3] = strtoul(cp, &cp, 10); 106 if (*cp != '\0') 107 return EINVAL; 108 109 addr->ipv4 = 0; 110 for (i = 0; i < 4; i++) { 111 if (a[i] > 255) 112 return EINVAL; 113 addr->ipv4 = (addr->ipv4 << 8) | a[i]; 114 } 115 116 return EOK; 117 } 118 119 static int naddr_format(inet_naddr_t *naddr, char **bufp) 120 { 121 int rc; 122 123 rc = asprintf(bufp, "%d.%d.%d.%d/%d", naddr->ipv4 >> 24, 124 (naddr->ipv4 >> 16) & 0xff, (naddr->ipv4 >> 8) & 0xff, 125 naddr->ipv4 & 0xff, naddr->bits); 126 127 if (rc < 0) 128 return ENOMEM; 129 130 return EOK; 131 } 132 133 static int addr_format(inet_addr_t *addr, char **bufp) 134 { 135 int rc; 136 137 rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24, 138 (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff, 139 addr->ipv4 & 0xff); 140 141 if (rc < 0) 142 return ENOMEM; 143 144 return EOK; 145 } 146 57 147 static int addr_create_static(int argc, char *argv[]) 58 148 { … … 88 178 } 89 179 90 rc = inet_naddr_parse(addr_spec, &naddr);180 rc = naddr_parse(addr_spec, &naddr); 91 181 if (rc != EOK) { 92 182 printf(NAME ": Invalid network address format '%s'.\n", … … 177 267 route_name = argv[2]; 178 268 179 rc = inet_naddr_parse(dest_str, &dest);269 rc = naddr_parse(dest_str, &dest); 180 270 if (rc != EOK) { 181 271 printf(NAME ": Invalid network address format '%s'.\n", … … 184 274 } 185 275 186 rc = inet_addr_parse(router_str, &router);276 rc = addr_parse(router_str, &router); 187 277 if (rc != EOK) { 188 278 printf(NAME ": Invalid address format '%s'.\n", router_str); … … 276 366 } 277 367 278 rc = inet_naddr_format(&ainfo.naddr, &astr);368 rc = naddr_format(&ainfo.naddr, &astr); 279 369 if (rc != EOK) { 280 370 printf("Memory allocation failed.\n"); … … 340 430 } 341 431 342 rc = inet_naddr_format(&srinfo.dest, &dest_str);432 rc = naddr_format(&srinfo.dest, &dest_str); 343 433 if (rc != EOK) { 344 434 printf("Memory allocation failed.\n"); … … 347 437 } 348 438 349 rc = inet_addr_format(&srinfo.router, &router_str);439 rc = addr_format(&srinfo.router, &router_str); 350 440 if (rc != EOK) { 351 441 printf("Memory allocation failed.\n"); -
uspace/app/ping/ping.c
r8fdb18e ref904895 38 38 #include <fibril_synch.h> 39 39 #include <inet/dnsr.h> 40 #include <inet/addr.h>41 40 #include <inet/inetping.h> 42 41 #include <io/console.h> … … 73 72 } 74 73 74 static int addr_parse(const char *text, inet_addr_t *addr) 75 { 76 unsigned long a[4]; 77 char *cp = (char *)text; 78 int i; 79 80 for (i = 0; i < 3; i++) { 81 a[i] = strtoul(cp, &cp, 10); 82 if (*cp != '.') 83 return EINVAL; 84 ++cp; 85 } 86 87 a[3] = strtoul(cp, &cp, 10); 88 if (*cp != '\0') 89 return EINVAL; 90 91 addr->ipv4 = 0; 92 for (i = 0; i < 4; i++) { 93 if (a[i] > 255) 94 return EINVAL; 95 addr->ipv4 = (addr->ipv4 << 8) | a[i]; 96 } 97 98 return EOK; 99 } 100 101 static int addr_format(inet_addr_t *addr, char **bufp) 102 { 103 int rc; 104 105 rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24, 106 (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff, 107 addr->ipv4 & 0xff); 108 109 if (rc < 0) 110 return ENOMEM; 111 112 return EOK; 113 } 114 75 115 static void ping_signal_done(void) 76 116 { … … 86 126 int rc; 87 127 88 rc = inet_addr_format(&sdu->src, &asrc);128 rc = addr_format(&sdu->src, &asrc); 89 129 if (rc != EOK) 90 130 return ENOMEM; 91 131 92 rc = inet_addr_format(&sdu->dest, &adest);132 rc = addr_format(&sdu->dest, &adest); 93 133 if (rc != EOK) { 94 134 free(asrc); … … 202 242 203 243 /* Parse destination address */ 204 rc = inet_addr_parse(argv[argi], &dest_addr);244 rc = addr_parse(argv[argi], &dest_addr); 205 245 if (rc != EOK) { 206 246 /* Try interpreting as a host name */ … … 221 261 } 222 262 223 rc = inet_addr_format(&src_addr, &asrc);263 rc = addr_format(&src_addr, &asrc); 224 264 if (rc != EOK) { 225 265 printf(NAME ": Out of memory.\n"); … … 227 267 } 228 268 229 rc = inet_addr_format(&dest_addr, &adest);269 rc = addr_format(&dest_addr, &adest); 230 270 if (rc != EOK) { 231 271 printf(NAME ": Out of memory.\n"); -
uspace/app/vlaunch/vlaunch.c
r8fdb18e ref904895 121 121 } 122 122 123 pixel_t grd_bg = PIXEL(255, 2 55, 255, 255);123 pixel_t grd_bg = PIXEL(255, 240, 240, 240); 124 124 pixel_t btn_bg = PIXEL(255, 0, 0, 0); 125 125 pixel_t btn_fg = PIXEL(255, 240, 240, 240); 126 pixel_t lbl_bg = PIXEL(255, 2 55, 255, 255);126 pixel_t lbl_bg = PIXEL(255, 240, 240, 240); 127 127 pixel_t lbl_fg = PIXEL(255, 0, 0, 0); 128 128 -
uspace/lib/c/Makefile
r8fdb18e ref904895 92 92 generic/task.c \ 93 93 generic/futex.c \ 94 generic/inet/addr.c \95 94 generic/inet.c \ 96 95 generic/inetcfg.c \ -
uspace/lib/c/include/inet/inet.h
r8fdb18e ref904895 36 36 #define LIBC_INET_INET_H_ 37 37 38 #include <inet/addr.h>39 38 #include <sys/types.h> 40 39 41 40 #define INET_TTL_MAX 255 41 42 typedef struct { 43 uint32_t ipv4; 44 } inet_addr_t; 42 45 43 46 typedef struct { -
uspace/lib/c/include/inet/inetcfg.h
r8fdb18e ref904895 38 38 #include <inet/inet.h> 39 39 #include <sys/types.h> 40 41 /** Network address */ 42 typedef struct { 43 /** Address */ 44 uint32_t ipv4; 45 /** Number of valid bits in @c ipv4 */ 46 int bits; 47 } inet_naddr_t; 40 48 41 49 /** Address object info */ -
uspace/lib/gui/window.c
r8fdb18e ref904895 424 424 425 425 while (!list_empty(&win->events.list)) { 426 window_event_t *event = (window_event_t *) list_first(&win->events.list); 427 list_remove(&event->link); 428 free(event); 426 list_remove(list_first(&win->events.list)); 429 427 } 430 428 -
uspace/srv/hid/compositor/compositor.c
r8fdb18e ref904895 90 90 typedef struct { 91 91 link_t link; 92 atomic_t ref_cnt;93 92 service_id_t in_dsid; 94 93 service_id_t out_dsid; … … 139 138 } viewport_t; 140 139 141 static desktop_rect_t viewport_bound_rect;142 140 static FIBRIL_MUTEX_INITIALIZE(viewport_list_mtx); 143 141 static LIST_INITIALIZE(viewport_list); … … 217 215 218 216 link_initialize(&win->link); 219 atomic_set(&win->ref_cnt, 0);220 217 prodcons_initialize(&win->queue); 221 218 transform_identity(&win->transform); … … 235 232 static void window_destroy(window_t *win) 236 233 { 237 if (win && atomic_get(&win->ref_cnt) == 0) { 238 while (!list_empty(&win->queue.list)) { 239 window_event_t *event = (window_event_t *) list_first(&win->queue.list); 240 list_remove(&event->link); 241 free(event); 242 } 243 234 if (win) { 244 235 if (win->surface) { 245 236 surface_destroy(win->surface); … … 319 310 } 320 311 321 static void comp_restrict_pointers(void)322 {323 fibril_mutex_lock(&viewport_list_mtx);324 325 sysarg_t x_res = coord_origin;326 sysarg_t y_res = coord_origin;327 sysarg_t w_res = 0;328 sysarg_t h_res = 0;329 330 if (!list_empty(&viewport_list)) {331 viewport_t *vp = (viewport_t *) list_first(&viewport_list);332 x_res = vp->pos.x;333 y_res = vp->pos.y;334 surface_get_resolution(vp->surface, &w_res, &h_res);335 }336 337 list_foreach(viewport_list, link) {338 viewport_t *vp = list_get_instance(link, viewport_t, link);339 sysarg_t w_vp, h_vp;340 surface_get_resolution(vp->surface, &w_vp, &h_vp);341 rectangle_union(342 x_res, y_res, w_res, h_res,343 vp->pos.x, vp->pos.y, w_vp, h_vp,344 &x_res, &y_res, &w_res, &h_res);345 }346 347 viewport_bound_rect.x = x_res;348 viewport_bound_rect.y = y_res;349 viewport_bound_rect.w = w_res;350 viewport_bound_rect.h = h_res;351 352 fibril_mutex_unlock(&viewport_list_mtx);353 354 fibril_mutex_lock(&pointer_list_mtx);355 356 list_foreach(pointer_list, link) {357 pointer_t *ptr = list_get_instance(link, pointer_t, link);358 ptr->pos.x = ptr->pos.x > viewport_bound_rect.x ? ptr->pos.x : viewport_bound_rect.x;359 ptr->pos.y = ptr->pos.y > viewport_bound_rect.y ? ptr->pos.y : viewport_bound_rect.y;360 ptr->pos.x = ptr->pos.x < viewport_bound_rect.x + viewport_bound_rect.w ?361 ptr->pos.x : viewport_bound_rect.x + viewport_bound_rect.w;362 ptr->pos.y = ptr->pos.y < viewport_bound_rect.y + viewport_bound_rect.h ?363 ptr->pos.y : viewport_bound_rect.y + viewport_bound_rect.h;364 }365 366 fibril_mutex_unlock(&pointer_list_mtx);367 }368 369 312 static void comp_damage(sysarg_t x_dmg_glob, sysarg_t y_dmg_glob, 370 313 sysarg_t w_dmg_glob, sysarg_t h_dmg_glob) … … 752 695 } 753 696 754 loc_service_unregister(win->in_dsid);755 loc_service_unregister(win->out_dsid);756 757 /* In case the client was killed, input fibril of the window might be758 * still blocked on the condition within comp_window_get_event. */759 window_event_t *event_dummy = (window_event_t *) malloc(sizeof(window_event_t));760 if (event_dummy) {761 link_initialize(&event_dummy->link);762 prodcons_produce(&win->queue, &event_dummy->link);763 }764 765 697 /* Calculate damage. */ 766 698 sysarg_t x = 0; … … 774 706 } 775 707 708 /* Release window resources. */ 709 loc_service_unregister(win->in_dsid); 710 loc_service_unregister(win->out_dsid); 711 while (!list_empty(&win->queue.list)) { 712 list_remove(list_first(&win->queue.list)); 713 } 714 window_destroy(win); 715 776 716 comp_damage(x, y, width, height); 777 717 … … 873 813 874 814 if (win) { 875 atomic_inc(&win->ref_cnt);876 815 async_answer_0(iid, EOK); 877 816 } else { … … 886 825 887 826 if (!IPC_GET_IMETHOD(call)) { 888 async_answer_0(callid, EOK); 889 atomic_dec(&win->ref_cnt); 890 window_destroy(win); 827 async_answer_0(callid, EINVAL); 891 828 return; 892 829 } … … 905 842 906 843 if (!IPC_GET_IMETHOD(call)) { 907 comp_window_close(win, callid, &call); 908 atomic_dec(&win->ref_cnt); 909 window_destroy(win); 844 async_answer_0(callid, EINVAL); 910 845 return; 911 846 } … … 922 857 break; 923 858 case WINDOW_CLOSE: 924 /* Postpone the closing until the phone is hung up to cover 925 * the case when the client is killed abruptly. */ 926 async_answer_0(callid, EOK); 859 comp_window_close(win, callid, &call); 927 860 break; 928 861 case WINDOW_CLOSE_REQUEST: … … 978 911 async_answer_0(iid, EOK); 979 912 980 comp_restrict_pointers();981 913 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 982 914 } … … 1024 956 fibril_mutex_unlock(&viewport_list_mtx); 1025 957 async_answer_0(iid, EOK); 1026 1027 comp_restrict_pointers();1028 comp_damage(0, 0, UINT32_MAX, UINT32_MAX);1029 958 } 1030 959 } … … 1462 1391 surface_get_resolution(pointer->cursor.states[pointer->state], 1463 1392 &cursor_width, &cursor_height); 1464 if (pointer->pos.x + dx < viewport_bound_rect.x) {1465 dx = -1 * (pointer->pos.x - viewport_bound_rect.x);1466 }1467 if (pointer->pos.y + dy < viewport_bound_rect.y) {1468 dy = -1 * (pointer->pos.y - viewport_bound_rect.y);1469 }1470 if (pointer->pos.x + dx > viewport_bound_rect.x + viewport_bound_rect.w) {1471 dx = (viewport_bound_rect.x + viewport_bound_rect.w - pointer->pos.x);1472 }1473 if (pointer->pos.y + dy > viewport_bound_rect.y + viewport_bound_rect.h) {1474 dy = (viewport_bound_rect.y + viewport_bound_rect.h - pointer->pos.y);1475 }1476 1393 pointer->pos.x += dx; 1477 1394 pointer->pos.y += dy; … … 1993 1910 fibril_mutex_unlock(&viewport_list_mtx); 1994 1911 1995 comp_restrict_pointers();1996 1912 comp_damage(x, y, width, height); 1997 1913 } else { … … 2206 2122 return -1; 2207 2123 } 2208 2209 comp_restrict_pointers(); 2124 2210 2125 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2211 2126 -
uspace/srv/net/inetsrv/inetsrv.h
r8fdb18e ref904895 40 40 #include <adt/list.h> 41 41 #include <stdbool.h> 42 #include <inet/addr.h>43 42 #include <inet/iplink.h> 44 43 #include <ipc/loc.h> … … 62 61 link_t client_list; 63 62 } inetping_client_t; 63 64 /** Host address */ 65 typedef struct { 66 uint32_t ipv4; 67 } inet_addr_t; 68 69 /** Network address */ 70 typedef struct { 71 /** Address */ 72 uint32_t ipv4; 73 /** Number of valid bits in @c ipv4 */ 74 int bits; 75 } inet_naddr_t; 64 76 65 77 /** Address object info */
Note:
See TracChangeset
for help on using the changeset viewer.