diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2022-07-18 11:21:05 +0000 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2022-07-25 14:03:48 +0000 |
commit | 8636a320413c12d1747c695ac594ca643ac539ba (patch) | |
tree | 9c0ba086b2f92827a0a32585f3b52a839e574796 /extras/libmemif/examples/common/icmp_proto.c | |
parent | c8cd079a0004b75892a08c7cac9a48b39e24e580 (diff) |
libmemif: fix chain buffer support
Type: fix
This patch fixes chain buffer support as transmit side
missing to set the flag to the descriptor in case of
chain buffers.
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I73ff11be69a388f14fea39a19272d8eb76148fba
Diffstat (limited to 'extras/libmemif/examples/common/icmp_proto.c')
-rw-r--r-- | extras/libmemif/examples/common/icmp_proto.c | 59 |
1 files changed, 7 insertions, 52 deletions
diff --git a/extras/libmemif/examples/common/icmp_proto.c b/extras/libmemif/examples/common/icmp_proto.c index fafc8e425b9..70825eafdb2 100644 --- a/extras/libmemif/examples/common/icmp_proto.c +++ b/extras/libmemif/examples/common/icmp_proto.c @@ -198,54 +198,6 @@ resolve_icmp (struct icmphdr *icmp, void *icmp_resp) return sizeof (struct icmphdr); } -int -resolve_packet (void *in_pck, ssize_t in_size, void *out_pck, - uint32_t *out_size, uint8_t ip_addr[4], uint8_t hw_addr[6]) -{ - struct ether_header *eh; - struct ether_arp *eah; - struct iphdr *ip, *ip_out; - struct icmphdr *icmp; - *out_size = 0; - - if ((in_pck == NULL) || (out_pck == NULL)) - return -1; - - eh = (struct ether_header *) in_pck; - *out_size = resolve_eth (eh, out_pck, hw_addr); - - if (eh->ether_type == 0x0608) - { - eah = (struct ether_arp *) (in_pck + *out_size); - *out_size += resolve_eth_arp (eah, out_pck + *out_size, ip_addr); - } - else if (eh->ether_type == 0x0008) - { -#ifdef ICMP_DBG - print_packet (in_pck + *out_size); -#endif - ip = (struct iphdr *) (in_pck + *out_size); - ip_out = (struct iphdr *) (out_pck + *out_size); - *out_size += resolve_ip (ip, out_pck + *out_size, ip_addr); - if (ip->protocol == 1) - { - icmp = (struct icmphdr *) (in_pck + *out_size); - *out_size += resolve_icmp (icmp, out_pck + *out_size); - ((struct icmphdr *) (out_pck + *out_size - sizeof (struct icmphdr))) - ->checksum = cksum (out_pck + *out_size - sizeof (struct icmphdr), - sizeof (struct icmphdr)); - /* payload */ - memcpy (out_pck + *out_size, in_pck + *out_size, - in_size - *out_size); - *out_size = in_size; - ip_out->tot_len = - __bswap_16 (*out_size - sizeof (struct ether_header)); - ip_out->check = cksum (ip_out, sizeof (struct iphdr)); - } - } - return 0; -} - static ssize_t generate_eth (struct ether_header *eh, uint8_t hw_daddr[6]) { @@ -373,8 +325,8 @@ generate_packet2 (void *pck, uint32_t *size, uint8_t saddr[4], while (0) int -resolve_packet_zero_copy (void *pck, uint32_t *size, uint8_t ip_addr[4], - uint8_t hw_addr[6]) +resolve_packet (void *pck, uint32_t *size, uint8_t ip_addr[4], + uint8_t hw_addr[6]) { struct ether_header *eh; struct ether_arp *eah; @@ -385,6 +337,10 @@ resolve_packet_zero_copy (void *pck, uint32_t *size, uint8_t ip_addr[4], if (pck == NULL) return 0; +#ifdef ICMP_DBG + print_packet (pck); +#endif + GET_HEADER (eh, struct ether_header, pck, offset); memcpy (eh->ether_dhost, eh->ether_shost, 6); @@ -450,8 +406,7 @@ resolve_packet_zero_copy (void *pck, uint32_t *size, uint8_t ip_addr[4], } int -resolve_packet_zero_copy_add_encap (void **pck_, uint32_t *size, - uint8_t ip_addr[4]) +resolve_packet_with_encap (void **pck_, uint32_t *size, uint8_t ip_addr[4]) { struct ether_header *eh; struct iphdr *ip; |