Changeset 287d729 in mainline
- Timestamp:
- 2013-04-25T06:45:04Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fff7ef4
- Parents:
- c55cbbf
- Location:
- uspace
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest1/nettest1.c
rc55cbbf r287d729 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_init(); 357 if (rc != EOK) { 358 printf("Failed connecting DNS resolution " 359 "service (%d).\n", rc); 360 return rc; 361 } 362 363 rc = dnsr_name2host(argv[argc - 1], &hinfo); 364 if (rc != EOK) { 365 printf("Error resolving host '%s'.\n", argv[argc - 1]); 366 return rc; 367 } 368 369 address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 355 370 } 356 371 -
uspace/app/nettest2/nettest2.c
rc55cbbf r287d729 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_init(); 303 if (rc != EOK) { 304 printf("Failed connecting DNS resolution " 305 "service (%d).\n", rc); 306 return rc; 307 } 308 309 rc = dnsr_name2host(argv[argc - 1], &hinfo); 310 if (rc != EOK) { 311 printf("Error resolving host '%s'.\n", argv[argc - 1]); 312 return rc; 313 } 314 315 address_in.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 301 316 } 302 317 -
uspace/app/nettest3/nettest3.c
rc55cbbf r287d729 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_init(); 81 if (rc != EOK) { 82 printf("Failed connecting DNS resolution " 83 "service (%d).\n", rc); 84 return rc; 85 } 86 87 rc = dnsr_name2host(argv[1], &hinfo); 88 if (rc != EOK) { 89 printf("Error resolving host '%s'.\n", argv[1]); 90 return rc; 91 } 92 93 addr.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 94 addr.sin_family = AF_INET; 79 95 } 80 96 printf("result: rc=%d, family=%d, addr=%x\n", rc, -
uspace/app/nterm/conn.c
rc55cbbf r287d729 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_init(); 88 if (rc != EOK) { 89 printf("Failed connecting DNS resolution " 90 "service (%d).\n", rc); 91 goto error; 92 } 93 94 rc = dnsr_name2host(addr_s, &hinfo); 95 if (rc != EOK) { 96 printf("Error resolving host '%s'.\n", addr_s); 97 goto error; 98 } 99 100 addr.sin_addr.s_addr = host2uint32_t_be(hinfo->addr.ipv4); 85 101 } 86 102 … … 88 104 if (*endptr != '\0') { 89 105 printf("Invalid port number %s\n", port_s); 90 return EINVAL;106 goto error; 91 107 } 92 108 … … 95 111 goto error; 96 112 97 printf("Connecting to address%s port %u\n", addr_s, ntohs(addr.sin_port));113 printf("Connecting to host %s port %u\n", addr_s, ntohs(addr.sin_port)); 98 114 99 115 rc = connect(conn_fd, (struct sockaddr *)&addr, sizeof(addr)); -
uspace/app/nterm/nterm.c
rc55cbbf r287d729 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
rc55cbbf r287d729 69 69 static void print_syntax(void) 70 70 { 71 printf("syntax: " NAME " [-r] < addr>\n");71 printf("syntax: " NAME " [-r] <host>\n"); 72 72 } 73 73 -
uspace/lib/c/generic/dnsr.c
rc55cbbf r287d729 59 59 } 60 60 61 int dnsr_name2host(c har *name, dnsr_hostinfo_t **rinfo)61 int dnsr_name2host(const char *name, dnsr_hostinfo_t **rinfo) 62 62 { 63 63 async_exch_t *exch = async_exchange_begin(dnsr_sess); -
uspace/lib/c/include/inet/dnsr.h
rc55cbbf r287d729 46 46 47 47 extern int dnsr_init(void); 48 extern int dnsr_name2host(c har *, dnsr_hostinfo_t **);48 extern int dnsr_name2host(const char *, dnsr_hostinfo_t **); 49 49 extern void dnsr_hostinfo_destroy(dnsr_hostinfo_t *); 50 50 extern int dnsr_get_srvaddr(inet_addr_t *);
Note:
See TracChangeset
for help on using the changeset viewer.