miniupnpd/pf: replace delete_filter_rule()
now use delete_redirect_and_filter_rules()
This commit is contained in:
parent
37208eecae
commit
9d23b88cef
|
@ -579,8 +579,9 @@ error:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int
|
||||
delete_redirect_rule(const char * ifname, unsigned short eport, int proto)
|
||||
static int
|
||||
priv_delete_redirect_rule(const char * ifname, unsigned short eport,
|
||||
int proto, unsigned short * iport)
|
||||
{
|
||||
int i, n;
|
||||
struct pfioc_rule pr;
|
||||
|
@ -618,6 +619,12 @@ delete_redirect_rule(const char * ifname, unsigned short eport, int proto)
|
|||
#endif
|
||||
&& (pr.rule.proto == proto) )
|
||||
{
|
||||
/* retrieve iport in order to remove filter rule */
|
||||
#ifndef PF_NEWSTYLE
|
||||
if(iport) *iport = pr.rule.rpool.proxy_port[0];
|
||||
#else
|
||||
if(iport) *iport = pr.rule.rdr.proxy_port[0];
|
||||
#endif
|
||||
pr.action = PF_CHANGE_GET_TICKET;
|
||||
if(ioctl(dev, DIOCCHANGERULE, &pr) < 0)
|
||||
{
|
||||
|
@ -640,7 +647,15 @@ error:
|
|||
}
|
||||
|
||||
int
|
||||
delete_filter_rule(const char * ifname, unsigned short iport, int proto)
|
||||
delete_redirect_rule(const char * ifname, unsigned short eport,
|
||||
int proto)
|
||||
{
|
||||
return priv_delete_redirect_rule(ifname, eport, proto, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
priv_delete_filter_rule(const char * ifname, unsigned short iport,
|
||||
int proto)
|
||||
{
|
||||
#ifndef PF_ENABLE_FILTER_RULES
|
||||
UNUSED(ifname); UNUSED(iport); UNUSED(proto);
|
||||
|
@ -693,6 +708,20 @@ error:
|
|||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
delete_redirect_and_filter_rules(const char * ifname, unsigned short eport,
|
||||
int proto)
|
||||
{
|
||||
int r;
|
||||
unsigned short iport;
|
||||
r = priv_delete_redirect_rule(ifname, eport, proto, &iport);
|
||||
if(r == 0)
|
||||
{
|
||||
priv_delete_filter_rule(ifname, iport, proto);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
int
|
||||
get_redirect_rule_by_index(int index,
|
||||
char * ifname, unsigned short * eport,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: obsdrdr.h,v 1.20 2012/03/05 20:36:20 nanard Exp $ */
|
||||
/* $Id: obsdrdr.h,v 1.22 2014/02/28 20:18:41 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006 Thomas Bernard
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -52,10 +52,11 @@ get_redirect_rule_by_index(int index,
|
|||
int
|
||||
delete_redirect_rule(const char * ifname, unsigned short eport, int proto);
|
||||
|
||||
/* delete_filter_rule()
|
||||
/* delete_redirect_and_filter_rules()
|
||||
*/
|
||||
int
|
||||
delete_filter_rule(const char * ifname, unsigned short eport, int proto);
|
||||
delete_redirect_and_filter_rules(const char * ifname, unsigned short eport,
|
||||
int proto);
|
||||
|
||||
int
|
||||
clear_redirect_rules(void);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* $Id: upnpredirect.c,v 1.80 2012/05/01 20:08:22 nanard Exp $ */
|
||||
/* $Id: upnpredirect.c,v 1.82 2014/02/28 20:18:35 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2012 Thomas Bernard
|
||||
* (c) 2006-2014 Thomas Bernard
|
||||
* This software is subject to the conditions detailed
|
||||
* in the LICENCE file provided within the distribution */
|
||||
|
||||
|
@ -419,23 +419,11 @@ _upnp_delete_redir(unsigned short eport, int proto)
|
|||
int r;
|
||||
#if defined(__linux__)
|
||||
r = delete_redirect_and_filter_rules(eport, proto);
|
||||
#elif defined(USE_PF)
|
||||
r = delete_redirect_and_filter_rules(ext_if_name, eport, proto);
|
||||
#else
|
||||
char iaddr[INET6_ADDRSTRLEN];
|
||||
unsigned short iport;
|
||||
char desc[64];
|
||||
char rhost[64];
|
||||
unsigned int timestamp;
|
||||
u_int64_t packets;
|
||||
u_int64_t bytes;
|
||||
int r2 = get_redirect_rule(ext_if_name, eport, proto,
|
||||
&iaddr, sizeof(iaddr), &iport,
|
||||
&desc, sizeof(desc),
|
||||
&rhost, sizeof(rhost),
|
||||
×tamp,
|
||||
&packets, &bytes);
|
||||
r = delete_redirect_rule(ext_if_name, eport, proto);
|
||||
if (r2==0)
|
||||
delete_filter_rule(ext_if_name, iport, proto);
|
||||
delete_filter_rule(ext_if_name, eport, proto);
|
||||
#endif
|
||||
#ifdef ENABLE_LEASEFILE
|
||||
lease_file_remove( eport, proto);
|
||||
|
|
Loading…
Reference in New Issue