EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
Data Structures | Functions
iptables.h File Reference

File containing the definition of the IP tables utilities. More...

#include <stdbool.h>
#include <inttypes.h>
#include <utarray.h>
#include "allocs.h"
#include "os.h"
Include dependency graph for iptables.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  iptables_context
 iptables context structure definition More...
 

Functions

struct iptables_contextiptables_init (const char *path, UT_array *ifinfo_array, bool exec_iptables)
 Initialises the iptables rules list. More...
 
void iptables_free (struct iptables_context *ctx)
 Free the iptables context. More...
 
int iptables_add_bridge (struct iptables_context *ctx, char *sip, char *sif, char *dip, char *dif)
 Add a bridge rule to the list of rules. More...
 
int iptables_delete_bridge (struct iptables_context *ctx, const char *sip, const char *sif, const char *dip, const char *dif)
 Delete a bridge rule. More...
 
int iptables_add_nat (struct iptables_context *ctx, char *sip, char *sif, char *nif)
 Add a NAT rule. More...
 
int iptables_delete_nat (struct iptables_context *ctx, char *sip, char *sif, char *nif)
 Delete a NAT rule. More...
 

Detailed Description

File containing the definition of the IP tables utilities.

Author
Alexandru Mereacre
Date
2020

Function Documentation

◆ iptables_add_bridge()

int iptables_add_bridge ( struct iptables_context ctx,
char *  sip,
char *  sif,
char *  dip,
char *  dif 
)

Add a bridge rule to the list of rules.

Parameters
ctxThe iptables context
sipSource IP string
sifSource interface name string
dipDestination IP string
difDestination interface name string
Returns
0 on sucess, -1 on error

◆ iptables_add_nat()

int iptables_add_nat ( struct iptables_context ctx,
char *  sip,
char *  sif,
char *  nif 
)

Add a NAT rule.

Parameters
ctxThe iptables context
sipSource IP string
sifSource interface name string
nifNAT interface name string
Returns
0 on success, -1 on error

◆ iptables_delete_bridge()

int iptables_delete_bridge ( struct iptables_context ctx,
const char *  sip,
const char *  sif,
const char *  dip,
const char *  dif 
)

Delete a bridge rule.

Parameters
ctxThe iptables context
sipSource IP string
sifSource interface name string
dipDestination IP string
difDestination interface name string
Returns
0 on success, -1 on error

◆ iptables_delete_nat()

int iptables_delete_nat ( struct iptables_context ctx,
char *  sip,
char *  sif,
char *  nif 
)

Delete a NAT rule.

Parameters
ctxThe iptables context
sipSource IP string
sifSource interface name string
nifNAT interface name string
Returns
0 on success, -1 on error

◆ iptables_free()

void iptables_free ( struct iptables_context ctx)

Free the iptables context.

Parameters
ctxThe iptables context

◆ iptables_init()

struct iptables_context* iptables_init ( const char *  path,
UT_array *  ifinfo_array,
bool  exec_iptables 
)

Initialises the iptables rules list.

Parameters
pathThe iptables binary path
ifinfo_arrayArray of interface configuration info structure
exec_iptablesExecute the iptables command
Returns
struct iptables_context*, pointer to newly created iptables context, NULL on failure