Changes in / [69483af:eef14771] in mainline
- Files:
-
- 19 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
r69483af reef14771 112 112 $(USPACE_PATH)/srv/hid/remcons/remcons \ 113 113 $(USPACE_PATH)/srv/hid/isdv4_tablet/isdv4_tablet \ 114 $(USPACE_PATH)/srv/net/dnsrsrv/dnsrsrv \ 114 115 $(USPACE_PATH)/srv/net/ethip/ethip \ 115 116 $(USPACE_PATH)/srv/net/inetsrv/inetsrv \ … … 165 166 $(USPACE_PATH)/app/dltest2/dltest2 \ 166 167 $(USPACE_PATH)/app/dload/dload \ 168 $(USPACE_PATH)/app/dnscfg/dnscfg \ 169 $(USPACE_PATH)/app/dnsres/dnsres \ 167 170 $(USPACE_PATH)/app/edit/edit \ 168 171 $(USPACE_PATH)/app/inet/inet \ -
uspace/Makefile
r69483af reef14771 39 39 app/bnchmark \ 40 40 app/devctl \ 41 app/dnscfg \ 42 app/dnsres \ 41 43 app/edit \ 42 44 app/getterm \ … … 82 84 srv/devman \ 83 85 srv/loader \ 86 srv/net/dnsrsrv \ 84 87 srv/net/ethip \ 85 88 srv/net/inetsrv \ -
uspace/app/inet/inet.c
r69483af reef14771 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 36 36 37 37 #include <errno.h> 38 #include <inet/addr.h> 38 39 #include <inet/inetcfg.h> 39 40 #include <loc.h> … … 54 55 } 55 56 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 147 57 static int addr_create_static(int argc, char *argv[]) 148 58 { … … 178 88 } 179 89 180 rc = naddr_parse(addr_spec, &naddr);90 rc = inet_naddr_parse(addr_spec, &naddr); 181 91 if (rc != EOK) { 182 92 printf(NAME ": Invalid network address format '%s'.\n", … … 267 177 route_name = argv[2]; 268 178 269 rc = naddr_parse(dest_str, &dest);179 rc = inet_naddr_parse(dest_str, &dest); 270 180 if (rc != EOK) { 271 181 printf(NAME ": Invalid network address format '%s'.\n", … … 274 184 } 275 185 276 rc = addr_parse(router_str, &router);186 rc = inet_addr_parse(router_str, &router); 277 187 if (rc != EOK) { 278 188 printf(NAME ": Invalid address format '%s'.\n", router_str); … … 366 276 } 367 277 368 rc = naddr_format(&ainfo.naddr, &astr);278 rc = inet_naddr_format(&ainfo.naddr, &astr); 369 279 if (rc != EOK) { 370 280 printf("Memory allocation failed.\n"); … … 430 340 } 431 341 432 rc = naddr_format(&srinfo.dest, &dest_str);342 rc = inet_naddr_format(&srinfo.dest, &dest_str); 433 343 if (rc != EOK) { 434 344 printf("Memory allocation failed.\n"); … … 437 347 } 438 348 439 rc = addr_format(&srinfo.router, &router_str);349 rc = inet_addr_format(&srinfo.router, &router_str); 440 350 if (rc != EOK) { 441 351 printf("Memory allocation failed.\n"); -
uspace/app/init/init.c
r69483af reef14771 359 359 srv_start("/srv/tcp"); 360 360 srv_start("/srv/udp"); 361 srv_start("/srv/dnsrsrv"); 361 362 362 363 srv_start("/srv/clipboard"); -
uspace/app/nettest1/nettest1.c
r69483af reef14771 46 46 #include <arg_parse.h> 47 47 48 #include <inet/dnsr.h> 48 49 #include <net/in.h> 49 50 #include <net/in6.h> … … 75 76 printf( 76 77 "Network Networking test 1 aplication - sockets\n" 77 "Usage: echo [options] numeric_address\n"78 "Usage: nettest1 [options] host\n" 78 79 "Where options are:\n" 79 80 "-f protocol_family | --family=protocol_family\n" … … 290 291 struct sockaddr_in address_in; 291 292 struct sockaddr_in6 address_in6; 293 dnsr_hostinfo_t *hinfo; 292 294 uint8_t *address_start; 293 295 … … 319 321 } 320 322 321 /* If not before the last argument containing the address*/323 /* If not before the last argument containing the host */ 322 324 if (index >= argc) { 323 printf("Command line error: missing address\n");325 printf("Command line error: missing host name\n"); 324 326 nettest1_print_help(); 325 327 return EINVAL; … … 348 350 } 349 351 350 /* Parse the last argument which should contain the address */352 /* Parse the last argument which should contain the host/address */ 351 353 rc = inet_pton(family, argv[argc - 1], address_start); 352 354 if (rc != EOK) { 353 fprintf(stderr, "Address parse error %d\n", rc); 354 return rc; 355 /* Try interpreting as a host name */ 356 rc = dnsr_name2host(argv[argc - 1], &hinfo); 357 if (rc != EOK) { 358 printf("Error resolving host '%s'.\n", argv[argc - 1]); 359 return rc; 360 } 361 362 address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 355 363 } 356 364 -
uspace/app/nettest2/nettest2.c
r69483af reef14771 47 47 #include <stdbool.h> 48 48 49 #include <inet/dnsr.h> 49 50 #include <net/in.h> 50 51 #include <net/in6.h> … … 71 72 printf( 72 73 "Network Networking test 2 aplication - UDP transfer\n" 73 "Usage: echo [options] address\n"74 "Usage: nettest2 [options] host\n" 74 75 "Where options are:\n" 75 76 "-f protocol_family | --family=protocol_family\n" … … 227 228 struct sockaddr_in address_in; 228 229 struct sockaddr_in6 address_in6; 230 dnsr_hostinfo_t *hinfo; 229 231 socklen_t addrlen; 230 232 uint8_t *address_start; … … 265 267 } 266 268 267 /* If not before the last argument containing the address*/269 /* If not before the last argument containing the host */ 268 270 if (index >= argc) { 269 printf("Command line error: missing address\n");271 printf("Command line error: missing host name\n"); 270 272 nettest2_print_help(); 271 273 return EINVAL; … … 294 296 } 295 297 296 /* Parse the last argument which should contain the address.*/298 /* Parse the last argument which should contain the host/address */ 297 299 rc = inet_pton(family, argv[argc - 1], address_start); 298 300 if (rc != EOK) { 299 fprintf(stderr, "Address parse error %d\n", rc); 300 return rc; 301 /* Try interpreting as a host name */ 302 rc = dnsr_name2host(argv[argc - 1], &hinfo); 303 if (rc != EOK) { 304 printf("Error resolving host '%s'.\n", argv[argc - 1]); 305 return rc; 306 } 307 308 address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 301 309 } 302 310 -
uspace/app/nettest3/nettest3.c
r69483af reef14771 39 39 #include <str.h> 40 40 41 #include <inet/dnsr.h> 41 42 #include <net/in.h> 42 43 #include <net/in6.h> … … 60 61 int fd; 61 62 char *endptr; 63 dnsr_hostinfo_t *hinfo; 62 64 63 65 port = 7; … … 75 77 rc = inet_pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr); 76 78 if (rc != EOK) { 77 fprintf(stderr, "Error parsing address\n"); 78 return 1; 79 /* Try interpreting as a host name */ 80 rc = dnsr_name2host(argv[1], &hinfo); 81 if (rc != EOK) { 82 printf("Error resolving host '%s'.\n", argv[1]); 83 return rc; 84 } 85 86 addr.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 87 addr.sin_family = AF_INET; 79 88 } 80 89 printf("result: rc=%d, family=%d, addr=%x\n", rc, -
uspace/app/nterm/conn.c
r69483af reef14771 33 33 */ 34 34 35 #include <byteorder.h> 35 36 #include <stdbool.h> 36 37 #include <errno.h> 37 38 #include <fibril.h> 39 #include <inet/dnsr.h> 38 40 #include <net/socket.h> 39 41 #include <stdio.h> … … 74 76 { 75 77 struct sockaddr_in addr; 78 dnsr_hostinfo_t *hinfo = NULL; 76 79 int rc; 77 80 char *endptr; … … 81 84 rc = inet_pton(addr.sin_family, addr_s, (uint8_t *)&addr.sin_addr); 82 85 if (rc != EOK) { 83 printf("Invalid addres %s\n", addr_s); 84 return EINVAL; 86 /* Try interpreting as a host name */ 87 rc = dnsr_name2host(addr_s, &hinfo); 88 if (rc != EOK) { 89 printf("Error resolving host '%s'.\n", addr_s); 90 goto error; 91 } 92 93 addr.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 85 94 } 86 95 … … 88 97 if (*endptr != '\0') { 89 98 printf("Invalid port number %s\n", port_s); 90 return EINVAL;99 goto error; 91 100 } 92 101 … … 95 104 goto error; 96 105 97 printf("Connecting to address%s port %u\n", addr_s, ntohs(addr.sin_port));106 printf("Connecting to host %s port %u\n", addr_s, ntohs(addr.sin_port)); 98 107 99 108 rc = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr)); -
uspace/app/nterm/nterm.c
r69483af reef14771 104 104 static void print_syntax(void) 105 105 { 106 printf("syntax: nterm < ip-address> <port>\n");106 printf("syntax: nterm <host> <port>\n"); 107 107 } 108 108 -
uspace/app/ping/ping.c
r69483af reef14771 1 1 /* 2 * Copyright (c) 201 2Jiri Svoboda2 * Copyright (c) 2013 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <inet/dnsr.h> 40 #include <inet/addr.h> 39 41 #include <inet/inetping.h> 40 42 #include <io/console.h> … … 68 70 static void print_syntax(void) 69 71 { 70 printf("syntax: " NAME " [-r] <addr>\n"); 71 } 72 73 static int addr_parse(const char *text, inet_addr_t *addr) 74 { 75 unsigned long a[4]; 76 char *cp = (char *)text; 77 int i; 78 79 for (i = 0; i < 3; i++) { 80 a[i] = strtoul(cp, &cp, 10); 81 if (*cp != '.') 82 return EINVAL; 83 ++cp; 84 } 85 86 a[3] = strtoul(cp, &cp, 10); 87 if (*cp != '\0') 88 return EINVAL; 89 90 addr->ipv4 = 0; 91 for (i = 0; i < 4; i++) { 92 if (a[i] > 255) 93 return EINVAL; 94 addr->ipv4 = (addr->ipv4 << 8) | a[i]; 95 } 96 97 return EOK; 98 } 99 100 static int addr_format(inet_addr_t *addr, char **bufp) 101 { 102 int rc; 103 104 rc = asprintf(bufp, "%d.%d.%d.%d", addr->ipv4 >> 24, 105 (addr->ipv4 >> 16) & 0xff, (addr->ipv4 >> 8) & 0xff, 106 addr->ipv4 & 0xff); 107 108 if (rc < 0) 109 return ENOMEM; 110 111 return EOK; 72 printf("syntax: " NAME " [-r] <host>\n"); 112 73 } 113 74 … … 125 86 int rc; 126 87 127 rc = addr_format(&sdu->src, &asrc);88 rc = inet_addr_format(&sdu->src, &asrc); 128 89 if (rc != EOK) 129 90 return ENOMEM; 130 91 131 rc = addr_format(&sdu->dest, &adest);92 rc = inet_addr_format(&sdu->dest, &adest); 132 93 if (rc != EOK) { 133 94 free(asrc); … … 213 174 int main(int argc, char *argv[]) 214 175 { 176 dnsr_hostinfo_t *hinfo = NULL; 177 char *asrc = NULL; 178 char *adest = NULL; 179 char *sdest = NULL; 215 180 int rc; 216 181 int argi; … … 220 185 printf(NAME ": Failed connecting to internet ping service " 221 186 "(%d).\n", rc); 222 return 1;187 goto error; 223 188 } 224 189 … … 233 198 if (argc - argi != 1) { 234 199 print_syntax(); 235 return 1;200 goto error; 236 201 } 237 202 238 203 /* Parse destination address */ 239 rc = addr_parse(argv[argi], &dest_addr); 240 if (rc != EOK) { 241 printf(NAME ": Invalid address format.\n"); 242 print_syntax(); 243 return 1; 204 rc = inet_addr_parse(argv[argi], &dest_addr); 205 if (rc != EOK) { 206 /* Try interpreting as a host name */ 207 rc = dnsr_name2host(argv[argi], &hinfo); 208 if (rc != EOK) { 209 printf(NAME ": Error resolving host '%s'.\n", argv[argi]); 210 goto error; 211 } 212 213 dest_addr = hinfo->addr; 244 214 } 245 215 … … 248 218 if (rc != EOK) { 249 219 printf(NAME ": Failed determining source address.\n"); 250 return 1; 251 } 220 goto error; 221 } 222 223 rc = inet_addr_format(&src_addr, &asrc); 224 if (rc != EOK) { 225 printf(NAME ": Out of memory.\n"); 226 goto error; 227 } 228 229 rc = inet_addr_format(&dest_addr, &adest); 230 if (rc != EOK) { 231 printf(NAME ": Out of memory.\n"); 232 goto error; 233 } 234 235 if (hinfo != NULL) { 236 rc = asprintf(&sdest, "%s (%s)", hinfo->name, adest); 237 if (rc < 0) { 238 printf(NAME ": Out of memory.\n"); 239 goto error; 240 } 241 } else { 242 sdest = adest; 243 adest = NULL; 244 } 245 246 printf("Sending ICMP echo request from %s to %s.\n", 247 asrc, sdest); 252 248 253 249 fid_t fid; … … 257 253 if (fid == 0) { 258 254 printf(NAME ": Failed creating transmit fibril.\n"); 259 return 1;255 goto error; 260 256 } 261 257 … … 265 261 if (fid == 0) { 266 262 printf(NAME ": Failed creating input fibril.\n"); 267 return 1;263 goto error; 268 264 } 269 265 … … 283 279 if (rc == ETIMEOUT) { 284 280 printf(NAME ": Echo request timed out.\n"); 285 return 1; 286 } 287 281 goto error; 282 } 283 284 free(asrc); 285 free(adest); 286 free(sdest); 287 dnsr_hostinfo_destroy(hinfo); 288 288 return 0; 289 error: 290 free(asrc); 291 free(adest); 292 free(sdest); 293 dnsr_hostinfo_destroy(hinfo); 294 return 1; 289 295 } 290 296 -
uspace/lib/c/Makefile
r69483af reef14771 74 74 generic/device/pci.c \ 75 75 generic/device/ahci.c \ 76 generic/dnsr.c \ 76 77 generic/dlfcn.c \ 77 78 generic/elf/elf_load.c \ … … 91 92 generic/task.c \ 92 93 generic/futex.c \ 94 generic/inet/addr.c \ 93 95 generic/inet.c \ 94 96 generic/inetcfg.c \ -
uspace/lib/c/include/inet/inet.h
r69483af reef14771 36 36 #define LIBC_INET_INET_H_ 37 37 38 #include <inet/addr.h> 38 39 #include <sys/types.h> 39 40 40 41 #define INET_TTL_MAX 255 41 42 typedef struct {43 uint32_t ipv4;44 } inet_addr_t;45 42 46 43 typedef struct { -
uspace/lib/c/include/inet/inetcfg.h
r69483af reef14771 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;48 40 49 41 /** Address object info */ -
uspace/lib/c/include/ipc/services.h
r69483af reef14771 53 53 } services_t; 54 54 55 #define SERVICE_NAME_DNSR "net/dnsr" 55 56 #define SERVICE_NAME_INET "net/inet" 56 57 #define SERVICE_NAME_INETCFG "net/inetcfg" -
uspace/srv/net/inetsrv/addrobj.c
r69483af reef14771 221 221 222 222 lsrc_addr.ipv4 = addr->naddr.ipv4; 223 ldest_addr = &dgram->dest;223 ldest_addr = ldest; 224 224 225 225 return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest_addr, dgram, -
uspace/srv/net/inetsrv/inetsrv.c
r69483af reef14771 98 98 } 99 99 100 rc = inet_link_discovery_start(); 100 inet_sroute_t *sroute = inet_sroute_new(); 101 if (sroute == NULL) { 102 log_msg(LOG_DEFAULT, LVL_ERROR, "Failed creating default route (%d).", rc); 103 return ENOMEM; 104 } 105 106 sroute->dest.ipv4 = 0; 107 sroute->dest.bits = 0; 108 sroute->router.ipv4 = (192 << 24) | (168 << 16) | (0 << 8) | 1; 109 sroute->name = str_dup("default"); 110 inet_sroute_add(sroute); 111 112 rc = inet_link_discovery_start(); 101 113 if (rc != EOK) 102 114 return EEXIST; -
uspace/srv/net/inetsrv/inetsrv.h
r69483af reef14771 40 40 #include <adt/list.h> 41 41 #include <stdbool.h> 42 #include <inet/addr.h> 42 43 #include <inet/iplink.h> 43 44 #include <ipc/loc.h> … … 61 62 link_t client_list; 62 63 } 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;76 64 77 65 /** Address object info */ -
uspace/srv/net/udp/assoc.c
r69483af reef14771 279 279 280 280 fibril_mutex_lock(&assoc->lock); 281 while (list_empty(&assoc->rcv_queue) ) {281 while (list_empty(&assoc->rcv_queue) && !assoc->reset) { 282 282 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - waiting"); 283 283 fibril_condvar_wait(&assoc->rcv_queue_cv, &assoc->lock); 284 } 285 286 if (assoc->reset) { 287 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv() - association was reset"); 288 fibril_mutex_unlock(&assoc->lock); 289 return ECONNABORTED; 284 290 } 285 291 … … 323 329 } 324 330 331 /** Reset association. 332 * 333 * This causes any pendingreceive operations to return immediately with 334 * UDP_ERESET. 335 */ 336 void udp_assoc_reset(udp_assoc_t *assoc) 337 { 338 fibril_mutex_lock(&assoc->lock); 339 assoc->reset = true; 340 fibril_condvar_broadcast(&assoc->rcv_queue_cv); 341 fibril_mutex_unlock(&assoc->lock); 342 } 343 325 344 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp, 326 345 udp_msg_t *msg) -
uspace/srv/net/udp/assoc.h
r69483af reef14771 51 51 extern int udp_assoc_recv(udp_assoc_t *, udp_msg_t **, udp_sock_t *); 52 52 extern void udp_assoc_received(udp_sockpair_t *, udp_msg_t *); 53 53 extern void udp_assoc_reset(udp_assoc_t *); 54 54 55 55 #endif -
uspace/srv/net/udp/sock.c
r69483af reef14771 537 537 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()"); 538 538 int socket_id = SOCKET_GET_SOCKET_ID(call); 539 539 540 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - find core"); 540 541 socket_core_t *sock_core = 541 542 socket_cores_find(&client->sockets, socket_id); 542 543 if (sock_core == NULL) { 544 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - core not found"); 543 545 async_answer_0(callid, ENOTSOCK); 544 546 return; 545 547 } 546 548 549 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - spec data"); 547 550 udp_sockdata_t *socket = 548 551 (udp_sockdata_t *) sock_core->specific_data; 552 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket"); 549 553 fibril_mutex_lock(&socket->lock); 550 554 555 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket buffer"); 556 fibril_mutex_lock(&socket->recv_buffer_lock); 557 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - set socket->sock_core = NULL"); 558 socket->sock_core = NULL; 559 fibril_mutex_unlock(&socket->recv_buffer_lock); 560 561 udp_uc_reset(socket->assoc); 562 551 563 int rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 552 564 udp_free_sock_data); 553 565 if (rc != EOK) { 566 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - socket_destroy failed"); 554 567 fibril_mutex_unlock(&socket->lock); 555 568 async_answer_0(callid, rc); 556 569 return; 557 570 } 558 571 572 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv"); 573 fibril_condvar_broadcast(&socket->recv_buffer_cv); 574 559 575 fibril_mutex_unlock(&socket->lock); 560 576 async_answer_0(callid, EOK); … … 582 598 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril()"); 583 599 600 fibril_mutex_lock(&sock->recv_buffer_lock); 601 584 602 while (true) { 585 603 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()"); 586 fibril_mutex_lock(&sock->recv_buffer_lock); 587 while (sock->recv_buffer_used != 0) { 604 while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) { 588 605 fibril_condvar_wait(&sock->recv_buffer_cv, 589 606 &sock->recv_buffer_lock); 590 607 } 591 608 609 fibril_mutex_unlock(&sock->recv_buffer_lock); 610 592 611 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] call udp_uc_receive()"); 593 612 urc = udp_uc_receive(sock->assoc, sock->recv_buffer, 594 613 UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock); 614 fibril_mutex_lock(&sock->recv_buffer_lock); 595 615 sock->recv_error = urc; 596 597 udp_sock_notify_data(sock->sock_core); 598 616 617 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] udp_uc_receive -> %d", urc); 618 619 if (sock->sock_core != NULL) 620 udp_sock_notify_data(sock->sock_core); 621 599 622 if (urc != UDP_EOK) { 623 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] urc != UDP_EOK, break"); 600 624 fibril_condvar_broadcast(&sock->recv_buffer_cv); 601 fibril_mutex_unlock(&sock->recv_buffer_lock); 602 break; 603 } 604 625 break; 626 } 627 605 628 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] got data - broadcast recv_buffer_cv"); 606 629 607 630 sock->recv_buffer_used = rcvd; 608 fibril_mutex_unlock(&sock->recv_buffer_lock);609 631 fibril_condvar_broadcast(&sock->recv_buffer_cv); 610 632 } 611 633 634 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop"); 635 fibril_mutex_unlock(&sock->recv_buffer_lock); 612 636 udp_uc_destroy(sock->assoc); 637 638 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() terminated"); 613 639 614 640 return 0; -
uspace/srv/net/udp/ucall.c
r69483af reef14771 113 113 log_msg(LOG_DEFAULT, LVL_DEBUG, "%s: udp_uc_receive()", assoc->name); 114 114 rc = udp_assoc_recv(assoc, &msg, fsock); 115 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_assoc_recv -> %d", rc); 115 116 switch (rc) { 117 case EOK: 118 break; 119 case ECONNABORTED: 120 return UDP_ERESET; 121 default: 122 assert(false); 116 123 } 117 124 … … 133 140 { 134 141 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_destroy()"); 142 udp_assoc_reset(assoc); 135 143 udp_assoc_remove(assoc); 136 144 udp_assoc_delete(assoc); 145 } 146 147 void udp_uc_reset(udp_assoc_t *assoc) 148 { 149 udp_assoc_reset(assoc); 137 150 } 138 151 -
uspace/srv/net/udp/ucall.h
r69483af reef14771 49 49 extern void udp_uc_status(udp_assoc_t *, udp_assoc_status_t *); 50 50 extern void udp_uc_destroy(udp_assoc_t *); 51 extern void udp_uc_reset(udp_assoc_t *); 51 52 52 53 #endif -
uspace/srv/net/udp/udp_type.h
r69483af reef14771 51 51 UDP_EUNSPEC, 52 52 /* No route to destination */ 53 UDP_ENOROUTE 53 UDP_ENOROUTE, 54 /** Association reset by user */ 55 UDP_ERESET 54 56 } udp_error_t; 55 57 … … 119 121 udp_sockpair_t ident; 120 122 123 /** True if association was reset by user */ 124 bool reset; 125 121 126 /** True if association was deleted by user */ 122 127 bool deleted;
Note:
See TracChangeset
for help on using the changeset viewer.