2024-03-11 23:37:21 +00:00
|
|
|
/* $Id: commonrdr.h,v 1.16 2024/03/11 23:28:19 nanard Exp $ */
|
2011-09-28 19:13:20 +00:00
|
|
|
/* MiniUPnP project
|
2024-03-11 23:37:21 +00:00
|
|
|
* (c) 2006-2024 Thomas Bernard
|
2020-06-03 22:27:49 +00:00
|
|
|
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
2011-09-28 19:13:20 +00:00
|
|
|
* This software is subject to the conditions detailed
|
|
|
|
* in the LICENCE file provided within the distribution */
|
2012-09-20 20:52:51 +00:00
|
|
|
#ifndef COMMONRDR_H_INCLUDED
|
|
|
|
#define COMMONRDR_H_INCLUDED
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
/* init and shutdown functions */
|
2014-02-11 09:38:50 +00:00
|
|
|
/* init_redirect() return values :
|
|
|
|
* 0 : OK
|
|
|
|
* -1 : error */
|
2011-09-28 19:13:20 +00:00
|
|
|
int
|
|
|
|
init_redirect(void);
|
|
|
|
|
|
|
|
void
|
|
|
|
shutdown_redirect(void);
|
|
|
|
|
2020-06-03 22:27:49 +00:00
|
|
|
/* get_redirect_rule_count()
|
|
|
|
* return value : -1 for error or the number of redirection rules */
|
|
|
|
int
|
|
|
|
get_redirect_rule_count(const char * ifname);
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
/* get_redirect_rule() gets internal IP and port from
|
2014-02-11 09:38:50 +00:00
|
|
|
* interface, external port and protocol
|
|
|
|
* return value :
|
|
|
|
* 0 success (rule found)
|
|
|
|
* -1 error or rule not found
|
2011-09-28 19:13:20 +00:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
get_redirect_rule(const char * ifname, unsigned short eport, int proto,
|
|
|
|
char * iaddr, int iaddrlen, unsigned short * iport,
|
|
|
|
char * desc, int desclen,
|
|
|
|
char * rhost, int rhostlen,
|
|
|
|
unsigned int * timestamp,
|
|
|
|
u_int64_t * packets, u_int64_t * bytes);
|
|
|
|
|
2014-02-11 09:38:50 +00:00
|
|
|
/* get_redirect_rule_by_index()
|
|
|
|
* return values :
|
|
|
|
* 0 success (rule found)
|
|
|
|
* -1 error or rule not found */
|
2011-09-28 19:13:20 +00:00
|
|
|
int
|
|
|
|
get_redirect_rule_by_index(int index,
|
|
|
|
char * ifname, unsigned short * eport,
|
|
|
|
char * iaddr, int iaddrlen, unsigned short * iport,
|
|
|
|
int * proto, char * desc, int desclen,
|
|
|
|
char * rhost, int rhostlen,
|
|
|
|
unsigned int * timestamp,
|
|
|
|
u_int64_t * packets, u_int64_t * bytes);
|
|
|
|
|
|
|
|
/* return an (malloc'ed) array of "external" port for which there is
|
|
|
|
* a port mapping. number is the size of the array */
|
|
|
|
unsigned short *
|
|
|
|
get_portmappings_in_range(unsigned short startport, unsigned short endport,
|
|
|
|
int proto, unsigned int * number);
|
|
|
|
|
2020-12-09 18:26:04 +00:00
|
|
|
/* update the port mapping internal port, description and timestamp */
|
2016-02-12 14:01:30 +00:00
|
|
|
int
|
|
|
|
update_portmapping(const char * ifname, unsigned short eport, int proto,
|
|
|
|
unsigned short iport, const char * desc,
|
|
|
|
unsigned int timestamp);
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-12-09 18:26:04 +00:00
|
|
|
/* update the port mapping description and timestamp */
|
2016-02-12 14:01:30 +00:00
|
|
|
int
|
|
|
|
update_portmapping_desc_timestamp(const char * ifname,
|
|
|
|
unsigned short eport, int proto,
|
|
|
|
const char * desc, unsigned int timestamp);
|
|
|
|
|
2020-09-28 20:44:24 +00:00
|
|
|
#if defined(USE_NETFILTER)
|
2019-10-02 20:29:29 +00:00
|
|
|
/*
|
|
|
|
* only provided by nftables implementation at the moment.
|
|
|
|
* Should be implemented for iptables too, for consistency
|
|
|
|
*/
|
2019-09-30 07:12:08 +00:00
|
|
|
|
|
|
|
typedef enum {
|
2019-10-02 20:29:29 +00:00
|
|
|
RDR_TABLE_NAME,
|
2021-08-18 15:46:29 +00:00
|
|
|
RDR_NAT_TABLE_NAME,
|
2019-10-02 20:29:29 +00:00
|
|
|
RDR_NAT_PREROUTING_CHAIN_NAME,
|
|
|
|
RDR_NAT_POSTROUTING_CHAIN_NAME,
|
|
|
|
RDR_FORWARD_CHAIN_NAME,
|
2024-03-01 09:20:28 +00:00
|
|
|
RDR_FAMILY_SPLIT,
|
2019-09-30 07:12:08 +00:00
|
|
|
} rdr_name_type;
|
|
|
|
|
2019-10-02 20:29:29 +00:00
|
|
|
/*
|
|
|
|
* used by the config file parsing in the core
|
|
|
|
* to set
|
|
|
|
*/
|
|
|
|
|
2019-09-30 07:12:08 +00:00
|
|
|
int set_rdr_name( rdr_name_type param, const char * string );
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-02-12 14:01:30 +00:00
|
|
|
#endif
|