EDGESEC
0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
|
File containing the definition of the interface mapper utilities. More...
#include <stdbool.h>
#include <netinet/in.h>
#include <inttypes.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <pthread.h>
#include <utarray.h>
#include <uthash.h>
#include "allocs.h"
#include "net.h"
#include "os.h"
Go to the source code of this file.
Data Structures | |
struct | netif_info_t |
Network interface definition structure. More... | |
struct | config_ifinfo_t |
Interface configuration info structure. More... | |
struct | hashmap_if_conn |
Subnet to interface connection mapper. More... | |
struct | vlan_conn |
MAC connection structure. More... | |
struct | hashmap_vlan_conn |
VLAN to interface connection mapper. More... | |
Macros | |
#define | LINK_TYPE_LEN 64 |
Typedefs | |
typedef struct config_ifinfo_t | config_ifinfo_t |
Interface configuration info structure. More... | |
typedef struct hashmap_if_conn | hmap_if_conn |
Subnet to interface connection mapper. More... | |
typedef struct hashmap_vlan_conn | hmap_vlan_conn |
VLAN to interface connection mapper. More... | |
Enumerations | |
enum | IF_STATE { IF_STATE_UNKNOWN = 0 , IF_STATE_NOTPRESENT , IF_STATE_DOWN , IF_STATE_LOWERLAYERDOWN , IF_STATE_TESTING , IF_STATE_DORMANT , IF_STATE_UP , IF_STATE_OTHER } |
Functions | |
int | get_if_mapper (hmap_if_conn *const *hmap, in_addr_t subnet, char ifname[static IF_NAMESIZE]) |
Get the interface name corresponding to an IP address of the subnet. More... | |
bool | put_if_mapper (hmap_if_conn **hmap, in_addr_t subnet, const char *ifname) |
Inserts an interface and subnet IP value into the interface connection mapper. More... | |
void | free_if_mapper (hmap_if_conn **hmap) |
Frees the interface connection mapper object. More... | |
int | get_vlan_mapper (hmap_vlan_conn *const *hmap, int vlanid, struct vlan_conn *conn) |
Get the vlan connection structure corresponding to a VLAN ID. More... | |
int | copy_vlan_mapper (hmap_vlan_conn *const *hmap, hmap_vlan_conn **copy) |
Makes a copy of the VLAn mapper structure. More... | |
bool | put_vlan_mapper (hmap_vlan_conn **hmap, const struct vlan_conn *conn) |
Inserts a vlan connection structure and VLAN ID value into the interface connection mapper. More... | |
void | free_vlan_mapper (hmap_vlan_conn **hmap) |
Frees the VLAN ID to interface connection mapper object. More... | |
int | get_ifname_from_ip (const UT_array *config_ifinfo_array, const char *ip, char ifname[static IF_NAMESIZE]) |
Get the interface name from an IP string. More... | |
int | get_brname_from_ip (const UT_array *config_ifinfo_array, const char *ip_addr, char brname[static IF_NAMESIZE]) |
Get the bridge name from an IP string. More... | |
bool | create_if_mapper (const UT_array *config_ifinfo_array, hmap_if_conn **hmap) |
Create the subnet to interface mapper. More... | |
int | create_vlan_mapper (const UT_array *config_ifinfo_array, hmap_vlan_conn **hmap) |
Create the VLAN ID to interface mapper. More... | |
int | init_ifbridge_names (UT_array *config_ifinfo_array, const char *ifname, const char *brname) |
Initialise the interface names. More... | |
File containing the definition of the interface mapper utilities.
#define LINK_TYPE_LEN 64 |
typedef struct config_ifinfo_t config_ifinfo_t |
Interface configuration info structure.
typedef struct hashmap_if_conn hmap_if_conn |
Subnet to interface connection mapper.
typedef struct hashmap_vlan_conn hmap_vlan_conn |
VLAN to interface connection mapper.
enum IF_STATE |
int copy_vlan_mapper | ( | hmap_vlan_conn *const * | hmap, |
hmap_vlan_conn ** | copy | ||
) |
Makes a copy of the VLAn mapper structure.
[in] | hmap | The VLAN ID to vlan connection mapper object |
[in,out] | copy | The copied VLAN mapper. |
bool create_if_mapper | ( | const UT_array * | config_ifinfo_array, |
hmap_if_conn ** | hmap | ||
) |
Create the subnet to interface mapper.
[in] | config_ifinfo_array | The connection info array |
[in,out] | hmap | The subnet to interface mapper |
int create_vlan_mapper | ( | const UT_array * | config_ifinfo_array, |
hmap_vlan_conn ** | hmap | ||
) |
Create the VLAN ID to interface mapper.
[in] | config_ifinfo_array | The connection info array |
[in,out] | hmap | The VLAN ID to interface mapper |
void free_if_mapper | ( | hmap_if_conn ** | hmap | ) |
Frees the interface connection mapper object.
hmap | The interface connection mapper object |
void free_vlan_mapper | ( | hmap_vlan_conn ** | hmap | ) |
Frees the VLAN ID to interface connection mapper object.
hmap | The VLAN ID to interface connection mapper object |
int get_brname_from_ip | ( | const UT_array * | config_ifinfo_array, |
const char * | ip_addr, | ||
char | brname[static IF_NAMESIZE] | ||
) |
Get the bridge name from an IP string.
[in] | config_ifinfo_array | The list of IP subnets |
[in] | ip_addr | The input IP address |
[out] | brname | The returned bridge name (buffer has to be preallocated to at least the size of config_ifinfo_t::brname). |
int get_if_mapper | ( | hmap_if_conn *const * | hmap, |
in_addr_t | subnet, | ||
char | ifname[static IF_NAMESIZE] | ||
) |
Get the interface name corresponding to an IP address of the subnet.
[in] | hmap | The interface connection mapper object |
[in] | subnet | The IP address of the subnet |
[out] | ifname | The buffer to store the returned interface name. Must be at least IF_NAMESIZE large. |
int get_ifname_from_ip | ( | const UT_array * | config_ifinfo_array, |
const char * | ip, | ||
char | ifname[static IF_NAMESIZE] | ||
) |
Get the interface name from an IP string.
[in] | config_ifinfo_array | The list of IP subnets |
[in] | ip | The input IP address |
[out] | ifname | The returned interface name (buffer has to be preallocated at least the size of config_ifinfo_t::ifname) |
int get_vlan_mapper | ( | hmap_vlan_conn *const * | hmap, |
int | vlanid, | ||
struct vlan_conn * | conn | ||
) |
Get the vlan connection structure corresponding to a VLAN ID.
[in] | hmap | The VLAN ID to vlan connection mapper object |
[in] | vlanid | The VLAN ID |
[out] | conn | The returned VLAN connection structure |
int init_ifbridge_names | ( | UT_array * | config_ifinfo_array, |
const char * | ifname, | ||
const char * | brname | ||
) |
Initialise the interface names.
[in,out] | config_ifinfo_array | The connection info array |
[in] | ifname | The interface name prefix |
[in] | brname | The bridge name prefix |
bool put_if_mapper | ( | hmap_if_conn ** | hmap, |
in_addr_t | subnet, | ||
const char * | ifname | ||
) |
Inserts an interface and subnet IP value into the interface connection mapper.
[in,out] | hmap | The interface connection mapper object |
[in] | subnet | The IP address of the subnet |
[in] | ifname | The interface name |
bool put_vlan_mapper | ( | hmap_vlan_conn ** | hmap, |
const struct vlan_conn * | conn | ||
) |
Inserts a vlan connection structure and VLAN ID value into the interface connection mapper.
[in,out] | hmap | The VLAN ID to interface connection mapper object |
[in] | conn | The VLAN connection structure |