move definition of release_ticket() to rtickets.h

This commit is contained in:
Thomas Bernard 2023-12-30 00:30:06 +01:00
parent 6e8b02b715
commit d135bd3f6d
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
3 changed files with 24 additions and 22 deletions

View File

@ -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;

View File

@ -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,

22
miniupnpd/pf/rtickets.h Normal file
View File

@ -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