Finalizing netfilter version of get_pinhole_info()
This commit is contained in:
parent
ddbc22865f
commit
457092c60a
|
@ -1,4 +1,7 @@
|
||||||
$Id: Changelog.txt,v 1.280 2012/05/01 22:37:52 nanard Exp $
|
$Id: Changelog.txt,v 1.281 2012/05/07 15:40:03 nanard Exp $
|
||||||
|
|
||||||
|
2012/05/07:
|
||||||
|
Finalizing netfilter version of get_pinhole_info()
|
||||||
|
|
||||||
2012/05/01:
|
2012/05/01:
|
||||||
Move IPv6FirewallControl related code from upnpredirect.c to upnppinhole.c
|
Move IPv6FirewallControl related code from upnpredirect.c to upnppinhole.c
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: iptpinhole.c,v 1.4 2012/05/01 22:37:53 nanard Exp $ */
|
/* $Id: iptpinhole.c,v 1.6 2012/05/07 15:40:04 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) 2012 Thomas Bernard
|
* (c) 2012 Thomas Bernard
|
||||||
|
@ -336,11 +336,36 @@ get_pinhole_info(unsigned short uid,
|
||||||
*proto = p->proto;
|
*proto = p->proto;
|
||||||
if(timestamp)
|
if(timestamp)
|
||||||
*timestamp = p->timestamp;
|
*timestamp = p->timestamp;
|
||||||
/* TODO */
|
if(packets || bytes) {
|
||||||
if(packets)
|
/* theses informations need to be read from netfilter */
|
||||||
*packets = 0;
|
IP6TC_HANDLE h;
|
||||||
if(bytes)
|
const struct ip6t_entry * e;
|
||||||
*bytes = 0;
|
const struct ip6t_entry_match * match;
|
||||||
|
h = ip6tc_init("filter");
|
||||||
|
if(!h) {
|
||||||
|
syslog(LOG_ERR, "ip6tc_init error : %s", ip6tc_strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
for(e = ip6tc_first_rule(miniupnpd_v6_filter_chain, h);
|
||||||
|
e;
|
||||||
|
e = ip6tc_next_rule(e, h)) {
|
||||||
|
if((e->ipv6.proto == p->proto) &&
|
||||||
|
(0 == memcmp(&e->ipv6.src, &p->saddr, sizeof(e->ipv6.src))) &&
|
||||||
|
(0 == memcmp(&e->ipv6.dst, &p->daddr, sizeof(e->ipv6.dst)))) {
|
||||||
|
const struct ip6t_tcp * info;
|
||||||
|
match = (const struct ip6t_entry_match *)&e->elems;
|
||||||
|
info = (const struct ip6t_tcp *)&match->data;
|
||||||
|
if((info->spts[0] == p->sport) && (info->dpts[0] == p->dport)) {
|
||||||
|
if(packets)
|
||||||
|
*packets = e->counters.pcnt;
|
||||||
|
if(bytes)
|
||||||
|
*bytes = e->counters.bcnt;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ip6tc_free(h);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: upnppinhole.c,v 1.2 2012/05/01 22:37:53 nanard Exp $ */
|
/* $Id: upnppinhole.c,v 1.3 2012/05/07 15:40:04 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
|
||||||
|
@ -220,11 +220,14 @@ upnp_get_pinhole_info(unsigned short uid,
|
||||||
#if defined(USE_PF) || defined(USE_NETFILTER)
|
#if defined(USE_PF) || defined(USE_NETFILTER)
|
||||||
int r;
|
int r;
|
||||||
unsigned int timestamp;
|
unsigned int timestamp;
|
||||||
u_int64_t packets_tmp, bytes_tmp;
|
u_int64_t packets_tmp;
|
||||||
|
/*u_int64_t bytes_tmp;*/
|
||||||
|
|
||||||
r = get_pinhole_info(uid, raddr, raddrlen, rport,
|
r = get_pinhole_info(uid, raddr, raddrlen, rport,
|
||||||
iaddr, iaddrlen, iport, proto, ×tamp,
|
iaddr, iaddrlen, iport, proto,
|
||||||
&packets_tmp, &bytes_tmp);
|
leasetime ? ×tamp : NULL,
|
||||||
|
packets ? &packets_tmp : NULL,
|
||||||
|
NULL/*&bytes_tmp*/);
|
||||||
if(r >= 0) {
|
if(r >= 0) {
|
||||||
if(leasetime) {
|
if(leasetime) {
|
||||||
time_t current_time;
|
time_t current_time;
|
||||||
|
|
Loading…
Reference in New Issue