| * SPDX-License-Identifier: Apache-2.0 |
| * Copyright(c) 2021 Cisco Systems, Inc. |
| #ifndef included_ip_psh_cksum_h |
| #define included_ip_psh_cksum_h |
| #include <vppinfra/vector/ip_csum.h> |
| STATIC_ASSERT (sizeof (ip4_psh_t) == 12, "ipv4 pseudo header is 12B"); |
| STATIC_ASSERT (sizeof (ip6_psh_t) == 40, "ipv6 pseudo header is 40B"); |
| ip4_pseudo_header_cksum (ip4_header_t *ip4) |
| psh.src = ip4->src_address; |
| psh.dst = ip4->dst_address; |
| psh.proto = ip4->protocol; |
| psh.l4len = clib_host_to_net_u16 (clib_net_to_host_u16 (ip4->length) - |
| return ~(clib_ip_csum ((u8 *) &psh, sizeof (ip4_psh_t))); |
| ip6_pseudo_header_cksum (ip6_header_t *ip6) |
| psh.src = ip6->src_address; |
| psh.dst = ip6->dst_address; |
| psh.l4len = ip6->payload_length; |
| psh.proto = clib_host_to_net_u32 ((u32) ip6->protocol); |
| return ~(clib_ip_csum ((u8 *) &psh, sizeof (ip6_psh_t))); |
| #endif /* included_ip_psh_cksum_h */ |