Changes in / [1c7ba2d:8fdb18e] in mainline
- Files:
-
- 19 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
boot/Makefile.common
r1c7ba2d r8fdb18e 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/dnsres/dnsres \ 167 169 $(USPACE_PATH)/app/edit/edit \ 168 170 $(USPACE_PATH)/app/inet/inet \ -
uspace/Makefile
r1c7ba2d r8fdb18e 39 39 app/bnchmark \ 40 40 app/devctl \ 41 app/dnsres \ 41 42 app/edit \ 42 43 app/getterm \ … … 82 83 srv/devman \ 83 84 srv/loader \ 85 srv/net/dnsrsrv \ 84 86 srv/net/ethip \ 85 87 srv/net/inetsrv \ -
uspace/app/init/init.c
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <inet/dnsr.h> 39 40 #include <inet/addr.h> 40 41 #include <inet/inetping.h> … … 69 70 static void print_syntax(void) 70 71 { 71 printf("syntax: " NAME " [-r] < addr>\n");72 printf("syntax: " NAME " [-r] <host>\n"); 72 73 } 73 74 … … 173 174 int main(int argc, char *argv[]) 174 175 { 176 dnsr_hostinfo_t *hinfo = NULL; 177 char *asrc = NULL; 178 char *adest = NULL; 179 char *sdest = NULL; 175 180 int rc; 176 181 int argi; … … 180 185 printf(NAME ": Failed connecting to internet ping service " 181 186 "(%d).\n", rc); 182 return 1;187 goto error; 183 188 } 184 189 … … 193 198 if (argc - argi != 1) { 194 199 print_syntax(); 195 return 1;200 goto error; 196 201 } 197 202 … … 199 204 rc = inet_addr_parse(argv[argi], &dest_addr); 200 205 if (rc != EOK) { 201 printf(NAME ": Invalid address format.\n"); 202 print_syntax(); 203 return 1; 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; 204 214 } 205 215 … … 208 218 if (rc != EOK) { 209 219 printf(NAME ": Failed determining source address.\n"); 210 return 1; 211 } 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); 212 248 213 249 fid_t fid; … … 217 253 if (fid == 0) { 218 254 printf(NAME ": Failed creating transmit fibril.\n"); 219 return 1;255 goto error; 220 256 } 221 257 … … 225 261 if (fid == 0) { 226 262 printf(NAME ": Failed creating input fibril.\n"); 227 return 1;263 goto error; 228 264 } 229 265 … … 243 279 if (rc == ETIMEOUT) { 244 280 printf(NAME ": Echo request timed out.\n"); 245 return 1; 246 } 247 281 goto error; 282 } 283 284 free(asrc); 285 free(adest); 286 free(sdest); 287 dnsr_hostinfo_destroy(hinfo); 248 288 return 0; 289 error: 290 free(asrc); 291 free(adest); 292 free(sdest); 293 dnsr_hostinfo_destroy(hinfo); 294 return 1; 249 295 } 250 296 -
uspace/lib/c/Makefile
r1c7ba2d r8fdb18e 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 \ -
uspace/lib/c/include/ipc/services.h
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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/udp/assoc.c
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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
r1c7ba2d r8fdb18e 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.