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

File containing the definition of the uci utilities. More...

#include <uci.h>
#include <utarray.h>
#include "os.h"
#include "squeue.h"
Include dependency graph for uci_wrt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  uctx
 
struct  hostapd_params
 

Functions

struct uctxuwrt_init_context (const char *path)
 Initialises the uci context. More...
 
void uwrt_free_context (struct uctx *context)
 Frees the uci context. More...
 
UT_array * uwrt_get_interfaces (const struct uctx *context, const char *ifname)
 Get the array of struct netif_info_t for each available interface. More...
 
int uwrt_set_interface_ip (const struct uctx *context, const char *ifname, const char *ip_addr, const char *netmask)
 Assigns an IP to an interface. More...
 
int uwrt_create_interface (const struct uctx *context, const char *ifname, const char *type, const char *ip_addr, const char *brd_addr, const char *netmask)
 Creates and interface and assigns an IP. More...
 
int uwrt_commit_section (const struct uctx *context, const char *section)
 Commit a uci section. More...
 
int uwrt_gen_dnsmasq_instance (const struct uctx *context, const struct string_queue *ifname_queue, const UT_array *server_array, const char *leasefile, const char *scriptfile)
 Generates a dnsmasq uci instance. More...
 
int uwrt_add_dhcp_pool (const struct uctx *context, const char *ifname, const char *ip_addr_low, const char *ip_addr_upp, const char *subnet_mask, const char *lease_time)
 Adds a dhcp pool entry. More...
 
int uwrt_gen_hostapd_instance (const struct uctx *context, const struct hostapd_params *params)
 Generate the hostapd config. More...
 
int uwrt_gen_firewall_zone (const struct uctx *context, const char *brname)
 Generate a firewall zone for a bridge. More...
 
int uwrt_add_firewall_nat (const struct uctx *context, const char *brname, const char *ip_addr, const char *nat_name)
 Adds a firewall rule for an IP address. More...
 
int uwrt_delete_firewall_nat (const struct uctx *context, const char *ip_addr)
 Deletes a firewall rule for an IP address. More...
 
int uwrt_add_firewall_bridge (const struct uctx *context, const char *sip, const char *sbr, const char *dip, const char *dbr)
 Adds a firewall bridge rule for two IP addresses. More...
 
int uwrt_delete_firewall_bridge (const struct uctx *context, const char *sip, const char *dip)
 Deletes a firewall bridge rule for two IP addresses. More...
 
int uwrt_cleanup_firewall (const struct uctx *context)
 Removes all the firewall rules. More...
 

Detailed Description

File containing the definition of the uci utilities.

Author
Alexandru Mereacre
Date
2022

Function Documentation

◆ uwrt_add_dhcp_pool()

int uwrt_add_dhcp_pool ( const struct uctx context,
const char *  ifname,
const char *  ip_addr_low,
const char *  ip_addr_upp,
const char *  subnet_mask,
const char *  lease_time 
)

Adds a dhcp pool entry.

Parameters
contextThe uci context
ifnameThe interface name
ip_addr_lowInterface string IP address lower bound
ip_addr_uppInterface string IP address upper bound
subnet_maskInterface string IP subnet mask
lease_timeInterface lease time string
Returns
int 0 on success, -1 on failure

◆ uwrt_add_firewall_bridge()

int uwrt_add_firewall_bridge ( const struct uctx context,
const char *  sip,
const char *  sbr,
const char *  dip,
const char *  dbr 
)

Adds a firewall bridge rule for two IP addresses.

Parameters
contextThe uci context
sipThe source IP address
sbrThe source bridge interface name
dipThe destination IP address
dbrThe destination bridge interface name
Returns
int 0 on success, -1 on failure

◆ uwrt_add_firewall_nat()

int uwrt_add_firewall_nat ( const struct uctx context,
const char *  brname,
const char *  ip_addr,
const char *  nat_name 
)

Adds a firewall rule for an IP address.

Parameters
contextThe uci context
brnameThe bridge name
ip_addrThe IP address
nat_nameThe NAT bridge name
Returns
int 0 on success, -1 on failure

◆ uwrt_cleanup_firewall()

int uwrt_cleanup_firewall ( const struct uctx context)

Removes all the firewall rules.

Parameters
contextThe uci context
Returns
int 0 on success, -1 on failure

◆ uwrt_commit_section()

int uwrt_commit_section ( const struct uctx context,
const char *  section 
)

Commit a uci section.

Parameters
contextThe uci context
sectionThe uci section
Returns
int 0 on success, -1 on failure

◆ uwrt_create_interface()

int uwrt_create_interface ( const struct uctx context,
const char *  ifname,
const char *  type,
const char *  ip_addr,
const char *  brd_addr,
const char *  netmask 
)

Creates and interface and assigns an IP.

Parameters
contextThe uci context
ifnameThe interface name
typeThe interface type
ip_addrThe interface IP4 address
brd_addrThe interface IP4 broadcast address
netmaskThe interface IP4 netmask
Returns
int 0 on success, -1 on failure

◆ uwrt_delete_firewall_bridge()

int uwrt_delete_firewall_bridge ( const struct uctx context,
const char *  sip,
const char *  dip 
)

Deletes a firewall bridge rule for two IP addresses.

Parameters
contextThe uci context
sipThe source IP address
dipThe destination IP address
Returns
int 0 on success, -1 on failure

◆ uwrt_delete_firewall_nat()

int uwrt_delete_firewall_nat ( const struct uctx context,
const char *  ip_addr 
)

Deletes a firewall rule for an IP address.

Parameters
contextThe uci context
ip_addrThe IP address
Returns
int 0 on success, -1 on failure

◆ uwrt_free_context()

void uwrt_free_context ( struct uctx context)

Frees the uci context.

Parameters
contextThe uci context

◆ uwrt_gen_dnsmasq_instance()

int uwrt_gen_dnsmasq_instance ( const struct uctx context,
const struct string_queue ifname_queue,
const UT_array *  server_array,
const char *  leasefile,
const char *  scriptfile 
)

Generates a dnsmasq uci instance.

Parameters
contextThe uci context
ifname_queueThe interface queue
server_arrayThe array of servers
leasefileThe lease file path string
scriptfileThe script file path string
Returns
int 0 on success, -1 on failure

◆ uwrt_gen_firewall_zone()

int uwrt_gen_firewall_zone ( const struct uctx context,
const char *  brname 
)

Generate a firewall zone for a bridge.

Parameters
contextThe uci context
brnameThe bridge name
Returns
int 0 on success, -1 on failure

◆ uwrt_gen_hostapd_instance()

int uwrt_gen_hostapd_instance ( const struct uctx context,
const struct hostapd_params params 
)

Generate the hostapd config.

Parameters
contextThe uci context
paramsThe hostapd params
Returns
int 0 on success, -1 on failure

◆ uwrt_get_interfaces()

UT_array* uwrt_get_interfaces ( const struct uctx context,
const char *  ifname 
)

Get the array of struct netif_info_t for each available interface.

Parameters
contextThe uci context
ifnameThe interface name, if NULL return all interfaces
Returns
UT_array* The returned array of struct netif_info_t This return variable must be cleaned up by utarray_free().

◆ uwrt_init_context()

struct uctx* uwrt_init_context ( const char *  path)

Initialises the uci context.

Parameters
pathThe path string to the config folder
Returns
The uci context, or NULL on error. This return variable must be cleaned up by uwrt_free_context().

◆ uwrt_set_interface_ip()

int uwrt_set_interface_ip ( const struct uctx context,
const char *  ifname,
const char *  ip_addr,
const char *  netmask 
)

Assigns an IP to an interface.

Parameters
contextThe uci context
ifnameThe interface name
ip_addrThe interface IP4 address
netmaskThe interface IP4 netmask
Returns
int 0 on success, -1 on failure