More C++ => ANSI C comments to compile with -ansi option

This commit is contained in:
Thomas Bernard 2012-04-15 00:34:57 +02:00
parent 76da677016
commit 50cb647305
3 changed files with 23 additions and 17 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.268 2012/04/12 13:08:15 nanard Exp $ $Id: Changelog.txt,v 1.270 2012/04/14 22:26:09 nanard Exp $
2012/04/15:
More C++ => ANSI C comments to compile with -ansi option
2012/04/12: 2012/04/12:
Set TTL on SSDP Notify sockets (IPv4). TTL is set to 2 (recommendation from Set TTL on SSDP Notify sockets (IPv4). TTL is set to 2 (recommendation from

View File

@ -1,4 +1,4 @@
/* $Id: upnpredirect.c,v 1.61 2012/03/05 04:41:22 nanard Exp $ */ /* $Id: upnpredirect.c,v 1.64 2012/04/14 22:12:09 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
@ -637,16 +637,18 @@ upnp_add_inboundpinhole(const char * raddr,
int * uid) int * uid)
{ {
int r, s, t, lt=0; int r, s, t, lt=0;
char iaddr_old[40]="", proto[6]="", idfound[5]="", leaseTmp[12]; // IPv6 Modification char iaddr_old[40]="", proto[6]="", idfound[5]="", leaseTmp[12]; /* IPv6 Modification*/
snprintf(proto, sizeof(proto), "%.5d", atoi(protocol)); snprintf(proto, sizeof(proto), "%.5d", atoi(protocol));
unsigned short iport_old = 0; unsigned short iport_old = 0;
time_t current = time(NULL); time_t current = time(NULL);
/*struct in6_addr address; // IPv6 Modification #if 0
if(inet_pton(AF_INET6, iaddr, &address) < 0) // IPv6 Modification struct in6_addr address; /* IPv6 Modification*/
if(inet_pton(AF_INET6, iaddr, &address) < 0) /* IPv6 Modification */
{ {
syslog(LOG_ERR, "inet_pton(%s) : %m", iaddr); syslog(LOG_ERR, "inet_pton(%s) : %m", iaddr);
return 0; return 0;
}*/ }
#endif
#if 0 #if 0
r = get_rule_from_file(raddr, rport, iaddr_old, &iport_old, proto, 0, 0, idfound); r = get_rule_from_file(raddr, rport, iaddr_old, &iport_old, proto, 0, 0, idfound);
@ -705,7 +707,7 @@ upnp_add_inboundpinhole_internal(const char * raddr, unsigned short rport,
static const char cmdval_full_udplite_raw[] = "ip6tables -t raw -I PREROUTING %d -p %s -i %s -s %s -d %s -j TRACE"; static const char cmdval_full_udplite_raw[] = "ip6tables -t raw -I PREROUTING %d -p %s -i %s -s %s -d %s -j TRACE";
static const char cmdval_udplite_raw[] = "ip6tables -t raw -I PREROUTING %d -p %s -i %s -d %s -j TRACE"; static const char cmdval_udplite_raw[] = "ip6tables -t raw -I PREROUTING %d -p %s -i %s -d %s -j TRACE";
#endif #endif
//printf("%s\n", raddr); /*printf("%s\n", raddr);*/
if(raddr!=NULL) if(raddr!=NULL)
{ {
#ifdef IPPROTO_UDPLITE #ifdef IPPROTO_UDPLITE
@ -742,7 +744,7 @@ upnp_add_inboundpinhole_internal(const char * raddr, unsigned short rport,
syslog(LOG_INFO, " -> %s", cmd); syslog(LOG_INFO, " -> %s", cmd);
syslog(LOG_INFO, " -> %s", cmd_raw); syslog(LOG_INFO, " -> %s", cmd_raw);
#endif #endif
// TODO Add a better checking error. /* TODO Add a better checking error.*/
if(system(cmd) < 0 || system(cmd_raw) < 0) if(system(cmd) < 0 || system(cmd_raw) < 0)
{ {
return 0; return 0;

View File

@ -1,4 +1,4 @@
/* $Id: upnpsoap.c,v 1.90 2012/02/04 23:34:40 nanard Exp $ */ /* $Id: upnpsoap.c,v 1.92 2012/04/14 22:12:09 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
@ -1262,26 +1262,28 @@ PinholeVerification(struct upnphttp * h, char * int_ip, unsigned short * int_por
/* Pinhole InternalClient address must correspond to the action sender */ /* Pinhole InternalClient address must correspond to the action sender */
syslog(LOG_INFO, "Checking internal IP@ and port (Security policy purpose)"); syslog(LOG_INFO, "Checking internal IP@ and port (Security policy purpose)");
char senderAddr[INET6_ADDRSTRLEN]=""; char senderAddr[INET6_ADDRSTRLEN]="";
#if 0
//char str[INET6_ADDRSTRLEN]=""; //char str[INET6_ADDRSTRLEN]="";
//connecthostport(int_ip, *int_port, str); //connecthostport(int_ip, *int_port, str);
//printf("int_ip: %s / str: %s\n", int_ip, str); //printf("int_ip: %s / str: %s\n", int_ip, str);
#endif
struct addrinfo hints, *ai, *p; struct addrinfo hints, *ai, *p;
struct in6_addr result_ip;/*unsigned char result_ip[16];*/ /* inet_pton() */ //IPv6 Modification struct in6_addr result_ip;/*unsigned char result_ip[16];*/ /* inet_pton() */
hints.ai_socktype = SOCK_STREAM; hints.ai_socktype = SOCK_STREAM;
hints.ai_family = AF_UNSPEC; hints.ai_family = AF_UNSPEC;
/* if ip not valid assume hostname and convert */ /* if ip not valid assume hostname and convert */
if (inet_pton(AF_INET6, int_ip, &result_ip) <= 0) //IPv6 Modification if (inet_pton(AF_INET6, int_ip, &result_ip) <= 0) /*IPv6 Modification*/
{ {
n = getaddrinfo(int_ip, NULL, &hints, &ai);//hp = gethostbyname(int_ip); n = getaddrinfo(int_ip, NULL, &hints, &ai);/*hp = gethostbyname(int_ip);*/
if(!n && ai->ai_family == AF_INET6) //IPv6 Modification if(!n && ai->ai_family == AF_INET6) /*IPv6 Modification*/
{ {
for(p = ai; p; p = p->ai_next)//ptr = hp->h_addr_list; ptr && *ptr; ptr++) for(p = ai; p; p = p->ai_next)/*ptr = hp->h_addr_list; ptr && *ptr; ptr++)*/
{ {
inet_ntop(AF_INET6, (struct in6_addr *) p, int_ip, sizeof(struct in6_addr)); ///IPv6 Modification inet_ntop(AF_INET6, (struct in6_addr *) p, int_ip, sizeof(struct in6_addr)); /*IPv6 Modification*/
result_ip = *((struct in6_addr *) p); result_ip = *((struct in6_addr *) p);
fprintf(stderr, "upnpsoap / AddPinhole: assuming int addr = %s", int_ip); fprintf(stderr, "upnpsoap / AddPinhole: assuming int addr = %s", int_ip);
/* TODO : deal with more than one ip per hostname */ /* TODO : deal with more than one ip per hostname */
@ -1299,7 +1301,6 @@ PinholeVerification(struct upnphttp * h, char * int_ip, unsigned short * int_por
if(inet_ntop(AF_INET6, &(h->clientaddr_v6), senderAddr, INET6_ADDRSTRLEN)<=0) if(inet_ntop(AF_INET6, &(h->clientaddr_v6), senderAddr, INET6_ADDRSTRLEN)<=0)
{ {
//printf("Failed to inet_ntop\n");
syslog(LOG_ERR, "inet_ntop: %m"); syslog(LOG_ERR, "inet_ntop: %m");
} }
#ifdef DEBUG #ifdef DEBUG
@ -1619,7 +1620,7 @@ CheckPinholeWorking(struct upnphttp * h, const char * action)
} }
else else
{ {
// d==-5 not same table // d==-6 not same chain // d==-7 not found a rule but policy traced /* d==-5 not same table // d==-6 not same chain // d==-7 not found a rule but policy traced */
isWorking=0; isWorking=0;
syslog(LOG_INFO, "%s: rule for ID=%s is not working, packet going through %s", action, uid, (d==-5)?"the wrong table":((d==-6)?"the wrong chain":"a chain policy")); syslog(LOG_INFO, "%s: rule for ID=%s is not working, packet going through %s", action, uid, (d==-5)?"the wrong table":((d==-6)?"the wrong chain":"a chain policy"));
bodylen = snprintf(body, sizeof(body), resp, bodylen = snprintf(body, sizeof(body), resp,