miniupnpd: Use SA_LEN consistently
This commit is contained in:
parent
3491535854
commit
c4d99670e7
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: getroute.c,v 1.3 2013/02/06 13:11:45 nanard Exp $ */
|
/* $Id: getroute.c,v 1.4 2014/03/31 12:27:14 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2006-2013 Thomas Bernard
|
* (c) 2006-2013 Thomas Bernard
|
||||||
|
@ -83,7 +83,7 @@ get_src_for_route_to(const struct sockaddr * dst,
|
||||||
sa = (struct sockaddr *)p;
|
sa = (struct sockaddr *)p;
|
||||||
sockaddr_to_string(sa, tmp, sizeof(tmp));
|
sockaddr_to_string(sa, tmp, sizeof(tmp));
|
||||||
syslog(LOG_DEBUG, "type=%d sa_len=%d sa_family=%d %s",
|
syslog(LOG_DEBUG, "type=%d sa_len=%d sa_family=%d %s",
|
||||||
i, sa->sa_len, sa->sa_family, tmp);
|
i, SA_LEN(sa), sa->sa_family, tmp);
|
||||||
if((i == RTA_DST || i == RTA_GATEWAY) &&
|
if((i == RTA_DST || i == RTA_GATEWAY) &&
|
||||||
(src_len && src)) {
|
(src_len && src)) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
|
@ -113,7 +113,7 @@ get_src_for_route_to(const struct sockaddr * dst,
|
||||||
*index = sdl->sdl_index;
|
*index = sdl->sdl_index;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
p += sa->sa_len;
|
p += SA_LEN(sa);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: ifacewatcher.c,v 1.5 2012/05/21 08:55:10 nanard Exp $ */
|
/* $Id: ifacewatcher.c,v 1.6 2014/03/31 12:27:14 nanard Exp $ */
|
||||||
/* Project MiniUPnP
|
/* Project MiniUPnP
|
||||||
* web : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* web : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2011 Thomas BERNARD
|
* (c) 2011 Thomas BERNARD
|
||||||
|
@ -15,12 +15,8 @@
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#if !defined(SA_LEN)
|
|
||||||
#define SA_LEN(sa) (sa)->sa_len
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SALIGN (sizeof(long) - 1)
|
#define SALIGN (sizeof(long) - 1)
|
||||||
#define SA_RLEN(sa) ((sa)->sa_len ? (((sa)->sa_len + SALIGN) & ~SALIGN) : (SALIGN + 1))
|
#define SA_RLEN(sa) (SA_LEN(sa) ? ((SA_LEN(sa) + SALIGN) & ~SALIGN) : (SALIGN + 1))
|
||||||
|
|
||||||
#include "../upnputils.h"
|
#include "../upnputils.h"
|
||||||
#include "../upnpglobalvars.h"
|
#include "../upnpglobalvars.h"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: upnputils.h,v 1.4 2013/02/06 10:50:04 nanard Exp $ */
|
/* $Id: upnputils.h,v 1.6 2014/03/31 12:32:57 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* MiniUPnP project
|
||||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||||
* (c) 2011-2013 Thomas Bernard
|
* (c) 2011-2013 Thomas Bernard
|
||||||
|
@ -29,5 +29,30 @@ set_non_blocking(int fd);
|
||||||
struct lan_addr_s *
|
struct lan_addr_s *
|
||||||
get_lan_for_peer(const struct sockaddr * peer);
|
get_lan_for_peer(const struct sockaddr * peer);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* define portability macros
|
||||||
|
*/
|
||||||
|
#if defined(__sun)
|
||||||
|
static size_t _sa_len(const struct sockaddr *addr)
|
||||||
|
{
|
||||||
|
if (addr->sa_family == AF_INET)
|
||||||
|
return (sizeof(struct sockaddr_in));
|
||||||
|
else if (addr->sa_family == AF_INET6)
|
||||||
|
return (sizeof(struct sockaddr_in6));
|
||||||
|
else
|
||||||
|
return (sizeof(struct sockaddr));
|
||||||
|
}
|
||||||
|
# define SA_LEN(sa) (_sa_len(sa))
|
||||||
|
#else
|
||||||
|
#if !defined(SA_LEN)
|
||||||
|
# define SA_LEN(sa) ((sa)->sa_len)
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef MAX
|
||||||
|
# define MAX(a,b) (((a)>(b))?(a):(b))
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue