From cb5f3cba1f2b5dbad67bcc107f3fe4a1875cc52d Mon Sep 17 00:00:00 2001 From: Will Storey Date: Mon, 9 Oct 2017 13:14:34 -0700 Subject: [PATCH 1/5] Delete unused function net_ip_compare() --- src/core/network.c | 12 ------------ src/core/network.h | 3 --- 2 files changed, 15 deletions(-) diff --git a/src/core/network.c b/src/core/network.c index 4494dbc6..36e04c7a 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -60,18 +60,6 @@ IPADDR ip4_any = { #endif }; -int net_ip_compare(IPADDR *ip1, IPADDR *ip2) -{ - if (ip1->family != ip2->family) - return 0; - - if (ip1->family == AF_INET6) - return memcmp(&ip1->ip, &ip2->ip, sizeof(ip1->ip)) == 0; - - return memcmp(&ip1->ip, &ip2->ip, 4) == 0; -} - - static void sin_set_ip(union sockaddr_union *so, const IPADDR *ip) { if (ip == NULL) { diff --git a/src/core/network.h b/src/core/network.h index d1582a2e..471ab2d8 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -33,9 +33,6 @@ extern IPADDR ip4_any; GIOChannel *g_io_channel_new(int handle); -/* returns 1 if IPADDRs are the same */ -int net_ip_compare(IPADDR *ip1, IPADDR *ip2); - int net_connect_ip_handle(const IPADDR *ip, int port, const IPADDR *my_ip); /* Connect to socket */ From 3b3939b146bb2f80182d572a2afc08ba405037a1 Mon Sep 17 00:00:00 2001 From: Will Storey Date: Mon, 9 Oct 2017 13:14:59 -0700 Subject: [PATCH 2/5] Delete commented out CYGWIN define --- src/core/network.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/network.c b/src/core/network.c index 36e04c7a..38f4e65a 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -48,9 +48,6 @@ GIOChannel *g_io_channel_new(int handle) return chan; } -/* Cygwin need this, don't know others.. */ -/*#define BLOCKING_SOCKETS 1*/ - IPADDR ip4_any = { AF_INET, #if defined(IN6ADDR_ANY_INIT) From b8b90c76d4ea87d7e50c2a34fbc36ab732e3e89e Mon Sep 17 00:00:00 2001 From: Will Storey Date: Mon, 9 Oct 2017 13:20:44 -0700 Subject: [PATCH 3/5] Delete unused function net_connect() --- src/core/network.c | 34 ---------------------------------- src/core/network.h | 2 -- 2 files changed, 36 deletions(-) diff --git a/src/core/network.c b/src/core/network.c index 38f4e65a..52619e4f 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -98,40 +98,6 @@ static int sin_get_port(union sockaddr_union *so) so->sin.sin_port); } -/* Connect to socket */ -GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip) -{ - IPADDR ip4, ip6, *ip; - - g_return_val_if_fail(addr != NULL, NULL); - - if (net_gethostbyname(addr, &ip4, &ip6) == -1) - return NULL; - - if (my_ip == NULL) { - /* prefer IPv4 addresses */ - ip = ip4.family != 0 ? &ip4 : &ip6; - } else if (IPADDR_IS_V6(my_ip)) { - /* my_ip is IPv6 address, use it if possible */ - if (ip6.family != 0) - ip = &ip6; - else { - my_ip = NULL; - ip = &ip4; - } - } else { - /* my_ip is IPv4 address, use it if possible */ - if (ip4.family != 0) - ip = &ip4; - else { - my_ip = NULL; - ip = &ip6; - } - } - - return net_connect_ip(ip, port, my_ip); -} - int net_connect_ip_handle(const IPADDR *ip, int port, const IPADDR *my_ip) { union sockaddr_union so; diff --git a/src/core/network.h b/src/core/network.h index 471ab2d8..a02f0db9 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -35,8 +35,6 @@ GIOChannel *g_io_channel_new(int handle); int net_connect_ip_handle(const IPADDR *ip, int port, const IPADDR *my_ip); -/* Connect to socket */ -GIOChannel *net_connect(const char *addr, int port, IPADDR *my_ip) G_GNUC_DEPRECATED; /* Connect to socket with ip address and SSL*/ GIOChannel *net_connect_ip_ssl(IPADDR *ip, int port, IPADDR *my_ip, SERVER_REC *server); /* Start TLS */ From da59fd7c2dd0641f623db2c67a244ddca3013d65 Mon Sep 17 00:00:00 2001 From: Will Storey Date: Fri, 13 Oct 2017 18:28:26 -0700 Subject: [PATCH 4/5] Revert "Delete unused function net_ip_compare()" This reverts commit cb5f3cba1f2b5dbad67bcc107f3fe4a1875cc52d. --- src/core/network.c | 12 ++++++++++++ src/core/network.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/src/core/network.c b/src/core/network.c index 52619e4f..4963a542 100644 --- a/src/core/network.c +++ b/src/core/network.c @@ -57,6 +57,18 @@ IPADDR ip4_any = { #endif }; +int net_ip_compare(IPADDR *ip1, IPADDR *ip2) +{ + if (ip1->family != ip2->family) + return 0; + + if (ip1->family == AF_INET6) + return memcmp(&ip1->ip, &ip2->ip, sizeof(ip1->ip)) == 0; + + return memcmp(&ip1->ip, &ip2->ip, 4) == 0; +} + + static void sin_set_ip(union sockaddr_union *so, const IPADDR *ip) { if (ip == NULL) { diff --git a/src/core/network.h b/src/core/network.h index a02f0db9..84f3a56c 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -33,6 +33,9 @@ extern IPADDR ip4_any; GIOChannel *g_io_channel_new(int handle); +/* returns 1 if IPADDRs are the same */ +int net_ip_compare(IPADDR *ip1, IPADDR *ip2); + int net_connect_ip_handle(const IPADDR *ip, int port, const IPADDR *my_ip); /* Connect to socket with ip address and SSL*/ From 233be9f580290ff3efa66e6256e46303b01781da Mon Sep 17 00:00:00 2001 From: Will Storey Date: Fri, 13 Oct 2017 18:30:57 -0700 Subject: [PATCH 5/5] Mark net_ip_compare() deprecated --- src/core/network.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/network.h b/src/core/network.h index 84f3a56c..e60f607f 100644 --- a/src/core/network.h +++ b/src/core/network.h @@ -33,8 +33,9 @@ extern IPADDR ip4_any; GIOChannel *g_io_channel_new(int handle); -/* returns 1 if IPADDRs are the same */ -int net_ip_compare(IPADDR *ip1, IPADDR *ip2); +/* Returns 1 if IPADDRs are the same. */ +/* Deprecated since it is unused. It will be deleted in a later release. */ +int net_ip_compare(IPADDR *ip1, IPADDR *ip2) G_GNUC_DEPRECATED; int net_connect_ip_handle(const IPADDR *ip, int port, const IPADDR *my_ip);