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

File containing the definition of the ip generic interface utilities. More...

#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "os.h"
Include dependency graph for ipgen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ipgenctx
 

Functions

struct ipgenctxipgen_init_context (char *path)
 Initialises the ipgen context. More...
 
void ipgen_free_context (struct ipgenctx *context)
 Frees the ipgen context. More...
 
int ipgen_create_interface (const struct ipgenctx *context, 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 ipgen_set_interface_ip (const struct ipgenctx *context, const char *ifname, const char *ip_addr, const char *brd_addr, const char *subnet_mask)
 Set the IP address for an interface. More...
 
int ipgen_reset_interface (const struct ipgenctx *context, const char *ifname)
 Resets the interface. More...
 

Detailed Description

File containing the definition of the ip generic interface utilities.

Author
Alexandru Mereacre
Date
2022

Function Documentation

◆ ipgen_create_interface()

int ipgen_create_interface ( const struct ipgenctx context,
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 ipgen context interface
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

◆ ipgen_free_context()

void ipgen_free_context ( struct ipgenctx context)

Frees the ipgen context.

Parameters
contextThe ipgen context created by ipgen_init_context()
contextThe ipgen context

◆ ipgen_init_context()

struct ipgenctx* ipgen_init_context ( char *  path)

Initialises the ipgen context.

Parameters
pathThe path string to the ip command
Returns
The ip generic context or NULL on failure. Must be cleaned-up with ipgen_free_context().

◆ ipgen_reset_interface()

int ipgen_reset_interface ( const struct ipgenctx context,
const char *  ifname 
)

Resets the interface.

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

◆ ipgen_set_interface_ip()

int ipgen_set_interface_ip ( const struct ipgenctx context,
const char *  ifname,
const char *  ip_addr,
const char *  brd_addr,
const char *  subnet_mask 
)

Set the IP address for an interface.

Parameters
contextThe ipgen context interface
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