net/icmpv6: Add a new function to finalize the ICMPv6 packet

Function names will be normalized then by the couple create/finalize.
This one only sets the checksum.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2018-12-17 15:34:00 +01:00 committed by Jukka Rissanen
parent 7e25568a22
commit 2ad71c7701
2 changed files with 18 additions and 0 deletions

View file

@ -140,6 +140,23 @@ int net_icmpv6_set_chksum(struct net_pkt *pkt)
return 0;
}
int net_icmpv6_finalize(struct net_pkt *pkt)
{
NET_PKT_DATA_ACCESS_CONTIGUOUS_DEFINE(icmp_access,
struct net_icmp_hdr);
struct net_icmp_hdr *icmp_hdr;
icmp_hdr = (struct net_icmp_hdr *)net_pkt_get_data_new(pkt,
&icmp_access);
if (!icmp_hdr) {
return -ENOBUFS;
}
icmp_hdr->chksum = net_calc_chksum_icmpv6(pkt);
return net_pkt_set_data(pkt, &icmp_access);
}
int net_icmpv6_get_hdr(struct net_pkt *pkt, struct net_icmp_hdr *hdr)
{
struct net_buf *frag;

View file

@ -176,6 +176,7 @@ int net_icmpv6_get_hdr(struct net_pkt *pkt, struct net_icmp_hdr *hdr);
int net_icmpv6_set_hdr(struct net_pkt *pkt, struct net_icmp_hdr *hdr);
int net_icmpv6_set_chksum(struct net_pkt *pkt);
int net_icmpv6_finalize(struct net_pkt *pkt);
int net_icmpv6_get_ns_hdr(struct net_pkt *pkt, struct net_icmpv6_ns_hdr *hdr);
int net_icmpv6_set_ns_hdr(struct net_pkt *pkt, struct net_icmpv6_ns_hdr *hdr);