• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/smb-759.0/lib/smb/

Lines Matching defs:mbuf

35 /* mbuf flags */
56 * Frees a single mbuf. Not commonly used outside of the file because it
59 * mbuf - The mbuf to free.
61 * The next mbuf in the chain.
63 mbuf_t mbuf_free(mbuf_t mbuf)
67 if (mbuf == NULL)
70 next = mbuf->m_next;
71 if (mbuf->m_type == MBUF_TYPE_FREE) {
74 if (mbuf->m_flags & M_EXT) {
75 if (mbuf->m_extfree)
76 mbuf->m_extfree(mbuf->m_extarg, mbuf->m_maxlen, (caddr_t)mbuf->m_data);
77 } else if (mbuf->m_data) {
78 free(mbuf->m_data);
80 mbuf->m_next = NULL;
81 mbuf->m_type = MBUF_TYPE_FREE;
82 mbuf->m_data = NULL;
83 free(mbuf);
93 * how - How to create the mbuf, always MBUF_WAITOK in userland.
94 * type - Type of mbuf to create, always MBUF_TYPE_DATA in userland.
95 * mbuf - Return location for the mbuf we created.
96 * maxlen - The data size that should be allocated for this mbuf
101 int smb_mbuf_get(uint32_t how, uint32_t type, mbuf_t *mbuf, size_t maxlen)
122 *mbuf = m;
131 * mbuf - The first mbuf in the chain to free.
133 void mbuf_freem(mbuf_t mbuf)
137 while (mbuf) {
138 m = mbuf_free(mbuf);
139 mbuf = m;
146 * Allocates an mbuf without a cluster for external data. Sets a flag to
149 * how - How to create the mbuf, always MBUF_WAITOK in userland.
150 * type - Type of mbuf to create, always MBUF_TYPE_DATA in userland.
151 * mbuf - Return location for the mbuf we created.
155 int mbuf_gethdr(uint32_t how, uint32_t type, mbuf_t *mbuf)
157 int error = smb_mbuf_get(how, type, mbuf, getpagesize());
161 (*mbuf)->m_flags |= M_PKTHDR | M_EOR;
168 * Allocates an mbuf without a cluster for external data.
170 * how - How to create the mbuf, always MBUF_WAITOK in userland.
171 * type - Type of mbuf to create, always MBUF_TYPE_DATA in userland.
172 * mbuf - Return location for the mbuf we created.
176 int mbuf_get(uint32_t how, uint32_t type, mbuf_t *mbuf)
178 return smb_mbuf_get(how, type, mbuf, getpagesize());
184 * Allocate a cluster of the requested size and attach it to an mbuf for use as
185 * external data. If mbuf points to a NULL mbuf_t, an mbuf will be allocated for
186 * you. If mbuf points to a non-NULL mbuf_t, mbuf_getcluster may return a different
189 * how - How to create the mbuf, always MBUF_WAITOK in userland.
190 * type - Type of mbuf to create, always MBUF_TYPE_DATA in userland.
192 * any size, unlike the kernel kpi mbuf code.
193 * mbuf - The mbuf the cluster will be attached to.
197 int mbuf_getcluster(uint32_t how, uint32_t type, size_t size, mbuf_t *mbuf)
200 /* We currently relocate the mbuf always */
201 if (*mbuf) {
202 mbuf_freem( *mbuf);
203 *mbuf = NULL;
205 error = smb_mbuf_get(how, type, mbuf, size);
206 if (!error && *mbuf)
207 (*mbuf)->m_flags |= M_PKTHDR | M_EOR;
214 * Attach an external buffer as a cluster for an mbuf. If mbuf points to a NULL
215 * mbuf_t, an mbuf will be allocated for you. If mbuf points to a non-NULL mbuf_t,
216 * the user-supplied mbuf will be used instead.
218 * how - How to create the mbuf, always MBUF_WAITOK in userland.
219 * type - Type of mbuf to create, always MBUF_TYPE_DATA in userland.
220 * mbuf - Pointer to the address of the mbuf; if NULL, an mbuf will be
221 * allocated, otherwise, it must point to a valid mbuf address.
224 * to defined a routine that will be invoked when the mbuf is
228 * is called at the time the mbuf is freed.
233 mbuf_t *mbuf, void * extbuf,
241 } else if (*mbuf == NULL) {
242 error = smb_mbuf_get(how, type, mbuf, 0);
243 } else if ((*mbuf)->m_data) {
244 free((*mbuf)->m_data);
245 (*mbuf)->m_data = NULL;
250 (*mbuf)->m_flags = M_EXT | M_PKTHDR | M_EOR;
251 (*mbuf)->m_maxlen = extsize;
252 (*mbuf)->m_data = extbuf;
253 (*mbuf)->m_extfree = extfree;
254 (*mbuf)->m_extarg = extarg;
261 * Gets the length of data in this mbuf.
263 * mbuf - The mbuf.
265 * size_t - The length of data in this mbuf.
267 size_t mbuf_len(const mbuf_t mbuf)
269 if (mbuf) {
270 return mbuf->m_len;
279 * Retrieves the maximum length of data that may be stored in this mbuf.
281 * mbuf - The mbuf.
283 * size_t - The maximum length of data for this mbuf.
285 size_t mbuf_maxlen(const mbuf_t mbuf)
287 if (mbuf) {
288 return mbuf->m_maxlen;
298 * the space available in the mbuf.
300 * mbuf - The mbuf.
303 void mbuf_setlen(mbuf_t mbuf, size_t len)
305 if (mbuf) {
306 mbuf->m_len = len;
315 * mbuf - The mbuf containing the packet header with the length to
320 size_t mbuf_pkthdr_len(const mbuf_t mbuf)
322 return mbuf->m_pkthdr_len;
330 * mbuf - The mbuf containing the packet header.
332 void mbuf_pkthdr_setlen(mbuf_t mbuf, size_t len)
334 mbuf->m_pkthdr_len = len;
342 * mbuf - The mbuf containing the packet header.
345 void mbuf_pkthdr_adjustlen(mbuf_t mbuf, int amount)
347 mbuf->m_pkthdr_len += amount;
353 * Returns the next mbuf in the chain.
355 * mbuf - The mbuf
357 * mbuf_t - The next mbuf in the chain.
359 mbuf_t mbuf_next(const mbuf_t mbuf)
361 if (mbuf) {
362 return mbuf->m_next;
371 * Sets the next mbuf in the chain.
373 * mbuf - The mbuf
374 * next - The new next mbuf.
378 int mbuf_setnext(mbuf_t mbuf, mbuf_t next)
382 if (mbuf->m_flags & M_EOR) {
383 mbuf->m_flags &= ~M_EOR;
386 mbuf->m_next = next;
393 * Returns a pointer to the start of data in this mbuf. There may be additional
395 * contiguous if it spans more than one mbuf. In addition, data that is virtually
398 * of data available in this mbuf. If a data structure you want to access stradles
399 * two mbufs in a chain, either use mbuf_pullup to get the data contiguous in one mbuf
400 * or copy the pieces of data from each mbuf in to a contiguous buffer. Using
402 * if you don't make sure there is space in the mbuf, mbuf_pullup may fail and
403 * free the mbuf.
405 * mbuf - The mbuf
406 * next - The new next mbuf.
408 * void * - A pointer to the data in the mbuf.
410 void *mbuf_data(const mbuf_t mbuf)
412 if (mbuf) {
413 return (void *)mbuf->m_data;
422 * Determines the space available in the mbuf following the current data.
424 * mbuf - The mbuf
428 size_t mbuf_trailingspace(const mbuf_t mbuf)
430 return mbuf->m_maxlen - mbuf->m_len;
436 * Copies data out of an mbuf in to a specified buffer. If the data is stored in
437 * a chain of mbufs, the data will be copied from each mbuf in the chain until
440 * mbuf - The mbuf chain to copy data out of.
441 * offset - The offset in to the mbuf to start copying.
447 int mbuf_copydata(const mbuf_t mbuf, size_t offset, size_t length, void *out_data)
451 mbuf_t m = mbuf;