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

File containing the definition of the network interface utilities. More...

#include <stdbool.h>
#include <netinet/in.h>
#include <inttypes.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <utarray.h>
#include <uthash.h>
#include "allocs.h"
#include "os.h"
Include dependency graph for iface.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  iface_context
 

Functions

struct iface_contextiface_init_context (void *params)
 Initialises the interface context. More...
 
void iface_free_context (struct iface_context *context)
 Initialises the interface context. More...
 
char * iface_get_vlan (char if_buf[static IF_NAMESIZE])
 Returns an exisiting WiFi interface name that supports VLAN. More...
 
UT_array * iface_get (const char *ifname)
 Get the array of struct netif_info_t for each available interface. More...
 
UT_array * iface_get_ip4 (const struct iface_context *context, const char *brname, const char *ifname)
 Get the IP4 addresses for a given interface. More...
 
int iface_create (const struct iface_context *context, const char *brname, const char *ifname, const char *type, const char *ip_addr, const char *brd_addr, const char *subnet_mask)
 Creates and interface and assigns an IP. More...
 
int iface_set_ip4 (const struct iface_context *context, const char *brname, const char *ifname, const char *ip_addr, const char *brd_addr, const char *subnet_mask)
 Sets the IP4 for a given interface. More...
 
int iface_commit (const struct iface_context *context)
 Commits the interface changes. More...
 
int reset_interface (const struct iface_context *context, const char *ifname)
 Resets an interface. More...
 

Detailed Description

File containing the definition of the network interface utilities.

Author
Alexandru Mereacre
Date
2020

Function Documentation

◆ iface_commit()

int iface_commit ( const struct iface_context context)

Commits the interface changes.

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

◆ iface_create()

int iface_create ( const struct iface_context context,
const char *  brname,
const char *  ifname,
const char *  type,
const char *  ip_addr,
const char *  brd_addr,
const char *  subnet_mask 
)

Creates and interface and assigns an IP.

Parameters
contextThe interface context
brnameThe bridge name
ifnameThe interface name
typeThe interface type
ip_addrThe interface IP4 address
brd_addrThe interface IP4 broadcast address
subnet_maskThe interface IP4 subnet mask
Returns
int 0 on success, -1 on failure

◆ iface_free_context()

void iface_free_context ( struct iface_context context)

Initialises the interface context.

Parameters
contextThe interface context

◆ iface_get()

UT_array* iface_get ( const char *  ifname)

Get the array of struct netif_info_t for each available interface.

Parameters
[in]ifnameThe interface name, if NULL return all interfaces
Returns
UT_array* The returned array of struct netif_info_t. Must be freed with utarray_free() when done.

◆ iface_get_ip4()

UT_array* iface_get_ip4 ( const struct iface_context context,
const char *  brname,
const char *  ifname 
)

Get the IP4 addresses for a given interface.

Parameters
contextThe interface context
[in]brnameThe bridge name
[in]ifnameThe interface name
Returns
UT_array* The returned array of IP4 strings. Must be freed with utarray_free() when done.

◆ iface_get_vlan()

char* iface_get_vlan ( char  if_buf[static IF_NAMESIZE])

Returns an exisiting WiFi interface name that supports VLAN.

Parameters
[out]if_bufInterface working buffer of at least size IF_NAMESIZE.
Returns
WiFi interface name (pointer to if_buf param), or NULL on error.

◆ iface_init_context()

struct iface_context* iface_init_context ( void *  params)

Initialises the interface context.

Parameters
paramsThe parameters for interface context
Returns
The interface context. Must be freed by iface_free_context().

◆ iface_set_ip4()

int iface_set_ip4 ( const struct iface_context context,
const char *  brname,
const char *  ifname,
const char *  ip_addr,
const char *  brd_addr,
const char *  subnet_mask 
)

Sets the IP4 for a given interface.

Parameters
contextThe interface context
brnameThe bridge name
ifnameThe interface name
ip_addrThe interface IP4 address
brd_addrThe interface IP4 broadcast address
subnet_maskThe interface IP4 subnet mask
Returns
int 0 on success, -1 on failure

◆ reset_interface()

int reset_interface ( const struct iface_context context,
const char *  ifname 
)

Resets an interface.

Parameters
contextThe interface context
ifnameThe interface name
Returns
int 0 on success, -1 on failure