blob: 06eeee82bc652b7e0ed0710f75771d28cd63cd76 [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*---------------------------------------------------------------------------
2 * Copyright (c) 2009-2014 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/*
17 * IPv4 and IPv6 Fragmentation Nodes
18 *
19 * A packet sent to those nodes require the following
20 * buffer attributes to be set:
21 * ip_frag.header_offset :
22 * Where to find the IPv4 (or IPv6) header in the packet. Previous
23 * bytes are left untouched and copied in every fragment. The fragments
24 * are then appended. This option is used for fragmented packets
25 * that are encapsulated.
26 * ip_frag.mtu :
27 * Maximum size of IP packets, header included, but ignoring
28 * the 'ip_frag.header_offset' copied bytes.
29 * ip_frag.next_index :
30 * One of ip_frag_next_t, indicating to which exit node the fragments
31 * should be sent to.
32 *
33 */
34
35#ifndef IP_FRAG_H
36#define IP_FRAG_H
37
38#include <vnet/vnet.h>
39
Dave Barachd7cb1b52016-12-09 09:52:16 -050040#define IP_FRAG_FLAG_IP4_HEADER 0x01 //Encapsulating IPv4 header
41#define IP_FRAG_FLAG_IP6_HEADER 0x02 //Encapsulating IPv6 header
Ed Warnickecb9cada2015-12-08 15:45:58 -070042
43#define IP4_FRAG_NODE_NAME "ip4-frag"
44#define IP6_FRAG_NODE_NAME "ip6-frag"
45
Damjan Marionb8abf872016-03-14 20:02:35 +010046extern vlib_node_registration_t ip4_frag_node;
47extern vlib_node_registration_t ip6_frag_node;
Ed Warnickecb9cada2015-12-08 15:45:58 -070048
Dave Barachd7cb1b52016-12-09 09:52:16 -050049typedef enum
50{
Ole Troanb3655e52018-08-16 22:08:49 +020051 IP4_FRAG_NEXT_IP4_REWRITE,
Ed Warnickecb9cada2015-12-08 15:45:58 -070052 IP4_FRAG_NEXT_IP4_LOOKUP,
53 IP4_FRAG_NEXT_IP6_LOOKUP,
Ole Troan9fb87552016-01-13 22:30:43 +010054 IP4_FRAG_NEXT_ICMP_ERROR,
Ed Warnickecb9cada2015-12-08 15:45:58 -070055 IP4_FRAG_NEXT_DROP,
56 IP4_FRAG_N_NEXT
57} ip4_frag_next_t;
58
Dave Barachd7cb1b52016-12-09 09:52:16 -050059typedef enum
60{
Ed Warnickecb9cada2015-12-08 15:45:58 -070061 IP6_FRAG_NEXT_IP4_LOOKUP,
62 IP6_FRAG_NEXT_IP6_LOOKUP,
Ole Troanb3655e52018-08-16 22:08:49 +020063 IP6_FRAG_NEXT_IP6_REWRITE,
Ed Warnickecb9cada2015-12-08 15:45:58 -070064 IP6_FRAG_NEXT_DROP,
65 IP6_FRAG_N_NEXT
66} ip6_frag_next_t;
67
68#define foreach_ip_frag_error \
69 /* Must be first. */ \
70 _(NONE, "packet fragmented") \
71 _(SMALL_PACKET, "packet smaller than MTU") \
72 _(FRAGMENT_SENT, "number of sent fragments") \
Ole Troan9fb87552016-01-13 22:30:43 +010073 _(CANT_FRAGMENT_HEADER, "can't fragment header") \
74 _(DONT_FRAGMENT_SET, "can't fragment this packet") \
Ed Warnickecb9cada2015-12-08 15:45:58 -070075 _(MALFORMED, "malformed packet") \
76 _(MEMORY, "could not allocate buffer") \
77 _(UNKNOWN, "unknown error")
78
Dave Barachd7cb1b52016-12-09 09:52:16 -050079typedef enum
80{
Ed Warnickecb9cada2015-12-08 15:45:58 -070081#define _(sym,str) IP_FRAG_ERROR_##sym,
Dave Barachd7cb1b52016-12-09 09:52:16 -050082 foreach_ip_frag_error
Ed Warnickecb9cada2015-12-08 15:45:58 -070083#undef _
Dave Barachd7cb1b52016-12-09 09:52:16 -050084 IP_FRAG_N_ERROR,
85} ip_frag_error_t;
Ed Warnickecb9cada2015-12-08 15:45:58 -070086
Ole Troan282093f2018-09-19 12:38:51 +020087void ip_frag_set_vnet_buffer (vlib_buffer_t * b, u16 mtu,
Dave Barachd7cb1b52016-12-09 09:52:16 -050088 u8 next_index, u8 flags);
Vijayabhaskar Katamreddye95d1a12018-06-28 11:08:29 -070089void
90ip4_frag_do_fragment (vlib_main_t * vm, u32 pi, u32 ** buffer,
91 ip_frag_error_t * error);
92void
93ip6_frag_do_fragment (vlib_main_t * vm, u32 pi, u32 ** buffer,
94 ip_frag_error_t * error);
Ed Warnickecb9cada2015-12-08 15:45:58 -070095#endif /* ifndef IP_FRAG_H */
Dave Barachd7cb1b52016-12-09 09:52:16 -050096
97/*
98 * fd.io coding-style-patch-verification: ON
99 *
100 * Local Variables:
101 * eval: (c-set-style "gnu")
102 * End:
103 */