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

Function m_append

freebsd/kern/uipc_mbuf.c:1180–1217  ·  view source on GitHub ↗

* Append the specified data to the indicated mbuf chain, * Extend the mbuf chain if the new data does not fit in * existing space. * * Return 1 if able to complete the job; otherwise 0. */

Source from the content-addressed store, hash-verified

1178 * Return 1 if able to complete the job; otherwise 0.
1179 */
1180int
1181m_append(struct mbuf *m0, int len, c_caddr_t cp)
1182{
1183 struct mbuf *m, *n;
1184 int remainder, space;
1185
1186 for (m = m0; m->m_next != NULL; m = m->m_next)
1187 ;
1188 remainder = len;
1189 space = M_TRAILINGSPACE(m);
1190 if (space > 0) {
1191 /*
1192 * Copy into available space.
1193 */
1194 if (space > remainder)
1195 space = remainder;
1196 bcopy(cp, mtod(m, caddr_t) + m->m_len, space);
1197 m->m_len += space;
1198 cp += space, remainder -= space;
1199 }
1200 while (remainder > 0) {
1201 /*
1202 * Allocate a new mbuf; could check space
1203 * and allocate a cluster instead.
1204 */
1205 n = m_get(M_NOWAIT, m->m_type);
1206 if (n == NULL)
1207 break;
1208 n->m_len = min(MLEN, remainder);
1209 bcopy(cp, mtod(n, caddr_t), n->m_len);
1210 cp += n->m_len, remainder -= n->m_len;
1211 m->m_next = n;
1212 m = n;
1213 }
1214 if (m0->m_flags & M_PKTHDR)
1215 m0->m_pkthdr.len += len - remainder;
1216 return (remainder == 0);
1217}
1218
1219/*
1220 * Apply function f to the data in an mbuf chain starting "off" bytes from

Callers 15

tkip_enmicFunction · 0.85
tkip_encryptFunction · 0.85
wep_encryptFunction · 0.85
ccmp_encryptFunction · 0.85
cvm_oct_xmitFunction · 0.85
cpswp_tx_enqueueFunction · 0.85
iflib_ether_padFunction · 0.85
ether_8021q_frameFunction · 0.85

Calls 2

minFunction · 0.85
m_getFunction · 0.50

Tested by

no test coverage detected