-.. code-block:: c
-
- static inline struct rte_mbuf *mcast_out_pkt(struct rte_mbuf *pkt, int use_clone)
- {
- struct rte_mbuf *hdr;
-
- /* Create new mbuf for the header. */
-
- if (unlikely ((hdr = rte_pktmbuf_alloc(header_pool)) == NULL))
- return NULL;
-
- /* If requested, then make a new clone packet. */
-
- if (use_clone != 0 && unlikely ((pkt = rte_pktmbuf_clone(pkt, clone_pool)) == NULL)) {
- rte_pktmbuf_free(hdr);
- return NULL;
- }
-
- /* prepend new header */
-
- hdr->pkt.next = pkt;
-
- /* update header's fields */
-
- hdr->pkt.pkt_len = (uint16_t)(hdr->pkt.data_len + pkt->pkt.pkt_len);
- hdr->pkt.nb_segs = pkt->pkt.nb_segs + 1;
-
- /* copy metadata from source packet */
-
- hdr->pkt.in_port = pkt->pkt.in_port;
- hdr->pkt.vlan_macip = pkt->pkt.vlan_macip;
- hdr->pkt.hash = pkt->pkt.hash;
- hdr->ol_flags = pkt->ol_flags;
- rte_mbuf_sanity_check(hdr, RTE_MBUF_PKT, 1);
-
- return hdr;
- }
+.. literalinclude:: ../../../examples/ipv4_multicast/main.c
+ :language: c
+ :start-after: mcast_out_pkt 8<
+ :end-before: >8 End of mcast_out_kt.