Plugin for IP-Address to Interface Punting
[vpp.git] / src / plugins / stn / stn.h
1 /*
2  * Copyright (c) 2017 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 SRC_PLUGINS_STN_STN_H_
17 #define SRC_PLUGINS_STN_STN_H_
18
19 #include <vlib/vlib.h>
20 #include <vnet/ip/ip4.h>
21 #include <vnet/ip/ip6.h>
22 #include <vppinfra/bihash_16_8.h>
23
24 typedef struct {
25   ip46_address_t address;
26   u32 next_node_index;
27   u32 sw_if_index;
28 } stn_rule_t;
29
30 typedef struct {
31   /* pool of stn rules */
32   stn_rule_t *rules;
33
34   /* number of rules */
35   u32 n_rules;
36
37   /* hash table used to retrieve the rule from the ip address */
38   clib_bihash_16_8_t rule_by_address_table;
39
40   u32 punt_to_stn_ip4_next_index;
41   u32 punt_to_stn_ip6_next_index;
42
43   u16 msg_id_base;
44 } stn_main_t;
45
46 typedef struct {
47   /** Destination address of intercepted packets */
48   ip46_address_t address;
49   /** TX interface to send packets to */
50   u32 sw_if_index;
51   /** Whether to delete the rule */
52   u8 del;
53 } stn_rule_add_del_args_t;
54
55 /**
56  * Add or delete an stn rule.
57  */
58 int stn_rule_add_del (stn_rule_add_del_args_t *args);
59
60 extern stn_main_t stn_main;
61
62 clib_error_t *
63 stn_api_init (vlib_main_t * vm, stn_main_t * sm);
64
65 #endif /* SRC_PLUGINS_STN_STN_H_ */