2 * Copyright (c) 2016-2018 Apple Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. Please obtain a copy of the License at
10 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * The Original Code and all software distributed under the License are
14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
18 * Please see the License for the specific language governing rights and
19 * limitations under the License.
21 * @APPLE_LICENSE_HEADER_END@
39 #define PBUF_ACTION_RV_SUCCESS 0
40 #define PBUF_ACTION_RV_FAILURE (-1)
43 uint8_t *pm_buffer
; // Pointer to start of buffer
44 u_int pm_buffer_len
; // Total length of buffer
45 u_int pm_offset
; // Offset to start of payload
46 u_int pm_len
; // Length of payload
47 uint32_t pm_csum_flags
;
48 uint32_t pm_csum_data
;
53 struct pf_mtag pm_pftag
;
54 struct pf_fragment_tag pm_pf_fragtag
;
55 int (*pm_action
)(struct pbuf_memory
*, enum pbuf_action
);
56 void *pm_action_cookie
;
60 enum pbuf_type pb_type
;
62 struct mbuf
*pbu_mbuf
;
63 struct pbuf_memory pbu_memory
;
65 #define pb_mbuf pb_u.pbu_mbuf
66 #define pb_memory pb_u.pbu_memory
69 uint32_t pb_packet_len
;
70 uint32_t pb_contig_len
;
71 uint32_t *pb_csum_flags
;
72 uint32_t *pb_csum_data
; /* data field used by csum routines */
77 struct pf_mtag
*pb_pftag
;
78 struct pf_fragment_tag
*pb_pf_fragtag
;
83 #define pbuf_is_valid(pb) (!((pb) == NULL || (pb)->pb_type == PBUF_TYPE_ZOMBIE))
85 void pbuf_init_mbuf(pbuf_t
*, struct mbuf
*, struct ifnet
*);
86 void pbuf_init_memory(pbuf_t
*, const struct pbuf_memory
*,
88 void pbuf_destroy(pbuf_t
*);
89 void pbuf_sync(pbuf_t
*);
91 struct mbuf
*pbuf_to_mbuf(pbuf_t
*, boolean_t
);
92 struct mbuf
*pbuf_clone_to_mbuf(pbuf_t
*);
94 void * pbuf_ensure_contig(pbuf_t
*, size_t);
95 void * pbuf_ensure_writable(pbuf_t
*, size_t);
97 void * pbuf_resize_segment(pbuf_t
*, int off
, int olen
, int nlen
);
98 void * pbuf_contig_segment(pbuf_t
*, int off
, int len
);
100 void pbuf_copy_data(pbuf_t
*, int, int, void *);
101 void pbuf_copy_back(pbuf_t
*, int, int, void *);
103 uint16_t pbuf_inet_cksum(const pbuf_t
*, uint32_t, uint32_t, uint32_t);
104 uint16_t pbuf_inet6_cksum(const pbuf_t
*, uint32_t, uint32_t, uint32_t);
106 mbuf_svc_class_t
pbuf_get_service_class(const pbuf_t
*);
108 #endif /* __PBUF_H__ */