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/fib/ip4_fib.h>
24 #include <vnet/fib/ip6_fib.h>
25 #include <vnet/srv6/sr.h>
26 #include <vnet/srv6/sr_packet.h>
28 #include <vppinfra/error.h>
29 #include <vppinfra/elog.h>
31 #define SRV6_GTP_UDP_DST_PORT 2152
33 #define SRV6_NHTYPE_NONE 0
34 #define SRV6_NHTYPE_IPV4 1
35 #define SRV6_NHTYPE_IPV6 2
36 #define SRV6_NHTYPE_NON_IP 3
38 #ifndef IP_PROTOCOL_IP6_ETHERNET
39 #define IP_PROTOCOL_IP6_ETHERNET 143
42 #define SRV6_GTP6_UNKNOW 0
43 #define SRV6_GTP6_DT4 1
44 #define SRV6_GTP6_DT6 2
45 #define SRV6_GTP6_DT46 3
47 #define SRV6_GTP4_UNKNOW 0
48 #define SRV6_GTP4_DT4 1
49 #define SRV6_GTP4_DT6 2
50 #define SRV6_GTP4_DT46 3
52 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
53 #define BITALIGN2(A,B) A; B
54 #define BITALIGN3(A,B,C) A; B; C
56 #define BITALIGN2(A,B) B; A
57 #define BITALIGN3(A,B,C) C; B; A
60 #define GTPU_EXTHDR_FLAG 0x04
61 #define GTPU_SEQ_FLAG 0x02
62 #define GTPU_EXTHDR_PDU_SESSION 0x85
64 #define SRH_TAG_ECHO_REPLY 0x0008
65 #define SRH_TAG_ECHO_REQUEST 0x0004
66 #define SRH_TAG_ERROR_INDICATION 0x0002
67 #define SRH_TAG_END_MARKER 0x0001
69 #define GTPU_RECOVERY_IE_TYPE 0x0e
71 #define GTPU_IE_MAX_SIZ 256
72 #define SRH_TLV_USER_PLANE_CONTAINER 0x0a /* tentative */
74 typedef enum mobile_policy_function_list
76 SRV6_MOBILE_POLICY_UNKNOWN_FUNCTION = 0,
77 SRV6_MOBILE_POLICY_T_M_GTP4_D,
78 SRV6_MOBILE_POLICY_T_M_GTP4_DT4,
79 SRV6_MOBILE_POLICY_T_M_GTP4_DT6,
80 SRV6_MOBILE_POLICY_T_M_GTP4_DT46,
81 SRV6_MOBILE_POLICY_END_M_GTP6_D,
82 } mobile_policy_function_list_t;
84 typedef enum mobile_localsid_function_list
86 SRV6_MOBILE_LOCALSID_UNKNOWN_FUNCTION = 0,
87 SRV6_MOBILE_LOCALSID_END_M_GTP4_E,
88 SRV6_MOBILE_LOCALSID_END_M_GTP6_E,
89 SRV6_MOBILE_LOCALSID_END_M_GTP6_D,
90 SRV6_MOBILE_LOCALSID_END_M_GTP6_D_DI,
91 SRV6_MOBILE_LOCALSID_END_M_GTP6_D_DT4,
92 SRV6_MOBILE_LOCALSID_END_M_GTP6_D_DT6,
93 SRV6_MOBILE_LOCALSID_END_M_GTP6_D_DT46,
94 } mobile_localsid_function_list_t;
100 } __attribute__ ((packed)) gtpu_recovery_ie;
107 } __attribute__ ((packed)) gtpu_exthdr_t;
113 u16 length; /* length in octets of the payload */
115 gtpu_exthdr_t ext[0];
116 } __attribute__ ((packed)) gtpu_header_t;
118 #define GTPU_TYPE_ECHO_REQUEST 1
119 #define GTPU_TYPE_ECHO_REPLY 2
120 #define GTPU_TYPE_ERROR_INDICATION 26
121 #define GTPU_TYPE_END_MARKER 254
122 #define GTPU_TYPE_GTPU 255
130 } __attribute__ ((packed)) gtpu_paging_policy_t;
138 struct gtpu_qfi_bits {BITALIGN3(u8 p:1,
146 gtpu_paging_policy_t paging[0];
148 } __attribute__ ((packed)) gtpu_pdu_session_t;
150 #define GTPU_PDU_SESSION_P_BIT_MASK 0x80
151 #define GTPU_PDU_SESSION_R_BIT_MASK 0x40
152 #define GTPU_PDU_SESSION_QFI_MASK 0x3f
154 #define SRV6_PDU_SESSION_U_BIT_MASK 0x01
155 #define SRV6_PDU_SESSION_R_BIT_MASK 0x02
156 #define SRV6_PDU_SESSION_QFI_MASK 0xfC
160 ip4_header_t ip4; /* 20 bytes */
161 udp_header_t udp; /* 8 bytes */
162 gtpu_header_t gtpu; /* 8 bytes */
163 } __attribute__ ((packed)) ip4_gtpu_header_t;
167 ip6_header_t ip6; /* 40 bytes */
168 udp_header_t udp; /* 8 bytes */
169 gtpu_header_t gtpu; /* 8 bytes */
170 } __attribute__ ((packed)) ip6_gtpu_header_t;
172 #define GTPU_V1_VER (1<<5)
174 #define GTPU_PT_GTP (1<<4)
181 } __attribute__ ((packed)) user_plane_sub_tlv_t;
183 #define USER_PLANE_SUB_TLV_IE 0x01
185 /* SRv6 mobile Plugin Params */
187 /* GTP6.D, GTP6.Di */
188 typedef struct srv6_end_gtp6_d_param_s
192 ip6_address_t sr_prefix;
200 } srv6_end_gtp6_d_param_t;
203 typedef struct srv6_end_gtp6_dt_param_s
210 } srv6_end_gtp6_dt_param_t;
213 typedef struct srv6_end_gtp6_e_param_s
218 } srv6_end_gtp6_e_param_t;
221 typedef struct srv6_t_gtp4_dt_param_s
228 } srv6_t_gtp4_dt_param_t;
231 typedef struct srv6_end_gtp4_e_param_s
234 ip4_address_t v4src_addr;
239 } srv6_end_gtp4_e_param_t;
242 typedef struct srv6_end_gtp4_d_param_s
246 ip6_address_t sr_prefix;
249 ip6_address_t v6src_prefix;
257 } srv6_end_gtp4_d_param_t;
259 typedef struct srv6_end_main_v4_s
261 vlib_main_t *vlib_main;
262 vnet_main_t *vnet_main;
264 u32 end_m_gtp4_e_node_index;
265 u32 error_node_index;
267 u32 dst_p_len; // dst prefix len
268 u32 src_p_len; // src prefix len
270 ip4_gtpu_header_t cache_hdr;
272 } srv6_end_main_v4_t;
274 typedef struct srv6_t_main_v4_decap_s
276 vlib_main_t *vlib_main;
277 vnet_main_t *vnet_main;
279 u32 t_m_gtp4_d_node_index;
280 u32 error_node_index;
282 ip6_header_t cache_hdr;
283 } srv6_t_main_v4_decap_t;
285 extern srv6_end_main_v4_t srv6_end_main_v4;
286 extern srv6_t_main_v4_decap_t srv6_t_main_v4_decap;
287 extern vlib_node_registration_t srv6_end_m_gtp4_e;
289 typedef struct srv6_end_main_v6_s
291 vlib_main_t *vlib_main;
292 vnet_main_t *vnet_main;
294 u32 end_m_gtp6_e_node_index;
295 u32 error_node_index;
297 ip6_gtpu_header_t cache_hdr;
298 } srv6_end_main_v6_t;
300 extern srv6_end_main_v6_t srv6_end_main_v6;
301 extern vlib_node_registration_t srv6_end_m_gtp6_e;
303 typedef struct srv6_end_main_v6_decap_s
305 vlib_main_t *vlib_main;
306 vnet_main_t *vnet_main;
308 u32 end_m_gtp6_d_node_index;
309 u32 error_node_index;
311 ip6_header_t cache_hdr;
312 } srv6_end_main_v6_decap_t;
314 extern srv6_end_main_v6_decap_t srv6_end_main_v6_decap;
315 extern vlib_node_registration_t srv6_end_m_gtp6_d;
317 typedef struct srv6_end_main_v6_decap_di_s
319 vlib_main_t *vlib_main;
320 vnet_main_t *vnet_main;
322 u32 end_m_gtp6_d_di_node_index;
323 u32 error_node_index;
325 ip6srv_combo_header_t cache_hdr;
326 } srv6_end_main_v6_decap_di_t;
328 extern srv6_end_main_v6_decap_di_t srv6_end_main_v6_decap_di;
329 extern vlib_node_registration_t srv6_end_m_gtp6_d_di;
331 typedef struct srv6_end_main_v6_dt_s
333 vlib_main_t *vlib_main;
334 vnet_main_t *vnet_main;
336 u32 end_m_gtp6_dt_node_index;
337 u32 error_node_index;
338 } srv6_end_main_v6_dt_t;
340 extern srv6_end_main_v6_dt_t srv6_end_main_v6_dt;
341 extern vlib_node_registration_t srv6_end_m_gtp6_dt;
343 typedef struct srv6_t_main_v4_dt_s
345 vlib_main_t *vlib_main;
346 vnet_main_t *vnet_main;
348 u32 t_m_gtp4_dt_node_index;
349 u32 error_node_index;
350 } srv6_t_main_v4_dt_t;
352 extern srv6_t_main_v4_dt_t srv6_t_main_v4_dt;
353 extern vlib_node_registration_t srv6_t_m_gtp4_dt;
355 #endif /* __included_srv6_end_h__ */
358 * fd.io coding-style-patch-verification: ON
361 * eval: (c-set-style "gnu")