]>
git.saurik.com Git - apple/xnu.git/blob - iokit/Families/IONetworking/IOMbufQueue.h
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 #ifndef _IOMBUFQUEUE_H
24 #define _IOMBUFQUEUE_H
27 #include <sys/param.h>
39 UInt32
IOMbufFree(struct mbuf
* m
)
54 return m_freem_list(m
);
58 void IOMbufQueueInit(IOMbufQueue
* q
, UInt32 capacity
)
60 q
->head
= q
->tail
= 0;
62 q
->capacity
= capacity
;
66 bool IOMbufQueueEnqueue(IOMbufQueue
* q
, struct mbuf
* m
)
68 if (q
->size
>= q
->capacity
) return false;
71 q
->tail
->m_nextpkt
= m
;
77 q
->tail
= q
->tail
->m_nextpkt
, q
->size
++)
84 bool IOMbufQueueEnqueue(IOMbufQueue
* q
, IOMbufQueue
* qe
)
91 q
->tail
->m_nextpkt
= qe
->head
;
95 qe
->head
= qe
->tail
= 0;
102 void IOMbufQueuePrepend(IOMbufQueue
* q
, struct mbuf
* m
)
106 for (tail
= m
, q
->size
++;
108 tail
= tail
->m_nextpkt
, q
->size
++)
111 tail
->m_nextpkt
= q
->head
;
118 void IOMbufQueuePrepend(IOMbufQueue
* q
, IOMbufQueue
* qp
)
122 qp
->tail
->m_nextpkt
= q
->head
;
128 qp
->head
= qp
->tail
= 0;
134 struct mbuf
* IOMbufQueueDequeue(IOMbufQueue
* q
)
136 struct mbuf
* m
= q
->head
;
139 if ((q
->head
= m
->m_nextpkt
) == 0)
148 struct mbuf
* IOMbufQueueDequeueAll(IOMbufQueue
* q
)
150 struct mbuf
* m
= q
->head
;
151 q
->head
= q
->tail
= 0;
157 struct mbuf
* IOMbufQueuePeek(IOMbufQueue
* q
)
163 UInt32
IOMbufQueueGetSize(IOMbufQueue
* q
)
169 UInt32
IOMbufQueueGetCapacity(IOMbufQueue
* q
)
175 void IOMbufQueueSetCapacity(IOMbufQueue
* q
, UInt32 capacity
)
177 q
->capacity
= capacity
;
180 #endif /* !_IOMBUFQUEUE_H */