diff options
author | Jay Sorg <jay.sorg@gmail.com> | 2013-04-03 23:06:08 -0700 |
---|---|---|
committer | Jay Sorg <jay.sorg@gmail.com> | 2013-04-03 23:06:08 -0700 |
commit | d9c0af1e7878578f8cfa505cea3714349c746b0d (patch) | |
tree | 350ae102fb4ed3c2fd88cac20fb4c8a21a57a8d6 /common | |
parent | b4ce83a685eae2f8aa0589b9a306b35eeb3b6e10 (diff) | |
download | xrdp-proprietary-d9c0af1e7878578f8cfa505cea3714349c746b0d.tar.gz xrdp-proprietary-d9c0af1e7878578f8cfa505cea3714349c746b0d.zip |
ipv6
Diffstat (limited to 'common')
-rw-r--r-- | common/os_calls.c | 63 | ||||
-rw-r--r-- | common/os_calls.h | 2 |
2 files changed, 59 insertions, 6 deletions
diff --git a/common/os_calls.c b/common/os_calls.c index 278cc8cc..ea122552 100644 --- a/common/os_calls.c +++ b/common/os_calls.c @@ -610,12 +610,65 @@ g_tcp_set_non_blocking(int sck) static int APP_CC address_match(const char *address, struct addrinfo *j) { - if ((address == 0) || (strcmp(address, "0.0.0.0") == 0)) + struct sockaddr_in *ipv4_in; + struct sockaddr_in6 *ipv6_in; + + if (address == 0) { return 1; } - /* TODO: check address */ - return 1; + if (address[0] == 0) + { + return 1; + } + if (g_strcmp(address, "0.0.0.0") == 0) + { + return 1; + } + if ((g_strcmp(address, "127.0.0.1") == 0) || + (g_strcmp(address, "::1") == 0) || + (g_strcmp(address, "localhost") == 0)) + { + if (j->ai_addr != 0) + { + if (j->ai_addr->sa_family == AF_INET) + { + ipv4_in = (struct sockaddr_in *) (j->ai_addr); + if (inet_pton(AF_INET, "127.0.0.1", &(ipv4_in->sin_addr))) + { + return 1; + } + } + if (j->ai_addr->sa_family == AF_INET6) + { + ipv6_in = (struct sockaddr_in6 *) (j->ai_addr); + if (inet_pton(AF_INET6, "::1", &(ipv6_in->sin6_addr))) + { + return 1; + } + } + } + } + if (j->ai_addr != 0) + { + if (j->ai_addr->sa_family == AF_INET) + { + ipv4_in = (struct sockaddr_in *) (j->ai_addr); + if (inet_pton(AF_INET, address, &(ipv4_in->sin_addr))) + { + return 1; + } + } + if (j->ai_addr->sa_family == AF_INET6) + { + ipv6_in = (struct sockaddr_in6 *) (j->ai_addr); + if (inet_pton(AF_INET6, address, &(ipv6_in->sin6_addr))) + { + return 1; + } + } + } + return 0; } /*****************************************************************************/ @@ -641,7 +694,7 @@ g_tcp_bind_flags(int sck, const char *port, const char *address, int flags) { if (address_match(address, i)) { - res = bind(sck, (struct sockaddr *)(i->ai_addr), i->ai_addrlen); + res = bind(sck, i->ai_addr, i->ai_addrlen); } i = i->ai_next; } @@ -2076,7 +2129,7 @@ g_htoi(char *str) /*****************************************************************************/ int APP_CC -g_pos(char *str, const char *to_find) +g_pos(const char *str, const char *to_find) { char *pp; diff --git a/common/os_calls.h b/common/os_calls.h index 8159dc3b..b7422c10 100644 --- a/common/os_calls.h +++ b/common/os_calls.h @@ -196,7 +196,7 @@ g_atoi(const char* str); int APP_CC g_htoi(char* str); int APP_CC -g_pos(char* str, const char* to_find); +g_pos(const char* str, const char* to_find); int APP_CC g_mbstowcs(twchar* dest, const char* src, int n); int APP_CC |