Changes in uspace/app/nettest2/nettest2.c [26de91a:c442f63] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nettest2/nettest2.c
r26de91a rc442f63 38 38 #include "print_error.h" 39 39 40 #include <assert.h>41 40 #include <malloc.h> 42 41 #include <stdio.h> … … 61 60 #define NETTEST2_TEXT "Networking test 2 - transfer" 62 61 63 static uint16_t family = AF_NONE;62 static uint16_t family = PF_INET; 64 63 static size_t size = 28; 65 64 static bool verbose = false; … … 272 271 /* Interpret as a host name */ 273 272 dnsr_hostinfo_t *hinfo = NULL; 274 rc = dnsr_name2host(addr_s, &hinfo, ipver_from_af(family));273 rc = dnsr_name2host(addr_s, &hinfo, family); 275 274 276 275 if (rc != EOK) { … … 282 281 } 283 282 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) { 288 printf("Address family does not match explicitly set family.\n"); 289 return EINVAL; 290 } 291 292 /* Prepare the address buffer */ 293 284 294 struct sockaddr *address; 285 295 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) { 297 printf("Address family does not match explicitly set family.\n"); 298 return EINVAL; 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; 299 311 } 300 312 … … 412 424 return rc; 413 425 414 free(address);415 416 426 if (verbose) 417 427 printf("\nExiting\n");
Note:
See TracChangeset
for help on using the changeset viewer.