|
EDGESEC
0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
|
File containing the implementation of the netlink utilities. More...
#include <stdbool.h>#include <stdio.h>#include <stdlib.h>#include <arpa/inet.h>#include <errno.h>#include <fcntl.h>#include <fnmatch.h>#include <linux/netlink.h>#include <linux/nl80211.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <netlink/attr.h>#include <netlink/genl/ctrl.h>#include <netlink/genl/family.h>#include <netlink/genl/genl.h>#include <netlink/msg.h>#include "libnetlink.h"#include "ll_map.h"#include "rt_names.h"#include "utils.h"#include "linux/if_addr.h"#include "linux/if_infiniband.h"#include "allocs.h"#include "iface_mapper.h"#include "ifaceu.h"#include "log.h"#include "net.h"#include "nl.h"#include "os.h"Functions | |
| void | free_nlmsg_chain (struct nlmsg_chain *info) |
| int | ip_link_list (req_filter_fn_t filter_fn, struct nlmsg_chain *linfo) |
| enum IF_STATE | get_operstate (__u8 state) |
| int | get_addrinfo (struct nlmsghdr *n, netif_info_t *info) |
| int | get_linkinfo (struct nlmsghdr *n, netif_info_t *info) |
| int | iplink_parse (int argc, const char *const *argv, struct iplink_req *req, const char **type) |
| UT_array * | nl_get_interfaces (int if_id) |
Get the array of struct netif_info_t for each available interface. More... | |
| int | nl_new_interface (const char *if_name, const char *type) |
| Creates a new interface object. More... | |
| 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. More... | |
| int | nl_set_interface_state (const char *if_name, bool state) |
| Set the interface state. More... | |
| struct nlctx * | nl_init_context (void) |
| Initialises the nl context. More... | |
| void | nl_free_context (struct nlctx *context) |
| Frees the nl context. More... | |
| 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. More... | |
| int | nl_reset_interface (const char *ifname) |
| Resets the interface. More... | |
| int | iwace_isvlan (uint32_t wiphy) |
| Check if wireless physical interface has VLAN capability. More... | |
| UT_array * | get_netiw_info (void) |
| Get the array of all wireless physical interfaces. More... | |
| int | nl_is_iw_vlan (const char *ifname) |
| Check if interface has the VLAN capability. More... | |
| char * | nl_get_valid_iw (char buf[static IF_NAMESIZE]) |
| Returns an exisiting WiFi interface name that supports VLAN. More... | |
Variables | |
| struct rtnl_handle | rth = {.fd = -1} |
File containing the implementation of the netlink utilities.
| void free_nlmsg_chain | ( | struct nlmsg_chain * | info | ) |
| int get_addrinfo | ( | struct nlmsghdr * | n, |
| netif_info_t * | info | ||
| ) |
| int get_linkinfo | ( | struct nlmsghdr * | n, |
| netif_info_t * | info | ||
| ) |
| UT_array* get_netiw_info | ( | void | ) |
Get the array of all wireless physical interfaces.
| enum IF_STATE get_operstate | ( | __u8 | state | ) |
| int ip_link_list | ( | req_filter_fn_t | filter_fn, |
| struct nlmsg_chain * | linfo | ||
| ) |
| int iplink_parse | ( | int | argc, |
| const char *const * | argv, | ||
| struct iplink_req * | req, | ||
| const char ** | type | ||
| ) |
| int iwace_isvlan | ( | uint32_t | wiphy | ) |
Check if wireless physical interface has VLAN capability.
| wiphy | Wireless physical interface ID |
| 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.
| context | The nl context interface |
| ifname | The interface name |
| type | The interface type |
| ip_addr | The interface IP4 address |
| brd_addr | The interface IP4 broadcast address |
| subnet_mask | The interface IP4 subnet mask |
| void nl_free_context | ( | struct nlctx * | context | ) |
Frees the nl context.
| context | The nl context created by nl_init_context() |
| UT_array* nl_get_interfaces | ( | int | if_id | ) |
Get the array of struct netif_info_t for each available interface.
| if_id | The intreface id, if 0 return all interfaces |
struct netif_info_t. You must utarray_free() this array when done. | char* nl_get_valid_iw | ( | char | buf[static IF_NAMESIZE] | ) |
Returns an exisiting WiFi interface name that supports VLAN.
| [out] | buf | Interface working buffer of at least IF_NAMESIZE bytes. |
buf param) | struct nlctx* nl_init_context | ( | void | ) |
Initialises the nl context.
| int nl_is_iw_vlan | ( | const char * | ifname | ) |
Check if interface has the VLAN capability.
| ifname | Interface name string |
| int nl_new_interface | ( | const char * | if_name, |
| const char * | type | ||
| ) |
Creates a new interface object.
| if_name | The interface string name |
| type | The interface string type (ex. "bridge") |
| int nl_reset_interface | ( | const char * | ifname | ) |
Resets the interface.
| ifname | The interface name string |
| 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.
| context | The nl context |
| ifname | The interface name string |
| ip_addr | The IP address string |
| brd_addr | The broadcast IP address string |
| subnet_mask | The subnet mask (e.g. 24 for /24) |
| int nl_set_interface_state | ( | const char * | if_name, |
| bool | state | ||
| ) |
Set the interface state.
| if_name | The interface name string |
| state | The interface state value (true - "up", false - "down") |
| struct rtnl_handle rth = {.fd = -1} |