From 23fda5688e8a109f8a50511538b14e4fbe4f738c Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Wed, 20 Feb 2002 22:37:38 +0000 Subject: [PATCH] - Change SA_LEN to SALEN, former one is already defined on some platforms. - Use SALEN everywhere appropriate. --- src/net.h | 8 +++----- src/net_packet.c | 4 ++-- src/net_socket.c | 12 ++++++------ src/netutl.c | 6 +++--- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/net.h b/src/net.h index 5f3e2a8..ea1657b 100644 --- a/src/net.h +++ b/src/net.h @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net.h,v 1.9.4.40 2002/02/20 22:15:32 guus Exp $ + $Id: net.h,v 1.9.4.41 2002/02/20 22:37:38 guus Exp $ */ #ifndef __TINC_NET_H__ @@ -65,12 +65,10 @@ typedef union { struct sockaddr_in6 in6; } sockaddr_t; -#define SA_PORT(s) ((s.sa.sa_family==AF_INET)?s.in.sin_port:(s.sa.sa_family==AF_INET6)?s.in6.sin6_port:0) - #ifdef HAVE_LINUX - #define SA_LEN(s) sizeof(sockaddr_t) + #define SALEN(s) sizeof(sockaddr_t) #else - #define SA_LEN(s) (s.sa_len) + #define SALEN(s) (s.sa_len) #endif typedef struct vpn_packet_t { diff --git a/src/net_packet.c b/src/net_packet.c index 7768332..42f9d89 100644 --- a/src/net_packet.c +++ b/src/net_packet.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_packet.c,v 1.1.2.3 2002/02/20 22:15:32 guus Exp $ + $Id: net_packet.c,v 1.1.2.4 2002/02/20 22:37:38 guus Exp $ */ #include "config.h" @@ -258,7 +258,7 @@ cp /* Send the packet */ - if((sendto(udp_socket, (char *)&inpkt->seqno, inpkt->len, 0, &(n->address.sa), SA_LEN(n->address.sa))) < 0) + if((sendto(udp_socket, (char *)&inpkt->seqno, inpkt->len, 0, &(n->address.sa), SALEN(n->address.sa))) < 0) { syslog(LOG_ERR, _("Error sending packet to %s (%s): %s"), n->name, n->hostname, strerror(errno)); diff --git a/src/net_socket.c b/src/net_socket.c index 9ce3fae..6cf69f2 100644 --- a/src/net_socket.c +++ b/src/net_socket.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: net_socket.c,v 1.1.2.2 2002/02/20 19:25:09 guus Exp $ + $Id: net_socket.c,v 1.1.2.3 2002/02/20 22:37:38 guus Exp $ */ #include "config.h" @@ -116,7 +116,7 @@ cp } #endif - if(bind(nfd, &sa->sa, sizeof(*sa))) + if(bind(nfd, &sa->sa, SALEN(sa->sa))) { close(nfd); addrstr = sockaddr2hostname(sa); @@ -170,7 +170,7 @@ cp } #endif - if(bind(nfd, &sa->sa, sizeof(*sa))) + if(bind(nfd, &sa->sa, SALEN(sa->sa))) { close(nfd); addrstr = sockaddr2hostname(sa); @@ -228,10 +228,10 @@ cp /* Connect */ - if(connect(c->socket, &c->address.sa, sizeof(c->address)) == -1) + if(connect(c->socket, &c->address.sa, SALEN(c->address.sa)) == -1) { close(c->socket); - syslog(LOG_ERR, _("%s: %s"), c->hostname, strerror(errno)); + syslog(LOG_ERR, _("Error while connecting to %s (%s): %s"), c->name, c->hostname, strerror(errno)); return -1; } @@ -334,7 +334,7 @@ begin: /* Connect */ - result = connect(c->socket, &c->address.sa, sizeof(c->address)); + result = connect(c->socket, &c->address.sa, SALEN(c->address.sa)); if(result == -1) { diff --git a/src/netutl.c b/src/netutl.c index 039082e..ca3ea2d 100644 --- a/src/netutl.c +++ b/src/netutl.c @@ -17,7 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: netutl.c,v 1.12.4.26 2002/02/20 22:15:32 guus Exp $ + $Id: netutl.c,v 1.12.4.27 2002/02/20 22:37:38 guus Exp $ */ #include "config.h" @@ -103,7 +103,7 @@ void sockaddr2str(sockaddr_t *sa, char **addrstr, char **portstr) char port[NI_MAXSERV]; int err; cp - if((err = getnameinfo(&sa->sa, SA_LEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST|NI_NUMERICSERV))) + if((err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), NI_NUMERICHOST|NI_NUMERICSERV))) { syslog(LOG_ERR, _("Error while translating addresses: %s"), gai_strerror(err)); cp_trace(); @@ -123,7 +123,7 @@ char *sockaddr2hostname(sockaddr_t *sa) char port[NI_MAXSERV] = "unknown"; int err; cp - if((err = getnameinfo(&sa->sa, SA_LEN(sa->sa), address, sizeof(address), port, sizeof(port), hostnames?0:(NI_NUMERICHOST|NI_NUMERICSERV)))) + if((err = getnameinfo(&sa->sa, SALEN(sa->sa), address, sizeof(address), port, sizeof(port), hostnames?0:(NI_NUMERICHOST|NI_NUMERICSERV)))) { syslog(LOG_ERR, _("Error while looking up hostname: %s"), gai_strerror(err)); } -- 2.25.1