testnftnlrdr.c: comments + debug output

This commit is contained in:
Thomas Bernard 2023-11-29 17:58:19 +01:00
parent 1bde68cc9e
commit ef5a1e1abc
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
1 changed files with 8 additions and 7 deletions

View File

@ -1,7 +1,7 @@
/* $Id: testnftnlrdr.c,v 1.2 2019/06/30 19:49:18 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
* (c) 2006-2020 Thomas Bernard
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2023 Thomas Bernard
* This software is subject to the conditions detailed
* in the LICENCE file provided within the distribution */
@ -30,7 +30,7 @@ static int
add_filter_rule(int proto, const char * rhost,
const char * iaddr, unsigned short iport)
{
return add_filter_rule2(NULL, rhost, iaddr, 0, iport, proto, NULL);
return add_filter_rule2(NULL/* ifname */, rhost, iaddr, 0/* eport */, iport, proto, NULL/* desc */);
}
static int
@ -38,7 +38,7 @@ addnatrule(int proto, unsigned short eport,
const char * iaddr, unsigned short iport,
const char * rhost)
{
return add_redirect_rule2(NULL, rhost, eport, iaddr, iport, proto, NULL, 0);
return add_redirect_rule2(NULL/* ifname */, rhost, eport, iaddr, iport, proto, NULL/* desc */, 0/* timestamp */);
}
int
@ -80,12 +80,12 @@ main(int argc, char ** argv)
desc[0] = '\0';
printf("test0\n");
if(get_redirect_rule_by_index(0, "", &p1,
addr, sizeof(addr), &p2,
if(get_redirect_rule_by_index(0/* index */, NULL/* ifname */, &p1/* eport */,
addr, sizeof(addr), &p2/* iport */,
&proto2, desc, sizeof(desc),
rhost, sizeof(rhost),
&timestamp,
&packets, &bytes) < 0)
&packets, &bytes) < 0)
{
printf("rule not found\n");
}
@ -93,6 +93,7 @@ main(int argc, char ** argv)
{
printf("redirected port %hu to %s:%hu proto %d packets=%" PRIu64 " bytes=%" PRIu64 "\n",
p1, addr, p2, proto2, packets, bytes);
printf("timestamp=%u desc=\"%s\"\n", timestamp, desc);
}
printf("test\n");
}