Changes in / [8fdb18e:1c7ba2d] in mainline
- Files:
-
- 19 deleted
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
r8fdb18e r1c7ba2d 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 \115 114 $(USPACE_PATH)/srv/net/ethip/ethip \ 116 115 $(USPACE_PATH)/srv/net/inetsrv/inetsrv \ … … 166 165 $(USPACE_PATH)/app/dltest2/dltest2 \ 167 166 $(USPACE_PATH)/app/dload/dload \ 168 $(USPACE_PATH)/app/dnsres/dnsres \169 167 $(USPACE_PATH)/app/edit/edit \ 170 168 $(USPACE_PATH)/app/inet/inet \ -
uspace/Makefile
r8fdb18e r1c7ba2d 39 39 app/bnchmark \ 40 40 app/devctl \ 41 app/dnsres \42 41 app/edit \ 43 42 app/getterm \ … … 83 82 srv/devman \ 84 83 srv/loader \ 85 srv/net/dnsrsrv \86 84 srv/net/ethip \ 87 85 srv/net/inetsrv \ -
uspace/app/init/init.c
r8fdb18e r1c7ba2d 359 359 srv_start("/srv/tcp"); 360 360 srv_start("/srv/udp"); 361 srv_start("/srv/dnsrsrv");362 361 363 362 srv_start("/srv/clipboard"); -
uspace/app/nettest1/nettest1.c
r8fdb18e r1c7ba2d 46 46 #include <arg_parse.h> 47 47 48 #include <inet/dnsr.h>49 48 #include <net/in.h> 50 49 #include <net/in6.h> … … 76 75 printf( 77 76 "Network Networking test 1 aplication - sockets\n" 78 "Usage: nettest1 [options] host\n"77 "Usage: echo [options] numeric_address\n" 79 78 "Where options are:\n" 80 79 "-f protocol_family | --family=protocol_family\n" … … 291 290 struct sockaddr_in address_in; 292 291 struct sockaddr_in6 address_in6; 293 dnsr_hostinfo_t *hinfo;294 292 uint8_t *address_start; 295 293 … … 321 319 } 322 320 323 /* If not before the last argument containing the host*/321 /* If not before the last argument containing the address */ 324 322 if (index >= argc) { 325 printf("Command line error: missing host name\n");323 printf("Command line error: missing address\n"); 326 324 nettest1_print_help(); 327 325 return EINVAL; … … 350 348 } 351 349 352 /* Parse the last argument which should contain the host/address */350 /* Parse the last argument which should contain the address */ 353 351 rc = inet_pton(family, argv[argc - 1], address_start); 354 352 if (rc != EOK) { 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); 353 fprintf(stderr, "Address parse error %d\n", rc); 354 return rc; 363 355 } 364 356 -
uspace/app/nettest2/nettest2.c
r8fdb18e r1c7ba2d 47 47 #include <stdbool.h> 48 48 49 #include <inet/dnsr.h>50 49 #include <net/in.h> 51 50 #include <net/in6.h> … … 72 71 printf( 73 72 "Network Networking test 2 aplication - UDP transfer\n" 74 "Usage: nettest2 [options] host\n"73 "Usage: echo [options] address\n" 75 74 "Where options are:\n" 76 75 "-f protocol_family | --family=protocol_family\n" … … 228 227 struct sockaddr_in address_in; 229 228 struct sockaddr_in6 address_in6; 230 dnsr_hostinfo_t *hinfo;231 229 socklen_t addrlen; 232 230 uint8_t *address_start; … … 267 265 } 268 266 269 /* If not before the last argument containing the host*/267 /* If not before the last argument containing the address */ 270 268 if (index >= argc) { 271 printf("Command line error: missing host name\n");269 printf("Command line error: missing address\n"); 272 270 nettest2_print_help(); 273 271 return EINVAL; … … 296 294 } 297 295 298 /* Parse the last argument which should contain the host/address*/296 /* Parse the last argument which should contain the address. */ 299 297 rc = inet_pton(family, argv[argc - 1], address_start); 300 298 if (rc != EOK) { 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); 299 fprintf(stderr, "Address parse error %d\n", rc); 300 return rc; 309 301 } 310 302 -
uspace/app/nettest3/nettest3.c
r8fdb18e r1c7ba2d 39 39 #include <str.h> 40 40 41 #include <inet/dnsr.h>42 41 #include <net/in.h> 43 42 #include <net/in6.h> … … 61 60 int fd; 62 61 char *endptr; 63 dnsr_hostinfo_t *hinfo;64 62 65 63 port = 7; … … 77 75 rc = inet_pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr); 78 76 if (rc != EOK) { 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; 77 fprintf(stderr, "Error parsing address\n"); 78 return 1; 88 79 } 89 80 printf("result: rc=%d, family=%d, addr=%x\n", rc, -
uspace/app/nterm/conn.c
r8fdb18e r1c7ba2d 33 33 */ 34 34 35 #include <byteorder.h>36 35 #include <stdbool.h> 37 36 #include <errno.h> 38 37 #include <fibril.h> 39 #include <inet/dnsr.h>40 38 #include <net/socket.h> 41 39 #include <stdio.h> … … 76 74 { 77 75 struct sockaddr_in addr; 78 dnsr_hostinfo_t *hinfo = NULL;79 76 int rc; 80 77 char *endptr; … … 84 81 rc = inet_pton(addr.sin_family, addr_s, (uint8_t *)&addr.sin_addr); 85 82 if (rc != EOK) { 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); 83 printf("Invalid addres %s\n", addr_s); 84 return EINVAL; 94 85 } 95 86 … … 97 88 if (*endptr != '\0') { 98 89 printf("Invalid port number %s\n", port_s); 99 goto error;90 return EINVAL; 100 91 } 101 92 … … 104 95 goto error; 105 96 106 printf("Connecting to host%s port %u\n", addr_s, ntohs(addr.sin_port));97 printf("Connecting to address %s port %u\n", addr_s, ntohs(addr.sin_port)); 107 98 108 99 rc = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr)); -
uspace/app/nterm/nterm.c
r8fdb18e r1c7ba2d 104 104 static void print_syntax(void) 105 105 { 106 printf("syntax: nterm < host> <port>\n");106 printf("syntax: nterm <ip-address> <port>\n"); 107 107 } 108 108 -
uspace/app/ping/ping.c
r8fdb18e r1c7ba2d 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <inet/dnsr.h>40 39 #include <inet/addr.h> 41 40 #include <inet/inetping.h> … … 70 69 static void print_syntax(void) 71 70 { 72 printf("syntax: " NAME " [-r] < host>\n");71 printf("syntax: " NAME " [-r] <addr>\n"); 73 72 } 74 73 … … 174 173 int main(int argc, char *argv[]) 175 174 { 176 dnsr_hostinfo_t *hinfo = NULL;177 char *asrc = NULL;178 char *adest = NULL;179 char *sdest = NULL;180 175 int rc; 181 176 int argi; … … 185 180 printf(NAME ": Failed connecting to internet ping service " 186 181 "(%d).\n", rc); 187 goto error;182 return 1; 188 183 } 189 184 … … 198 193 if (argc - argi != 1) { 199 194 print_syntax(); 200 goto error;195 return 1; 201 196 } 202 197 … … 204 199 rc = inet_addr_parse(argv[argi], &dest_addr); 205 200 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; 201 printf(NAME ": Invalid address format.\n"); 202 print_syntax(); 203 return 1; 214 204 } 215 205 … … 218 208 if (rc != EOK) { 219 209 printf(NAME ": Failed determining source address.\n"); 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); 210 return 1; 211 } 248 212 249 213 fid_t fid; … … 253 217 if (fid == 0) { 254 218 printf(NAME ": Failed creating transmit fibril.\n"); 255 goto error;219 return 1; 256 220 } 257 221 … … 261 225 if (fid == 0) { 262 226 printf(NAME ": Failed creating input fibril.\n"); 263 goto error;227 return 1; 264 228 } 265 229 … … 279 243 if (rc == ETIMEOUT) { 280 244 printf(NAME ": Echo request timed out.\n"); 281 goto error; 282 } 283 284 free(asrc); 285 free(adest); 286 free(sdest); 287 dnsr_hostinfo_destroy(hinfo); 245 return 1; 246 } 247 288 248 return 0; 289 error:290 free(asrc);291 free(adest);292 free(sdest);293 dnsr_hostinfo_destroy(hinfo);294 return 1;295 249 } 296 250 -
uspace/lib/c/Makefile
r8fdb18e r1c7ba2d 74 74 generic/device/pci.c \ 75 75 generic/device/ahci.c \ 76 generic/dnsr.c \77 76 generic/dlfcn.c \ 78 77 generic/elf/elf_load.c \ -
uspace/lib/c/include/ipc/services.h
r8fdb18e r1c7ba2d 53 53 } services_t; 54 54 55 #define SERVICE_NAME_DNSR "net/dnsr"56 55 #define SERVICE_NAME_INET "net/inet" 57 56 #define SERVICE_NAME_INETCFG "net/inetcfg" -
uspace/srv/net/inetsrv/addrobj.c
r8fdb18e r1c7ba2d 221 221 222 222 lsrc_addr.ipv4 = addr->naddr.ipv4; 223 ldest_addr = ldest;223 ldest_addr = &dgram->dest; 224 224 225 225 return inet_link_send_dgram(addr->ilink, &lsrc_addr, ldest_addr, dgram, -
uspace/srv/net/inetsrv/inetsrv.c
r8fdb18e r1c7ba2d 98 98 } 99 99 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(); 100 rc = inet_link_discovery_start(); 113 101 if (rc != EOK) 114 102 return EEXIST; -
uspace/srv/net/udp/assoc.c
r8fdb18e r1c7ba2d 279 279 280 280 fibril_mutex_lock(&assoc->lock); 281 while (list_empty(&assoc->rcv_queue) && !assoc->reset) {281 while (list_empty(&assoc->rcv_queue)) { 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;290 284 } 291 285 … … 329 323 } 330 324 331 /** Reset association.332 *333 * This causes any pendingreceive operations to return immediately with334 * 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 344 325 static int udp_assoc_queue_msg(udp_assoc_t *assoc, udp_sockpair_t *sp, 345 326 udp_msg_t *msg) -
uspace/srv/net/udp/assoc.h
r8fdb18e r1c7ba2d 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 extern void udp_assoc_reset(udp_assoc_t *); 53 54 54 55 55 #endif -
uspace/srv/net/udp/sock.c
r8fdb18e r1c7ba2d 537 537 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close()"); 538 538 int socket_id = SOCKET_GET_SOCKET_ID(call); 539 540 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - find core"); 539 541 540 socket_core_t *sock_core = 542 541 socket_cores_find(&client->sockets, socket_id); 543 542 if (sock_core == NULL) { 544 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - core not found");545 543 async_answer_0(callid, ENOTSOCK); 546 544 return; 547 545 } 548 549 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - spec data"); 546 550 547 udp_sockdata_t *socket = 551 548 (udp_sockdata_t *) sock_core->specific_data; 552 log_msg(LOG_DEFAULT, LVL_DEBUG, "tcp_sock_close() - lock socket");553 549 fibril_mutex_lock(&socket->lock); 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 550 563 551 int rc = socket_destroy(NULL, socket_id, &client->sockets, &gsock, 564 552 udp_free_sock_data); 565 553 if (rc != EOK) { 566 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - socket_destroy failed");567 554 fibril_mutex_unlock(&socket->lock); 568 555 async_answer_0(callid, rc); 569 556 return; 570 557 } 571 572 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_close - broadcast recv_buffer_cv"); 573 fibril_condvar_broadcast(&socket->recv_buffer_cv); 574 558 575 559 fibril_mutex_unlock(&socket->lock); 576 560 async_answer_0(callid, EOK); … … 598 582 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril()"); 599 583 600 fibril_mutex_lock(&sock->recv_buffer_lock);601 602 584 while (true) { 603 585 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] wait for rcv buffer empty()"); 604 while (sock->recv_buffer_used != 0 && sock->sock_core != NULL) { 586 fibril_mutex_lock(&sock->recv_buffer_lock); 587 while (sock->recv_buffer_used != 0) { 605 588 fibril_condvar_wait(&sock->recv_buffer_cv, 606 589 &sock->recv_buffer_lock); 607 590 } 608 609 fibril_mutex_unlock(&sock->recv_buffer_lock); 610 591 611 592 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] call udp_uc_receive()"); 612 593 urc = udp_uc_receive(sock->assoc, sock->recv_buffer, 613 594 UDP_FRAGMENT_SIZE, &rcvd, &xflags, &sock->recv_fsock); 614 fibril_mutex_lock(&sock->recv_buffer_lock);615 595 sock->recv_error = urc; 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 596 597 udp_sock_notify_data(sock->sock_core); 598 622 599 if (urc != UDP_EOK) { 623 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] urc != UDP_EOK, break");624 600 fibril_condvar_broadcast(&sock->recv_buffer_cv); 625 break; 626 } 627 601 fibril_mutex_unlock(&sock->recv_buffer_lock); 602 break; 603 } 604 628 605 log_msg(LOG_DEFAULT, LVL_DEBUG, "[] got data - broadcast recv_buffer_cv"); 629 606 630 607 sock->recv_buffer_used = rcvd; 608 fibril_mutex_unlock(&sock->recv_buffer_lock); 631 609 fibril_condvar_broadcast(&sock->recv_buffer_cv); 632 610 } 633 611 634 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() exited loop");635 fibril_mutex_unlock(&sock->recv_buffer_lock);636 612 udp_uc_destroy(sock->assoc); 637 638 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_sock_recv_fibril() terminated");639 613 640 614 return 0; -
uspace/srv/net/udp/ucall.c
r8fdb18e r1c7ba2d 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);116 115 switch (rc) { 117 case EOK:118 break;119 case ECONNABORTED:120 return UDP_ERESET;121 default:122 assert(false);123 116 } 124 117 … … 140 133 { 141 134 log_msg(LOG_DEFAULT, LVL_DEBUG, "udp_uc_destroy()"); 142 udp_assoc_reset(assoc);143 135 udp_assoc_remove(assoc); 144 136 udp_assoc_delete(assoc); 145 }146 147 void udp_uc_reset(udp_assoc_t *assoc)148 {149 udp_assoc_reset(assoc);150 137 } 151 138 -
uspace/srv/net/udp/ucall.h
r8fdb18e r1c7ba2d 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 *);52 51 53 52 #endif -
uspace/srv/net/udp/udp_type.h
r8fdb18e r1c7ba2d 51 51 UDP_EUNSPEC, 52 52 /* No route to destination */ 53 UDP_ENOROUTE, 54 /** Association reset by user */ 55 UDP_ERESET 53 UDP_ENOROUTE 56 54 } udp_error_t; 57 55 … … 121 119 udp_sockpair_t ident; 122 120 123 /** True if association was reset by user */124 bool reset;125 126 121 /** True if association was deleted by user */ 127 122 bool deleted;
Note:
See TracChangeset
for help on using the changeset viewer.