| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | .\" $NetBSD: mbuf.9,v 1.50 2010/12/02 12:54:13 wiz Exp $ | | 1 | .\" $NetBSD: mbuf.9,v 1.51 2013/06/17 09:58:21 ryo Exp $ |
2 | .\" | | 2 | .\" |
3 | .\" Copyright (c) 1997 The NetBSD Foundation, Inc. | | 3 | .\" Copyright (c) 1997 The NetBSD Foundation, Inc. |
4 | .\" All rights reserved. | | 4 | .\" All rights reserved. |
5 | .\" | | 5 | .\" |
6 | .\" This documentation is derived from text contributed to The NetBSD Foundation | | 6 | .\" This documentation is derived from text contributed to The NetBSD Foundation |
7 | .\" by S.P.Zeidler (aka stargazer). | | 7 | .\" by S.P.Zeidler (aka stargazer). |
8 | .\" | | 8 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | | 9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | | 10 | .\" modification, are permitted provided that the following conditions |
11 | .\" are met: | | 11 | .\" are met: |
12 | .\" 1. Redistributions of source code must retain the above copyright | | 12 | .\" 1. Redistributions of source code must retain the above copyright |
13 | .\" notice, this list of conditions and the following disclaimer. | | 13 | .\" notice, this list of conditions and the following disclaimer. |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | | 14 | .\" 2. Redistributions in binary form must reproduce the above copyright |
| @@ -17,46 +17,47 @@ | | | @@ -17,46 +17,47 @@ |
17 | .\" | | 17 | .\" |
18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 18 | .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 19 | .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 20 | .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 21 | .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 22 | .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 23 | .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 24 | .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 25 | .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 26 | .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 27 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
28 | .\" POSSIBILITY OF SUCH DAMAGE. | | 28 | .\" POSSIBILITY OF SUCH DAMAGE. |
29 | .\" | | 29 | .\" |
30 | .Dd March 24, 2008 | | 30 | .Dd June 17, 2013 |
31 | .Dt MBUF 9 | | 31 | .Dt MBUF 9 |
32 | .Os | | 32 | .Os |
33 | .Sh NAME | | 33 | .Sh NAME |
34 | .Nm mbuf , | | 34 | .Nm mbuf , |
35 | .Nm m_get , | | 35 | .Nm m_get , |
36 | .Nm m_getclr , | | 36 | .Nm m_getclr , |
37 | .Nm m_gethdr , | | 37 | .Nm m_gethdr , |
38 | .Nm m_devget , | | 38 | .Nm m_devget , |
39 | .Nm m_copym , | | 39 | .Nm m_copym , |
40 | .Nm m_copypacket , | | 40 | .Nm m_copypacket , |
41 | .Nm m_copydata , | | 41 | .Nm m_copydata , |
42 | .Nm m_copyback , | | 42 | .Nm m_copyback , |
43 | .Nm m_copyback_cow , | | 43 | .Nm m_copyback_cow , |
44 | .Nm m_cat , | | 44 | .Nm m_cat , |
45 | .Nm m_dup , | | 45 | .Nm m_dup , |
46 | .Nm m_makewritable , | | 46 | .Nm m_makewritable , |
47 | .Nm m_prepend , | | 47 | .Nm m_prepend , |
48 | .Nm m_pulldown , | | 48 | .Nm m_pulldown , |
49 | .Nm m_pullup , | | 49 | .Nm m_pullup , |
| | | 50 | .Nm m_copyup , |
50 | .Nm m_split , | | 51 | .Nm m_split , |
51 | .Nm m_adj , | | 52 | .Nm m_adj , |
52 | .Nm m_apply , | | 53 | .Nm m_apply , |
53 | .Nm m_free , | | 54 | .Nm m_free , |
54 | .Nm m_freem , | | 55 | .Nm m_freem , |
55 | .Nm mtod , | | 56 | .Nm mtod , |
56 | .Nm MGET , | | 57 | .Nm MGET , |
57 | .Nm MGETHDR , | | 58 | .Nm MGETHDR , |
58 | .Nm MEXTMALLOC , | | 59 | .Nm MEXTMALLOC , |
59 | .Nm MEXTADD , | | 60 | .Nm MEXTADD , |
60 | .Nm MCLGET , | | 61 | .Nm MCLGET , |
61 | .Nm M_COPY_PKTHDR , | | 62 | .Nm M_COPY_PKTHDR , |
62 | .Nm M_MOVE_PKTHDR , | | 63 | .Nm M_MOVE_PKTHDR , |
| @@ -91,26 +92,28 @@ | | | @@ -91,26 +92,28 @@ |
91 | .Ft int | | 92 | .Ft int |
92 | .Fn m_makewritable "struct mbuf **mp" "int off" "int len" "int how" | | 93 | .Fn m_makewritable "struct mbuf **mp" "int off" "int len" "int how" |
93 | .Ft void | | 94 | .Ft void |
94 | .Fn m_cat "struct mbuf *m" "struct mbuf *n" | | 95 | .Fn m_cat "struct mbuf *m" "struct mbuf *n" |
95 | .Ft struct mbuf * | | 96 | .Ft struct mbuf * |
96 | .Fn m_dup "struct mbuf *m" "int off0" "int len" "int wait" | | 97 | .Fn m_dup "struct mbuf *m" "int off0" "int len" "int wait" |
97 | .Ft struct mbuf * | | 98 | .Ft struct mbuf * |
98 | .Fn m_prepend "struct mbuf *m" "int len" "int how" | | 99 | .Fn m_prepend "struct mbuf *m" "int len" "int how" |
99 | .Ft struct mbuf * | | 100 | .Ft struct mbuf * |
100 | .Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp" | | 101 | .Fn m_pulldown "struct mbuf *m" "int off" "int len" "int *offp" |
101 | .Ft struct mbuf * | | 102 | .Ft struct mbuf * |
102 | .Fn m_pullup "struct mbuf *n" "int len" | | 103 | .Fn m_pullup "struct mbuf *n" "int len" |
103 | .Ft struct mbuf * | | 104 | .Ft struct mbuf * |
| | | 105 | .Fn m_copyup "struct mbuf *m" "int len" "int dstoff" |
| | | 106 | .Ft struct mbuf * |
104 | .Fn m_split "struct mbuf *m0" "int len0" "int wait" | | 107 | .Fn m_split "struct mbuf *m0" "int len0" "int wait" |
105 | .Ft void | | 108 | .Ft void |
106 | .Fn m_adj "struct mbuf *mp" "int req_len" | | 109 | .Fn m_adj "struct mbuf *mp" "int req_len" |
107 | .Ft int | | 110 | .Ft int |
108 | .Fn m_apply "struct mbuf *m" "int off" "int len" "int *f(void *, void *, unsigned int)" "void *arg" | | 111 | .Fn m_apply "struct mbuf *m" "int off" "int len" "int *f(void *, void *, unsigned int)" "void *arg" |
109 | .Ft struct mbuf * | | 112 | .Ft struct mbuf * |
110 | .Fn m_free "struct mbuf *m" | | 113 | .Fn m_free "struct mbuf *m" |
111 | .Ft void | | 114 | .Ft void |
112 | .Fn m_freem "struct mbuf *m" | | 115 | .Fn m_freem "struct mbuf *m" |
113 | .Ft datatype | | 116 | .Ft datatype |
114 | .Fn mtod "struct mbuf *m" "datatype" | | 117 | .Fn mtod "struct mbuf *m" "datatype" |
115 | .Ft void | | 118 | .Ft void |
116 | .Fn MGET "struct mbuf *m" "int how" "int type" | | 119 | .Fn MGET "struct mbuf *m" "int how" "int type" |
| @@ -475,26 +478,46 @@ will work for a structure of size | | | @@ -475,26 +478,46 @@ will work for a structure of size |
475 | Returns the resulting | | 478 | Returns the resulting |
476 | mbuf chain on success, frees it and returns | | 479 | mbuf chain on success, frees it and returns |
477 | .Dv NULL | | 480 | .Dv NULL |
478 | on failure. | | 481 | on failure. |
479 | If there is room, it will add up to | | 482 | If there is room, it will add up to |
480 | .Dv max_protohdr | | 483 | .Dv max_protohdr |
481 | - | | 484 | - |
482 | .Fa len | | 485 | .Fa len |
483 | extra bytes to the | | 486 | extra bytes to the |
484 | contiguous region to possibly avoid being called again. | | 487 | contiguous region to possibly avoid being called again. |
485 | .Fa len | | 488 | .Fa len |
486 | must be smaller or equal than | | 489 | must be smaller or equal than |
487 | .Dv MHLEN . | | 490 | .Dv MHLEN . |
| | | 491 | .It Fn m_copyup "struct mbuf *m" "int len" "int dstoff" |
| | | 492 | Similar to |
| | | 493 | .Fn m_pullup |
| | | 494 | but copies |
| | | 495 | .Fa len |
| | | 496 | bytes of data into a new mbuf at |
| | | 497 | .Fa dstoff |
| | | 498 | bytes into the mbuf. |
| | | 499 | The |
| | | 500 | .Fa dstoff |
| | | 501 | argument aligns the data and leaves room for a link layer header. |
| | | 502 | Returns the new |
| | | 503 | mbuf chain on success, and frees the mbuf chain and returns |
| | | 504 | .Dv NULL |
| | | 505 | on failure. |
| | | 506 | Note that |
| | | 507 | the function does not allocate mbuf clusters, so |
| | | 508 | .Fa len + dstoff |
| | | 509 | must be less than |
| | | 510 | .Dv MHLEN . |
488 | .It Fn m_split "struct mbuf *m0" "int len0" "int wait" | | 511 | .It Fn m_split "struct mbuf *m0" "int len0" "int wait" |
489 | Partitions an mbuf chain in two pieces, returning the tail, | | 512 | Partitions an mbuf chain in two pieces, returning the tail, |
490 | which is all but the first | | 513 | which is all but the first |
491 | .Fa len0 | | 514 | .Fa len0 |
492 | bytes. | | 515 | bytes. |
493 | In case of failure, it returns | | 516 | In case of failure, it returns |
494 | .Dv NULL | | 517 | .Dv NULL |
495 | and attempts to | | 518 | and attempts to |
496 | restore the chain to its original state. | | 519 | restore the chain to its original state. |
497 | .It Fn m_adj "struct mbuf *mp" "int req_len" | | 520 | .It Fn m_adj "struct mbuf *mp" "int req_len" |
498 | Shaves off | | 521 | Shaves off |
499 | .Fa req_len | | 522 | .Fa req_len |
500 | bytes from head or tail of the (valid) data area. | | 523 | bytes from head or tail of the (valid) data area. |