diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 09:36:41 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-01-22 09:36:41 +0000 |
commit | 85629f08bcea5d4a44b6d511422fd608bbc3fc45 (patch) | |
tree | fc8639d0223328741368e3180d4d1fc3e4f84871 | |
parent | 3c99a599155b970a81de26ffcea6f16940324e62 (diff) | |
download | busybox-w32-85629f08bcea5d4a44b6d511422fd608bbc3fc45.tar.gz busybox-w32-85629f08bcea5d4a44b6d511422fd608bbc3fc45.tar.bz2 busybox-w32-85629f08bcea5d4a44b6d511422fd608bbc3fc45.zip |
comment out unused old networking API parts
sockaddr2dotted: return IPV6 addrs in [addr]:port form (was addr:port)
-rw-r--r-- | include/libbb.h | 22 | ||||
-rw-r--r-- | libbb/xconnect.c | 24 | ||||
-rw-r--r-- | networking/ftpgetput.c | 2 | ||||
-rw-r--r-- | networking/wget.c | 4 |
4 files changed, 30 insertions, 22 deletions
diff --git a/include/libbb.h b/include/libbb.h index ede44526b..c1c9486c4 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -282,13 +282,10 @@ extern int xsocket(int domain, int type, int protocol); | |||
282 | extern void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); | 282 | extern void xbind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen); |
283 | extern void xlisten(int s, int backlog); | 283 | extern void xlisten(int s, int backlog); |
284 | extern void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); | 284 | extern void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); |
285 | extern int xconnect_tcp_v4(struct sockaddr_in *s_addr); | ||
286 | extern struct hostent *xgethostbyname(const char *name); | ||
287 | extern struct hostent *xgethostbyname2(const char *name, int af); | ||
288 | extern int setsockopt_reuseaddr(int fd); | 285 | extern int setsockopt_reuseaddr(int fd); |
289 | extern int setsockopt_broadcast(int fd); | 286 | extern int setsockopt_broadcast(int fd); |
290 | 287 | /* NB: returns port in host byte order */ | |
291 | /* "new" (ipv4+ipv6) API */ | 288 | unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port); |
292 | typedef struct len_and_sockaddr { | 289 | typedef struct len_and_sockaddr { |
293 | int len; | 290 | int len; |
294 | union { | 291 | union { |
@@ -320,13 +317,20 @@ extern int xconnect_stream(const len_and_sockaddr *lsa); | |||
320 | * UNIX socket address being returned, IPX sockaddr etc... */ | 317 | * UNIX socket address being returned, IPX sockaddr etc... */ |
321 | extern len_and_sockaddr* host2sockaddr(const char *host, int port); | 318 | extern len_and_sockaddr* host2sockaddr(const char *host, int port); |
322 | /* Assign sin[6]_port member if the socket is of corresponding type, | 319 | /* Assign sin[6]_port member if the socket is of corresponding type, |
323 | * otherwise noop. Useful for ftp. | 320 | * otherwise no-op. Useful for ftp. |
324 | * NB: does NOT do htons() internally, just direct assignment. */ | 321 | * NB: does NOT do htons() internally, just direct assignment. */ |
325 | extern void set_nport(len_and_sockaddr *lsa, unsigned port); | 322 | extern void set_nport(len_and_sockaddr *lsa, unsigned port); |
326 | /* Retrieve sin[6]_port or return -1 for non-inet lsa's */ | 323 | /* Retrieve sin[6]_port or return -1 for non-INET[6] lsa's */ |
327 | extern int get_nport(len_and_sockaddr *lsa); | 324 | extern int get_nport(len_and_sockaddr *lsa); |
328 | extern char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen); | 325 | extern char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen); |
329 | extern char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); | 326 | extern char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); |
327 | // "old" (ipv4 only) API | ||
328 | //void bb_lookup_host(struct sockaddr_in *s_in, const char *host); | ||
329 | //extern int xconnect_tcp_v4(struct sockaddr_in *s_addr); | ||
330 | // users: traceroute.c hostname.c ifconfig.c ping.c | ||
331 | extern struct hostent *xgethostbyname(const char *name); | ||
332 | // ping6 is the only user - convert to new API | ||
333 | extern struct hostent *xgethostbyname2(const char *name, int af); | ||
330 | 334 | ||
331 | 335 | ||
332 | extern char *xstrdup(const char *s); | 336 | extern char *xstrdup(const char *s); |
@@ -536,10 +540,6 @@ USE_DESKTOP(long long) int uncompress(int fd_in, int fd_out); | |||
536 | int inflate(int in, int out); | 540 | int inflate(int in, int out); |
537 | 541 | ||
538 | 542 | ||
539 | /* NB: returns port in host byte order */ | ||
540 | unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default_port); | ||
541 | void bb_lookup_host(struct sockaddr_in *s_in, const char *host); | ||
542 | |||
543 | int bb_make_directory(char *path, long mode, int flags); | 543 | int bb_make_directory(char *path, long mode, int flags); |
544 | 544 | ||
545 | int get_signum(const char *name); | 545 | int get_signum(const char *name); |
diff --git a/libbb/xconnect.c b/libbb/xconnect.c index 377e0657e..62cab95a1 100644 --- a/libbb/xconnect.c +++ b/libbb/xconnect.c | |||
@@ -60,7 +60,7 @@ unsigned bb_lookup_port(const char *port, const char *protocol, unsigned default | |||
60 | 60 | ||
61 | /* "Old" networking API - only IPv4 */ | 61 | /* "Old" networking API - only IPv4 */ |
62 | 62 | ||
63 | 63 | /* | |
64 | void bb_lookup_host(struct sockaddr_in *s_in, const char *host) | 64 | void bb_lookup_host(struct sockaddr_in *s_in, const char *host) |
65 | { | 65 | { |
66 | struct hostent *he; | 66 | struct hostent *he; |
@@ -71,13 +71,14 @@ void bb_lookup_host(struct sockaddr_in *s_in, const char *host) | |||
71 | memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length); | 71 | memcpy(&(s_in->sin_addr), he->h_addr_list[0], he->h_length); |
72 | } | 72 | } |
73 | 73 | ||
74 | |||
74 | int xconnect_tcp_v4(struct sockaddr_in *s_addr) | 75 | int xconnect_tcp_v4(struct sockaddr_in *s_addr) |
75 | { | 76 | { |
76 | int s = xsocket(AF_INET, SOCK_STREAM, 0); | 77 | int s = xsocket(AF_INET, SOCK_STREAM, 0); |
77 | xconnect(s, (struct sockaddr*) s_addr, sizeof(*s_addr)); | 78 | xconnect(s, (struct sockaddr*) s_addr, sizeof(*s_addr)); |
78 | return s; | 79 | return s; |
79 | } | 80 | } |
80 | 81 | */ | |
81 | 82 | ||
82 | /* "New" networking API */ | 83 | /* "New" networking API */ |
83 | 84 | ||
@@ -92,8 +93,8 @@ int get_nport(len_and_sockaddr *lsa) | |||
92 | if (lsa->sa.sa_family == AF_INET) { | 93 | if (lsa->sa.sa_family == AF_INET) { |
93 | return lsa->sin.sin_port; | 94 | return lsa->sin.sin_port; |
94 | } | 95 | } |
95 | return -1; | ||
96 | /* What? UNIX socket? IPX?? :) */ | 96 | /* What? UNIX socket? IPX?? :) */ |
97 | return -1; | ||
97 | } | 98 | } |
98 | 99 | ||
99 | void set_nport(len_and_sockaddr *lsa, unsigned port) | 100 | void set_nport(len_and_sockaddr *lsa, unsigned port) |
@@ -111,7 +112,7 @@ void set_nport(len_and_sockaddr *lsa, unsigned port) | |||
111 | /* What? UNIX socket? IPX?? :) */ | 112 | /* What? UNIX socket? IPX?? :) */ |
112 | } | 113 | } |
113 | 114 | ||
114 | /* peer: "1.2.3.4[:port]", "www.google.com[:port]" | 115 | /* host: "1.2.3.4[:port]", "www.google.com[:port]" |
115 | * port: if neither of above specifies port # | 116 | * port: if neither of above specifies port # |
116 | */ | 117 | */ |
117 | static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags) | 118 | static len_and_sockaddr* str2sockaddr(const char *host, int port, int ai_flags) |
@@ -252,11 +253,18 @@ static char* sockaddr2str(const struct sockaddr *sa, socklen_t salen, int flags) | |||
252 | int rc = getnameinfo(sa, salen, | 253 | int rc = getnameinfo(sa, salen, |
253 | host, sizeof(host), | 254 | host, sizeof(host), |
254 | serv, sizeof(serv), | 255 | serv, sizeof(serv), |
255 | flags | NI_NUMERICSERV /* do not resolve port# */ | 256 | /* do not resolve port# into service _name_ */ |
257 | flags | NI_NUMERICSERV | ||
256 | ); | 258 | ); |
257 | if (rc) return NULL; | 259 | if (rc) |
258 | // We probably need to use [%s]:%s for IPv6... | 260 | return NULL; |
259 | return xasprintf("%s:%s", host, serv); | 261 | #if ENABLE_FEATURE_IPV6 |
262 | if (sa->sa_family == AF_INET6) | ||
263 | return xasprintf("[%s]:%s", host, serv); | ||
264 | #endif | ||
265 | /* For now we don't support anything else, so it has to be INET */ | ||
266 | /*if (sa->sa_family == AF_INET)*/ | ||
267 | return xasprintf("%s:%s", host, serv); | ||
260 | } | 268 | } |
261 | 269 | ||
262 | char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen) | 270 | char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen) |
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 0e2d4173f..ccc0b5e46 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c | |||
@@ -347,7 +347,7 @@ int ftpgetput_main(int argc, char **argv) | |||
347 | * and we want to connect to only one IP... */ | 347 | * and we want to connect to only one IP... */ |
348 | server->lsa = host2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21)); | 348 | server->lsa = host2sockaddr(argv[0], bb_lookup_port(port, "tcp", 21)); |
349 | if (verbose_flag) { | 349 | if (verbose_flag) { |
350 | printf("Connecting to %s [%s]\n", argv[0], | 350 | printf("Connecting to %s (%s)\n", argv[0], |
351 | xmalloc_sockaddr2dotted(&server->lsa->sa, server->lsa->len)); | 351 | xmalloc_sockaddr2dotted(&server->lsa->sa, server->lsa->len)); |
352 | } | 352 | } |
353 | 353 | ||
diff --git a/networking/wget.c b/networking/wget.c index 056d2c7fc..0e0268770 100644 --- a/networking/wget.c +++ b/networking/wget.c | |||
@@ -235,9 +235,9 @@ int wget_main(int argc, char **argv) | |||
235 | * and we want to connect to only one IP... */ | 235 | * and we want to connect to only one IP... */ |
236 | lsa = host2sockaddr(server.host, server.port); | 236 | lsa = host2sockaddr(server.host, server.port); |
237 | if (!(opt & WGET_OPT_QUIET)) { | 237 | if (!(opt & WGET_OPT_QUIET)) { |
238 | fprintf(stderr, "Connecting to %s [%s]\n", server.host, | 238 | fprintf(stderr, "Connecting to %s (%s)\n", server.host, |
239 | xmalloc_sockaddr2dotted(&lsa->sa, lsa->len)); | 239 | xmalloc_sockaddr2dotted(&lsa->sa, lsa->len)); |
240 | /* We leak xmalloc_sockaddr2dotted result */ | 240 | /* We leak result of xmalloc_sockaddr2dotted */ |
241 | } | 241 | } |
242 | 242 | ||
243 | if (use_proxy || !target.is_ftp) { | 243 | if (use_proxy || !target.is_ftp) { |