iptcrdr.c: add iptc_init() check in init_redirect()
This commit is contained in:
parent
c4f2397d5c
commit
dd9bf47c68
|
@ -1,4 +1,7 @@
|
||||||
$Id: Changelog.txt,v 1.418 2016/02/11 10:35:11 nanard Exp $
|
$Id: Changelog.txt,v 1.421 2016/02/12 12:34:37 nanard Exp $
|
||||||
|
|
||||||
|
2016/02/12:
|
||||||
|
add iptc_init() check in iptcrdr.c/init_redirect()
|
||||||
|
|
||||||
2016/02/11:
|
2016/02/11:
|
||||||
use Linux libuuid uuid_generate() / BSD uuid_create() API
|
use Linux libuuid uuid_generate() / BSD uuid_create() API
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iptcrdr.c,v 1.53 2015/02/08 09:10:00 nanard Exp $ */
|
/* $Id: iptcrdr.c,v 1.57 2016/02/12 12: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-2016 Thomas Bernard
|
* (c) 2006-2016 Thomas Bernard
|
||||||
|
@ -91,9 +91,24 @@ addpeerdscprule(int proto, unsigned char dscp,
|
||||||
const char * iaddr, unsigned short iport,
|
const char * iaddr, unsigned short iport,
|
||||||
const char * rhost, unsigned short rport);
|
const char * rhost, unsigned short rport);
|
||||||
|
|
||||||
/* dummy init and shutdown functions */
|
/* dummy init and shutdown functions
|
||||||
|
* Only test iptc_init() */
|
||||||
int init_redirect(void)
|
int init_redirect(void)
|
||||||
{
|
{
|
||||||
|
IPTC_HANDLE h;
|
||||||
|
|
||||||
|
h = iptc_init("nat");
|
||||||
|
if(!h) {
|
||||||
|
syslog(LOG_ERR, "iptc_init() failed : %s",
|
||||||
|
iptc_strerror(errno));
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
#ifdef IPTABLES_143
|
||||||
|
iptc_free(h);
|
||||||
|
#else
|
||||||
|
iptc_free(&h);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* $Id: testiptcrdr.c,v 1.18 2012/04/24 22:41:53 nanard Exp $ */
|
/* $Id: testiptcrdr.c,v 1.21 2016/02/12 12:35:50 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-2015 Thomas Bernard
|
* (c) 2006-2016 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 */
|
||||||
|
|
||||||
|
@ -29,6 +29,8 @@ main(int argc, char ** argv)
|
||||||
if(argc<4)
|
if(argc<4)
|
||||||
return -1;
|
return -1;
|
||||||
openlog("testiptcrdr", LOG_PERROR|LOG_CONS, LOG_LOCAL0);
|
openlog("testiptcrdr", LOG_PERROR|LOG_CONS, LOG_LOCAL0);
|
||||||
|
if(init_redirect() < 0)
|
||||||
|
return -1;
|
||||||
eport = (unsigned short)atoi(argv[1]);
|
eport = (unsigned short)atoi(argv[1]);
|
||||||
iaddr = argv[2];
|
iaddr = argv[2];
|
||||||
iport = (unsigned short)atoi(argv[3]);
|
iport = (unsigned short)atoi(argv[3]);
|
||||||
|
@ -73,14 +75,15 @@ main(int argc, char ** argv)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("redirected port %hu to %s:%hu proto %d packets=%" PRIu64 " bytes=%" PRIu64 "\n",
|
printf("redirected port %hu to %s:%hu proto %d packets=%" PRIu64 " bytes=%" PRIu64 " ts=%u desc='%s'\n",
|
||||||
p1, addr, p2, proto2, packets, bytes);
|
p1, addr, p2, proto2, packets, bytes, timestamp, desc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("trying to list nat rules :\n");
|
printf("trying to list nat rules :\n");
|
||||||
list_redirect_rule(argv[1]);
|
list_redirect_rule(NULL);
|
||||||
printf("deleting\n");
|
printf("deleting\n");
|
||||||
delete_redirect_and_filter_rules(eport, proto);
|
delete_redirect_and_filter_rules(eport, proto);
|
||||||
|
shutdown_redirect();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue