EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
iface.h
Go to the documentation of this file.
1 
11 #ifndef IFACE_H_
12 #define IFACE_H_
13 
14 #include <stdbool.h>
15 #include <netinet/in.h>
16 #include <inttypes.h>
17 #include <net/ethernet.h>
18 #include <net/if.h>
19 
20 #include <utarray.h>
21 #include <uthash.h>
22 #include "allocs.h"
23 #include "os.h"
24 
25 #ifdef WITH_UCI_SERVICE
26 #include "uci_wrt.h"
27 #elif WITH_NETLINK_SERVICE
28 #include "nl.h"
29 #elif WITH_IP_GENERIC_SERVICE
30 #include "ipgen.h"
31 #endif
32 
33 struct iface_context {
34 #ifdef WITH_UCI_SERVICE
35  struct uctx *context;
36 #elif WITH_NETLINK_SERVICE
37  struct nlctx *context;
38 #elif WITH_IP_GENERIC_SERVICE
39  struct ipgenctx *context;
40 #endif
41 };
42 
49 struct iface_context *iface_init_context(void *params);
50 
56 void iface_free_context(struct iface_context *context);
57 
64 char *iface_get_vlan(char if_buf[static IF_NAMESIZE]);
65 
73 UT_array *iface_get(const char *ifname);
74 
84 UT_array *iface_get_ip4(const struct iface_context *context, const char *brname,
85  const char *ifname);
86 
99 int iface_create(const struct iface_context *context, const char *brname,
100  const char *ifname, const char *type, const char *ip_addr,
101  const char *brd_addr, const char *subnet_mask);
102 
114 int iface_set_ip4(const struct iface_context *context, const char *brname,
115  const char *ifname, const char *ip_addr, const char *brd_addr,
116  const char *subnet_mask);
117 
124 int iface_commit(const struct iface_context *context);
125 
133 int reset_interface(const struct iface_context *context, const char *ifname);
134 #endif
File containing the definition of the allocs functionalities.
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.
Definition: iface.c:225
int iface_commit(const struct iface_context *context)
Commits the interface changes.
Definition: iface.c:283
int reset_interface(const struct iface_context *context, const char *ifname)
Resets an interface.
Definition: iface.c:209
UT_array * iface_get(const char *ifname)
Get the array of struct netif_info_t for each available interface.
Definition: iface.c:101
char * iface_get_vlan(char if_buf[static IF_NAMESIZE])
Returns an exisiting WiFi interface name that supports VLAN.
Definition: iface.c:198
UT_array * iface_get_ip4(const struct iface_context *context, const char *brname, const char *ifname)
Get the IP4 addresses for a given interface.
Definition: iface.c:157
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.
Definition: iface.c:254
struct iface_context * iface_init_context(void *params)
Initialises the interface context.
Definition: iface.c:64
void iface_free_context(struct iface_context *context)
Initialises the interface context.
Definition: iface.c:45
File containing the definition of the ip generic interface utilities.
File containing the definition of the netlink utilities.
File containing the definition of the os functionalities.
Definition: iface.h:33
Definition: ipgen.h:22
Definition: nl.h:27
Definition: uci_wrt.h:20
File containing the definition of the uci utilities.