1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
10 * Contains functions/structures/macros to manipulate IPv4/IPv6 headers
11 * used internally by ipsec library.
15 * Move preceding (L3) headers down to remove ESP header and IV.
18 remove_esph(char *np, char *op, uint32_t hlen)
22 for (i = hlen; i-- != 0; np[i] = op[i])
27 * Move preceding (L3) headers up to free space for ESP header and IV.
30 insert_esph(char *np, char *op, uint32_t hlen)
34 for (i = 0; i != hlen; i++)
38 /* update original ip header fields for transport case */
40 update_trs_l3hdr(const struct rte_ipsec_sa *sa, void *p, uint32_t plen,
41 uint32_t l2len, uint32_t l3len, uint8_t proto)
47 if ((sa->type & RTE_IPSEC_SATP_IPV_MASK) == RTE_IPSEC_SATP_IPV4) {
49 rc = v4h->next_proto_id;
50 v4h->next_proto_id = proto;
51 v4h->total_length = rte_cpu_to_be_16(plen - l2len);
52 } else if (l3len == sizeof(*v6h)) {
56 v6h->payload_len = rte_cpu_to_be_16(plen - l2len -
58 /* need to add support for IPv6 with options */
65 /* update original and new ip header fields for tunnel case */
67 update_tun_l3hdr(const struct rte_ipsec_sa *sa, void *p, uint32_t plen,
68 uint32_t l2len, rte_be16_t pid)
73 if (sa->type & RTE_IPSEC_SATP_MODE_TUNLV4) {
76 v4h->total_length = rte_cpu_to_be_16(plen - l2len);
79 v6h->payload_len = rte_cpu_to_be_16(plen - l2len -