-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitmap_v6.h
76 lines (58 loc) · 2.22 KB
/
bitmap_v6.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef __BITMAP_v6_H__
#define __BITMAP_v6_H__
#include <stdint.h>
#include <stdlib.h>
#include "bitmap.h"
#include "mb_node.h"
#include "mm.h"
#include <arpa/inet.h>
//Tree bitmap
//use the 64-bit bitmap for ipv6 lookup
#define LENGTH_v6 128
#define LEVEL_v6 ((LENGTH_v6/STRIDE)+1)
#define UPDATE_LEVEL_v6 ((LENGTH_v6/STRIDE)+1)
struct ip_v6 {
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
uint64_t iplo;
uint64_t iphi;
#else
uint64_t iphi;
uint64_t iplo;
#endif
};
void * bitmapv6_do_search_lazy(struct mb_node *n, struct ip_v6 ip);
void * bitmapv6_do_search(struct mb_node *n, struct ip_v6 ip);
int bitmapv6_insert_prefix(struct mb_node *n, struct mm *m,
struct ip_v6 ip, int cidr, void *nhi);
int bitmapv6_delete_prefix(struct mb_node *n, struct mm *m,
struct ip_v6 ip, int cidr,
void (*destroy_nhi)(void *));
uint8_t bitmapv6_detect_overlap(struct mb_node *n,
struct ip_v6 ip,
uint8_t cidr, void **nhi_over);
uint8_t bitmapv6_detect_overlap_generic(struct mb_node *n,
struct ip_v6 ip, uint8_t cidr,
uint32_t bits_limit, void **nhi_over);
//return 1 means the prefix exists.
int bitmapv6_prefix_exist(struct mb_node *node, struct ip_v6 ip, uint8_t cidr);
void bitmapv6_print_all_prefix(struct mb_node *node,
void (*print_next_hop)(void *nhi));
void bitmapv6_destroy_trie(struct mb_node *node, struct mm *m,
void (*destroy_nhi)(void* nhi));
int bitmapv6_traverse_branch(struct mb_node *node, struct ip_v6 ip, int cidr,
traverse_func func, void *user_data);
void hton_ipv6(struct in6_addr *ip);
void lshift_ipv6(struct ip_v6 *ip, uint8_t bits);
void rshift_ipv6(struct ip_v6 *ip, uint8_t bits);
int bitmap_copy_branch_v6(struct mb_node *node,
struct mm *m,
struct ip_v6 ip, int cidr, struct copy_stash *stash);
int bitmap_insert_prefix_read_copy_v6(struct mb_node *root,
struct mm *m, struct ip_v6 ip, int cidr, void *nhi,
struct copy_stash *stash);
int bitmap_delete_prefix_read_copy_v6(struct mb_node *root,
struct mm *m, struct ip_v6 ip, int cidr, \
void (*destroy_nhi)(void *nhi), \
struct copy_stash *stash);
void bitmap_rcu_after_update_v6(struct copy_stash *stash);
#endif