EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
nl.h
Go to the documentation of this file.
1 
11 #ifndef NL_H_
12 #define NL_H_
13 
14 #include <stdbool.h>
15 #include <net/ethernet.h>
16 #include <net/if.h>
17 #include <netinet/if_ether.h>
18 #include <utarray.h>
19 #include "linux/rtnetlink.h"
20 
21 #ifdef DEBUG_LIBNL
22 #define NL_CB_TYPE NL_CB_DEBUG
23 #else
24 #define NL_CB_TYPE NL_CB_DEFAULT
25 #endif
26 
27 struct nlctx {
28  void *reserved;
29 };
30 
31 struct nl80211_state {
32  struct nl_sock *nl_sock;
34 };
35 
40 typedef struct {
41  char ifname[IF_NAMESIZE];
42  uint32_t ifindex;
43  uint64_t wdev;
44  uint8_t addr[ETHER_ADDR_LEN];
45  uint32_t wiphy;
46 } netiw_info_t;
47 
48 struct iplink_req {
49  struct nlmsghdr n;
50  struct ifinfomsg i;
51  char buf[1024];
52 };
53 
60 struct nlctx *nl_init_context(void);
61 
67 void nl_free_context(struct nlctx *context);
68 
76 UT_array *nl_get_interfaces(int if_id);
77 
85 int nl_new_interface(const char *if_name, const char *type);
86 
97 int nl_set_interface_ip(const struct nlctx *context, const char *ifname,
98  const char *ip_addr, const char *brd_addr,
99  const char *subnet_mask);
100 
108 int nl_set_interface_state(const char *if_name, bool state);
109 
121 int nl_create_interface(const struct nlctx *context, const char *ifname,
122  const char *type, const char *ip_addr,
123  const char *brd_addr, const char *subnet_mask);
124 
131 int nl_reset_interface(const char *ifname);
132 
139 int iwace_isvlan(uint32_t wiphy);
140 
146 UT_array *get_netiw_info(void);
147 
154 int nl_is_iw_vlan(const char *ifname);
155 
162 char *nl_get_valid_iw(char buf[static IF_NAMESIZE]);
163 
164 #endif
int nl_is_iw_vlan(const char *ifname)
Check if interface has the VLAN capability.
Definition: nl.c:1202
int nl_create_interface(const struct nlctx *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.
Definition: nl.c:849
void nl_free_context(struct nlctx *context)
Frees the nl context.
Definition: nl.c:843
int nl_set_interface_state(const char *if_name, bool state)
Set the interface state.
Definition: nl.c:797
int nl_new_interface(const char *if_name, const char *type)
Creates a new interface object.
Definition: nl.c:728
UT_array * nl_get_interfaces(int if_id)
Get the array of struct netif_info_t for each available interface.
Definition: nl.c:675
int nl_set_interface_ip(const struct nlctx *context, const char *ifname, const char *ip_addr, const char *brd_addr, const char *subnet_mask)
Set the interface IP.
Definition: nl.c:760
int iwace_isvlan(uint32_t wiphy)
Check if wireless physical interface has VLAN capability.
Definition: nl.c:1119
char * nl_get_valid_iw(char buf[static IF_NAMESIZE])
Returns an exisiting WiFi interface name that supports VLAN.
Definition: nl.c:1240
int nl_reset_interface(const char *ifname)
Resets the interface.
Definition: nl.c:896
struct nlctx * nl_init_context(void)
Initialises the nl context.
Definition: nl.c:832
UT_array * get_netiw_info(void)
Get the array of all wireless physical interfaces.
Definition: nl.c:1161
Network wireless interface information structure.
Definition: nl.h:40
uint64_t wdev
Definition: nl.h:43
uint32_t ifindex
Definition: nl.h:42
Definition: nl.h:31
int nl80211_id
Definition: nl.h:33
struct nl_sock * nl_sock
Definition: nl.h:32
Definition: nl.h:27
void * reserved
Definition: nl.h:28