From 57b4b3d7eac35e82b76574403621d696a165233e Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Sun, 22 Nov 2015 16:58:20 +0100 Subject: [PATCH] Code cleanup --- src/transport/tcp.c | 20 ++++++++++---------- src/transport/tcp4.c | 2 +- src/transport/tcp6.c | 2 +- src/transport/udp.c | 24 ++++++++++++------------ src/transport/udp4.c | 2 +- src/transport/udp6.c | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/transport/tcp.c b/src/transport/tcp.c index 0327a08..e24dc29 100644 --- a/src/transport/tcp.c +++ b/src/transport/tcp.c @@ -44,8 +44,8 @@ #endif /* for tcp4 and tcp6 */ -#ifndef TCP_FAMILY -# define TCP_FAMILY AF_UNSPEC +#ifndef TCP_DOMAIN +# define TCP_DOMAIN AF_UNSPEC #endif @@ -155,8 +155,8 @@ AppTransportPluginDefinition transport = /* functions */ /* plug-in */ /* tcp_init */ -static int _init_client(TCP * tcp, char const * name); -static int _init_server(TCP * tcp, char const * name); +static int _init_client(TCP * tcp, char const * name, int domain); +static int _init_server(TCP * tcp, char const * name, int domain); static TCP * _tcp_init(AppTransportPluginHelper * helper, AppTransportMode mode, char const * name) @@ -174,10 +174,10 @@ static TCP * _tcp_init(AppTransportPluginHelper * helper, AppTransportMode mode, switch((tcp->mode = mode)) { case ATM_CLIENT: - res = _init_client(tcp, name); + res = _init_client(tcp, name, TCP_DOMAIN); break; case ATM_SERVER: - res = _init_server(tcp, name); + res = _init_server(tcp, name, TCP_DOMAIN); break; default: res = -error_set_code(-EINVAL, "%s", @@ -197,7 +197,7 @@ static TCP * _tcp_init(AppTransportPluginHelper * helper, AppTransportMode mode, return tcp; } -static int _init_client(TCP * tcp, char const * name) +static int _init_client(TCP * tcp, char const * name, int domain) { struct addrinfo * aip; #ifdef DEBUG @@ -207,7 +207,7 @@ static int _init_client(TCP * tcp, char const * name) tcp->u.client.tcp = tcp; tcp->u.client.fd = -1; /* obtain the remote address */ - if((tcp->ai = _init_address(name, TCP_FAMILY, 0)) == NULL) + if((tcp->ai = _init_address(name, domain, 0)) == NULL) return -1; /* connect to the remote host */ for(aip = tcp->ai; aip != NULL; aip = aip->ai_next) @@ -257,7 +257,7 @@ static int _init_client(TCP * tcp, char const * name) return (aip != NULL) ? 0 : -1; } -static int _init_server(TCP * tcp, char const * name) +static int _init_server(TCP * tcp, char const * name, int domain) { struct addrinfo * aip; TCPSocket tcpsocket; @@ -267,7 +267,7 @@ static int _init_server(TCP * tcp, char const * name) tcp->u.server.fd = -1; /* obtain the local address */ - if((tcp->ai = _init_address(name, TCP_FAMILY, AI_PASSIVE)) == NULL) + if((tcp->ai = _init_address(name, domain, AI_PASSIVE)) == NULL) return -1; for(aip = tcp->ai; aip != NULL; aip = aip->ai_next) { diff --git a/src/transport/tcp4.c b/src/transport/tcp4.c index c00ab61..168d565 100644 --- a/src/transport/tcp4.c +++ b/src/transport/tcp4.c @@ -15,5 +15,5 @@ -#define TCP_FAMILY AF_INET +#define TCP_DOMAIN AF_INET #include "tcp.c" diff --git a/src/transport/tcp6.c b/src/transport/tcp6.c index d2a570c..80f9e77 100644 --- a/src/transport/tcp6.c +++ b/src/transport/tcp6.c @@ -15,5 +15,5 @@ -#define TCP_FAMILY AF_INET6 +#define TCP_DOMAIN AF_INET6 #include "tcp.c" diff --git a/src/transport/udp.c b/src/transport/udp.c index a3a4247..782d747 100644 --- a/src/transport/udp.c +++ b/src/transport/udp.c @@ -45,8 +45,8 @@ #endif /* for udp4 and udp6 */ -#ifndef UDP_FAMILY -# define UDP_FAMILY AF_UNSPEC +#ifndef UDP_DOMAIN +# define UDP_DOMAIN AF_UNSPEC #endif @@ -138,8 +138,8 @@ AppTransportPluginDefinition transport = /* functions */ /* plug-in */ /* udp_init */ -static int _init_client(UDP * udp, char const * name); -static int _init_server(UDP * udp, char const * name); +static int _init_client(UDP * udp, char const * name, int domain); +static int _init_server(UDP * udp, char const * name, int domain); static int _init_socket(UDP * udp); static UDP * _udp_init(AppTransportPluginHelper * helper, @@ -159,10 +159,10 @@ static UDP * _udp_init(AppTransportPluginHelper * helper, switch((udp->mode) = mode) { case ATM_CLIENT: - res = _init_client(udp, name); + res = _init_client(udp, name, UDP_DOMAIN); break; case ATM_SERVER: - res = _init_server(udp, name); + res = _init_server(udp, name, UDP_DOMAIN); break; default: res = -error_set_code(-EINVAL, "%s", @@ -178,11 +178,11 @@ static UDP * _udp_init(AppTransportPluginHelper * helper, return udp; } -static int _init_client(UDP * udp, char const * name) +static int _init_client(UDP * udp, char const * name, int domain) { memset(&udp->u, 0, sizeof(udp->u)); /* obtain the remote address */ - if((udp->ai = _init_address(name, UDP_FAMILY, 0)) == NULL) + if((udp->ai = _init_address(name, domain, 0)) == NULL) return -1; for(udp->aip = udp->ai; udp->aip != NULL; udp->aip = udp->aip->ai_next) { @@ -203,12 +203,12 @@ static int _init_client(UDP * udp, char const * name) return 0; } -static int _init_server(UDP * udp, char const * name) +static int _init_server(UDP * udp, char const * name, int domain) { udp->u.server.clients = NULL; udp->u.server.clients_cnt = 0; /* obtain the local address */ - if((udp->ai = _init_address(name, UDP_FAMILY, AI_PASSIVE)) == NULL) + if((udp->ai = _init_address(name, domain, AI_PASSIVE)) == NULL) return -1; for(udp->aip = udp->ai; udp->aip != NULL; udp->aip = udp->aip->ai_next) { @@ -327,7 +327,7 @@ static int _udp_client_send(UDP * udp, AppTransportClient * client, ntohs(sa->sin_port), buffer_get_size(buffer)); } else - fprintf(stderr, "DEBUG: %s() %s family=%d size=%lu\n", __func__, + fprintf(stderr, "DEBUG: %s() %s domain=%d size=%lu\n", __func__, "sendto()", udp->aip->ai_family, buffer_get_size(buffer)); #endif @@ -366,7 +366,7 @@ static int _udp_send(UDP * udp, AppMessage * message) ntohs(sa->sin_port), buffer_get_size(buffer)); } else - fprintf(stderr, "DEBUG: %s() %s family=%d size=%lu\n", __func__, + fprintf(stderr, "DEBUG: %s() %s domain=%d size=%lu\n", __func__, "sendto()", udp->aip->ai_family, buffer_get_size(buffer)); #endif diff --git a/src/transport/udp4.c b/src/transport/udp4.c index 489d29f..9b329fd 100644 --- a/src/transport/udp4.c +++ b/src/transport/udp4.c @@ -15,5 +15,5 @@ -#define UDP_FAMILY AF_INET +#define UDP_DOMAIN AF_INET #include "udp.c" diff --git a/src/transport/udp6.c b/src/transport/udp6.c index 9ba916f..095607c 100644 --- a/src/transport/udp6.c +++ b/src/transport/udp6.c @@ -15,5 +15,5 @@ -#define UDP_FAMILY AF_INET6 +#define UDP_DOMAIN AF_INET6 #include "udp.c"