EDGESEC  0.1.0-alpha.0+sha.ca29a8277b72f80785649ea9ef9cd7edf642d939
Secure router - reference implementation
mac_mapper.h
Go to the documentation of this file.
1 
11 #ifndef MAC_MAPPER_H
12 #define MAC_MAPPER_H
13 
14 #include <stdbool.h>
15 #include <inttypes.h>
16 #include <utarray.h>
17 #include <uthash.h>
18 
19 #include "bridge_list.h"
20 
21 #include "../ap/ap_config.h"
22 
23 #include "../utils/allocs.h"
24 #include "../utils/hashmap.h"
25 #include "../utils/os.h"
26 
27 #define MAX_DEVICE_LABEL_SIZE 255
28 
34 struct mac_conn_info {
36  int vlanid;
37  bool nat;
40  uint8_t pass[AP_SECRET_LEN];
41  ssize_t pass_len;
42  char
46  char ifname[IF_NAMESIZE];
50  uint64_t join_timestamp;
51 };
52 
57 struct mac_conn {
58  uint8_t mac_addr[ETHER_ADDR_LEN];
59  struct mac_conn_info info;
60 };
61 
66 typedef struct hashmap_mac_conn {
67  char key[ETHER_ADDR_LEN];
68  struct mac_conn_info value;
69  UT_hash_handle hh;
71 
81 int get_mac_mapper(hmap_mac_conn **hmap, uint8_t mac_addr[ETHER_ADDR_LEN],
82  struct mac_conn_info *info);
83 
91 bool put_mac_mapper(hmap_mac_conn **hmap, struct mac_conn conn);
92 
98 void free_mac_mapper(hmap_mac_conn **hmap);
99 
107 int get_mac_list(hmap_mac_conn **hmap, struct mac_conn **list);
108 
116 void init_default_mac_info(struct mac_conn_info *info, int default_open_vlanid,
117  bool allow_all_nat);
118 
128 int get_ip_mapper(hmap_mac_conn **hmap, char *ip, uint8_t *mac_addr);
129 #endif
#define AP_SECRET_LEN
Definition: ap_config.h:26
AP_CONNECTION_STATUS
The AP conection status.
Definition: ap_config.h:41
File containing the definition of the bridge creation functions.
#define MAX_DEVICE_LABEL_SIZE
Definition: mac_mapper.h:27
bool put_mac_mapper(hmap_mac_conn **hmap, struct mac_conn conn)
Insert a MAC into the MAC mapper connection object.
Definition: mac_mapper.c:49
int get_mac_list(hmap_mac_conn **hmap, struct mac_conn **list)
Get the MAC list from the MAC mapper connection object.
Definition: mac_mapper.c:90
struct hashmap_mac_conn hmap_mac_conn
MAC mapper connection structure.
void init_default_mac_info(struct mac_conn_info *info, int default_open_vlanid, bool allow_all_nat)
Generate a default mac info configuration.
Definition: mac_mapper.c:112
int get_mac_mapper(hmap_mac_conn **hmap, uint8_t mac_addr[ETHER_ADDR_LEN], struct mac_conn_info *info)
Get the MAC connection info structure for a given MAC address.
Definition: mac_mapper.c:20
void free_mac_mapper(hmap_mac_conn **hmap)
Frees the MAC mapper connection object.
Definition: mac_mapper.c:81
int get_ip_mapper(hmap_mac_conn **hmap, char *ip, uint8_t *mac_addr)
Get the MAC address for a given IP address.
Definition: mac_mapper.c:128
#define OS_INET_ADDRSTRLEN
Definition: net.h:25
#define MAX_RANDOM_UUID_LEN
Definition: os.h:31
MAC mapper connection structure.
Definition: mac_mapper.h:66
char key[ETHER_ADDR_LEN]
Definition: mac_mapper.h:67
struct mac_conn_info value
Definition: mac_mapper.h:68
UT_hash_handle hh
Definition: mac_mapper.h:69
MAC connection info structure.
Definition: mac_mapper.h:34
char ip_addr[OS_INET_ADDRSTRLEN]
Definition: mac_mapper.h:43
char label[MAX_DEVICE_LABEL_SIZE]
Definition: mac_mapper.h:48
int vlanid
Definition: mac_mapper.h:36
char ifname[IF_NAMESIZE]
Definition: mac_mapper.h:46
enum AP_CONNECTION_STATUS status
Definition: mac_mapper.h:35
bool nat
Definition: mac_mapper.h:37
char ip_sec_addr[OS_INET_ADDRSTRLEN]
Definition: mac_mapper.h:44
bool allow_connection
Definition: mac_mapper.h:38
uint8_t pass[AP_SECRET_LEN]
Definition: mac_mapper.h:40
uint64_t join_timestamp
Definition: mac_mapper.h:50
ssize_t pass_len
Definition: mac_mapper.h:41
MAC connection structure.
Definition: mac_mapper.h:57
struct mac_conn_info info
Definition: mac_mapper.h:59
uint8_t mac_addr[ETHER_ADDR_LEN]
Definition: mac_mapper.h:58