diff options
author | Denis Vlasenko | 2007-01-11 16:50:23 +0000 |
---|---|---|
committer | Denis Vlasenko | 2007-01-11 16:50:23 +0000 |
commit | 8e9ccba371480fb1fb3da9235fabdbb7861523c3 (patch) | |
tree | 369636a4a765a571e1c6a6ecf2a52ca0131cc90e /include/libbb.h | |
parent | 085231fbbad159d2275cbd5ecdcf4732512bb80f (diff) | |
download | busybox-8e9ccba371480fb1fb3da9235fabdbb7861523c3.zip busybox-8e9ccba371480fb1fb3da9235fabdbb7861523c3.tar.gz |
ipv6-ization efforts continue. Few bugs are found,
unknown number likely introduced...
Diffstat (limited to 'include/libbb.h')
-rw-r--r-- | include/libbb.h | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/include/libbb.h b/include/libbb.h index 62d5fce..c4d187e 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -293,19 +293,10 @@ extern void xconnect(int s, const struct sockaddr *s_addr, socklen_t addrlen); extern int xconnect_tcp_v4(struct sockaddr_in *s_addr); extern struct hostent *xgethostbyname(const char *name); extern struct hostent *xgethostbyname2(const char *name, int af); - extern int setsockopt_reuseaddr(int fd); extern int setsockopt_broadcast(int fd); -/* Create server TCP socket bound to bindaddr:port. bindaddr can be NULL, - * numeric IP ("N.N.N.N") or numeric IPv6 address, - * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). - * If there is no suffix, port argument is used */ -extern int create_and_bind_stream_or_die(const char *bindaddr, int port); -/* Create client TCP socket connected to peer:port. Peer cannot be NULL. - * Peer can be numeric IP ("N.N.N.N"), numeric IPv6 address or hostname, - * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). - * If there is no suffix, port argument is used */ -extern int create_and_connect_stream_or_die(const char *peer, int port); + +/* "new" (ipv4+ipv6) API */ typedef struct len_and_sockaddr { int len; union { @@ -316,11 +307,29 @@ typedef struct len_and_sockaddr { #endif }; } len_and_sockaddr; +/* Create server TCP socket bound to bindaddr:port. bindaddr can be NULL, + * numeric IP ("N.N.N.N") or numeric IPv6 address, + * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). + * If there is no suffix, port argument is used */ +extern int create_and_bind_stream_or_die(const char *bindaddr, int port); +/* Create client TCP socket connected to peer:port. Peer cannot be NULL. + * Peer can be numeric IP ("N.N.N.N"), numeric IPv6 address or hostname, + * and can have ":PORT" suffix (for IPv6 use "[X:X:...:X]:PORT"). + * If there is no suffix, port argument is used */ +extern int create_and_connect_stream_or_die(const char *peer, int port); +/* Connect to peer identified by lsa */ +extern int xconnect_stream(const len_and_sockaddr *lsa); /* Return malloc'ed len_and_sockaddr with socket address of host:port * Currently will return IPv4 or IPv6 sockaddrs only * (depending on host), but in theory nothing prevents e.g. * UNIX socket address being returned, IPX sockaddr etc... */ extern len_and_sockaddr* host2sockaddr(const char *host, int port); +/* assign sin[6]_port member if the socket is of corresponding type, + * otherwise noop. Useful for ftp. + * NB: does NOT do htons() internally, just direct assignment. */ +extern void set_port(len_and_sockaddr *lsa, unsigned port); +char* xmalloc_sockaddr2host(const struct sockaddr *sa, socklen_t salen); +char* xmalloc_sockaddr2dotted(const struct sockaddr *sa, socklen_t salen); extern char *xstrdup(const char *s); |