ikev2: add support for custom ipsec-over-udp port
[vpp.git] / src / vnet / dpo / dvr_dpo.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 __DVR_DPO_H__
17 #define __DVR_DPO_H__
18
19 #include <vnet/dpo/dpo.h>
20
21 /**
22  * Control how the reinject is performed
23  */
24 typedef enum dvr_dpo_reinject_t_
25 {
26     DVR_REINJECT_L2,
27     DVR_REINJECT_L3,
28 } __clib_packed dvr_dpo_reinject_t;
29
30 /**
31  * @brief
32  * The DVR DPO. Used as the resolving object for a DVR route.
33  * This is used, in place of the usual L3 Adjacency, to retransmit
34  * the packet with the original L2 header intact but also to run L3 features.
35  * After running L3 features the packet is re-injected back into the L2 path
36  * so it can pick up the necessary VLAN tags of the egress interface.
37  * This re-injection is done with an output feature.
38  */
39 typedef struct dvr_dpo_t_
40 {
41     /**
42      * The Software interface index that the packets will output on
43      */
44     u32 dd_sw_if_index;
45
46     /**
47      * The protocol of packets using this DPO
48      */
49     dpo_proto_t dd_proto;
50
51     /**
52      * Control for how the re-inject is performed
53      */
54     dvr_dpo_reinject_t dd_reinject;
55
56     /**
57      * number of locks.
58      */
59     u16 dd_locks;
60 } dvr_dpo_t;
61
62 /* 8 bytes is a factor of cache line size so this struct will never span */
63 STATIC_ASSERT_SIZEOF(dvr_dpo_t, 8);
64
65 extern void dvr_dpo_add_or_lock (u32 sw_if_index,
66                                  dpo_proto_t dproto,
67                                  dpo_id_t *dpo);
68
69 extern void dvr_dpo_module_init(void);
70
71 /**
72  * @brief pool of all interface DPOs
73  */
74 extern dvr_dpo_t *dvr_dpo_pool;
75
76 static inline dvr_dpo_t *
77 dvr_dpo_get (index_t index)
78 {
79     return (pool_elt_at_index(dvr_dpo_pool, index));
80 }
81
82 #endif