Changeset 4c14b88 in mainline for uspace/app
- Timestamp:
- 2013-12-31T07:57:14Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1b973dc
- Parents:
- 6297465 (diff), 208b5f5 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/app
- Files:
-
- 20 added
- 1 deleted
- 14 edited
-
dnsres/dnsres.c (modified) (4 diffs)
-
download/Makefile (modified) (1 diff)
-
download/main.c (modified) (5 diffs)
-
getterm/getterm.c (modified) (2 diffs)
-
hdisk/Makefile (added)
-
hdisk/common.h (added)
-
hdisk/func_gpt.c (added)
-
hdisk/func_gpt.h (added)
-
hdisk/func_mbr.c (added)
-
hdisk/func_mbr.h (added)
-
hdisk/func_none.c (added)
-
hdisk/func_none.h (added)
-
hdisk/hdisk.c (added)
-
hdisk/hdisk.h (added)
-
hdisk/input.c (added)
-
hdisk/input.h (added)
-
init/init.c (modified) (1 diff)
-
netspeed/netspeed.c (modified) (7 diffs)
-
nettest1/nettest1.c (modified) (4 diffs)
-
nettest2/nettest2.c (modified) (5 diffs)
-
nettest3/nettest3.c (modified) (7 diffs)
-
nterm/conn.c (modified) (5 diffs)
-
ping/ping.c (modified) (8 diffs)
-
ping6/ping6.c (deleted)
-
tester/Makefile (modified) (1 diff)
-
tester/tester.c (modified) (1 diff)
-
tester/tester.h (modified) (2 diffs)
-
tester/thread/setjmp1.c (added)
-
tester/thread/setjmp1.def (added)
-
untar/Makefile (added)
-
untar/main.c (added)
-
untar/tar.c (added)
-
untar/tar.h (added)
-
viewer/Makefile (added)
-
viewer/viewer.c (added)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/dnsres/dnsres.c
r6297465 r4c14b88 36 36 #include <inet/addr.h> 37 37 #include <inet/dnsr.h> 38 #include <net/socket_codes.h>39 38 #include <stdio.h> 40 39 #include <stdlib.h> … … 54 53 } 55 54 56 uint16_t af;55 uint16_t ver; 57 56 char *hname; 58 57 … … 63 62 } 64 63 65 af = AF_INET;64 ver = ip_v4; 66 65 hname = argv[2]; 67 66 } else if (str_cmp(argv[1], "-6") == 0) { … … 71 70 } 72 71 73 af = AF_INET6;72 ver = ip_v6; 74 73 hname = argv[2]; 75 74 } else { 76 af = 0;75 ver = ip_any; 77 76 hname = argv[1]; 78 77 } 79 78 80 79 dnsr_hostinfo_t *hinfo; 81 int rc = dnsr_name2host(hname, &hinfo, af);80 int rc = dnsr_name2host(hname, &hinfo, ver); 82 81 if (rc != EOK) { 83 82 printf("%s: Error resolving '%s'.\n", NAME, hname); -
uspace/app/download/Makefile
r6297465 r4c14b88 29 29 USPACE_PREFIX = ../.. 30 30 LIBS = $(LIBHTTP_PREFIX)/libhttp.a $(LIBURI_PREFIX)/liburi.a 31 EXTRA_CFLAGS = -I$(LIBHTTP_PREFIX) -I$(LIBURI_PREFIX)31 EXTRA_CFLAGS = -I$(LIBHTTP_PREFIX)/include -I$(LIBURI_PREFIX) 32 32 DEFS = -DRELEASE=$(RELEASE) 33 33 BINARY = download -
uspace/app/download/main.c
r6297465 r4c14b88 47 47 #include <net/socket.h> 48 48 49 #include <http .h>49 #include <http/http.h> 50 50 #include <uri.h> 51 51 … … 132 132 fprintf(stderr, "Failed creating request\n"); 133 133 uri_destroy(uri); 134 free(server_path);135 134 return 3; 136 135 } 137 136 138 http_header_t *header_host = http_header_create("Host", uri->host); 139 if (header_host == NULL) { 140 fprintf(stderr, "Failed creating Host header\n"); 141 uri_destroy(uri); 142 free(server_path); 143 return 3; 144 } 145 list_append(&header_host->link, &req->headers); 146 147 http_header_t *header_ua = http_header_create("User-Agent", USER_AGENT); 148 if (header_ua == NULL) { 149 fprintf(stderr, "Failed creating User-Agent header\n"); 150 uri_destroy(uri); 151 free(server_path); 152 return 3; 153 } 154 list_append(&header_ua->link, &req->headers); 137 int rc = http_headers_append(&req->headers, "Host", uri->host); 138 if (rc != EOK) { 139 fprintf(stderr, "Failed setting Host header: %s\n", str_error(rc)); 140 uri_destroy(uri); 141 return rc; 142 } 143 144 rc = http_headers_append(&req->headers, "User-Agent", USER_AGENT); 145 if (rc != EOK) { 146 fprintf(stderr, "Failed creating User-Agent header: %s\n", str_error(rc)); 147 uri_destroy(uri); 148 return rc; 149 } 155 150 156 151 http_t *http = http_create(uri->host, port); 157 152 if (http == NULL) { 158 153 uri_destroy(uri); 159 free(server_path);160 154 fprintf(stderr, "Failed creating HTTP object\n"); 161 155 return 3; 162 156 } 163 157 164 intrc = http_connect(http);158 rc = http_connect(http); 165 159 if (rc != EOK) { 166 160 fprintf(stderr, "Failed connecting: %s\n", str_error(rc)); 167 161 uri_destroy(uri); 168 free(server_path);169 162 return rc; 170 163 } … … 174 167 fprintf(stderr, "Failed sending request: %s\n", str_error(rc)); 175 168 uri_destroy(uri); 176 free(server_path);177 169 return rc; 178 170 } 179 171 180 172 http_response_t *response = NULL; 181 rc = http_receive_response(http, &response); 173 rc = http_receive_response(&http->recv_buffer, &response, 16 * 1024, 174 100); 182 175 if (rc != EOK) { 183 176 fprintf(stderr, "Failed receiving response: %s\n", str_error(rc)); 184 177 uri_destroy(uri); 185 free(server_path);186 178 return rc; 187 179 } … … 197 189 fprintf(stderr, "Failed allocating buffer\n)"); 198 190 uri_destroy(uri); 199 free(server_path);200 191 return ENOMEM; 201 192 } 202 193 203 194 int body_size; 204 while ((body_size = http_receive_body(http, buf, buf_size)) > 0) {195 while ((body_size = recv_buffer(&http->recv_buffer, buf, buf_size)) > 0) { 205 196 fwrite(buf, 1, body_size, stdout); 206 197 } … … 212 203 213 204 uri_destroy(uri); 214 free(server_path);215 205 return EOK; 216 206 } -
uspace/app/getterm/getterm.c
r6297465 r4c14b88 112 112 reopen(&stderr, 2, term, O_WRONLY, "w"); 113 113 114 /*115 * FIXME: fdopen() should actually detect that we are opening a console116 * and it should set line-buffering mode automatically.117 */118 setvbuf(stdout, NULL, _IOLBF, BUFSIZ);119 120 114 if (stdin == NULL) 121 115 return -2; … … 126 120 if (stderr == NULL) 127 121 return -4; 122 123 /* 124 * FIXME: fdopen() should actually detect that we are opening a console 125 * and it should set line-buffering mode automatically. 126 */ 127 setvbuf(stdout, NULL, _IOLBF, BUFSIZ); 128 128 129 129 version_print(term); -
uspace/app/init/init.c
r6297465 r4c14b88 360 360 srv_start("/srv/udp"); 361 361 srv_start("/srv/dnsrsrv"); 362 srv_start("/srv/dhcp"); 363 srv_start("/srv/nconfsrv"); 362 364 363 365 srv_start("/srv/clipboard"); -
uspace/app/netspeed/netspeed.c
r6297465 r4c14b88 36 36 */ 37 37 38 #include <assert.h> 39 #include <inet/dnsr.h> 40 #include <net/in.h> 41 #include <net/inet.h> 42 #include <net/socket.h> 38 43 #include <stdio.h> 39 44 #include <stdlib.h> … … 41 46 #include <str_error.h> 42 47 #include <task.h> 43 44 #include <net/in.h>45 #include <net/inet.h>46 #include <net/socket.h>47 48 48 49 #define NAME "netspeed" … … 114 115 } 115 116 116 static int client(sock_type_t sock_type, const char * address, unsigned port,117 static int client(sock_type_t sock_type, const char *host, unsigned port, 117 118 unsigned long count, char *buf, size_t bufsize) 118 119 { 119 struct sockaddr_in addr; 120 121 addr.sin_family = AF_INET; 122 addr.sin_port = htons(port); 123 124 int rc = inet_pton(AF_INET, address, (void *) &addr.sin_addr.s_addr); 125 if (rc != EOK) { 126 fprintf(stderr, "inet_pton failed: %s\n", str_error(rc)); 127 return rc; 128 } 129 130 int conn_sd = socket(PF_INET, sock_type, 0); 120 inet_addr_t iaddr; 121 struct sockaddr *saddr; 122 socklen_t saddrlen; 123 124 int rc = inet_addr_parse(host, &iaddr); 125 if (rc != EOK) { 126 dnsr_hostinfo_t *hinfo = NULL; 127 rc = dnsr_name2host(host, &hinfo, ip_any); 128 if (rc != EOK) { 129 fprintf(stderr, "Error resolving host '%s'.\n", host); 130 return ENOENT; 131 } 132 133 iaddr = hinfo->addr; 134 } 135 136 rc = inet_addr_sockaddr(&iaddr, port, &saddr, &saddrlen); 137 if (rc != EOK) { 138 assert(rc == ENOMEM); 139 fprintf(stderr, "Out of memory.\n"); 140 return ENOMEM; 141 } 142 143 int conn_sd = socket(saddr->sa_family, sock_type, 0); 131 144 if (conn_sd < 0) { 132 145 fprintf(stderr, "socket failed: %s\n", str_error(rc)); … … 135 148 136 149 if (sock_type == SOCK_STREAM) { 137 rc = connect(conn_sd, (struct sockaddr *) &addr, sizeof(addr));150 rc = connect(conn_sd, saddr, saddrlen); 138 151 if (rc != EOK) { 139 152 fprintf(stderr, "connect failed: %s\n", str_error(rc)); … … 151 164 rc = send(conn_sd, buf, bufsize, 0); 152 165 } else { 153 rc = sendto(conn_sd, buf, bufsize, 0, 154 (struct sockaddr *) &addr, sizeof(addr)); 166 rc = sendto(conn_sd, buf, bufsize, 0, saddr, saddrlen); 155 167 } 156 168 if (rc != EOK) { … … 161 173 162 174 closesocket(conn_sd); 175 free(saddr); 163 176 return rc; 164 177 } … … 167 180 { 168 181 fprintf(stderr, "Usage: netspeed <tcp|udp> server [port] <buffer size>\n"); 169 fprintf(stderr, " netspeed <tcp|udp> client < ip> <port> <count> <buffer size>\n");182 fprintf(stderr, " netspeed <tcp|udp> client <host> <port> <count> <buffer size>\n"); 170 183 } 171 184 -
uspace/app/nettest1/nettest1.c
r6297465 r4c14b88 38 38 #include "print_error.h" 39 39 40 #include <assert.h> 40 41 #include <malloc.h> 41 42 #include <stdio.h> … … 59 60 #define NETTEST1_TEXT "Networking test 1 - sockets" 60 61 61 static uint16_t family = AF_ INET;62 static uint16_t family = AF_NONE; 62 63 static sock_type_t type = SOCK_DGRAM; 63 64 static size_t size = 27; … … 326 327 } 327 328 328 char * addr_s= argv[argc - 1];329 char *host = argv[argc - 1]; 329 330 330 331 /* Interpret as address */ 331 inet_addr_t addr_addr;332 rc = inet_addr_parse( addr_s, &addr_addr);332 inet_addr_t iaddr; 333 rc = inet_addr_parse(host, &iaddr); 333 334 334 335 if (rc != EOK) { 335 336 /* Interpret as a host name */ 336 337 dnsr_hostinfo_t *hinfo = NULL; 337 rc = dnsr_name2host( addr_s, &hinfo, family);338 rc = dnsr_name2host(host, &hinfo, ipver_from_af(family)); 338 339 339 340 if (rc != EOK) { 340 printf("Error resolving host '%s'.\n", addr_s);341 printf("Error resolving host '%s'.\n", host); 341 342 return EINVAL; 342 343 } 343 344 344 addr_addr = hinfo->addr; 345 } 346 347 struct sockaddr_in addr; 348 struct sockaddr_in6 addr6; 349 uint16_t af = inet_addr_sockaddr_in(&addr_addr, &addr, &addr6); 350 351 if (af != family) { 345 iaddr = hinfo->addr; 346 } 347 348 rc = inet_addr_sockaddr(&iaddr, port, &address, &addrlen); 349 if (rc != EOK) { 350 assert(rc == ENOMEM); 351 printf("Out of memory.\n"); 352 return ENOMEM; 353 } 354 355 if (family == AF_NONE) 356 family = address->sa_family; 357 358 if (address->sa_family != family) { 352 359 printf("Address family does not match explicitly set family.\n"); 353 360 return EINVAL; 354 }355 356 /* Prepare the address buffer */357 358 switch (af) {359 case AF_INET:360 addr.sin_port = htons(port);361 address = (struct sockaddr *) &addr;362 addrlen = sizeof(addr);363 break;364 case AF_INET6:365 addr6.sin6_port = htons(port);366 address = (struct sockaddr *) &addr6;367 addrlen = sizeof(addr6);368 break;369 default:370 fprintf(stderr, "Address family is not supported\n");371 return EAFNOSUPPORT;372 361 } 373 362 … … 434 423 &time_before)); 435 424 425 free(address); 426 436 427 if (verbose) 437 428 printf("Exiting\n"); -
uspace/app/nettest2/nettest2.c
r6297465 r4c14b88 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"); -
uspace/app/nettest3/nettest3.c
r6297465 r4c14b88 37 37 #include <async.h> 38 38 #include <stdio.h> 39 #include <stdlib.h> 39 40 #include <str.h> 40 41 … … 52 53 static char buf[BUF_SIZE]; 53 54 54 static struct sockaddr_in addr; 55 static struct sockaddr *address; 56 static socklen_t addrlen; 55 57 56 58 static uint16_t port; … … 62 64 char *endptr; 63 65 dnsr_hostinfo_t *hinfo; 66 inet_addr_t addr; 67 char *addr_s; 64 68 65 69 port = 7; … … 69 73 70 74 /* Connect to local IP address by default */ 71 addr.sin_family = AF_INET; 72 addr.sin_port = htons(port); 73 addr.sin_addr.s_addr = htonl(0x7f000001); 75 inet_addr(&addr, 127, 0, 0, 1); 74 76 75 77 if (argc >= 2) { 76 78 printf("parsing address '%s'\n", argv[1]); 77 rc = inet_ pton(AF_INET, argv[1], (uint8_t *)&addr.sin_addr.s_addr);79 rc = inet_addr_parse(argv[1], &addr); 78 80 if (rc != EOK) { 79 81 /* Try interpreting as a host name */ 80 rc = dnsr_name2host(argv[1], &hinfo, AF_INET);82 rc = dnsr_name2host(argv[1], &hinfo, ip_v4); 81 83 if (rc != EOK) { 82 84 printf("Error resolving host '%s'.\n", argv[1]); 83 85 return rc; 84 86 } 85 86 uint16_t af = inet_addr_sockaddr_in(&hinfo->addr, &addr, NULL); 87 if (af != AF_INET) { 88 printf("Host '%s' not resolved as IPv4 address.\n", argv[1]); 89 return rc; 90 } 87 88 addr = hinfo->addr; 91 89 } 92 printf("result: rc=%d, family=%d, addr=%x\n", rc, 93 addr.sin_family, addr.sin_addr.s_addr); 90 rc = inet_addr_format(&addr, &addr_s); 91 if (rc != EOK) { 92 assert(rc == ENOMEM); 93 printf("Out of memory.\n"); 94 return rc; 95 } 96 printf("result: rc=%d, ver=%d, addr=%s\n", rc, 97 addr.version, addr_s); 98 free(addr_s); 94 99 } 95 100 96 101 if (argc >= 3) { 97 102 printf("parsing port '%s'\n", argv[2]); 98 addr.sin_port = htons(strtoul(argv[2], &endptr, 10));103 port = htons(strtoul(argv[2], &endptr, 10)); 99 104 if (*endptr != '\0') { 100 105 fprintf(stderr, "Error parsing port\n"); … … 103 108 } 104 109 110 rc = inet_addr_sockaddr(&hinfo->addr, port, &address, &addrlen); 111 if (rc != EOK) { 112 printf("Out of memory.\n"); 113 return rc; 114 } 115 105 116 printf("socket()\n"); 106 fd = socket( PF_INET, SOCK_STREAM, IPPROTO_TCP);117 fd = socket(address->sa_family, SOCK_STREAM, IPPROTO_TCP); 107 118 printf(" -> %d\n", fd); 108 119 if (fd < 0) … … 110 121 111 122 printf("connect()\n"); 112 rc = connect(fd, (struct sockaddr *) &addr, sizeof(addr));123 rc = connect(fd, address, addrlen); 113 124 printf(" -> %d\n", rc); 114 125 if (rc != 0) … … 133 144 printf(" -> %d\n", rc); 134 145 146 free(address); 147 135 148 return 0; 136 149 } -
uspace/app/nterm/conn.c
r6297465 r4c14b88 38 38 #include <fibril.h> 39 39 #include <inet/dnsr.h> 40 #include <net/inet.h> 40 41 #include <net/socket.h> 41 42 #include <stdio.h> 43 #include <stdlib.h> 42 44 #include <str_error.h> 43 45 #include <sys/types.h> … … 73 75 } 74 76 75 int conn_open(const char * addr_s, const char *port_s)77 int conn_open(const char *host, const char *port_s) 76 78 { 77 79 int conn_fd = -1; 80 struct sockaddr *saddr = NULL; 81 socklen_t saddrlen; 78 82 79 83 /* Interpret as address */ 80 inet_addr_t addr_addr;81 int rc = inet_addr_parse( addr_s, &addr_addr);84 inet_addr_t iaddr; 85 int rc = inet_addr_parse(host, &iaddr); 82 86 83 87 if (rc != EOK) { 84 88 /* Interpret as a host name */ 85 89 dnsr_hostinfo_t *hinfo = NULL; 86 rc = dnsr_name2host( addr_s, &hinfo, 0);90 rc = dnsr_name2host(host, &hinfo, ip_any); 87 91 88 92 if (rc != EOK) { 89 printf("Error resolving host '%s'.\n", addr_s);93 printf("Error resolving host '%s'.\n", host); 90 94 goto error; 91 95 } 92 96 93 addr_addr = hinfo->addr;97 iaddr = hinfo->addr; 94 98 } 95 96 struct sockaddr_in addr;97 struct sockaddr_in6 addr6;98 uint16_t af = inet_addr_sockaddr_in(&addr_addr, &addr, &addr6);99 99 100 100 char *endptr; … … 105 105 } 106 106 107 printf("Connecting to host %s port %u\n", addr_s, port); 107 rc = inet_addr_sockaddr(&iaddr, port, &saddr, &saddrlen); 108 if (rc != EOK) { 109 assert(rc == ENOMEM); 110 printf("Out of memory.\n"); 111 return ENOMEM; 112 } 108 113 109 conn_fd = socket(PF_INET, SOCK_STREAM, 0); 114 printf("Connecting to host %s port %u\n", host, port); 115 116 conn_fd = socket(saddr->sa_family, SOCK_STREAM, 0); 110 117 if (conn_fd < 0) 111 118 goto error; 112 119 113 switch (af) { 114 case AF_INET: 115 addr.sin_port = htons(port); 116 rc = connect(conn_fd, (struct sockaddr *) &addr, sizeof(addr)); 117 break; 118 case AF_INET6: 119 addr6.sin6_port = htons(port); 120 rc = connect(conn_fd, (struct sockaddr *) &addr6, sizeof(addr6)); 121 break; 122 default: 123 printf("Unknown address family.\n"); 124 goto error; 125 } 126 120 rc = connect(conn_fd, saddr, saddrlen); 127 121 if (rc != EOK) 128 122 goto error; … … 134 128 fibril_add_ready(rcv_fid); 135 129 130 free(saddr); 136 131 return EOK; 137 138 132 error: 139 133 if (conn_fd >= 0) { … … 141 135 conn_fd = -1; 142 136 } 137 free(saddr); 143 138 144 139 return EIO; -
uspace/app/ping/ping.c
r6297465 r4c14b88 37 37 #include <errno.h> 38 38 #include <fibril_synch.h> 39 #include <net/socket_codes.h>40 39 #include <inet/dnsr.h> 41 40 #include <inet/addr.h> … … 77 76 }; 78 77 79 static addr32_t src;80 static addr32_t dest;78 static inet_addr_t src_addr; 79 static inet_addr_t dest_addr; 81 80 82 81 static bool repeat_forever = false; 83 82 static size_t repeat_count = 1; 84 83 85 static const char *short_options = " rn:";84 static const char *short_options = "46rn:"; 86 85 87 86 static void print_syntax(void) 88 87 { 89 printf("Syntax: %s [-n <count>|-r] <host>\n", NAME); 88 printf("Syntax: %s [<options>] <host>\n", NAME); 89 printf("\t-n <count> Repeat the specified number of times\n"); 90 printf("\t-r Repeat forever\n"); 91 printf("\t-4|-6 Use IPv4 or IPv6 destination host address\n"); 90 92 } 91 93 … … 108 110 static int ping_ev_recv(inetping_sdu_t *sdu) 109 111 { 110 inet_addr_t src_addr;111 inet_addr_set(sdu->src, &src_addr);112 113 inet_addr_t dest_addr;114 inet_addr_set(sdu->dest, &dest_addr);115 116 112 char *asrc; 117 113 int rc = inet_addr_format(&src_addr, &asrc); … … 140 136 inetping_sdu_t sdu; 141 137 142 sdu.src = src ;143 sdu.dest = dest ;138 sdu.src = src_addr; 139 sdu.dest = dest_addr; 144 140 sdu.seq_no = seq_no; 145 141 sdu.data = (void *) "foo"; … … 222 218 char *adest = NULL; 223 219 char *sdest = NULL; 220 ip_ver_t ip_ver = ip_any; 224 221 225 222 int rc = inetping_init(&ev_ops); … … 244 241 } 245 242 break; 243 case '4': 244 ip_ver = ip_v4; 245 break; 246 case '6': 247 ip_ver = ip_v6; 248 break; 246 249 default: 247 250 printf("Unknown option passed.\n"); … … 258 261 259 262 /* Parse destination address */ 260 inet_addr_t dest_addr;261 263 rc = inet_addr_parse(argv[optind], &dest_addr); 262 264 if (rc != EOK) { 263 265 /* Try interpreting as a host name */ 264 rc = dnsr_name2host(argv[optind], &hinfo, AF_INET);266 rc = dnsr_name2host(argv[optind], &hinfo, ip_ver); 265 267 if (rc != EOK) { 266 268 printf("Error resolving host '%s'.\n", argv[optind]); … … 271 273 } 272 274 273 uint16_t af = inet_addr_get(&dest_addr, &dest, NULL);274 if (af != AF_INET) {275 printf("Destination '%s' is not an IPv4 address.\n",276 argv[optind]);277 goto error;278 }279 280 275 /* Determine source address */ 281 rc = inetping_get_srcaddr( dest, &src);276 rc = inetping_get_srcaddr(&dest_addr, &src_addr); 282 277 if (rc != EOK) { 283 278 printf("Failed determining source address.\n"); 284 279 goto error; 285 280 } 286 287 inet_addr_t src_addr;288 inet_addr_set(src, &src_addr);289 281 290 282 rc = inet_addr_format(&src_addr, &asrc); -
uspace/app/tester/Makefile
r6297465 r4c14b88 37 37 util.c \ 38 38 thread/thread1.c \ 39 thread/setjmp1.c \ 39 40 print/print1.c \ 40 41 print/print2.c \ -
uspace/app/tester/tester.c
r6297465 r4c14b88 48 48 test_t tests[] = { 49 49 #include "thread/thread1.def" 50 #include "thread/setjmp1.def" 50 51 #include "print/print1.def" 51 52 #include "print/print2.def" -
uspace/app/tester/tester.h
r6297465 r4c14b88 39 39 #include <stdbool.h> 40 40 #include <stacktrace.h> 41 #include <stdio.h> 41 42 42 43 #define IPC_TEST_SERVICE 10240 … … 80 81 81 82 extern const char *test_thread1(void); 83 extern const char *test_setjmp1(void); 82 84 extern const char *test_print1(void); 83 85 extern const char *test_print2(void);
Note:
See TracChangeset
for help on using the changeset viewer.
