Changes in uspace/app/nettest2/nettest2.c [c442f63:26de91a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest2/nettest2.c
rc442f63 r26de91a 38 38 #include "print_error.h" 39 39 40 #include <assert.h> 40 41 #include <malloc.h> 41 42 #include <stdio.h> … … 60 61 #define NETTEST2_TEXT "Networking test 2 - transfer" 61 62 62 static uint16_t family = PF_INET;63 static uint16_t family = AF_NONE; 63 64 static size_t size = 28; 64 65 static bool verbose = false; … … 271 272 /* Interpret as a host name */ 272 273 dnsr_hostinfo_t *hinfo = NULL; 273 rc = dnsr_name2host(addr_s, &hinfo, family);274 rc = dnsr_name2host(addr_s, &hinfo, ipver_from_af(family)); 274 275 275 276 if (rc != EOK) { … … 281 282 } 282 283 283 struct sockaddr_in addr; 284 struct sockaddr_in6 addr6; 285 uint16_t af = inet_addr_sockaddr_in(&addr_addr, &addr, &addr6); 286 287 if (af != family) { 284 struct sockaddr *address; 285 socklen_t addrlen; 286 rc = inet_addr_sockaddr(&addr_addr, port, &address, &addrlen); 287 if (rc != EOK) { 288 assert(rc == ENOMEM); 289 printf("Out of memory.\n"); 290 return ENOMEM; 291 } 292 293 if (family == AF_NONE) 294 family = address->sa_family; 295 296 if (address->sa_family != family) { 288 297 printf("Address family does not match explicitly set family.\n"); 289 298 return EINVAL; 290 }291 292 /* Prepare the address buffer */293 294 struct sockaddr *address;295 socklen_t addrlen;296 297 switch (af) {298 case AF_INET:299 addr.sin_port = htons(port);300 address = (struct sockaddr *) &addr;301 addrlen = sizeof(addr);302 break;303 case AF_INET6:304 addr6.sin6_port = htons(port);305 address = (struct sockaddr *) &addr6;306 addrlen = sizeof(addr6);307 break;308 default:309 fprintf(stderr, "Address family is not supported\n");310 return EAFNOSUPPORT;311 299 } 312 300 … … 424 412 return rc; 425 413 414 free(address); 415 426 416 if (verbose) 427 417 printf("\nExiting\n");
Note:
See TracChangeset
for help on using the changeset viewer.