version 1.1.1.2, 2012/05/29 12:55:57
|
version 1.1.1.3, 2013/07/22 00:32:35
|
Line 1
|
Line 1
|
/* $Id$ */ |
/* $Id$ */ |
/* 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 */ |
|
|
Line 11
|
Line 11
|
#include <syslog.h> |
#include <syslog.h> |
|
|
#include "iptcrdr.h" |
#include "iptcrdr.h" |
|
#include "../commonrdr.h" |
|
|
#ifndef PRIu64 |
#ifndef PRIu64 |
#define PRIu64 "llu" |
#define PRIu64 "llu" |
Line 22 main(int argc, char ** argv)
|
Line 23 main(int argc, char ** argv)
|
unsigned short eport, iport; |
unsigned short eport, iport; |
const char * iaddr; |
const char * iaddr; |
printf("Usage %s <ext_port> <internal_ip> <internal_port>\n", argv[0]); |
printf("Usage %s <ext_port> <internal_ip> <internal_port>\n", argv[0]); |
| |
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); |
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]); |
|
#if 0 |
printf("trying to redirect port %hu to %s:%hu\n", eport, iaddr, iport); |
printf("trying to redirect port %hu to %s:%hu\n", eport, iaddr, iport); |
if(addnatrule(IPPROTO_TCP, eport, iaddr, iport) < 0) |
if(addnatrule(IPPROTO_TCP, eport, iaddr, iport) < 0) |
return -1; |
return -1; |
if(add_filter_rule(IPPROTO_TCP, iaddr, iport) < 0) |
if(add_filter_rule(IPPROTO_TCP, iaddr, iport) < 0) |
return -1; |
return -1; |
|
#endif |
/* test */ |
/* test */ |
{ |
{ |
unsigned short p1, p2; |
unsigned short p1, p2; |
char addr[16]; |
char addr[16]; |
int proto2; |
int proto2; |
char desc[256]; |
char desc[256]; |
|
char rhost[256]; |
|
unsigned int timestamp; |
u_int64_t packets, bytes; |
u_int64_t packets, bytes; |
|
|
desc[0] = '\0'; |
desc[0] = '\0'; |
if(get_redirect_rule_by_index(0, "", &p1, addr, sizeof(addr), | if(get_redirect_rule_by_index(0, "", &p1, |
&p2, &proto2, desc, sizeof(desc), | addr, sizeof(addr), &p2, |
| &proto2, desc, sizeof(desc), |
| rhost, sizeof(rhost), |
| ×tamp, |
&packets, &bytes) < 0) |
&packets, &bytes) < 0) |
{ |
{ |
printf("rule not found\n"); |
printf("rule not found\n"); |