MCPcopy Create free account
hub / github.com/F-Stack/f-stack / copypktopts

Function copypktopts

freebsd/netinet6/ip6_output.c:2746–2783  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2744} while (/*CONSTCOND*/ 0)
2745
2746static int
2747copypktopts(struct ip6_pktopts *dst, struct ip6_pktopts *src, int canwait)
2748{
2749 if (dst == NULL || src == NULL) {
2750 printf("ip6_clearpktopts: invalid argument\n");
2751 return (EINVAL);
2752 }
2753
2754 dst->ip6po_hlim = src->ip6po_hlim;
2755 dst->ip6po_tclass = src->ip6po_tclass;
2756 dst->ip6po_flags = src->ip6po_flags;
2757 dst->ip6po_minmtu = src->ip6po_minmtu;
2758 dst->ip6po_prefer_tempaddr = src->ip6po_prefer_tempaddr;
2759 if (src->ip6po_pktinfo) {
2760 dst->ip6po_pktinfo = malloc(sizeof(*dst->ip6po_pktinfo),
2761 M_IP6OPT, canwait);
2762 if (dst->ip6po_pktinfo == NULL)
2763 goto bad;
2764 *dst->ip6po_pktinfo = *src->ip6po_pktinfo;
2765 }
2766 if (src->ip6po_nexthop) {
2767 dst->ip6po_nexthop = malloc(src->ip6po_nexthop->sa_len,
2768 M_IP6OPT, canwait);
2769 if (dst->ip6po_nexthop == NULL)
2770 goto bad;
2771 bcopy(src->ip6po_nexthop, dst->ip6po_nexthop,
2772 src->ip6po_nexthop->sa_len);
2773 }
2774 PKTOPT_EXTHDRCPY(ip6po_hbh);
2775 PKTOPT_EXTHDRCPY(ip6po_dest1);
2776 PKTOPT_EXTHDRCPY(ip6po_dest2);
2777 PKTOPT_EXTHDRCPY(ip6po_rthdr); /* not copy the cached route */
2778 return (0);
2779
2780 bad:
2781 ip6_clearpktopts(dst, -1);
2782 return (ENOBUFS);
2783}
2784#undef PKTOPT_EXTHDRCPY
2785
2786struct ip6_pktopts *

Callers 2

ip6_copypktoptsFunction · 0.85
ip6_setpktoptsFunction · 0.85

Calls 3

mallocFunction · 0.85
ip6_clearpktoptsFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected