713dce6a5b808d8cc3d2d8dcca102f11db0f82b6
[vpp.git] / vnet / vnet / lisp-cp / control.h
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef VNET_CONTROL_H_
17 #define VNET_CONTROL_H_
18
19 #include <vnet/vnet.h>
20 #include <vnet/lisp-cp/gid_dictionary.h>
21 #include <vnet/lisp-cp/lisp_types.h>
22
23 typedef struct
24 {
25   gid_address_t src;
26   gid_address_t dst;
27   u32 src_mapping_index;
28 } pending_map_request_t;
29
30 typedef struct
31 {
32   gid_address_t seid;
33   gid_address_t deid;
34   ip_address_t src_loc;
35   ip_address_t dst_loc;
36 } fwd_entry_t;
37
38 typedef enum
39 {
40   IP4_MISS_PACKET,
41   IP6_MISS_PACKET
42 } miss_packet_type_t;
43
44 typedef struct
45 {
46   /* headers */
47   u8 data[100];
48   u32 length;
49   miss_packet_type_t type;
50 } miss_packet_t;
51
52 typedef struct
53 {
54   /* eid table */
55   gid_dictionary_t mapping_index_by_gid;
56
57   /* pool of mappings */
58   mapping_t * mapping_pool;
59
60   /* pool of locators */
61   locator_t * locator_pool;
62
63   /* pool of locator-sets */
64   locator_set_t * locator_set_pool;
65
66   /* vector of locator-set vectors composed of and indexed by locator index */
67   u32 ** locator_to_locator_sets;
68
69   /* hash map of locators by name */
70   uword * locator_set_index_by_name;
71
72   /* vector of eid index vectors supported and indexed by locator-set index */
73   u32 ** locator_set_to_eids;
74
75   /* vectors of indexes for local locator-sets and mappings */
76   u32 * local_mappings_indexes;
77   u32 * local_locator_set_indexes;
78
79   /* hash map of forwarding entries by mapping index */
80   u32 * fwd_entry_by_mapping_index;
81
82   /* forwarding entries pool */
83   fwd_entry_t * fwd_entry_pool;
84
85   /* hash map keyed by nonce of pending map-requests */
86   uword * pending_map_requests_by_nonce;
87
88   /* pool of pending map requests */
89   pending_map_request_t * pending_map_requests_pool;
90
91   /* vector of map-resolver addresses */
92   ip_address_t * map_resolvers;
93
94   /* commodity */
95   ip4_main_t * im4;
96   ip6_main_t * im6;
97   vlib_main_t * vlib_main;
98   vnet_main_t * vnet_main;
99 } lisp_cp_main_t;
100
101 /* lisp-gpe control plane */
102 lisp_cp_main_t lisp_control_main;
103
104 extern vlib_node_registration_t lisp_cp_input_node;
105 extern vlib_node_registration_t lisp_cp_lookup_node;
106
107 clib_error_t *
108 lisp_cp_init ();
109
110 typedef struct
111 {
112   u8 is_add;
113   union
114   {
115     u8 * name;
116     u32 index;
117   };
118   locator_t * locators;
119   u8 local;
120 } vnet_lisp_add_del_locator_set_args_t;
121
122 int
123 vnet_lisp_add_del_locator_set (vnet_lisp_add_del_locator_set_args_t * a,
124                                u32 * ls_index);
125
126 typedef struct
127 {
128   u8 is_add;
129   gid_address_t deid;
130   u32 locator_set_index;
131
132   u32 ttl;
133   u8 action;
134   u8 authoritative;
135
136   u8 local;
137 } vnet_lisp_add_del_mapping_args_t;
138
139 int
140 vnet_lisp_add_del_mapping (vnet_lisp_add_del_mapping_args_t *a,
141                            u32 * map_index);
142
143 typedef struct
144 {
145   u8 is_add;
146   ip_address_t address;
147 } vnet_lisp_add_del_map_resolver_args_t;
148
149 int
150 vnet_lisp_add_del_map_resolver (vnet_lisp_add_del_map_resolver_args_t * a);
151
152 always_inline lisp_cp_main_t *
153 vnet_lisp_cp_get_main() {
154   return &lisp_control_main;
155 }
156
157 #endif /* VNET_CONTROL_H_ */