Lines Matching refs:mbuf

34 	most common usage of an mbuf is to store a packet or data on a
35 socket waiting to be sent or received. The mbuf is a contiguous
37 than would fit in an mbuf, external data is used. Most mbufs with
53 @abstract Constants defining mbuf flags. Only the flags listed below
55 @constant MBUF_EXT Indicates this mbuf has external data.
56 @constant MBUF_PKTHDR Indicates this mbuf has a packet header.
57 @constant MBUF_EOR Indicates this mbuf is the end of a record.
93 structures. The mbuf type is used to store what sort of data the
94 mbuf contains.
95 @constant MBUF_MT_FREE Indicates the mbuf is free and is
96 sitting on the queue of free mbufs. If you find that an mbuf you
99 @constant MBUF_MT_DATA Indicates this mbuf is being used to store
101 @constant MBUF_MT_HEADER Indicates this mbuf has a packet header,
210 @abstract Method of allocating an mbuf.
217 @constant MBUF_WAITOK Allow a call to allocate an mbuf to block.
218 @constant MBUF_DONTWAIT Don't allow the mbuf allocation call to
232 @discussion The mbuf_stat contains mbuf statistics.
239 @field mtypes An array of counts of each type of mbuf allocated.
242 @field msize Length of an mbuf.
243 @field mclbytes Length of an mbuf cluster.
246 @field mlen Length of data in an mbuf.
247 @field mhlen Length of data in an mbuf with a packet header.
250 @field bigmclbytes Length of a big mbuf cluster.
259 u_short mtypes[256]; /* type specific mbuf allocations */
262 u_int32_t msize; /* length of an mbuf */
263 u_int32_t mclbytes; /* length of an mbuf cluster */
265 u_int32_t mlen; /* length of data in an mbuf */
266 u_int32_t mhlen; /* length of data in a header mbuf */
279 @discussion Returns a pointer to the start of data in this mbuf.
282 than one mbuf. In addition, data that is virtually contiguous
285 determine the lenght of data available in this mbuf. If a data
287 either use mbuf_pullup to get the data contiguous in one mbuf
288 or copy the pieces of data from each mbuf in to a contiguous
291 is space in the mbuf, mbuf_pullup may fail and free the mbuf.
292 @param mbuf The mbuf.
293 @result A pointer to the data in the mbuf.
295 extern void *mbuf_data(mbuf_t mbuf);
300 data in an mbuf. An mbuf's data may come from a cluster or be
301 embedded in the mbuf structure itself. The data pointer
305 @param mbuf The mbuf.
308 extern void *mbuf_datastart(mbuf_t mbuf);
312 @discussion Sets the data and length values for an mbuf. The data
313 value must be in a valid range. In the case of an mbuf with a cluster,
316 data embedded directly in an mbuf (no cluster), the data value must
318 mbuf and the data + length must also be in the same range.
319 @param mbuf The mbuf.
321 @param len The new length of data in the mbuf.
324 extern errno_t mbuf_setdata(mbuf_t mbuf, void *data, size_t len);
332 @param mbuf The mbuf.
337 extern errno_t mbuf_align_32(mbuf_t mbuf, size_t len);
352 @param ptr A pointer to data stored in an mbuf.
353 @result The 64 bit physical address of the mbuf data or NULL if ptr
354 does not point to data stored in an mbuf.
363 @discussion Allocates an mbuf without a cluster for external data.
365 @param type The type of the mbuf.
366 @param mbuf The mbuf.
369 extern errno_t mbuf_get(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf);
373 @discussion Allocates an mbuf without a cluster for external data.
377 @param type The type of the mbuf.
378 @param mbuf The mbuf.
381 extern errno_t mbuf_gethdr(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf);
385 @discussion Attach an external buffer as a cluster for an mbuf. If mbuf
386 points to a NULL mbuf_t, an mbuf will be allocated for you. If
387 mbuf points to a non-NULL mbuf_t, the user-supplied mbuf will
391 @param type The type of the mbuf if mbuf is non-NULL; otherwise ignored.
392 @param mbuf Pointer to the address of the mbuf; if NULL, an mbuf will
393 be allocated, otherwise, it must point to a valid mbuf address.
394 If the user-supplied mbuf is already attached to a cluster, the
395 current cluster will be freed before the mbuf gets attached to
401 mbuf is freed.
404 when it is called at the time the mbuf is freed.
410 mbuf_t *mbuf, caddr_t extbuf, void (*extfree)(caddr_t , u_int, caddr_t),
416 mbuf by calling mbuf_attachcluster(). The allocated cluster
417 can also be freed (without being attached to an mbuf) by
452 an mbuf for use as external data. If mbuf points to a NULL
453 mbuf_t, an mbuf will be allocated for you. If mbuf points to
457 @param type The type of the mbuf.
463 @param mbuf The mbuf the cluster will be attached to.
465 for the mbuf, any intermediate mbuf that may have been allocated
466 will be freed. If you specify an mbuf value in *mbuf,
477 mbuf_t *mbuf);
481 @discussion Allocate a cluster and attach it to an mbuf for use as
482 external data. If mbuf points to a NULL mbuf_t, an mbuf will be
483 allocated for you. If mbuf points to a non-NULL mbuf_t,
487 @param type The type of the mbuf.
488 @param mbuf The mbuf the cluster will be attached to.
490 for the mbuf, any intermediate mbuf that may have been allocated
491 will be freed. If you specify an mbuf value in *mbuf,
494 extern errno_t mbuf_mclget(mbuf_how_t how, mbuf_type_t type, mbuf_t *mbuf);
498 @discussion Allocate an mbuf chain to store a single packet of the
500 of mbufs will be created. The mbuf type will be set to
504 @param packetlen The total length of the packet mbuf to be allocated.
524 @param Upon success, *mbuf will be a reference to the new mbuf.
532 unsigned int * maxchunks, mbuf_t *mbuf);
538 or more mbufs. The mbuf type will be set to MBUF_TYPE_DATA.
540 each mbuf chain making up a packet.
543 @param packetlen The total length of the packet mbuf to be allocated.
563 @param Upon success, *mbuf will be a reference to the new mbuf.
571 size_t packetlen, unsigned int * maxchunks, mbuf_t *mbuf);
576 @discussion Allocate an mbuf, allocate and attach a cluster, and set
579 @param mbuf Upon success, *mbuf will be a reference to the new mbuf.
582 extern errno_t mbuf_getpacket(mbuf_how_t how, mbuf_t *mbuf);
586 @discussion Frees a single mbuf. Not commonly used because it
588 @param mbuf The mbuf to free.
589 @result The next mbuf in the chain.
591 extern mbuf_t mbuf_free(mbuf_t mbuf);
596 @param mbuf The first mbuf in the chain to free.
598 extern void mbuf_freem(mbuf_t mbuf);
602 @discussion Frees linked list of mbuf chains. Walks through
604 @param mbuf The first mbuf in the linked list to free.
607 extern int mbuf_freem_list(mbuf_t mbuf);
611 @discussion Determines the space available in the mbuf proceeding
613 @param mbuf The mbuf.
614 @result The number of unused bytes at the start of the mbuf.
616 extern size_t mbuf_leadingspace(const mbuf_t mbuf);
620 @discussion Determines the space available in the mbuf following
622 @param mbuf The mbuf.
625 extern size_t mbuf_trailingspace(const mbuf_t mbuf);
631 @discussion Copies len bytes from offset from src to a new mbuf. If
632 the original mbuf contains a packet header, the new mbuf will
634 associated with the original mbuf. mbuf_dup() should be used
635 instead if tags are to be copied to the new mbuf.
636 @param src The source mbuf.
637 @param offset The offset in the mbuf to start copying from.
640 @param new_mbuf Upon success, the newly allocated mbuf.
648 @discussion Exactly duplicates an mbuf chain. If the original mbuf
649 contains a packet header (including tags), the new mbuf will have
651 with the original mbuf.
652 @param src The source mbuf.
654 @param new_mbuf Upon success, the newly allocated mbuf.
661 @discussion Prepend len bytes to an mbuf. If there is space
662 (mbuf_leadingspace >= len), the mbuf's data ptr is changed and
663 the same mbuf is returned. If there is no space, a new mbuf may
664 be allocated and prepended to the mbuf chain. If the operation
665 fails, the mbuf may be freed (*mbuf will be NULL).
666 @param mbuf The mbuf to prepend data to. This may change if a new
667 mbuf must be allocated or may be NULL if the operation fails.
668 @param len The length, in bytes, to be prepended to the mbuf.
672 extern errno_t mbuf_prepend(mbuf_t *mbuf, size_t len, mbuf_how_t how);
676 @discussion Split an mbuf chain at a specific offset.
677 @param src The mbuf to be split.
678 @param offset The offset in the buffer where the mbuf should be
681 @param new_mbuf Upon success, the second half of the split mbuf
684 failure, the original mbuf chain passed in to src will be
692 @discussion Move the next len bytes in to mbuf from other mbufs in
694 header contiguous in the first mbuf. If mbuf_pullup fails, the
695 entire mbuf chain will be freed.
696 @param mbuf The mbuf in the chain the data should be contiguous in.
697 @param len The number of bytes to pull from the next mbuf(s).
699 error, the mbuf chain has been freed.
701 extern errno_t mbuf_pullup(mbuf_t *mbuf, size_t len);
705 @discussion Make length bytes at offset in the mbuf chain
707 modified. Upon return, location will be the mbuf the data is
708 contiguous in and offset will be the offset in that mbuf at
709 which the data is located. In the case of a failure, the mbuf
711 @param src The start of the mbuf chain.
714 will be overwritten with the offset from the mbuf returned in
717 @param location Upon success, *location will be the mbuf the data is
726 @discussion Trims len bytes from the mbuf. If the length is greater
727 than zero, the bytes are trimmed from the front of the mbuf. If
729 of the mbuf chain.
730 @param mbuf The mbuf chain to trim.
731 @param len The number of bytes to trim from the mbuf chain.
733 extern void mbuf_adj(mbuf_t mbuf, int len);
737 @discussion Adds amount to the mbuf len. Verifies that the new
739 maximum amount of data that may be stored in the mbuf). This
742 @param mbuf The mbuf to adjust.
746 extern errno_t mbuf_adjustlen(mbuf_t mbuf, int amount);
750 @discussion Concatenate mbuf chain src to dst using m_next and return
752 does not prevent two chains of different mbuf types to be
755 caller to ensure that the resulted concatenated mbuf chain is
757 @param dst The destination mbuf chain.
758 @param src The source mbuf chain.
759 @result A pointer to the head of the concatenated mbuf chain. This
760 should be treated as the updated destination mbuf chain; the
761 caller must no longer refer to the original src or dst mbuf
762 chain. Otherwise it returns NULL if the original dst mbuf
769 @discussion Copies data out of an mbuf in to a specified buffer. If
771 from each mbuf in the chain until length bytes have been copied.
772 @param mbuf The mbuf chain to copy data out of.
773 @param offset The offset in to the mbuf to start copying.
779 extern errno_t mbuf_copydata(const mbuf_t mbuf, size_t offset, size_t length,
784 @discussion Copies data from a buffer to an mbuf chain.
788 chain, ENOBUFS will be returned. The mbuf chain will be shorter
789 than expected but all of the data up to the end of the mbuf
793 bytes in the mbuf chain before starting to write the buffer in
794 to the chain. If the mbuf chain does not contain this many
796 @param mbuf The first mbuf in the chain to copy the data in to.
798 @param length The length, in bytes, of the data to copy in to the mbuf
804 extern errno_t mbuf_copyback(mbuf_t mbuf, size_t offset, size_t length,
809 @discussion Check if a cluster of an mbuf is referenced by another mbuf.
812 @param mbuf The mbuf with the cluster to test.
813 @result 0 if there is no reference by another mbuf, 1 otherwise.
815 extern int mbuf_mclhasreference(mbuf_t mbuf);
818 /* mbuf header */
822 @discussion Returns the next mbuf in the chain.
823 @param mbuf The mbuf.
824 @result The next mbuf in the chain.
826 extern mbuf_t mbuf_next(const mbuf_t mbuf);
830 @discussion Sets the next mbuf in the chain.
831 @param mbuf The mbuf.
832 @param next The new next mbuf.
835 extern errno_t mbuf_setnext(mbuf_t mbuf, mbuf_t next);
839 @discussion Gets the next packet from the mbuf.
840 @param mbuf The mbuf.
843 extern mbuf_t mbuf_nextpkt(const mbuf_t mbuf);
847 @discussion Sets the next packet attached to this mbuf.
848 @param mbuf The mbuf.
851 extern void mbuf_setnextpkt(mbuf_t mbuf, mbuf_t nextpkt);
855 @discussion Gets the length of data in this mbuf.
856 @param mbuf The mbuf.
859 extern size_t mbuf_len(const mbuf_t mbuf);
864 not set the length over the space available in the mbuf.
865 @param mbuf The mbuf.
869 extern void mbuf_setlen(mbuf_t mbuf, size_t len);
874 in this mbuf. This value assumes that the data pointer was set
877 @param mbuf The mbuf.
878 @result The maximum lenght of data for this mbuf.
880 extern size_t mbuf_maxlen(const mbuf_t mbuf);
884 @discussion Gets the type of mbuf.
885 @param mbuf The mbuf.
888 extern mbuf_type_t mbuf_type(const mbuf_t mbuf);
892 @discussion Sets the type of mbuf.
893 @param mbuf The mbuf.
897 extern errno_t mbuf_settype(mbuf_t mbuf, mbuf_type_t new_type);
902 @param mbuf The mbuf.
905 extern mbuf_flags_t mbuf_flags(const mbuf_t mbuf);
910 @param mbuf The mbuf.
914 extern errno_t mbuf_setflags(mbuf_t mbuf, mbuf_flags_t flags);
920 @param mbuf The mbuf.
925 extern errno_t mbuf_setflags_mask(mbuf_t mbuf, mbuf_flags_t flags,
931 @param src The mbuf from which the packet header will be copied.
932 @param mbuf The mbuf to which the packet header will be copied.
940 @param mbuf The mbuf containing the packet header with the length to
944 extern size_t mbuf_pkthdr_len(const mbuf_t mbuf);
949 @param mbuf The mbuf containing the packet header.
952 extern void mbuf_pkthdr_setlen(mbuf_t mbuf, size_t len);
957 @param mbuf The mbuf containing the packet header.
961 extern void mbuf_pkthdr_adjustlen(mbuf_t mbuf, int amount);
967 The interface is only valid for as long as the mbuf is not freed
968 and the rcvif for the mbuf is not changed. Take a reference on
970 the following: free the mbuf, change the rcvif, pass the mbuf to
971 any function that may free the mbuf or change the rcvif.
972 @param mbuf The mbuf containing the packet header.
975 extern ifnet_t mbuf_pkthdr_rcvif(const mbuf_t mbuf);
980 @param mbuf The mbuf containing the packet header.
984 extern errno_t mbuf_pkthdr_setrcvif(mbuf_t mbuf, ifnet_t ifp);
989 @param mbuf The mbuf containing the packet header.
992 extern void *mbuf_pkthdr_header(const mbuf_t mbuf);
997 @param mbuf The mbuf containing the packet header.
1001 extern void mbuf_pkthdr_setheader(mbuf_t mbuf, void *header);
1009 modifying data should call this function on an mbuf before
1016 @param mbuf The mbuf that has been modified.
1018 extern void mbuf_inbound_modified(mbuf_t mbuf);
1048 @param mbuf The mbuf that should be finalized.
1050 mbuf.
1051 @param protocol_offset The offset from the start of the mbuf to the
1055 extern void mbuf_outbound_finalize(mbuf_t mbuf, u_int32_t protocol_family,
1062 mbuf to indicate which vlan the packet was received for.
1063 @param mbuf The mbuf containing the packet.
1067 extern errno_t mbuf_set_vlan_tag(mbuf_t mbuf, u_int16_t vlan);
1076 @param mbuf The mbuf containing the packet.
1081 extern errno_t mbuf_get_vlan_tag(mbuf_t mbuf, u_int16_t *vlan);
1086 the mbuf.
1087 @param mbuf The mbuf containing the packet.
1090 extern errno_t mbuf_clear_vlan_tag(mbuf_t mbuf);
1101 @param mbuf The mbuf containing the packet.
1107 extern errno_t mbuf_set_csum_requested(mbuf_t mbuf,
1115 @param mbuf The mbuf containing the packet.
1121 extern errno_t mbuf_get_csum_requested(mbuf_t mbuf,
1128 @param mbuf The mbuf containing the packet.
1134 extern errno_t mbuf_get_tso_requested(mbuf_t mbuf,
1140 @param mbuf The mbuf containing the packet.
1143 extern errno_t mbuf_clear_csum_requested(mbuf_t mbuf);
1149 @param mbuf The mbuf containing the packet.
1157 extern errno_t mbuf_set_csum_performed(mbuf_t mbuf,
1165 @param mbuf The mbuf containing the packet.
1173 extern errno_t mbuf_get_csum_performed(mbuf_t mbuf,
1180 mbuf, i.e. an mbuf that is not a packet header, nor one with
1190 header mbuf. This is equivalent to the legacy MHLEN macro.
1207 @param mbuf The mbuf containing the packet.
1210 extern errno_t mbuf_clear_csum_performed(mbuf_t mbuf);
1226 at the beginning of the first mbuf.
1227 @param mbuf The mbuf (or chain of mbufs) containing the packet.
1231 the offset of the transport header from the beginning of mbuf.
1238 extern errno_t mbuf_inet_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
1255 at the beginning of the first mbuf.
1256 @param mbuf The mbuf (or chain of mbufs) containing the packet.
1260 the offset of the transport header from the beginning of mbuf.
1267 extern errno_t mbuf_inet6_cksum(mbuf_t mbuf, int protocol, u_int32_t offset,
1270 /* mbuf tags */
1295 @discussion Allocate an mbuf tag. Mbuf tags allow various portions
1297 mbuf through the stack.
1300 (MBUF_PKTHDR flag is set). Mbuf tags are freed when the mbuf is
1302 @param mbuf The mbuf to attach this tag to.
1307 will be associated with this tag on this mbuf.
1314 extern errno_t mbuf_tag_allocate(mbuf_t mbuf, mbuf_tag_id_t module_id,
1319 @discussion Find the data associated with an mbuf tag.
1320 @param mbuf The mbuf the tag is attached to.
1329 extern errno_t mbuf_tag_find(mbuf_t mbuf, mbuf_tag_id_t module_id,
1334 @discussion Frees a previously allocated mbuf tag.
1335 @param mbuf The mbuf the tag was allocated on.
1339 extern void mbuf_tag_free(mbuf_t mbuf, mbuf_tag_id_t module_id,
1342 /* mbuf stats */
1346 @discussion Get the mbuf statistics.
1378 @discussion Get the traffic class of an mbuf packet
1379 @param mbuf The mbuf to get the traffic class of.
1382 extern mbuf_traffic_class_t mbuf_get_traffic_class(mbuf_t mbuf);
1386 @discussion Set the traffic class of an mbuf packet.
1387 @param mbuf The mbuf to set the traffic class on.
1391 extern errno_t mbuf_set_traffic_class(mbuf_t mbuf, mbuf_traffic_class_t tc);
1396 of the packet specified by the mbuf.
1397 @param mbuf The mbuf to retrieve the status from.
1400 extern int mbuf_is_traffic_class_privileged(mbuf_t mbuf);
1463 @discussion Get the service class of an mbuf packet
1464 @param mbuf The mbuf to get the service class of.
1467 extern mbuf_svc_class_t mbuf_get_service_class(mbuf_t mbuf);
1471 @discussion Set the service class of an mbuf packet.
1472 @param mbuf The mbuf to set the service class on.
1476 extern errno_t mbuf_set_service_class(mbuf_t mbuf, mbuf_svc_class_t sc);
1481 of the packet specified by the mbuf.
1482 @param mbuf The mbuf to retrieve the status from.
1485 extern int mbuf_is_service_class_privileged(mbuf_t mbuf);
1489 @abstract Constants defining mbuf auxiliary flags. Only the flags
1507 @param mbuf The mbuf containing the packet header.
1511 extern errno_t mbuf_pkthdr_aux_flags(mbuf_t mbuf,