blob: 6abb6a9ebf03ab4483c8640682a72d66f4c2989f [file] [log] [blame]
Ed Warnickecb9cada2015-12-08 15:45:58 -07001/*
2 * Copyright (c) 2015 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 * ip4/packet.h: ip4 packet format
17 *
18 * Copyright (c) 2008 Eliot Dresselhaus
19 *
20 * Permission is hereby granted, free of charge, to any person obtaining
21 * a copy of this software and associated documentation files (the
22 * "Software"), to deal in the Software without restriction, including
23 * without limitation the rights to use, copy, modify, merge, publish,
24 * distribute, sublicense, and/or sell copies of the Software, and to
25 * permit persons to whom the Software is furnished to do so, subject to
26 * the following conditions:
27 *
28 * The above copyright notice and this permission notice shall be
29 * included in all copies or substantial portions of the Software.
30 *
31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 */
39
40#ifndef included_ip4_packet_h
41#define included_ip4_packet_h
42
43#include <vnet/ip/ip_packet.h> /* for ip_csum_t */
Dave Barach68b0fb02017-02-28 15:15:56 -050044#include <vnet/tcp/tcp_packet.h> /* for tcp_header_t */
Ed Warnickecb9cada2015-12-08 15:45:58 -070045#include <vppinfra/byte_order.h> /* for clib_net_to_host_u16 */
Jieqiang Wangc8833b22020-08-07 14:18:04 +000046#include <vppinfra/warnings.h> /* for WARN_OFF/WARN_ON macro */
Ed Warnickecb9cada2015-12-08 15:45:58 -070047
48/* IP4 address which can be accessed either as 4 bytes
49 or as a 32-bit number. */
Dave Barachd7cb1b52016-12-09 09:52:16 -050050typedef union
51{
Ed Warnickecb9cada2015-12-08 15:45:58 -070052 u8 data[4];
53 u32 data_u32;
54 /* Aliases. */
55 u8 as_u8[4];
Neale Rannsa3af3372017-03-28 03:49:52 -070056 u16 as_u16[2];
Ed Warnickecb9cada2015-12-08 15:45:58 -070057 u32 as_u32;
58} ip4_address_t;
59
Dave Barachd7cb1b52016-12-09 09:52:16 -050060typedef struct
61{
Ed Warnickecb9cada2015-12-08 15:45:58 -070062 /* IP address must be first for ip_interface_address_get_address() to work */
63 ip4_address_t ip4_addr;
64 u32 fib_index;
65} ip4_address_fib_t;
66
67always_inline void
Neale Rannsd69f4392018-08-31 06:30:16 -040068ip4_addr_fib_init (ip4_address_fib_t * addr_fib,
69 const ip4_address_t * address, u32 fib_index)
Ed Warnickecb9cada2015-12-08 15:45:58 -070070{
Dave Barach178cf492018-11-13 16:34:13 -050071 clib_memcpy_fast (&addr_fib->ip4_addr, address,
72 sizeof (addr_fib->ip4_addr));
Ed Warnickecb9cada2015-12-08 15:45:58 -070073 addr_fib->fib_index = fib_index;
74}
75
76/* (src,dst) pair of addresses as found in packet header. */
Dave Barachd7cb1b52016-12-09 09:52:16 -050077typedef struct
78{
Ed Warnickecb9cada2015-12-08 15:45:58 -070079 ip4_address_t src, dst;
80} ip4_address_pair_t;
81
Damjan Mariona35cc142018-03-16 01:25:27 +010082typedef struct
83{
84 ip4_address_t addr, mask;
85} ip4_address_and_mask_t;
86
Dave Barachd7cb1b52016-12-09 09:52:16 -050087typedef union
88{
89 struct
90 {
Ed Warnickecb9cada2015-12-08 15:45:58 -070091 /* 4 bit packet length (in 32bit units) and version VVVVLLLL.
92 e.g. for packets w/ no options ip_version_and_header_length == 0x45. */
93 u8 ip_version_and_header_length;
94
95 /* Type of service. */
Neale Ranns038e1df2019-07-19 14:01:02 +000096 ip_dscp_t tos;
Ed Warnickecb9cada2015-12-08 15:45:58 -070097
98 /* Total layer 3 packet length including this header. */
99 u16 length;
100
101 /* Fragmentation ID. */
102 u16 fragment_id;
103
104 /* 3 bits of flags and 13 bits of fragment offset (in units
105 of 8 byte quantities). */
106 u16 flags_and_fragment_offset;
107#define IP4_HEADER_FLAG_MORE_FRAGMENTS (1 << 13)
108#define IP4_HEADER_FLAG_DONT_FRAGMENT (1 << 14)
109#define IP4_HEADER_FLAG_CONGESTION (1 << 15)
110
111 /* Time to live decremented by router at each hop. */
112 u8 ttl;
113
114 /* Next level protocol packet. */
115 u8 protocol;
116
117 /* Checksum. */
118 u16 checksum;
119
120 /* Source and destination address. */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500121 union
122 {
123 struct
124 {
Ed Warnickecb9cada2015-12-08 15:45:58 -0700125 ip4_address_t src_address, dst_address;
126 };
127 ip4_address_pair_t address_pair;
Dave Barachd7cb1b52016-12-09 09:52:16 -0500128 };
Ed Warnickecb9cada2015-12-08 15:45:58 -0700129 };
130
131 /* For checksumming we'll want to access IP header in word sized chunks. */
132 /* For 64 bit machines. */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500133 /* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700134 CLIB_PACKED (struct {
135 u64 checksum_data_64[2];
136 u32 checksum_data_64_32[1];
137 });
Dave Barachd7cb1b52016-12-09 09:52:16 -0500138 /* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700139
140 /* For 32 bit machines. */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500141 /* *INDENT-OFF* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700142 CLIB_PACKED (struct {
143 u32 checksum_data_32[5];
144 });
Dave Barachd7cb1b52016-12-09 09:52:16 -0500145 /* *INDENT-ON* */
Ed Warnickecb9cada2015-12-08 15:45:58 -0700146} ip4_header_t;
147
148/* Value of ip_version_and_header_length for packets w/o options. */
149#define IP4_VERSION_AND_HEADER_LENGTH_NO_OPTIONS \
150 ((4 << 4) | (sizeof (ip4_header_t) / sizeof (u32)))
151
Neale Rannsc667ffd2018-06-27 18:59:03 -0700152#define IP4_ROUTER_ALERT_OPTION 20
153
Klement Sekeraf126e742019-10-10 09:46:06 +0000154always_inline u16
Neale Rannsd69f4392018-08-31 06:30:16 -0400155ip4_get_fragment_offset (const ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500156{
157 return clib_net_to_host_u16 (i->flags_and_fragment_offset) & 0x1fff;
158}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700159
Klement Sekeraf126e742019-10-10 09:46:06 +0000160always_inline u16
Neale Rannsd69f4392018-08-31 06:30:16 -0400161ip4_get_fragment_more (const ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500162{
163 return clib_net_to_host_u16 (i->flags_and_fragment_offset) &
164 IP4_HEADER_FLAG_MORE_FRAGMENTS;
165}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700166
167always_inline int
Neale Rannsd69f4392018-08-31 06:30:16 -0400168ip4_is_fragment (const ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500169{
170 return (i->flags_and_fragment_offset &
171 clib_net_to_host_u16 (0x1fff | IP4_HEADER_FLAG_MORE_FRAGMENTS));
172}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700173
174always_inline int
Neale Rannsd69f4392018-08-31 06:30:16 -0400175ip4_is_first_fragment (const ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500176{
177 return (i->flags_and_fragment_offset &
178 clib_net_to_host_u16 (0x1fff | IP4_HEADER_FLAG_MORE_FRAGMENTS)) ==
179 clib_net_to_host_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS);
180}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700181
182/* Fragment offset in bytes. */
183always_inline int
Neale Rannsd69f4392018-08-31 06:30:16 -0400184ip4_get_fragment_offset_bytes (const ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500185{
186 return 8 * ip4_get_fragment_offset (i);
187}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700188
189always_inline int
Neale Rannsd69f4392018-08-31 06:30:16 -0400190ip4_header_bytes (const ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500191{
192 return sizeof (u32) * (i->ip_version_and_header_length & 0xf);
193}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700194
195always_inline void *
196ip4_next_header (ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500197{
198 return (void *) i + ip4_header_bytes (i);
199}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700200
Jieqiang Wangc8833b22020-08-07 14:18:04 +0000201/* Turn off array bounds check due to ip4_header_t
202 option field operations. */
203
204/* *INDENT-OFF* */
205WARN_OFF(array-bounds)
206/* *INDENT-ON* */
207
Ed Warnickecb9cada2015-12-08 15:45:58 -0700208always_inline u16
209ip4_header_checksum (ip4_header_t * i)
210{
Damjan Marione5f00502020-07-16 00:48:55 +0200211 int option_len = (i->ip_version_and_header_length & 0xf) - 5;
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200212 uword sum = 0;
213#if uword_bits == 64
214 u32 *iphdr = (u32 *) i;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700215
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200216 sum += iphdr[0];
217 sum += iphdr[1];
218 sum += *(u16 *) (iphdr + 2);
219 /* skip checksum */
220 sum += iphdr[3];
221 sum += iphdr[4];
Ed Warnickecb9cada2015-12-08 15:45:58 -0700222
Damjan Marione5f00502020-07-16 00:48:55 +0200223 if (PREDICT_FALSE (option_len > 0))
224 switch (option_len)
225 {
226 case 10:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200227 sum += iphdr[14];
Damjan Marione5f00502020-07-16 00:48:55 +0200228 case 9:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200229 sum += iphdr[13];
Damjan Marione5f00502020-07-16 00:48:55 +0200230 case 8:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200231 sum += iphdr[12];
Damjan Marione5f00502020-07-16 00:48:55 +0200232 case 7:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200233 sum += iphdr[11];
Damjan Marione5f00502020-07-16 00:48:55 +0200234 case 6:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200235 sum += iphdr[10];
Damjan Marione5f00502020-07-16 00:48:55 +0200236 case 5:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200237 sum += iphdr[9];
Damjan Marione5f00502020-07-16 00:48:55 +0200238 case 4:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200239 sum += iphdr[8];
Damjan Marione5f00502020-07-16 00:48:55 +0200240 case 3:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200241 sum += iphdr[7];
Damjan Marione5f00502020-07-16 00:48:55 +0200242 case 2:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200243 sum += iphdr[6];
Damjan Marione5f00502020-07-16 00:48:55 +0200244 case 1:
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200245 sum += iphdr[5];
Damjan Marione5f00502020-07-16 00:48:55 +0200246 default:
247 break;
248 }
Ed Warnickecb9cada2015-12-08 15:45:58 -0700249
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200250 sum = ((u32) sum) + (sum >> 32);
251#else
252 u16 *iphdr = (u16 *) i;
253
254 sum += iphdr[0];
255 sum += iphdr[1];
256 sum += iphdr[2];
257 sum += iphdr[3];
258 sum += iphdr[4];
259 /* skip checksum */
260 sum += iphdr[6];
261 sum += iphdr[7];
262 sum += iphdr[8];
263 sum += iphdr[9];
264
265 if (PREDICT_FALSE (option_len > 0))
266 switch (option_len)
267 {
268 case 10:
269 sum += iphdr[28];
270 sum += iphdr[29];
271 case 9:
272 sum += iphdr[26];
273 sum += iphdr[27];
274 case 8:
275 sum += iphdr[24];
276 sum += iphdr[25];
277 case 7:
278 sum += iphdr[22];
279 sum += iphdr[23];
280 case 6:
281 sum += iphdr[20];
282 sum += iphdr[21];
283 case 5:
284 sum += iphdr[18];
285 sum += iphdr[19];
286 case 4:
287 sum += iphdr[16];
288 sum += iphdr[17];
289 case 3:
290 sum += iphdr[14];
291 sum += iphdr[15];
292 case 2:
293 sum += iphdr[12];
294 sum += iphdr[13];
295 case 1:
296 sum += iphdr[10];
297 sum += iphdr[11];
298 default:
299 break;
300 }
301#endif
302
Damjan Marione5f00502020-07-16 00:48:55 +0200303 sum = ((u16) sum) + (sum >> 16);
304 sum = ((u16) sum) + (sum >> 16);
Damjan Marion9a0f2a52020-07-16 16:22:48 +0200305 return ~((u16) sum);
Ed Warnickecb9cada2015-12-08 15:45:58 -0700306}
307
Jieqiang Wangc8833b22020-08-07 14:18:04 +0000308/* *INDENT-OFF* */
309WARN_ON(array-bounds)
310/* *INDENT-ON* */
311
Neale Ranns95346962019-11-25 13:04:44 +0000312always_inline void
313ip4_header_set_dscp (ip4_header_t * ip4, ip_dscp_t dscp)
314{
315 ip4->tos &= ~0xfc;
316 /* not masking the dscp value to save th instruction
317 * it shouldn't b necessary since the argument is an enum
318 * whose range is therefore constrained in the CP. in the
319 * DP it will have been taken from another packet, so again
320 * constrained in value */
321 ip4->tos |= dscp << IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT;
322}
323
324always_inline void
325ip4_header_set_ecn (ip4_header_t * ip4, ip_ecn_t ecn)
326{
327 ip4->tos &= ~IP_PACKET_TC_FIELD_ECN_MASK;
328 ip4->tos |= ecn;
329}
330
331always_inline void
332ip4_header_set_ecn_w_chksum (ip4_header_t * ip4, ip_ecn_t ecn)
333{
334 ip_csum_t sum = ip4->checksum;
335 u8 old = ip4->tos;
336 u8 new = (old & ~IP_PACKET_TC_FIELD_ECN_MASK) | ecn;
337
338 sum = ip_csum_update (sum, old, new, ip4_header_t, tos);
339 ip4->checksum = ip_csum_fold (sum);
340 ip4->tos = new;
341}
342
343always_inline ip_dscp_t
344ip4_header_get_dscp (const ip4_header_t * ip4)
345{
346 return (ip4->tos >> IP_PACKET_TC_FIELD_DSCP_BIT_SHIFT);
347}
348
349always_inline ip_ecn_t
350ip4_header_get_ecn (const ip4_header_t * ip4)
351{
352 return (ip4->tos & IP_PACKET_TC_FIELD_ECN_MASK);
353}
354
355always_inline void
356ip4_header_set_df (ip4_header_t * ip4)
357{
358 ip4->flags_and_fragment_offset |=
359 clib_host_to_net_u16 (IP4_HEADER_FLAG_DONT_FRAGMENT);
360}
361
362always_inline void
363ip4_header_clear_df (ip4_header_t * ip4)
364{
365 ip4->flags_and_fragment_offset &=
366 ~clib_host_to_net_u16 (IP4_HEADER_FLAG_DONT_FRAGMENT);
367}
368
369always_inline u8
Neale Rannse5b94dd2019-12-31 05:13:14 +0000370ip4_header_get_df (const ip4_header_t * ip4)
Neale Ranns95346962019-11-25 13:04:44 +0000371{
372 return (! !(ip4->flags_and_fragment_offset &
373 clib_host_to_net_u16 (IP4_HEADER_FLAG_DONT_FRAGMENT)));
374}
375
Ed Warnickecb9cada2015-12-08 15:45:58 -0700376static inline uword
377ip4_header_checksum_is_valid (ip4_header_t * i)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500378{
379 return i->checksum == ip4_header_checksum (i);
380}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700381
382#define ip4_partial_header_checksum_x1(ip0,sum0) \
383do { \
384 if (BITS (ip_csum_t) > 32) \
385 { \
386 sum0 = ip0->checksum_data_64[0]; \
387 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64[1]); \
388 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64_32[0]); \
389 } \
390 else \
391 { \
392 sum0 = ip0->checksum_data_32[0]; \
393 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[1]); \
394 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[2]); \
395 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[3]); \
396 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[4]); \
397 } \
398} while (0)
399
400#define ip4_partial_header_checksum_x2(ip0,ip1,sum0,sum1) \
401do { \
402 if (BITS (ip_csum_t) > 32) \
403 { \
404 sum0 = ip0->checksum_data_64[0]; \
405 sum1 = ip1->checksum_data_64[0]; \
406 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64[1]); \
407 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_64[1]); \
408 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_64_32[0]); \
409 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_64_32[0]); \
410 } \
411 else \
412 { \
413 sum0 = ip0->checksum_data_32[0]; \
414 sum1 = ip1->checksum_data_32[0]; \
415 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[1]); \
416 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[1]); \
417 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[2]); \
418 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[2]); \
419 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[3]); \
420 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[3]); \
421 sum0 = ip_csum_with_carry (sum0, ip0->checksum_data_32[4]); \
422 sum1 = ip_csum_with_carry (sum1, ip1->checksum_data_32[4]); \
423 } \
424} while (0)
425
426always_inline uword
Neale Rannsd69f4392018-08-31 06:30:16 -0400427ip4_address_is_multicast (const ip4_address_t * a)
Dave Barachd7cb1b52016-12-09 09:52:16 -0500428{
429 return (a->data[0] & 0xf0) == 0xe0;
430}
Ed Warnickecb9cada2015-12-08 15:45:58 -0700431
Neale Rannsd724e4f2020-04-02 15:02:16 +0000432always_inline uword
433ip4_address_is_global_broadcast (const ip4_address_t * a)
434{
435 return (a->as_u32) == 0xffffffff;
436}
437
Ed Warnickecb9cada2015-12-08 15:45:58 -0700438always_inline void
Dave Barachd7cb1b52016-12-09 09:52:16 -0500439ip4_multicast_address_set_for_group (ip4_address_t * a,
440 ip_multicast_group_t g)
Ed Warnickecb9cada2015-12-08 15:45:58 -0700441{
Damjan Marion2c29d752015-12-18 10:26:56 +0100442 ASSERT ((u32) g < (1 << 28));
Ed Warnickecb9cada2015-12-08 15:45:58 -0700443 a->as_u32 = clib_host_to_net_u32 ((0xe << 28) + g);
444}
445
446always_inline void
Neale Rannsd69f4392018-08-31 06:30:16 -0400447ip4_multicast_ethernet_address (u8 * ethernet_address,
448 const ip4_address_t * a)
Eyal Baric5b13602016-11-24 19:42:43 +0200449{
Neale Rannsd69f4392018-08-31 06:30:16 -0400450 const u8 *d = a->as_u8;
Eyal Baric5b13602016-11-24 19:42:43 +0200451
452 ethernet_address[0] = 0x01;
453 ethernet_address[1] = 0x00;
454 ethernet_address[2] = 0x5e;
455 ethernet_address[3] = d[1] & 0x7f;
456 ethernet_address[4] = d[2];
457 ethernet_address[5] = d[3];
458}
459
460always_inline void
Ed Warnickecb9cada2015-12-08 15:45:58 -0700461ip4_tcp_reply_x1 (ip4_header_t * ip0, tcp_header_t * tcp0)
462{
463 u32 src0, dst0;
464
465 src0 = ip0->src_address.data_u32;
466 dst0 = ip0->dst_address.data_u32;
467 ip0->src_address.data_u32 = dst0;
468 ip0->dst_address.data_u32 = src0;
469
Dave Barach68b0fb02017-02-28 15:15:56 -0500470 src0 = tcp0->src;
471 dst0 = tcp0->dst;
472 tcp0->src = dst0;
473 tcp0->dst = src0;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700474}
475
476always_inline void
477ip4_tcp_reply_x2 (ip4_header_t * ip0, ip4_header_t * ip1,
478 tcp_header_t * tcp0, tcp_header_t * tcp1)
479{
480 u32 src0, dst0, src1, dst1;
481
482 src0 = ip0->src_address.data_u32;
483 src1 = ip1->src_address.data_u32;
484 dst0 = ip0->dst_address.data_u32;
485 dst1 = ip1->dst_address.data_u32;
486 ip0->src_address.data_u32 = dst0;
487 ip1->src_address.data_u32 = dst1;
488 ip0->dst_address.data_u32 = src0;
489 ip1->dst_address.data_u32 = src1;
490
Dave Barach68b0fb02017-02-28 15:15:56 -0500491 src0 = tcp0->src;
492 src1 = tcp1->src;
493 dst0 = tcp0->dst;
494 dst1 = tcp1->dst;
495 tcp0->src = dst0;
496 tcp1->src = dst1;
497 tcp0->dst = src0;
498 tcp1->dst = src1;
Ed Warnickecb9cada2015-12-08 15:45:58 -0700499}
500
501#endif /* included_ip4_packet_h */
Dave Barachd7cb1b52016-12-09 09:52:16 -0500502
503/*
504 * fd.io coding-style-patch-verification: ON
505 *
506 * Local Variables:
507 * eval: (c-set-style "gnu")
508 * End:
509 */