From d135bd3f6d7302c1d082f763cda3494d67189f2a Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Sat, 30 Dec 2023 00:30:06 +0100 Subject: [PATCH] move definition of release_ticket() to rtickets.h --- miniupnpd/pf/obsdrdr.c | 12 +----------- miniupnpd/pf/pfpinhole.c | 12 +----------- miniupnpd/pf/rtickets.h | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+), 22 deletions(-) create mode 100644 miniupnpd/pf/rtickets.h diff --git a/miniupnpd/pf/obsdrdr.c b/miniupnpd/pf/obsdrdr.c index 7614f06..86234ef 100644 --- a/miniupnpd/pf/obsdrdr.c +++ b/miniupnpd/pf/obsdrdr.c @@ -69,22 +69,12 @@ #include "obsdrdr.h" #include "../upnpglobalvars.h" #include "../getifaddr.h" +#include "rtickets.h" #ifndef USE_PF #error "USE_PF macro is undefined, check consistency between config.h and Makefile" #else -#if defined(PF_NEWSTYLE) && defined(DIOCXEND) -#define PF_RELEASETICKETS -#define release_ticket(device, ticket_num) {\ - if (ioctl((device), DIOCXEND, &(ticket_num)) < 0) {\ - syslog(LOG_ERR, "ioctl(dev, DIOCXEND, ...): %m");\ - }\ -} -#else -#define release_ticket(device, ticket_num) (void)(ticket_num) -#endif - /* list to keep timestamps for port mappings having a lease duration */ struct timestamp_entry { struct timestamp_entry * next; diff --git a/miniupnpd/pf/pfpinhole.c b/miniupnpd/pf/pfpinhole.c index c5a616e..32b405c 100644 --- a/miniupnpd/pf/pfpinhole.c +++ b/miniupnpd/pf/pfpinhole.c @@ -34,6 +34,7 @@ #include "../upnpglobalvars.h" #include "../macros.h" #include "../upnputils.h" +#include "rtickets.h" /* the pass rules created by add_pinhole() are as follow : * @@ -55,17 +56,6 @@ static int next_uid = 1; #define PINEHOLE_LABEL_FORMAT "pinhole-%d ts-%u: %s" #define PINEHOLE_LABEL_FORMAT_SKIPDESC "pinhole-%d ts-%u: %*s" -#if defined(PF_NEWSTYLE) && defined(DIOCXEND) -#define PF_RELEASETICKETS -#define release_ticket(device, ticket_num) {\ - if (ioctl((device), DIOCXEND, &(ticket_num)) < 0) {\ - syslog(LOG_ERR, "ioctl(dev, DIOCXEND, ...): %m");\ - }\ -} -#else -#define release_ticket(device, ticket_num) (void)(ticket_num) -#endif - int add_pinhole(const char * ifname, const char * rem_host, unsigned short rem_port, const char * int_client, unsigned short int_port, diff --git a/miniupnpd/pf/rtickets.h b/miniupnpd/pf/rtickets.h new file mode 100644 index 0000000..b1edee0 --- /dev/null +++ b/miniupnpd/pf/rtickets.h @@ -0,0 +1,22 @@ +/* $Id: $ */ +/* MiniUPnP project + * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/ + * (c) 2023 Thomas Bernard + * This software is subject to the conditions detailed + * in the LICENCE file provided within the distribution */ + +#ifndef RTICKETS_H_INCLUDED +#define RTICKETS_H_INCLUDED + +#if defined(PF_NEWSTYLE) && defined(DIOCXEND) +#define PF_RELEASETICKETS +#define release_ticket(device, ticket_num) {\ + if (ioctl((device), DIOCXEND, &(ticket_num)) < 0) {\ + syslog(LOG_ERR, "ioctl(dev, DIOCXEND, ...): %m");\ + }\ +} +#else +#define release_ticket(device, ticket_num) (void)(ticket_num) +#endif + +#endif