From cd0a8721d11e7cdd04561f3d8e226fbad0a147ce Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Mon, 6 May 2013 17:45:30 -0700 Subject: [PATCH] disable ipv6 for now --- common/os_calls.c | 70 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/common/os_calls.c b/common/os_calls.c index af54facfc6..f5f5cd60c7 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -439,7 +439,7 @@ g_tcp_socket(void) unsigned int option_len; #endif -#if !defined(NO_ARPA_INET_H_IP6) +#if 0 && !defined(NO_ARPA_INET_H_IP6) rv = (int)socket(AF_INET6, SOCK_STREAM, 0); #else rv = (int)socket(AF_INET, SOCK_STREAM, 0); @@ -448,7 +448,7 @@ g_tcp_socket(void) { return -1; } -#if !defined(NO_ARPA_INET_H_IP6) +#if 0 && !defined(NO_ARPA_INET_H_IP6) option_len = sizeof(option_value); if (getsockopt(rv, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&option_value, &option_len) == 0) @@ -525,6 +525,7 @@ g_tcp_close(int sck) /*****************************************************************************/ /* returns error, zero is good */ +#if 0 int APP_CC g_tcp_connect(int sck, const char *address, const char *port) { @@ -578,6 +579,37 @@ g_tcp_connect(int sck, const char *address, const char *port) } return res; } +#else +int APP_CC +g_tcp_connect(int sck, const char* address, const char* port) +{ + struct sockaddr_in s; + struct hostent* h; + + g_memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons((tui16)atoi(port)); + s.sin_addr.s_addr = inet_addr(address); + if (s.sin_addr.s_addr == INADDR_NONE) + { + h = gethostbyname(address); + if (h != 0) + { + if (h->h_name != 0) + { + if (h->h_addr_list != 0) + { + if ((*(h->h_addr_list)) != 0) + { + s.sin_addr.s_addr = *((int*)(*(h->h_addr_list))); + } + } + } + } + } + return connect(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} +#endif /*****************************************************************************/ /* returns error, zero is good */ @@ -613,6 +645,7 @@ g_tcp_set_non_blocking(int sck) return 0; } +#if 0 /*****************************************************************************/ /* return boolean */ static int APP_CC @@ -678,7 +711,9 @@ address_match(const char *address, struct addrinfo *j) } return 0; } +#endif +#if 0 /*****************************************************************************/ /* returns error, zero is good */ static int APP_CC @@ -720,6 +755,19 @@ g_tcp_bind(int sck, const char *port) flags = AI_ADDRCONFIG | AI_PASSIVE; return g_tcp_bind_flags(sck, port, 0, flags); } +#else +int APP_CC +g_tcp_bind(int sck, const char* port) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons((tui16)atoi(port)); + s.sin_addr.s_addr = INADDR_ANY; + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} +#endif /*****************************************************************************/ int APP_CC @@ -737,6 +785,7 @@ g_tcp_local_bind(int sck, const char *port) #endif } +#if 0 /*****************************************************************************/ /* returns error, zero is good */ int APP_CC @@ -747,6 +796,23 @@ g_tcp_bind_address(int sck, const char *port, const char *address) flags = AI_ADDRCONFIG | AI_PASSIVE; return g_tcp_bind_flags(sck, port, address, flags); } +#else +int APP_CC +g_tcp_bind_address(int sck, const char* port, const char* address) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons((tui16)atoi(port)); + s.sin_addr.s_addr = INADDR_ANY; + if (inet_aton(address, &s.sin_addr) < 0) + { + return -1; /* bad address */ + } + return bind(sck, (struct sockaddr*)&s, sizeof(struct sockaddr_in)); +} +#endif /*****************************************************************************/ /* returns error, zero is good */