FD.io VPP  v21.01.1
Vector Packet Processing
ip6_to_ip4.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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  * @file
17  * @brief IPv6 to IPv4 translation
18  */
19 #ifndef __included_ip6_to_ip4_h__
20 #define __included_ip6_to_ip4_h__
21 
22 #include <vnet/ip/ip.h>
23 
24 /**
25  * IPv6 to IPv4 set call back function type
26  */
28  ip4_header_t * ip4, void *ctx);
29 
31  ip6_header_t * ip6,
32  ip4_header_t * ip4, void *ctx);
33 
34 /* *INDENT-OFF* */
36  { 0, 1, ~0, ~0,
37  2, 2, 9, 8,
38  12, 12, 12, 12,
39  12, 12, 12, 12,
40  12, 12, 12, 12,
41  12, 12, 12, 12,
42  24, 24, 24, 24,
43  24, 24, 24, 24,
44  24, 24, 24, 24,
45  24, 24, 24, 24
46  };
47 /* *INDENT-ON* */
48 
49 #define frag_id_6to4(id) ((id) ^ ((id) >> 16))
50 
51 /**
52  * @brief Parse some useful information from IPv6 header.
53  *
54  * @param vm vlib main
55  * @param b vlib buffer
56  * @param ip6 IPv6 header.
57  * @param buff_len Buffer length.
58  * @param l4_protocol L4 protocol number.
59  * @param l4_offset L4 header offset.
60  * @param frag_hdr_offset Fragment header offset if present, 0 otherwise.
61  *
62  * @returns 0 on success, non-zero value otherwise.
63  */
66  u32 buff_len, u8 * l4_protocol, u16 * l4_offset,
67  u16 * frag_hdr_offset)
68 {
69  ip6_ext_header_t *last_hdr, *frag_hdr;
70  u32 length;
72  (vm, b, ip6, IP_PROTOCOL_IPV6_FRAGMENTATION, &length, &frag_hdr,
73  &last_hdr))
74  {
75  return -1;
76  }
77 
78  if (length > 0)
79  {
80  if (frag_hdr)
81  {
82  *frag_hdr_offset = (u8 *) frag_hdr - (u8 *) ip6;
83  }
84  else
85  {
86  *frag_hdr_offset = 0;
87  }
88  *l4_protocol = last_hdr->next_hdr;
89  }
90  else
91  {
92  *frag_hdr_offset = 0;
93  *l4_protocol = ip6->protocol;
94  }
95  *l4_offset = sizeof (*ip6) + length;
96 
97  return (buff_len < (*l4_offset + 4)) ||
98  (clib_net_to_host_u16 (ip6->payload_length) <
99  (*l4_offset + 4 - sizeof (*ip6)));
100 }
101 
102 /**
103  * @brief Get L4 information like port number or ICMP id from IPv6 packet.
104  *
105  * @param ip6 IPv6 header.
106  * @param buffer_len Buffer length.
107  * @param ip_protocol L4 protocol
108  * @param src_port L4 src port or icmp id
109  * @param dst_post L4 dst port or icmp id
110  * @param icmp_type_or_tcp_flags ICMP type or TCP flags, if applicable
111  * @param tcp_ack_number TCP ack number, if applicable
112  * @param tcp_seq_number TCP seq number, if applicable
113  *
114  * @returns 1 on success, 0 otherwise.
115  */
118  u16 buffer_len, u8 * ip_protocol, u16 * src_port,
119  u16 * dst_port, u8 * icmp_type_or_tcp_flags,
120  u32 * tcp_ack_number, u32 * tcp_seq_number)
121 {
122  u8 l4_protocol;
123  u16 l4_offset;
124  u16 frag_offset;
125  u8 *l4;
126 
127  if (ip6_parse
128  (vm, b, ip6, buffer_len, &l4_protocol, &l4_offset, &frag_offset))
129  return 0;
130 
131  if (frag_offset &&
132  ip6_frag_hdr_offset (((ip6_frag_hdr_t *)
133  u8_ptr_add (ip6, frag_offset))))
134  return 0; //Can't deal with non-first fragment for now
135 
136  if (ip_protocol)
137  {
138  *ip_protocol = l4_protocol;
139  }
140  l4 = u8_ptr_add (ip6, l4_offset);
141  if (l4_protocol == IP_PROTOCOL_TCP || l4_protocol == IP_PROTOCOL_UDP)
142  {
143  if (src_port)
144  *src_port = ((udp_header_t *) (l4))->src_port;
145  if (dst_port)
146  *dst_port = ((udp_header_t *) (l4))->dst_port;
147  if (icmp_type_or_tcp_flags && l4_protocol == IP_PROTOCOL_TCP)
148  *icmp_type_or_tcp_flags = ((tcp_header_t *) (l4))->flags;
149  if (tcp_ack_number && l4_protocol == IP_PROTOCOL_TCP)
150  *tcp_ack_number = ((tcp_header_t *) (l4))->ack_number;
151  if (tcp_seq_number && l4_protocol == IP_PROTOCOL_TCP)
152  *tcp_seq_number = ((tcp_header_t *) (l4))->seq_number;
153  }
154  else if (l4_protocol == IP_PROTOCOL_ICMP6)
155  {
156  icmp46_header_t *icmp = (icmp46_header_t *) (l4);
157  if (icmp_type_or_tcp_flags)
158  *icmp_type_or_tcp_flags = ((icmp46_header_t *) (l4))->type;
159  if (icmp->type == ICMP6_echo_request)
160  {
161  if (src_port)
162  *src_port = ((u16 *) (icmp))[2];
163  if (dst_port)
164  *dst_port = ((u16 *) (icmp))[2];
165  }
166  else if (icmp->type == ICMP6_echo_reply)
167  {
168  if (src_port)
169  *src_port = ((u16 *) (icmp))[2];
170  if (dst_port)
171  *dst_port = ((u16 *) (icmp))[2];
172  }
173  else if (clib_net_to_host_u16 (ip6->payload_length) >= 64)
174  {
175  u16 ip6_pay_len;
176  ip6_header_t *inner_ip6;
177  u8 inner_l4_protocol;
178  u16 inner_l4_offset;
179  u16 inner_frag_offset;
180  u8 *inner_l4;
181 
182  ip6_pay_len = clib_net_to_host_u16 (ip6->payload_length);
183  inner_ip6 = (ip6_header_t *) u8_ptr_add (icmp, 8);
184 
185  if (ip6_parse (vm, b, inner_ip6, ip6_pay_len - 8,
186  &inner_l4_protocol, &inner_l4_offset,
187  &inner_frag_offset))
188  return 0;
189 
190  if (inner_frag_offset &&
191  ip6_frag_hdr_offset (((ip6_frag_hdr_t *)
192  u8_ptr_add (inner_ip6,
193  inner_frag_offset))))
194  return 0;
195 
196  inner_l4 = u8_ptr_add (inner_ip6, inner_l4_offset);
197  if (inner_l4_protocol == IP_PROTOCOL_TCP ||
198  inner_l4_protocol == IP_PROTOCOL_UDP)
199  {
200  if (src_port)
201  *src_port = ((udp_header_t *) (inner_l4))->dst_port;
202  if (dst_port)
203  *dst_port = ((udp_header_t *) (inner_l4))->src_port;
204  }
205  else if (inner_l4_protocol == IP_PROTOCOL_ICMP6)
206  {
207  icmp46_header_t *inner_icmp = (icmp46_header_t *) (inner_l4);
208  if (inner_icmp->type == ICMP6_echo_request)
209  {
210  if (src_port)
211  *src_port = ((u16 *) (inner_icmp))[2];
212  if (dst_port)
213  *dst_port = ((u16 *) (inner_icmp))[2];
214  }
215  else if (inner_icmp->type == ICMP6_echo_reply)
216  {
217  if (src_port)
218  *src_port = ((u16 *) (inner_icmp))[2];
219  if (dst_port)
220  *dst_port = ((u16 *) (inner_icmp))[2];
221  }
222  }
223  }
224  }
225  return 1;
226 }
227 
228 /**
229  * @brief Convert type and code value from ICMP6 to ICMP4.
230  *
231  * @param icmp ICMP header.
232  * @param inner_ip6 Inner IPv6 header if present, 0 otherwise.
233  *
234  * @returns 0 on success, non-zero value otherwise.
235  */
237 icmp6_to_icmp_header (icmp46_header_t * icmp, ip6_header_t ** inner_ip6)
238 {
239  *inner_ip6 = NULL;
240  switch (icmp->type)
241  {
242  case ICMP6_echo_request:
243  icmp->type = ICMP4_echo_request;
244  break;
245  case ICMP6_echo_reply:
246  icmp->type = ICMP4_echo_reply;
247  break;
248  case ICMP6_destination_unreachable:
249  *inner_ip6 = (ip6_header_t *) u8_ptr_add (icmp, 8);
250 
251  switch (icmp->code)
252  {
253  case ICMP6_destination_unreachable_no_route_to_destination: //0
254  case ICMP6_destination_unreachable_beyond_scope_of_source_address: //2
255  case ICMP6_destination_unreachable_address_unreachable: //3
256  icmp->type = ICMP4_destination_unreachable;
257  icmp->code =
258  ICMP4_destination_unreachable_destination_unreachable_host;
259  break;
260  case ICMP6_destination_unreachable_destination_administratively_prohibited: //1
261  icmp->type =
262  ICMP4_destination_unreachable;
263  icmp->code =
264  ICMP4_destination_unreachable_communication_administratively_prohibited;
265  break;
266  case ICMP6_destination_unreachable_port_unreachable:
267  icmp->type = ICMP4_destination_unreachable;
268  icmp->code = ICMP4_destination_unreachable_port_unreachable;
269  break;
270  default:
271  return -1;
272  }
273  break;
274  case ICMP6_packet_too_big:
275  *inner_ip6 = (ip6_header_t *) u8_ptr_add (icmp, 8);
276 
277  icmp->type = ICMP4_destination_unreachable;
278  icmp->code = 4;
279  {
280  u32 advertised_mtu = clib_net_to_host_u32 (*((u32 *) (icmp + 1)));
281  advertised_mtu -= 20;
282  //FIXME: = minimum(advertised MTU-20, MTU_of_IPv4_nexthop, (MTU_of_IPv6_nexthop)-20)
283  ((u16 *) (icmp))[3] = clib_host_to_net_u16 (advertised_mtu);
284  }
285  break;
286 
287  case ICMP6_time_exceeded:
288  *inner_ip6 = (ip6_header_t *) u8_ptr_add (icmp, 8);
289 
290  icmp->type = ICMP4_time_exceeded;
291  break;
292 
293  case ICMP6_parameter_problem:
294  *inner_ip6 = (ip6_header_t *) u8_ptr_add (icmp, 8);
295 
296  switch (icmp->code)
297  {
298  case ICMP6_parameter_problem_erroneous_header_field:
299  icmp->type = ICMP4_parameter_problem;
300  icmp->code = ICMP4_parameter_problem_pointer_indicates_error;
301  u32 pointer = clib_net_to_host_u32 (*((u32 *) (icmp + 1)));
302  if (pointer >= 40)
303  return -1;
304 
305  ((u8 *) (icmp + 1))[0] =
307  break;
308  case ICMP6_parameter_problem_unrecognized_next_header:
309  icmp->type = ICMP4_destination_unreachable;
310  icmp->code = ICMP4_destination_unreachable_port_unreachable;
311  break;
312  case ICMP6_parameter_problem_unrecognized_option:
313  default:
314  return -1;
315  }
316  break;
317  default:
318  return -1;
319  break;
320  }
321  return 0;
322 }
323 
324 /**
325  * @brief Translate TOS value from IPv6 to IPv4.
326  *
327  * @param ip_version_traffic_class_and_flow_label in network byte order
328  *
329  * @returns IPv4 TOS value.
330  */
332 ip6_translate_tos (u32 ip_version_traffic_class_and_flow_label)
333 {
334  return (clib_net_to_host_u32 (ip_version_traffic_class_and_flow_label)
335  & 0x0ff00000) >> 20;
336 }
337 
338 /**
339  * @brief Translate ICMP6 packet to ICMP4.
340  *
341  * @param p Buffer to translate.
342  * @param fn The function to translate outer header.
343  * @param ctx A context passed in the outer header translate function.
344  * @param inner_fn The function to translate inner header.
345  * @param inner_ctx A context passed in the inner header translate function.
346  *
347  * @returns 0 on success, non-zero value otherwise.
348  */
349 always_inline int
351  ip6_to_ip4_icmp_set_fn_t fn, void *ctx,
352  ip6_to_ip4_icmp_set_fn_t inner_fn, void *inner_ctx)
353 {
354  ip6_header_t *ip6, *inner_ip6;
355  ip4_header_t *ip4, *inner_ip4;
356  u32 ip6_pay_len;
357  icmp46_header_t *icmp;
358  ip_csum_t csum;
359  int rv;
360  ip6_address_t old_src, old_dst;
361 
362  ip6 = vlib_buffer_get_current (p);
363  ip6_pay_len = clib_net_to_host_u16 (ip6->payload_length);
364  icmp = (icmp46_header_t *) (ip6 + 1);
365  ASSERT (ip6_pay_len + sizeof (*ip6) <= p->current_length);
366 
367  //No extensions headers allowed here
368  if (ip6->protocol != IP_PROTOCOL_ICMP6)
369  return -1;
370 
371  //There are no fragmented ICMP messages, so no extension header for now
372  if (icmp6_to_icmp_header (icmp, &inner_ip6))
373  return -1;
374 
375  if (inner_ip6)
376  {
377  u16 *inner_L4_checksum, inner_l4_offset, inner_frag_offset,
378  inner_frag_id;
379  u8 *inner_l4, inner_protocol;
380 
381  //We have two headers to translate
382  // FROM
383  // [ IPv6 ]<- ext ->[IC][ IPv6 ]<- ext ->[L4 header ...
384  // Handled cases:
385  // [ IPv6 ][IC][ IPv6 ][L4 header ...
386  // [ IPv6 ][IC][ IPv6 ][Fr][L4 header ...
387  // TO
388  // [ IPv4][IC][ IPv4][L4 header ...
389 
390  if (ip6_parse (vm, p, inner_ip6, ip6_pay_len - 8,
391  &inner_protocol, &inner_l4_offset, &inner_frag_offset))
392  return -1;
393 
394  inner_l4 = u8_ptr_add (inner_ip6, inner_l4_offset);
395  inner_ip4 =
396  (ip4_header_t *) u8_ptr_add (inner_l4, -sizeof (*inner_ip4));
397  if (inner_frag_offset)
398  {
399  ip6_frag_hdr_t *inner_frag =
400  (ip6_frag_hdr_t *) u8_ptr_add (inner_ip6, inner_frag_offset);
401  inner_frag_id = frag_id_6to4 (inner_frag->identification);
402  }
403  else
404  {
405  inner_frag_id = 0;
406  }
407 
408  //Do the translation of the inner packet
409  if (inner_protocol == IP_PROTOCOL_TCP)
410  {
411  inner_L4_checksum = (u16 *) u8_ptr_add (inner_l4, 16);
412  }
413  else if (inner_protocol == IP_PROTOCOL_UDP)
414  {
415  inner_L4_checksum = (u16 *) u8_ptr_add (inner_l4, 6);
416  }
417  else if (inner_protocol == IP_PROTOCOL_ICMP6)
418  {
419  icmp46_header_t *inner_icmp = (icmp46_header_t *) inner_l4;
420  //It cannot be of a different type as ip6_icmp_to_icmp6_in_place succeeded
421  inner_icmp->type = (inner_icmp->type == ICMP6_echo_request) ?
422  ICMP4_echo_request : ICMP4_echo_reply;
423  inner_protocol = IP_PROTOCOL_ICMP; //Will be copied to ip6 later
424  inner_L4_checksum = &inner_icmp->checksum;
425  }
426  else
427  {
428  return -1;
429  }
430 
431  old_src.as_u64[0] = inner_ip6->src_address.as_u64[0];
432  old_src.as_u64[1] = inner_ip6->src_address.as_u64[1];
433  old_dst.as_u64[0] = inner_ip6->dst_address.as_u64[0];
434  old_dst.as_u64[1] = inner_ip6->dst_address.as_u64[1];
435 
436  if ((rv = inner_fn (inner_ip6, inner_ip4, inner_ctx)) != 0)
437  return rv;
438 
439  inner_ip4->ip_version_and_header_length =
441  inner_ip4->tos =
444  inner_ip4->length =
445  u16_net_add (inner_ip6->payload_length,
446  sizeof (*ip4) + sizeof (*ip6) - inner_l4_offset);
447  inner_ip4->fragment_id = inner_frag_id;
448  inner_ip4->flags_and_fragment_offset =
449  clib_host_to_net_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS);
450  inner_ip4->ttl = inner_ip6->hop_limit;
451  inner_ip4->protocol = inner_protocol;
452  inner_ip4->checksum = ip4_header_checksum (inner_ip4);
453 
454  if (inner_ip4->protocol == IP_PROTOCOL_ICMP)
455  {
456  //Recompute ICMP checksum
457  icmp46_header_t *inner_icmp = (icmp46_header_t *) inner_l4;
458  inner_icmp->checksum = 0;
459  csum =
460  ip_incremental_checksum (0, inner_icmp,
461  clib_net_to_host_u16 (inner_ip4->length)
462  - sizeof (*inner_ip4));
463  inner_icmp->checksum = ~ip_csum_fold (csum);
464  }
465  else
466  {
467  //Update to new pseudo-header
468  csum = *inner_L4_checksum;
469  csum = ip_csum_sub_even (csum, old_src.as_u64[0]);
470  csum = ip_csum_sub_even (csum, old_src.as_u64[1]);
471  csum = ip_csum_sub_even (csum, old_dst.as_u64[0]);
472  csum = ip_csum_sub_even (csum, old_dst.as_u64[1]);
473  csum = ip_csum_add_even (csum, inner_ip4->src_address.as_u32);
474  csum = ip_csum_add_even (csum, inner_ip4->dst_address.as_u32);
475  *inner_L4_checksum = ip_csum_fold (csum);
476  }
477 
478  //Move up icmp header
479  ip4 = (ip4_header_t *) u8_ptr_add (inner_l4, -2 * sizeof (*ip4) - 8);
480  clib_memcpy_fast (u8_ptr_add (inner_l4, -sizeof (*ip4) - 8), icmp, 8);
481  icmp = (icmp46_header_t *) u8_ptr_add (inner_l4, -sizeof (*ip4) - 8);
482  }
483  else
484  {
485  //Only one header to translate
486  ip4 = (ip4_header_t *) u8_ptr_add (ip6, sizeof (*ip6) - sizeof (*ip4));
487  }
488 
489  vlib_buffer_advance (p, (u32) (((u8 *) ip4) - ((u8 *) ip6)));
490 
491  if ((rv = fn (ip6, ip4, ctx)) != 0)
492  return rv;
493 
494  ip4->ip_version_and_header_length =
496  ip4->tos = ip6_translate_tos (ip6->ip_version_traffic_class_and_flow_label);
497  ip4->fragment_id = 0;
498  ip4->flags_and_fragment_offset = 0;
499  ip4->ttl = ip6->hop_limit;
500  ip4->protocol = IP_PROTOCOL_ICMP;
501  //TODO fix the length depending on offset length
502  ip4->length = u16_net_add (ip6->payload_length,
503  (inner_ip6 ==
504  NULL) ? sizeof (*ip4) : (2 * sizeof (*ip4) -
505  sizeof (*ip6)));
506  ip4->checksum = ip4_header_checksum (ip4);
507 
508  //Recompute ICMP checksum
509  icmp->checksum = 0;
510  csum =
511  ip_incremental_checksum (0, icmp,
512  clib_net_to_host_u16 (ip4->length) -
513  sizeof (*ip4));
514  icmp->checksum = ~ip_csum_fold (csum);
515 
516  return 0;
517 }
518 
519 #endif /* __included_ip6_to_ip4_h__ */
520 
521 /*
522  * fd.io coding-style-patch-verification: ON
523  *
524  * Local Variables:
525  * eval: (c-set-style "gnu")
526  * End:
527  */
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105
ip4_address_t src_address
Definition: ip4_packet.h:125
int(* ip6_to_ip4_icmp_set_fn_t)(ip6_header_t *ip6, ip4_header_t *ip4, void *ctx)
IPv6 to IPv4 set call back function type.
Definition: ip6_to_ip4.h:27
vl_api_ip_port_and_mask_t dst_port
Definition: flow_types.api:92
#define clib_memcpy_fast(a, b, c)
Definition: string.h:81
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:113
uword ip_csum_t
Definition: ip_packet.h:246
vlib_main_t * vm
Definition: in2out_ed.c:1580
int(* ip6_to_ip4_tcp_udp_set_fn_t)(vlib_buffer_t *b, ip6_header_t *ip6, ip4_header_t *ip4, void *ctx)
Definition: ip6_to_ip4.h:30
u16 flags_and_fragment_offset
Definition: ip4_packet.h:106
static u16 ip6_get_port(vlib_main_t *vm, vlib_buffer_t *b, ip6_header_t *ip6, u16 buffer_len, u8 *ip_protocol, u16 *src_port, u16 *dst_port, u8 *icmp_type_or_tcp_flags, u32 *tcp_ack_number, u32 *tcp_seq_number)
Get L4 information like port number or ICMP id from IPv6 packet.
Definition: ip6_to_ip4.h:117
struct _tcp_header tcp_header_t
ip6_address_t src_address
Definition: ip6_packet.h:310
unsigned char u8
Definition: types.h:56
static int ip6_walk_ext_hdr(vlib_main_t *vm, vlib_buffer_t *b, const ip6_header_t *ip6_header, u8 find_hdr, u32 *length, ip6_ext_header_t **ext_hdr, ip6_ext_header_t **last_ext_hdr)
Definition: ip6_packet.h:605
static_always_inline int icmp6_to_icmp_header(icmp46_header_t *icmp, ip6_header_t **inner_ip6)
Convert type and code value from ICMP6 to ICMP4.
Definition: ip6_to_ip4.h:237
#define u8_ptr_add(ptr, index)
Definition: ip_types.h:56
#define static_always_inline
Definition: clib.h:109
vl_api_ip6_address_t ip6
Definition: one.api:424
ip4_address_t dst_address
Definition: ip4_packet.h:125
const cJSON *const b
Definition: cJSON.h:255
static_always_inline u8 ip6_translate_tos(u32 ip_version_traffic_class_and_flow_label)
Translate TOS value from IPv6 to IPv4.
Definition: ip6_to_ip4.h:332
unsigned int u32
Definition: types.h:88
#define frag_id_6to4(id)
Definition: ip6_to_ip4.h:49
vl_api_fib_path_type_t type
Definition: fib_types.api:123
icmp
Definition: map.api:387
long ctx[MAX_CONNS]
Definition: main.c:144
unsigned short u16
Definition: types.h:57
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:233
#define always_inline
Definition: ipsec.h:28
vl_api_ip4_address_t ip4
Definition: one.api:376
vl_api_ip_port_and_mask_t src_port
Definition: flow_types.api:91
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
Definition: ip4_packet.h:107
ip_protocol
Definition: ip_packet.h:47
#define ip6_frag_hdr_offset(hdr)
Definition: ip6_packet.h:669
#define ASSERT(truth)
ip_dscp_t tos
Definition: ip4_packet.h:96
static ip_csum_t ip_csum_sub_even(ip_csum_t c, ip_csum_t x)
Definition: ip_packet.h:274
static u8 icmp6_to_icmp_updater_pointer_table[]
Definition: ip6_to_ip4.h:35
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:252
char const int length
Definition: cJSON.h:163
u32 ip_version_traffic_class_and_flow_label
Definition: ip6_packet.h:297
u16 payload_length
Definition: ip6_packet.h:301
static int icmp6_to_icmp(vlib_main_t *vm, vlib_buffer_t *p, ip6_to_ip4_icmp_set_fn_t fn, void *ctx, ip6_to_ip4_icmp_set_fn_t inner_fn, void *inner_ctx)
Translate ICMP6 packet to ICMP4.
Definition: ip6_to_ip4.h:350
VLIB buffer representation.
Definition: buffer.h:102
#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS
Definition: ip4_packet.h:149
#define u16_net_add(u, val)
Definition: ip_types.h:57
static_always_inline int ip6_parse(vlib_main_t *vm, vlib_buffer_t *b, const ip6_header_t *ip6, u32 buff_len, u8 *l4_protocol, u16 *l4_offset, u16 *frag_hdr_offset)
Parse some useful information from IPv6 header.
Definition: ip6_to_ip4.h:65
u8 ip_version_and_header_length
Definition: ip4_packet.h:93
static ip_csum_t ip_incremental_checksum(ip_csum_t sum, void *_data, uword n_bytes)
Definition: ip_packet.h:320
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:314
static u16 ip_csum_fold(ip_csum_t c)
Definition: ip_packet.h:302
static ip_csum_t ip_csum_add_even(ip_csum_t c, ip_csum_t x)
Definition: ip_packet.h:257
ip6_address_t dst_address
Definition: ip6_packet.h:310