4 * Copyright (c) 2019 Arrcus Inc and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
18 #ifndef __included_srv6_end_h__
19 #define __included_srv6_end_h__
21 #include <vnet/vnet.h>
22 #include <vnet/ip/ip.h>
23 #include <vnet/srv6/sr.h>
24 #include <vnet/srv6/sr_packet.h>
26 #include <vppinfra/error.h>
27 #include <vppinfra/elog.h>
29 #define SRV6_GTP_UDP_DST_PORT 2152
31 #define SRV6_NHTYPE_NONE 0
32 #define SRV6_NHTYPE_IPV4 1
33 #define SRV6_NHTYPE_IPV6 2
34 #define SRV6_NHTYPE_NON_IP 3
36 #ifndef IP_PROTOCOL_IP6_ETHERNET
37 #define IP_PROTOCOL_IP6_ETHERNET 143
40 #define SRV6_GTP6_UNKNOW 0
41 #define SRV6_GTP6_DT4 1
42 #define SRV6_GTP6_DT6 2
43 #define SRV6_GTP6_DT46 3
45 #define SRV6_GTP4_UNKNOW 0
46 #define SRV6_GTP4_DT4 1
47 #define SRV6_GTP4_DT6 2
48 #define SRV6_GTP4_DT46 3
50 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
51 #define BITALIGN2(A,B) A; B
52 #define BITALIGN3(A,B,C) A; B; C
54 #define BITALIGN2(A,B) B; A
55 #define BITALIGN3(A,B,C) C; B; A
58 #define GTPU_EXTHDR_FLAG 0x04
59 #define GTPU_SEQ_FLAG 0x02
60 #define GTPU_EXTHDR_PDU_SESSION 0x85
62 #define SRH_TAG_ECHO_REPLY 0x0008
63 #define SRH_TAG_ECHO_REQUEST 0x0004
64 #define SRH_TAG_ERROR_INDICATION 0x0002
65 #define SRH_TAG_END_MARKER 0x0001
67 #define GTPU_RECOVERY_IE_TYPE 0x0e
69 #define GTPU_IE_MAX_SIZ 256
70 #define SRH_TLV_USER_PLANE_CONTAINER 0x0a /* tentative */
77 } __attribute__ ((packed)) gtpu_recovery_ie;
86 } __attribute__ ((packed)) gtpu_exthdr_t;
94 u16 length; /* length in octets of the payload */
97 } __attribute__ ((packed)) gtpu_header_t;
100 #define GTPU_TYPE_ECHO_REQUEST 1
101 #define GTPU_TYPE_ECHO_REPLY 2
102 #define GTPU_TYPE_ERROR_INDICATION 26
103 #define GTPU_TYPE_END_MARKER 254
104 #define GTPU_TYPE_GTPU 255
113 } __attribute__ ((packed)) gtpu_paging_policy_t;
123 struct gtpu_qfi_bits {BITALIGN3(u8 p:1,
131 gtpu_paging_policy_t paging[0];
133 } __attribute__ ((packed)) gtpu_pdu_session_t;
136 #define GTPU_PDU_SESSION_P_BIT_MASK 0x80
137 #define GTPU_PDU_SESSION_R_BIT_MASK 0x40
138 #define GTPU_PDU_SESSION_QFI_MASK 0x3f
140 #define SRV6_PDU_SESSION_U_BIT_MASK 0x01
141 #define SRV6_PDU_SESSION_R_BIT_MASK 0x02
142 #define SRV6_PDU_SESSION_QFI_MASK 0xfC
147 ip4_header_t ip4; /* 20 bytes */
148 udp_header_t udp; /* 8 bytes */
149 gtpu_header_t gtpu; /* 8 bytes */
150 } __attribute__ ((packed)) ip4_gtpu_header_t;
156 ip6_header_t ip6; /* 40 bytes */
157 udp_header_t udp; /* 8 bytes */
158 gtpu_header_t gtpu; /* 8 bytes */
159 } __attribute__ ((packed)) ip6_gtpu_header_t;
162 #define GTPU_V1_VER (1<<5)
164 #define GTPU_PT_GTP (1<<4)
172 } __attribute__ ((packed)) user_plane_sub_tlv_t;
175 #define USER_PLANE_SUB_TLV_IE 0x01
177 typedef struct srv6_end_gtp6_param_s
181 ip6_address_t sr_prefix;
183 } srv6_end_gtp6_param_t;
185 typedef struct srv6_end_gtp6_dt_param_s
192 } srv6_end_gtp6_dt_param_t;
194 typedef struct srv6_t_gtp4_dt_param_s
201 } srv6_t_gtp4_dt_param_t;
203 typedef struct srv6_end_gtp4_param_s
207 ip6_address_t sr_prefix;
210 ip6_address_t v6src_prefix;
214 } srv6_end_gtp4_param_t;
216 typedef struct srv6_end_main_v4_s
218 vlib_main_t *vlib_main;
219 vnet_main_t *vnet_main;
221 u32 end_m_gtp4_e_node_index;
222 u32 error_node_index;
224 u32 dst_p_len; // dst prefix len
225 u32 src_p_len; // src prefix len
227 ip4_gtpu_header_t cache_hdr;
229 } srv6_end_main_v4_t;
231 typedef struct srv6_t_main_v4_decap_s
233 vlib_main_t *vlib_main;
234 vnet_main_t *vnet_main;
236 u32 t_m_gtp4_d_node_index;
237 u32 error_node_index;
239 ip6_header_t cache_hdr;
240 } srv6_t_main_v4_decap_t;
242 extern srv6_end_main_v4_t srv6_end_main_v4;
243 extern srv6_t_main_v4_decap_t srv6_t_main_v4_decap;
244 extern vlib_node_registration_t srv6_end_m_gtp4_e;
246 typedef struct srv6_end_main_v6_s
248 vlib_main_t *vlib_main;
249 vnet_main_t *vnet_main;
251 u32 end_m_gtp6_e_node_index;
252 u32 error_node_index;
254 ip6_gtpu_header_t cache_hdr;
255 } srv6_end_main_v6_t;
257 extern srv6_end_main_v6_t srv6_end_main_v6;
258 extern vlib_node_registration_t srv6_end_m_gtp6_e;
260 typedef struct srv6_end_main_v6_decap_s
262 vlib_main_t *vlib_main;
263 vnet_main_t *vnet_main;
265 u32 end_m_gtp6_d_node_index;
266 u32 error_node_index;
268 ip6_header_t cache_hdr;
269 } srv6_end_main_v6_decap_t;
271 extern srv6_end_main_v6_decap_t srv6_end_main_v6_decap;
272 extern vlib_node_registration_t srv6_end_m_gtp6_d;
274 typedef struct srv6_end_main_v6_decap_di_s
276 vlib_main_t *vlib_main;
277 vnet_main_t *vnet_main;
279 u32 end_m_gtp6_d_di_node_index;
280 u32 error_node_index;
282 ip6srv_combo_header_t cache_hdr;
283 } srv6_end_main_v6_decap_di_t;
285 extern srv6_end_main_v6_decap_di_t srv6_end_main_v6_decap_di;
286 extern vlib_node_registration_t srv6_end_m_gtp6_d_di;
288 typedef struct srv6_end_main_v6_dt_s
290 vlib_main_t *vlib_main;
291 vnet_main_t *vnet_main;
293 u32 end_m_gtp6_dt_node_index;
294 u32 error_node_index;
295 } srv6_end_main_v6_dt_t;
297 extern srv6_end_main_v6_dt_t srv6_end_main_v6_dt;
298 extern vlib_node_registration_t srv6_end_m_gtp6_dt;
300 typedef struct srv6_t_main_v4_dt_s
302 vlib_main_t *vlib_main;
303 vnet_main_t *vnet_main;
305 u32 t_m_gtp4_dt_node_index;
306 u32 error_node_index;
307 } srv6_t_main_v4_dt_t;
309 extern srv6_t_main_v4_dt_t srv6_t_main_v4_dt;
310 extern vlib_node_registration_t srv6_t_m_gtp4_dt;
312 #endif /* __included_srv6_end_h__ */
315 * fd.io coding-style-patch-verification: ON
318 * eval: (c-set-style "gnu")