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

Function m_copypacket

freebsd/kern/uipc_mbuf.c:565–610  ·  view source on GitHub ↗

* Copy an entire packet, including header (which must be present). * An optimization of the common case `m_copym(m, 0, M_COPYALL, how)'. * Note that the copy is read-only, because clusters are not copied, * only their reference counts are incremented. * Preserve alignment of the first mbuf so if the creator has left * some room at the beginning (e.g. for inserting protocol headers) * the cop

Source from the content-addressed store, hash-verified

563 * the copies still have the room available.
564 */
565struct mbuf *
566m_copypacket(struct mbuf *m, int how)
567{
568 struct mbuf *top, *n, *o;
569
570 MBUF_CHECKSLEEP(how);
571 n = m_get(how, m->m_type);
572 top = n;
573 if (n == NULL)
574 goto nospace;
575
576 if (!m_dup_pkthdr(n, m, how))
577 goto nospace;
578 n->m_len = m->m_len;
579 if (m->m_flags & (M_EXT|M_EXTPG)) {
580 n->m_data = m->m_data;
581 mb_dupcl(n, m);
582 } else {
583 n->m_data = n->m_pktdat + (m->m_data - m->m_pktdat );
584 bcopy(mtod(m, char *), mtod(n, char *), n->m_len);
585 }
586
587 m = m->m_next;
588 while (m) {
589 o = m_get(how, m->m_type);
590 if (o == NULL)
591 goto nospace;
592
593 n->m_next = o;
594 n = n->m_next;
595
596 n->m_len = m->m_len;
597 if (m->m_flags & (M_EXT|M_EXTPG)) {
598 n->m_data = m->m_data;
599 mb_dupcl(n, m);
600 } else {
601 bcopy(mtod(m, char *), mtod(n, char *), n->m_len);
602 }
603
604 m = m->m_next;
605 }
606 return top;
607nospace:
608 m_freem(top);
609 return (NULL);
610}
611
612static void
613m_copyfromunmapped(const struct mbuf *m, int off, int len, caddr_t cp)

Callers 12

pf_send_icmpFunction · 0.85
ieee80211_dwds_mcastFunction · 0.85
X_ip_mforwardFunction · 0.85
phyint_sendFunction · 0.85
pim_register_prepareFunction · 0.85
bridge_outputFunction · 0.85
bridge_spanFunction · 0.85
pppoe_startFunction · 0.85
ng_pppoe_rcvdataFunction · 0.85
ng_pppoe_rcvdata_etherFunction · 0.85
pppoe_tickerFunction · 0.85
ng_source_dup_modFunction · 0.85

Calls 4

m_dup_pkthdrFunction · 0.85
mb_dupclFunction · 0.85
m_freemFunction · 0.70
m_getFunction · 0.50

Tested by

no test coverage detected