links

lynx-like text mode web browser
git clone anongit@rnpnr.xyz:links.git
Log | Files | Refs | Feed | README | LICENSE

Commit: 6368a8f4728abf7452c36b8a05a6b99f243b3fe3
Parent: 38aa1cffa67bffc0dfa1353e54c673956147e204
Author: Randy Palamar
Date:   Thu, 26 Aug 2021 17:35:51 -0600

connect.c: delete unused code

Diffstat:
Mconnect.c | 105-------------------------------------------------------------------------------
Mlinks.h | 3---
2 files changed, 0 insertions(+), 108 deletions(-)

diff --git a/connect.c b/connect.c @@ -152,111 +152,6 @@ void make_connection(struct connection *c, int port, int *sock, void (*func)(str if (as) setcstate(c, S_DNS); } -int is_ipv6(int h) -{ - union { - struct sockaddr sa; - struct sockaddr_in sin; - struct sockaddr_in6 sin6; - char pad[128]; - } u; - socklen_t len = sizeof(u); - int rs; - EINTRLOOP(rs, getsockname(h, &u.sa, &len)); - if (rs) return 0; - return u.sa.sa_family == AF_INET6; -} - -int get_pasv_socket(struct connection *c, int cc, int *sock, unsigned char *port) -{ - int s; - int rs; - struct sockaddr_in sa; - struct sockaddr_in sb; - socklen_t len = sizeof(sa); - memset(&sa, 0, sizeof sa); - memset(&sb, 0, sizeof sb); - EINTRLOOP(rs, getsockname(cc, (struct sockaddr *)(void *)&sa, &len)); - if (rs) goto e; - if (sa.sin_family != AF_INET) { - errno = EINVAL; - goto e; - } - s = c_socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); - *sock = s; - set_nonblock(s); - memcpy(&sb, &sa, sizeof(struct sockaddr_in)); - sb.sin_port = htons(0); - EINTRLOOP(rs, bind(s, (struct sockaddr *)(void *)&sb, sizeof sb)); - if (rs) goto e; - len = sizeof(sa); - EINTRLOOP(rs, getsockname(s, (struct sockaddr *)(void *)&sa, &len)); - if (rs) goto e; - EINTRLOOP(rs, listen(s, 1)); - if (rs) goto e; - memcpy(port, &sa.sin_addr.s_addr, 4); - memcpy(port + 4, &sa.sin_port, 2); - return 0; - - e: - setcstate(c, get_error_from_errno(errno)); - retry_connection(c); - return -1; -} - -int get_pasv_socket_ipv6(struct connection *c, int cc, int *sock, unsigned char *result) -{ - int s; - int rs; - struct sockaddr_in6 sa; - struct sockaddr_in6 sb; - socklen_t len = sizeof(sa); - memset(&sa, 0, sizeof sa); - memset(&sb, 0, sizeof sb); - EINTRLOOP(rs, getsockname(cc, (struct sockaddr *)(void *)&sa, &len)); - if (rs) goto e; - if (sa.sin6_family != AF_INET6) { - errno = EINVAL; - goto e; - } - s = c_socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP); - *sock = s; - set_nonblock(s); - memcpy(&sb, &sa, sizeof(struct sockaddr_in6)); - sb.sin6_port = htons(0); - EINTRLOOP(rs, bind(s, (struct sockaddr *)(void *)&sb, sizeof sb)); - if (rs) goto e; - len = sizeof(sa); - EINTRLOOP(rs, getsockname(s, (struct sockaddr *)(void *)&sa, &len)); - if (rs) goto e; - EINTRLOOP(rs, listen(s, 1)); - if (rs) goto e; - sprintf(cast_char result, "|2|%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x|%d|", - sa.sin6_addr.s6_addr[0], - sa.sin6_addr.s6_addr[1], - sa.sin6_addr.s6_addr[2], - sa.sin6_addr.s6_addr[3], - sa.sin6_addr.s6_addr[4], - sa.sin6_addr.s6_addr[5], - sa.sin6_addr.s6_addr[6], - sa.sin6_addr.s6_addr[7], - sa.sin6_addr.s6_addr[8], - sa.sin6_addr.s6_addr[9], - sa.sin6_addr.s6_addr[10], - sa.sin6_addr.s6_addr[11], - sa.sin6_addr.s6_addr[12], - sa.sin6_addr.s6_addr[13], - sa.sin6_addr.s6_addr[14], - sa.sin6_addr.s6_addr[15], - htons(sa.sin6_port) & 0xffff); - return 0; - - e: - setcstate(c, get_error_from_errno(errno)); - retry_connection(c); - return -1; -} - static void ssl_setup_downgrade(struct connection *c) { #if !defined(HAVE_NSS) diff --git a/links.h b/links.h @@ -759,9 +759,6 @@ void close_socket(int *); void make_connection(struct connection *, int, int *, void (*)(struct connection *)); void retry_connect(struct connection *, int, int); void continue_connection(struct connection *, int *, void (*)(struct connection *)); -int is_ipv6(int); -int get_pasv_socket(struct connection *, int, int *, unsigned char *); -int get_pasv_socket_ipv6(struct connection *, int, int *, unsigned char *); void write_to_socket(struct connection *, int, unsigned char *, int, void (*)(struct connection *)); struct read_buffer *alloc_read_buffer(void); void read_from_socket(struct connection *, int, struct read_buffer *, void (*)(struct connection *, struct read_buffer *));