Monero
Loading...
Searching...
No Matches
iptcrdr.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <syslog.h>
#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <dlfcn.h>
#include <xtables.h>
#include <linux/netfilter/xt_DSCP.h>
#include <libiptc/libiptc.h>
#include <linux/version.h>
#include "config.h"
#include "tiny_nf_nat.h"
#include "../macros.h"
#include "iptcrdr.h"
#include "../upnpglobalvars.h"
Include dependency graph for iptcrdr.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  rdr_desc

Macros

#define IPTC_HANDLE   iptc_handle_t
#define IPT_ALIGN   XT_ALIGN

Functions

int set_rdr_name (rdr_name_type param, const char *string)
static int addnatrule (int proto, unsigned short eport, const char *iaddr, unsigned short iport, const char *rhost)
static int add_filter_rule (int proto, const char *rhost, const char *iaddr, unsigned short iport)
static int addpeernatrule (int proto, const char *eaddr, unsigned short eport, const char *iaddr, unsigned short iport, const char *rhost, unsigned short rport)
static int addpeerdscprule (int proto, unsigned char dscp, const char *iaddr, unsigned short iport, const char *rhost, unsigned short rport)
int init_redirect (void)
void shutdown_redirect (void)
static int snprintip (char *dst, size_t size, uint32_t ip)
static void add_redirect_desc (unsigned short eport, int proto, const char *desc, unsigned int timestamp)
static void del_redirect_desc (unsigned short eport, int proto)
static void get_redirect_desc (unsigned short eport, int proto, char *desc, int desclen, unsigned int *timestamp)
int add_redirect_rule2 (const char *ifname, const char *rhost, unsigned short eport, const char *iaddr, unsigned short iport, int proto, const char *desc, unsigned int timestamp)
int add_peer_redirect_rule2 (const char *ifname, const char *rhost, unsigned short rport, const char *eaddr, unsigned short eport, const char *iaddr, unsigned short iport, int proto, const char *desc, unsigned int timestamp)
int add_peer_dscp_rule2 (const char *ifname, const char *rhost, unsigned short rport, unsigned char dscp, const char *iaddr, unsigned short iport, int proto, const char *desc, unsigned int timestamp)
int add_filter_rule2 (const char *ifname, const char *rhost, const char *iaddr, unsigned short eport, unsigned short iport, int proto, const char *desc)
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)
int get_nat_redirect_rule (const char *nat_chain_name, 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)
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)
int get_peer_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 short *rport, unsigned int *timestamp, u_int64_t *packets, u_int64_t *bytes)
static int delete_rule_and_commit (unsigned int index, IPTC_HANDLE h, const char *miniupnpd_chain, const char *logcaller)
int delete_filter_rule (const char *ifname, unsigned short port, int proto)
int delete_redirect_and_filter_rules (unsigned short eport, int proto)
static struct ipt_entry_match * get_tcp_match (unsigned short dport, unsigned short sport)
static struct ipt_entry_match * get_udp_match (unsigned short dport, unsigned short sport)
static struct ipt_entry_target * get_dnat_target (const char *daddr, unsigned short dport)
static struct ipt_entry_target * get_snat_target (const char *saddr, unsigned short sport)
static struct ipt_entry_target * get_dscp_target (unsigned char dscp)
static int iptc_init_verify_and_append (const char *table, const char *miniupnpd_chain, struct ipt_entry *e, const char *logcaller)
static struct ipt_entry_target * get_accept_target (void)
unsigned short * get_portmappings_in_range (unsigned short startport, unsigned short endport, int proto, unsigned int *number)
int update_portmapping_desc_timestamp (const char *ifname, unsigned short eport, int proto, const char *desc, unsigned int timestamp)
static int update_rule_and_commit (const char *table, const char *chain, unsigned index, const struct ipt_entry *e)
int update_portmapping (const char *ifname, unsigned short eport, int proto, unsigned short iport, const char *desc, unsigned int timestamp)

Variables

static const char * miniupnpd_nat_chain = "MINIUPNPD"
static const char * miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING"
static const char * miniupnpd_forward_chain = "MINIUPNPD"
static struct rdr_descrdr_desc_list = 0

Macro Definition Documentation

◆ IPT_ALIGN

#define IPT_ALIGN   XT_ALIGN

◆ IPTC_HANDLE

#define IPTC_HANDLE   iptc_handle_t

Function Documentation

◆ add_filter_rule()

int add_filter_rule ( int proto,
const char * rhost,
const char * iaddr,
unsigned short iport )
static

◆ add_filter_rule2()

int add_filter_rule2 ( const char * ifname,
const char * rhost,
const char * iaddr,
unsigned short eport,
unsigned short iport,
int proto,
const char * desc )

◆ add_peer_dscp_rule2()

int add_peer_dscp_rule2 ( const char * ifname,
const char * rhost,
unsigned short rport,
unsigned char dscp,
const char * iaddr,
unsigned short iport,
int proto,
const char * desc,
unsigned int timestamp )

◆ add_peer_redirect_rule2()

int add_peer_redirect_rule2 ( const char * ifname,
const char * rhost,
unsigned short rport,
const char * eaddr,
unsigned short eport,
const char * iaddr,
unsigned short iport,
int proto,
const char * desc,
unsigned int timestamp )

◆ add_redirect_desc()

void add_redirect_desc ( unsigned short eport,
int proto,
const char * desc,
unsigned int timestamp )
static

◆ add_redirect_rule2()

int add_redirect_rule2 ( const char * ifname,
const char * rhost,
unsigned short eport,
const char * iaddr,
unsigned short iport,
int proto,
const char * desc,
unsigned int timestamp )

◆ addnatrule()

int addnatrule ( int proto,
unsigned short eport,
const char * iaddr,
unsigned short iport,
const char * rhost )
static

◆ addpeerdscprule()

int addpeerdscprule ( int proto,
unsigned char dscp,
const char * iaddr,
unsigned short iport,
const char * rhost,
unsigned short rport )
static

◆ addpeernatrule()

int addpeernatrule ( int proto,
const char * eaddr,
unsigned short eport,
const char * iaddr,
unsigned short iport,
const char * rhost,
unsigned short rport )
static

◆ del_redirect_desc()

void del_redirect_desc ( unsigned short eport,
int proto )
static

◆ delete_filter_rule()

int delete_filter_rule ( const char * ifname,
unsigned short port,
int proto )

◆ delete_redirect_and_filter_rules()

int delete_redirect_and_filter_rules ( unsigned short eport,
int proto )

◆ delete_rule_and_commit()

int delete_rule_and_commit ( unsigned int index,
IPTC_HANDLE h,
const char * miniupnpd_chain,
const char * logcaller )
static

◆ get_accept_target()

struct ipt_entry_target * get_accept_target ( void )
static

◆ get_dnat_target()

struct ipt_entry_target * get_dnat_target ( const char * daddr,
unsigned short dport )
static

◆ get_dscp_target()

struct ipt_entry_target * get_dscp_target ( unsigned char dscp)
static

◆ get_nat_redirect_rule()

int get_nat_redirect_rule ( const char * nat_chain_name,
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 )

◆ get_peer_rule_by_index()

int get_peer_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 short * rport,
unsigned int * timestamp,
u_int64_t * packets,
u_int64_t * bytes )

◆ get_portmappings_in_range()

unsigned short * get_portmappings_in_range ( unsigned short startport,
unsigned short endport,
int proto,
unsigned int * number )

◆ get_redirect_desc()

void get_redirect_desc ( unsigned short eport,
int proto,
char * desc,
int desclen,
unsigned int * timestamp )
static

◆ get_redirect_rule()

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 )

◆ get_redirect_rule_by_index()

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 )

◆ get_snat_target()

struct ipt_entry_target * get_snat_target ( const char * saddr,
unsigned short sport )
static

◆ get_tcp_match()

struct ipt_entry_match * get_tcp_match ( unsigned short dport,
unsigned short sport )
static

◆ get_udp_match()

struct ipt_entry_match * get_udp_match ( unsigned short dport,
unsigned short sport )
static

◆ init_redirect()

int init_redirect ( void )

◆ iptc_init_verify_and_append()

int iptc_init_verify_and_append ( const char * table,
const char * miniupnpd_chain,
struct ipt_entry * e,
const char * logcaller )
static

◆ set_rdr_name()

int set_rdr_name ( rdr_name_type param,
const char * string )

used by the core to override default chain names if specified in config file

Parameters
paramwhich string to set
stringthe new name to use. Do not dispose after setting (i.e. use strdup if not static).
Returns
0 if successful

◆ shutdown_redirect()

void shutdown_redirect ( void )

◆ snprintip()

int snprintip ( char * dst,
size_t size,
uint32_t ip )
static

◆ update_portmapping()

int update_portmapping ( const char * ifname,
unsigned short eport,
int proto,
unsigned short iport,
const char * desc,
unsigned int timestamp )

◆ update_portmapping_desc_timestamp()

int update_portmapping_desc_timestamp ( const char * ifname,
unsigned short eport,
int proto,
const char * desc,
unsigned int timestamp )

◆ update_rule_and_commit()

int update_rule_and_commit ( const char * table,
const char * chain,
unsigned index,
const struct ipt_entry * e )
static

Variable Documentation

◆ miniupnpd_forward_chain

const char* miniupnpd_forward_chain = "MINIUPNPD"
static

◆ miniupnpd_nat_chain

const char* miniupnpd_nat_chain = "MINIUPNPD"
static

◆ miniupnpd_nat_postrouting_chain

const char* miniupnpd_nat_postrouting_chain = "MINIUPNPD-POSTROUTING"
static

◆ rdr_desc_list

struct rdr_desc* rdr_desc_list = 0
static