Monero
Loading...
Searching...
No Matches
commonrdr.h
Go to the documentation of this file.
1/* $Id: commonrdr.h,v 1.11 2019/10/02 22:12:02 nanard Exp $ */
2/* MiniUPnP project
3 * (c) 2006-2020 Thomas Bernard
4 * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
5 * This software is subject to the conditions detailed
6 * in the LICENCE file provided within the distribution */
7#ifndef COMMONRDR_H_INCLUDED
8#define COMMONRDR_H_INCLUDED
9
10#include "config.h"
11
12/* init and shutdown functions */
13/* init_redirect() return values :
14 * 0 : OK
15 * -1 : error */
16int
17init_redirect(void);
18
19void
21
22/* get_redirect_rule_count()
23 * return value : -1 for error or the number of redirection rules */
24int
26
27/* get_redirect_rule() gets internal IP and port from
28 * interface, external port and protocol
29 * return value :
30 * 0 success (rule found)
31 * -1 error or rule not found
32 */
33int
34get_redirect_rule(const char * ifname, unsigned short eport, int proto,
35 char * iaddr, int iaddrlen, unsigned short * iport,
36 char * desc, int desclen,
37 char * rhost, int rhostlen,
38 unsigned int * timestamp,
39 u_int64_t * packets, u_int64_t * bytes);
40
41/* get_redirect_rule_by_index()
42 * return values :
43 * 0 success (rule found)
44 * -1 error or rule not found */
45int
47 char * ifname, unsigned short * eport,
48 char * iaddr, int iaddrlen, unsigned short * iport,
49 int * proto, char * desc, int desclen,
50 char * rhost, int rhostlen,
51 unsigned int * timestamp,
52 u_int64_t * packets, u_int64_t * bytes);
53
54/* return an (malloc'ed) array of "external" port for which there is
55 * a port mapping. number is the size of the array */
56unsigned short *
57get_portmappings_in_range(unsigned short startport, unsigned short endport,
58 int proto, unsigned int * number);
59
60/* update the port mapping internal port, description and timestamp */
61int
62update_portmapping(const char * ifname, unsigned short eport, int proto,
63 unsigned short iport, const char * desc,
64 unsigned int timestamp);
65
66/* update the port mapping description and timestamp */
67int
69 unsigned short eport, int proto,
70 const char * desc, unsigned int timestamp);
71
72#if defined(USE_NETFILTER)
73/*
74 * only provided by nftables implementation at the moment.
75 * Should be implemented for iptables too, for consistency
76 */
77
78typedef enum {
79 RDR_TABLE_NAME,
80 RDR_NAT_PREROUTING_CHAIN_NAME,
81 RDR_NAT_POSTROUTING_CHAIN_NAME,
82 RDR_FORWARD_CHAIN_NAME,
83} rdr_name_type;
84
85/*
86 * used by the config file parsing in the core
87 * to set
88 */
89
90int set_rdr_name( rdr_name_type param, const char * string );
91
92#endif
93
94#endif
unsigned short * get_portmappings_in_range(unsigned short startport, unsigned short endport, int proto, unsigned int *number)
Definition ipfrdr.c:729
void shutdown_redirect(void)
Definition ipfrdr.c:215
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)
Definition ipfrdr.c:323
int update_portmapping(const char *ifname, unsigned short eport, int proto, unsigned short iport, const char *desc, unsigned int timestamp)
Definition ipfrdr.c:809
int update_portmapping_desc_timestamp(const char *ifname, unsigned short eport, int proto, const char *desc, unsigned int timestamp)
Definition ipfrdr.c:822
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)
Definition ipfrdr.c:403
int get_redirect_rule_count(const char *ifname)
Definition nftnlrdr.c:545
int init_redirect(void)
Definition ipfrdr.c:199
int set_rdr_name(rdr_name_type param, const char *string)
Definition iptcrdr.c:88
static const char * ifname
Definition testipfwrdr.c:17