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_NONE
37 #define IP_PROTOCOL_NONE 59
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 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
46 #define BITALIGN2(A,B) A; B
47 #define BITALIGN3(A,B,C) A; B; C
49 #define BITALIGN2(A,B) B; A
50 #define BITALIGN3(A,B,C) C; B; A
53 #define GTPU_EXTHDR_FLAG 0x04
54 #define GTPU_SEQ_FLAG 0x02
55 #define GTPU_EXTHDR_PDU_SESSION 0x85
57 #define SRH_TAG_ECHO_REPLY 0x0008
58 #define SRH_TAG_ECHO_REQUEST 0x0004
59 #define SRH_TAG_ERROR_INDICATION 0x0002
60 #define SRH_TAG_END_MARKER 0x0001
68 } __attribute__ ((packed)) gtpu_exthdr_t;
76 u16 length; /* length in octets of the payload */
79 } __attribute__ ((packed)) gtpu_header_t;
82 #define GTPU_TYPE_ECHO_REQUEST 1
83 #define GTPU_TYPE_ECHO_REPLY 2
84 #define GTPU_TYPE_ERROR_INDICATION 26
85 #define GTPU_TYPE_END_MARKER 254
86 #define GTPU_TYPE_GTPU 255
95 } __attribute__ ((packed)) gtpu_paging_policy_t;
105 struct gtpu_qfi_bits {BITALIGN3(u8 p:1,
113 gtpu_paging_policy_t paging[0];
115 } __attribute__ ((packed)) gtpu_pdu_session_t;
118 #define GTPU_PDU_SESSION_P_BIT_MASK 0x80
119 #define GTPU_PDU_SESSION_R_BIT_MASK 0x40
120 #define GTPU_PDU_SESSION_QFI_MASK 0x3f
122 #define SRV6_PDU_SESSION_U_BIT_MASK 0x01
123 #define SRV6_PDU_SESSION_R_BIT_MASK 0x02
124 #define SRV6_PDU_SESSION_QFI_MASK 0xfC
129 ip4_header_t ip4; /* 20 bytes */
130 udp_header_t udp; /* 8 bytes */
131 gtpu_header_t gtpu; /* 8 bytes */
132 } __attribute__ ((packed)) ip4_gtpu_header_t;
138 ip6_header_t ip6; /* 40 bytes */
139 udp_header_t udp; /* 8 bytes */
140 gtpu_header_t gtpu; /* 8 bytes */
141 } __attribute__ ((packed)) ip6_gtpu_header_t;
144 #define GTPU_V1_VER (1<<5)
146 #define GTPU_PT_GTP (1<<4)
148 typedef struct srv6_end_gtp6_param_s
152 ip6_address_t sr_prefix;
154 } srv6_end_gtp6_param_t;
156 typedef struct srv6_end_gtp4_param_s
160 ip6_address_t sr_prefix;
163 ip6_address_t v6src_prefix;
167 } srv6_end_gtp4_param_t;
169 typedef struct srv6_end_main_v4_s
171 vlib_main_t *vlib_main;
172 vnet_main_t *vnet_main;
174 u32 end_m_gtp4_e_node_index;
175 u32 error_node_index;
177 u32 dst_p_len; // dst prefix len
178 u32 src_p_len; // src prefix len
180 ip4_gtpu_header_t cache_hdr;
182 } srv6_end_main_v4_t;
184 typedef struct srv6_t_main_v4_decap_s
186 vlib_main_t *vlib_main;
187 vnet_main_t *vnet_main;
189 u32 t_m_gtp4_d_node_index;
190 u32 error_node_index;
192 ip6_header_t cache_hdr;
193 } srv6_t_main_v4_decap_t;
195 extern srv6_end_main_v4_t srv6_end_main_v4;
196 extern srv6_t_main_v4_decap_t srv6_t_main_v4_decap;
197 extern vlib_node_registration_t srv6_end_m_gtp4_e;
199 typedef struct srv6_end_main_v6_s
201 vlib_main_t *vlib_main;
202 vnet_main_t *vnet_main;
204 u32 end_m_gtp6_e_node_index;
205 u32 error_node_index;
207 ip6_gtpu_header_t cache_hdr;
208 } srv6_end_main_v6_t;
210 extern srv6_end_main_v6_t srv6_end_main_v6;
211 extern vlib_node_registration_t srv6_end_m_gtp6_e;
213 typedef struct srv6_end_main_v6_decap_s
215 vlib_main_t *vlib_main;
216 vnet_main_t *vnet_main;
218 u32 end_m_gtp6_d_node_index;
219 u32 error_node_index;
221 ip6_header_t cache_hdr;
222 } srv6_end_main_v6_decap_t;
224 extern srv6_end_main_v6_decap_t srv6_end_main_v6_decap;
225 extern vlib_node_registration_t srv6_end_m_gtp6_d;
227 typedef struct srv6_end_main_v6_decap_di_s
229 vlib_main_t *vlib_main;
230 vnet_main_t *vnet_main;
232 u32 end_m_gtp6_d_di_node_index;
233 u32 error_node_index;
235 ip6srv_combo_header_t cache_hdr;
236 } srv6_end_main_v6_decap_di_t;
238 extern srv6_end_main_v6_decap_di_t srv6_end_main_v6_decap_di;
239 extern vlib_node_registration_t srv6_end_m_gtp6_d_di;
241 #endif /* __included_srv6_end_h__ */
244 * fd.io coding-style-patch-verification: ON
247 * eval: (c-set-style "gnu")