Compile miniupnpd OK with -ansi flag.

This commit is contained in:
Thomas Bernard 2012-02-05 00:40:50 +01:00
parent a0a1e45ac5
commit 9ee74defc8
8 changed files with 56 additions and 44 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.252 2012/02/04 23:05:20 nanard Exp $ $Id: Changelog.txt,v 1.253 2012/02/04 23:34:38 nanard Exp $
2012/02/05:
Compile ok with -ansi flag.
2012/02/04: 2012/02/04:
Added friendl_name= option to config file Added friendl_name= option to config file

View File

@ -1,7 +1,7 @@
/* $Id: ifacewatcher.c,v 1.2 2011/07/30 13:11:39 nanard Exp $ */ /* $Id: ifacewatcher.c,v 1.3 2012/02/04 23:34:40 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-2009 Thomas Bernard * (c) 2006-2012 Thomas Bernard
* *
* ifacewatcher.c * ifacewatcher.c
* *
@ -239,7 +239,7 @@ ProcessInterfaceWatchNotify(int s)
struct ifaddrmsg *ifa; struct ifaddrmsg *ifa;
int len; int len;
struct rtattr *rth; // struct rtattr *rth;
int rtl; int rtl;
unsigned int ext_if_name_index = 0; unsigned int ext_if_name_index = 0;

View File

@ -1,4 +1,4 @@
/* $Id: miniupnpd.c,v 1.141 2012/02/04 23:05:22 nanard Exp $ */ /* $Id: miniupnpd.c,v 1.142 2012/02/04 23:34:39 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-2012 Thomas Bernard * (c) 2006-2012 Thomas Bernard
@ -193,32 +193,32 @@ OpenAndConfNFqueue(){
inet_pton(AF_INET, "239.255.255.250", &(ssdp.sin_addr)); inet_pton(AF_INET, "239.255.255.250", &(ssdp.sin_addr));
//Get a queue connection handle from the module /* Get a queue connection handle from the module */
if (!(nfqHandle = nfq_open())) { if (!(nfqHandle = nfq_open())) {
syslog(LOG_ERR, "Error in nfq_open(): %m"); syslog(LOG_ERR, "Error in nfq_open(): %m");
return -1; return -1;
} }
//Unbind the handler from processing any IP packets /* Unbind the handler from processing any IP packets
// Not totally sure why this is done, or if it's necessary... Not totally sure why this is done, or if it's necessary... */
if ((e = nfq_unbind_pf(nfqHandle, AF_INET)) < 0) { if ((e = nfq_unbind_pf(nfqHandle, AF_INET)) < 0) {
syslog(LOG_ERR, "Error in nfq_unbind_pf(): %m"); syslog(LOG_ERR, "Error in nfq_unbind_pf(): %m");
return -1; return -1;
} }
//Bind this handler to process IP packets... /* Bind this handler to process IP packets... */
if (nfq_bind_pf(nfqHandle, AF_INET) < 0) { if (nfq_bind_pf(nfqHandle, AF_INET) < 0) {
syslog(LOG_ERR, "Error in nfq_bind_pf(): %m"); syslog(LOG_ERR, "Error in nfq_bind_pf(): %m");
return -1; return -1;
} }
// Install a callback on queue -Q /* Install a callback on queue -Q */
if (!(myQueue = nfq_create_queue(nfqHandle, nfqueue, &nfqueue_cb, NULL))) { if (!(myQueue = nfq_create_queue(nfqHandle, nfqueue, &nfqueue_cb, NULL))) {
syslog(LOG_ERR, "Error in nfq_create_queue(): %m"); syslog(LOG_ERR, "Error in nfq_create_queue(): %m");
return -1; return -1;
} }
// Turn on packet copy mode /* Turn on packet copy mode */
if (nfq_set_mode(myQueue, NFQNL_COPY_PACKET, 0xffff) < 0) { if (nfq_set_mode(myQueue, NFQNL_COPY_PACKET, 0xffff) < 0) {
syslog(LOG_ERR, "Error setting packet copy mode (): %m"); syslog(LOG_ERR, "Error setting packet copy mode (): %m");
return -1; return -1;
@ -289,7 +289,8 @@ static int nfqueue_cb(
} else { } else {
syslog(LOG_ERR,"nfq_get_msg_packet_hdr failed"); syslog(LOG_ERR,"nfq_get_msg_packet_hdr failed");
return 1; // from nfqueue source: 0 = ok, >0 = soft error, <0 hard error return 1;
/* from nfqueue source: 0 = ok, >0 = soft error, <0 hard error */
} }
return 0; return 0;
@ -1075,7 +1076,7 @@ main(int argc, char * * argv)
int sudpv6 = -1; /* IP v6 socket for receiving SSDP */ int sudpv6 = -1; /* IP v6 socket for receiving SSDP */
#endif #endif
#ifdef ENABLE_NATPMP #ifdef ENABLE_NATPMP
int * snatpmp; int * snatpmp = NULL;
#endif #endif
#ifdef ENABLE_NFQUEUE #ifdef ENABLE_NFQUEUE
int nfqh = -1; int nfqh = -1;
@ -1084,7 +1085,7 @@ main(int argc, char * * argv)
int sifacewatcher = -1; int sifacewatcher = -1;
#endif #endif
int * snotify; int * snotify = NULL;
int addr_count; int addr_count;
LIST_HEAD(httplisthead, upnphttp) upnphttphead; LIST_HEAD(httplisthead, upnphttp) upnphttphead;
struct upnphttp * e = 0; struct upnphttp * e = 0;
@ -1114,12 +1115,15 @@ main(int argc, char * * argv)
addr_count = 0; addr_count = 0;
for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next) for(lan_addr = lan_addrs.lh_first; lan_addr != NULL; lan_addr = lan_addr->list.le_next)
addr_count++; addr_count++;
snotify = (int*) malloc(addr_count * sizeof(int)); if(addr_count > 0) {
memset(snotify, 0, sizeof(snotify)); snotify = calloc(addr_count, sizeof(int));
}
#ifdef ENABLE_NATPMP #ifdef ENABLE_NATPMP
snatpmp = (int*) malloc(addr_count * sizeof(int)); if(addr_count > 0) {
for(i = 0; i < addr_count; i++) snatpmp = malloc(addr_count * sizeof(int));
snatpmp[i] = -1; for(i = 0; i < addr_count; i++)
snatpmp[i] = -1;
}
#endif #endif
LIST_INIT(&upnphttphead); LIST_INIT(&upnphttphead);

View File

@ -1,7 +1,7 @@
/* $Id: miniupnpdctl.c,v 1.8 2010/02/15 10:19:46 nanard Exp $ */ /* $Id: miniupnpdctl.c,v 1.9 2012/02/04 23:34:39 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 Thomas Bernard * (c) 2006-2012 Thomas Bernard
* This software is subject to the conditions detailed * This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */ * in the LICENCE file provided within the distribution */
@ -31,7 +31,7 @@ main(int argc, char * * argv)
int s; int s;
struct sockaddr_un addr; struct sockaddr_un addr;
// signal(SIGINT, sighandler); /*signal(SIGINT, sighandler);*/
s = socket(AF_UNIX, SOCK_STREAM, 0); s = socket(AF_UNIX, SOCK_STREAM, 0);
if(s<0) if(s<0)
{ {

View File

@ -1,4 +1,4 @@
/* $Id: natpmp.c,v 1.27 2012/02/01 11:13:30 nanard Exp $ */ /* $Id: natpmp.c,v 1.28 2012/02/04 23:34:39 nanard Exp $ */
/* MiniUPnP project /* MiniUPnP project
* (c) 2007-2012 Thomas Bernard * (c) 2007-2012 Thomas Bernard
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
@ -38,7 +38,7 @@ int OpenAndConfNATPMPSocket(in_addr_t addr)
memset(&natpmp_addr, 0, sizeof(natpmp_addr)); memset(&natpmp_addr, 0, sizeof(natpmp_addr));
natpmp_addr.sin_family = AF_INET; natpmp_addr.sin_family = AF_INET;
natpmp_addr.sin_port = htons(NATPMP_PORT); natpmp_addr.sin_port = htons(NATPMP_PORT);
//natpmp_addr.sin_addr.s_addr = INADDR_ANY; /*natpmp_addr.sin_addr.s_addr = INADDR_ANY; */
natpmp_addr.sin_addr.s_addr = addr; natpmp_addr.sin_addr.s_addr = addr;
if(bind(snatpmp, (struct sockaddr *)&natpmp_addr, sizeof(natpmp_addr)) < 0) if(bind(snatpmp, (struct sockaddr *)&natpmp_addr, sizeof(natpmp_addr)) < 0)
{ {

View File

@ -1,4 +1,4 @@
/* $Id: iptcrdr.c,v 1.46 2011/07/30 13:14:36 nanard Exp $ */ /* $Id: iptcrdr.c,v 1.47 2012/02/04 23:34:41 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-2011 Thomas Bernard * (c) 2006-2011 Thomas Bernard
@ -278,7 +278,7 @@ get_redirect_rule(const char * ifname, unsigned short eport, int proto,
continue; continue;
} }
target = (void *)e + e->target_offset; target = (void *)e + e->target_offset;
//target = ipt_get_target(e); /* target = ipt_get_target(e); */
mr = (const struct ip_nat_multi_range *)&target->data[0]; mr = (const struct ip_nat_multi_range *)&target->data[0];
snprintip(iaddr, iaddrlen, ntohl(mr->range[0].min_ip)); snprintip(iaddr, iaddrlen, ntohl(mr->range[0].min_ip));
*iport = ntohs(mr->range[0].min.all); *iport = ntohs(mr->range[0].min.all);

View File

@ -1,4 +1,4 @@
/* $Id: testupnpdescgen.c,v 1.26 2012/02/04 23:05:21 nanard Exp $ */ /* $Id: testupnpdescgen.c,v 1.27 2012/02/04 23:34:39 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-2012 Thomas Bernard * (c) 2006-2012 Thomas Bernard
@ -84,7 +84,7 @@ xml_pretty_print(const char * s, int len, FILE * f)
if(elt_close==1) if(elt_close==1)
{ {
/*fputc('\n', f); n++; */ /*fputc('\n', f); n++; */
//elt_close = 0; /* elt_close = 0; */
if(indent > 0) if(indent > 0)
indent--; indent--;
} }

View File

@ -1,7 +1,7 @@
/* $Id: upnpsoap.c,v 1.89 2012/01/20 21:45:58 nanard Exp $ */ /* $Id: upnpsoap.c,v 1.90 2012/02/04 23:34:40 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-2011 Thomas Bernard * (c) 2006-2012 Thomas Bernard
* This software is subject to the conditions detailed * This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */ * in the LICENCE file provided within the distribution */
@ -1147,8 +1147,7 @@ CheckStatus(struct upnphttp * h)
static int static int
DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port, const char * protocol, char * leaseTime) DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port, const char * protocol, char * leaseTime)
{ {
//int n; /* ** Internal IP can't be wildcarded */
// ** Internal IP can't be wildcarded
if (!int_ip) if (!int_ip)
{ {
SoapError(h, 708, "WildCardNotPermittedInSrcIP"); SoapError(h, 708, "WildCardNotPermittedInSrcIP");
@ -1161,16 +1160,17 @@ DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port,
return 0; return 0;
} }
// ** Internal port can't be wilcarded. /* ** Internal port can't be wilcarded. */
// printf("\tint_port: *%d*\n", *int_port); /* printf("\tint_port: *%d*\n", *int_port); */
if (*int_port == 0) if (*int_port == 0)
{ {
SoapError(h, 706, "InternalPortWilcardingNotAllowed"); SoapError(h, 706, "InternalPortWilcardingNotAllowed");
return 0; return 0;
} }
// ** Protocol can't be wilcarded and can't be an unknown port (here deal with only UDP, TCP, UDPLITE) /* ** Protocol can't be wilcarded and can't be an unknown port
// printf("\tprotocol: *%s*\n", protocol); * (here deal with only UDP, TCP, UDPLITE) */
/* printf("\tprotocol: *%s*\n", protocol); */
if (atoi(protocol) == 65535) if (atoi(protocol) == 65535)
{ {
SoapError(h, 707, "ProtocolWilcardingNotAllowed"); SoapError(h, 707, "ProtocolWilcardingNotAllowed");
@ -1187,8 +1187,8 @@ DataVerification(struct upnphttp * h, char * int_ip, unsigned short * int_port,
return 0; return 0;
} }
// ** Lease Time can't be wilcarded nor >86400. /* ** Lease Time can't be wilcarded nor >86400. */
// printf("\tlease time: %s\n", leaseTime); /* printf("\tlease time: %s\n", leaseTime); */
if(!leaseTime || !atoi(leaseTime) || atoi(leaseTime)>86400) if(!leaseTime || !atoi(leaseTime) || atoi(leaseTime)>86400)
{ {
/* lease duration is never infinite, nor wilcarded. In this case, use default value */ /* lease duration is never infinite, nor wilcarded. In this case, use default value */
@ -1355,7 +1355,8 @@ AddPinhole(struct upnphttp * h, const char * action)
rport = (unsigned short)atoi(rem_port); rport = (unsigned short)atoi(rem_port);
iport = (unsigned short)atoi(int_port); iport = (unsigned short)atoi(int_port);
// ** As there is no security policy, InternalClient must be equal to the CP's IP address. /* ** As there is no security policy, InternalClient must be equal
* to the CP's IP address. */
if(DataVerification(h, int_ip, &iport, protocol, leaseTime) == 0 if(DataVerification(h, int_ip, &iport, protocol, leaseTime) == 0
|| PinholeVerification(h, int_ip, &iport) <= 0) || PinholeVerification(h, int_ip, &iport) <= 0)
{ {
@ -1363,7 +1364,7 @@ AddPinhole(struct upnphttp * h, const char * action)
return ; return ;
} }
// ** RemoteHost can be wilcarded or an IDN. /* ** RemoteHost can be wilcarded or an IDN. */
/*printf("\trem_host: %s\n", rem_host);*/ /*printf("\trem_host: %s\n", rem_host);*/
if (rem_host!=NULL && !strchr(rem_host, ':')) if (rem_host!=NULL && !strchr(rem_host, ':'))
{ {
@ -1420,7 +1421,8 @@ UpdatePinhole(struct upnphttp * h, const char * action)
return; return;
} }
// Check that client is not deleting an pinhole he doesn't have access to, because of its public access /* Check that client is not deleting an pinhole
* it doesn't have access to, because of its public access */
n = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt); n = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt);
if (n > 0) if (n > 0)
{ {
@ -1529,7 +1531,8 @@ DeletePinhole(struct upnphttp * h, const char * action)
return; return;
} }
// Check that client is not deleting an pinhole he doesn't have access to, because of its public access /* Check that client is not deleting an pinhole
* it doesn't have access to, because of its public access */
n = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt); n = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt);
if (n > 0) if (n > 0)
{ {
@ -1591,7 +1594,8 @@ CheckPinholeWorking(struct upnphttp * h, const char * action)
return; return;
} }
// Check that client is not checking a pinhole he doesn't have access to, because of its public access /* Check that client is not checking a pinhole
* it doesn't have access to, because of its public access */
r = upnp_get_pinhole_info(eaddr, eport, iaddr, &iport, proto, uid, lt); r = upnp_get_pinhole_info(eaddr, eport, iaddr, &iport, proto, uid, lt);
if (r > 0) if (r > 0)
{ {
@ -1688,7 +1692,8 @@ GetPinholePackets(struct upnphttp * h, const char * action)
return; return;
} }
// Check that client is not getting infos of a pinhole he doesn't have access to, because of its public access /* Check that client is not getting infos of a pinhole
* it doesn't have access to, because of its public access */
r = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt); r = upnp_get_pinhole_info(0, 0, iaddr, &iport, proto, uid, lt);
if (r > 0) if (r > 0)
{ {