mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-22 10:48:08 +00:00
pf/obsdrdr.c: add_timestamp_entry()
This commit is contained in:
parent
4eda8234c2
commit
7112203428
@ -1,5 +1,6 @@
|
|||||||
/* $Id: obsdrdr.c,v 1.86 2016/02/12 13:11:03 nanard Exp $ */
|
/* $Id: obsdrdr.c,v 1.86 2016/02/12 13:11:03 nanard Exp $ */
|
||||||
/* MiniUPnP project
|
/* vim: tabstop=4 shiftwidth=4 noexpandtab
|
||||||
|
* 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
|
||||||
* This software is subject to the conditions detailed
|
* This software is subject to the conditions detailed
|
||||||
@ -71,7 +72,7 @@
|
|||||||
#error "USE_PF macro is undefined, check consistency between config.h and Makefile"
|
#error "USE_PF macro is undefined, check consistency between config.h and Makefile"
|
||||||
#else
|
#else
|
||||||
|
|
||||||
/* list too keep timestamps for port mappings having a lease duration */
|
/* list to keep timestamps for port mappings having a lease duration */
|
||||||
struct timestamp_entry {
|
struct timestamp_entry {
|
||||||
struct timestamp_entry * next;
|
struct timestamp_entry * next;
|
||||||
unsigned int timestamp;
|
unsigned int timestamp;
|
||||||
@ -113,6 +114,26 @@ remove_timestamp_entry(unsigned short eport, int proto)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
add_timestamp_entry(unsigned short eport, int proto, unsigned timestamp)
|
||||||
|
{
|
||||||
|
struct timestamp_entry * tmp;
|
||||||
|
tmp = malloc(sizeof(struct timestamp_entry));
|
||||||
|
if(tmp)
|
||||||
|
{
|
||||||
|
tmp->next = timestamp_list;
|
||||||
|
tmp->timestamp = timestamp;
|
||||||
|
tmp->eport = eport;
|
||||||
|
tmp->protocol = (short)proto;
|
||||||
|
timestamp_list = tmp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "add_timestamp_entry() malloc(%lu) error",
|
||||||
|
sizeof(struct timestamp_entry));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* /dev/pf when opened */
|
/* /dev/pf when opened */
|
||||||
int dev = -1;
|
int dev = -1;
|
||||||
|
|
||||||
@ -361,18 +382,7 @@ add_redirect_rule2(const char * ifname,
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if(r == 0 && timestamp > 0)
|
if(r == 0 && timestamp > 0)
|
||||||
{
|
add_timestamp_entry(eport, proto, timestamp);
|
||||||
struct timestamp_entry * tmp;
|
|
||||||
tmp = malloc(sizeof(struct timestamp_entry));
|
|
||||||
if(tmp)
|
|
||||||
{
|
|
||||||
tmp->next = timestamp_list;
|
|
||||||
tmp->timestamp = timestamp;
|
|
||||||
tmp->eport = eport;
|
|
||||||
tmp->protocol = (short)proto;
|
|
||||||
timestamp_list = tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user