-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfdb.h
46 lines (32 loc) · 904 Bytes
/
fdb.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef _FDB_H_
#define _FDB_H_
#include <pthread.h>
#include <netinet/in.h>
#include <net/ethernet.h>
#include <uthash.h>
#define FDB_DEFAULT_CACHE_MAX_TTL 10
/* key is MAC Address */
struct fdb_entry {
/* uthash key */
struct mackey {
u_int8_t mac[ETH_ALEN];
} mac;
struct sockaddr_storage vtep_addr;
int ttl;
UT_hash_handle hh;
};
struct fdb {
struct fdb_entry * table;
int fdb_max_ttl;
pthread_t decrease_ttl_t;
pthread_mutex_t mutex;
};
/* prototypes */
struct fdb * init_fdb (void);
void destroy_fdb (struct fdb * fdb);
int fdb_add_entry (struct fdb * fdb, u_int8_t * mac, struct sockaddr_storage vtep_addr);
int fdb_del_entry (struct fdb * fdb, u_int8_t * mac);
struct sockaddr * fdb_search_vtep_addr (struct fdb * fdb, u_int8_t * mac);
struct fdb_entry * fdb_search_entry (struct fdb * fdb, u_int8_t * mac);
void fdb_decrease_ttl_thread_init (struct fdb * fdb);
#endif