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 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
41 #define BITALIGN2(A,B) A; B
42 #define BITALIGN3(A,B,C) A; B; C
44 #define BITALIGN2(A,B) B; A
45 #define BITALIGN3(A,B,C) C; B; A
48 #define GTPU_EXTHDR_FLAG 0x04
49 #define GTPU_EXTHDR_PDU_SESSION 0x85
51 #define SRH_TAG_ECHO_REPLY 0x0008
52 #define SRH_TAG_ECHO_REQUEST 0x0004
53 #define SRH_TAG_ERROR_INDICATION 0x0002
54 #define SRH_TAG_END_MARKER 0x0001
62 } __attribute__ ((packed)) gtpu_exthdr_t;
70 u16 length; /* length in octets of the payload */
73 } __attribute__ ((packed)) gtpu_header_t;
76 #define GTPU_TYPE_ECHO_REQUEST 1
77 #define GTPU_TYPE_ECHO_REPLY 2
78 #define GTPU_TYPE_ERROR_INDICATION 26
79 #define GTPU_TYPE_END_MARKER 254
80 #define GTPU_TYPE_GTPU 255
89 } __attribute__ ((packed)) gtpu_paging_policy_t;
99 struct gtpu_qfi_bits {BITALIGN3(u8 p:1,
107 gtpu_paging_policy_t paging[0];
109 } __attribute__ ((packed)) gtpu_pdu_session_t;
112 #define GTPU_PDU_SESSION_P_BIT_MASK 0x80
113 #define GTPU_PDU_SESSION_R_BIT_MASK 0x40
114 #define GTPU_PDU_SESSION_QFI_MASK 0x3f
116 #define SRV6_PDU_SESSION_U_BIT_MASK 0x01
117 #define SRV6_PDU_SESSION_R_BIT_MASK 0x02
118 #define SRV6_PDU_SESSION_QFI_MASK 0xfC
123 ip4_header_t ip4; /* 20 bytes */
124 udp_header_t udp; /* 8 bytes */
125 gtpu_header_t gtpu; /* 8 bytes */
126 } __attribute__ ((packed)) ip4_gtpu_header_t;
132 ip6_header_t ip6; /* 40 bytes */
133 udp_header_t udp; /* 8 bytes */
134 gtpu_header_t gtpu; /* 8 bytes */
135 } __attribute__ ((packed)) ip6_gtpu_header_t;
138 #define GTPU_V1_VER (1<<5)
140 #define GTPU_PT_GTP (1<<4)
142 typedef struct srv6_end_gtp6_param_s
146 ip6_address_t sr_prefix;
148 } srv6_end_gtp6_param_t;
150 typedef struct srv6_end_gtp4_param_s
154 ip6_address_t sr_prefix;
157 ip6_address_t v6src_prefix;
161 } srv6_end_gtp4_param_t;
163 typedef struct srv6_end_main_v4_s
165 vlib_main_t *vlib_main;
166 vnet_main_t *vnet_main;
168 u32 end_m_gtp4_e_node_index;
169 u32 error_node_index;
171 u32 dst_p_len; // dst prefix len
172 u32 src_p_len; // src prefix len
174 ip4_gtpu_header_t cache_hdr;
176 } srv6_end_main_v4_t;
178 typedef struct srv6_end_main_v4_decap_s
180 vlib_main_t *vlib_main;
181 vnet_main_t *vnet_main;
183 u32 end_m_gtp4_d_node_index;
184 u32 error_node_index;
186 ip6_header_t cache_hdr;
187 } srv6_end_main_v4_decap_t;
189 extern srv6_end_main_v4_t srv6_end_main_v4;
190 extern srv6_end_main_v4_decap_t srv6_end_main_v4_decap;
191 extern vlib_node_registration_t srv6_end_m_gtp4_e;
193 typedef struct srv6_end_main_v6_s
195 vlib_main_t *vlib_main;
196 vnet_main_t *vnet_main;
198 u32 end_m_gtp6_e_node_index;
199 u32 error_node_index;
201 ip6_gtpu_header_t cache_hdr;
202 } srv6_end_main_v6_t;
204 extern srv6_end_main_v6_t srv6_end_main_v6;
205 extern vlib_node_registration_t srv6_end_m_gtp6_e;
207 typedef struct srv6_end_main_v6_decap_s
209 vlib_main_t *vlib_main;
210 vnet_main_t *vnet_main;
212 u32 end_m_gtp6_d_node_index;
213 u32 error_node_index;
215 ip6_header_t cache_hdr;
216 } srv6_end_main_v6_decap_t;
218 extern srv6_end_main_v6_decap_t srv6_end_main_v6_decap;
219 extern vlib_node_registration_t srv6_end_m_gtp6_d;
221 typedef struct srv6_end_main_v6_decap_di_s
223 vlib_main_t *vlib_main;
224 vnet_main_t *vnet_main;
226 u32 end_m_gtp6_d_di_node_index;
227 u32 error_node_index;
229 ip6srv_combo_header_t cache_hdr;
230 } srv6_end_main_v6_decap_di_t;
232 extern srv6_end_main_v6_decap_di_t srv6_end_main_v6_decap_di;
233 extern vlib_node_registration_t srv6_end_m_gtp6_d_di;
235 #endif /* __included_srv6_end_h__ */
238 * fd.io coding-style-patch-verification: ON
241 * eval: (c-set-style "gnu")