xref: /haiku/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h (revision 2b76973fa2401f7a5edf68e6470f3d3210cbcff3)
1 /*
2  * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3  * All rights reserved. Distributed under the terms of the MIT License.
4  */
5 #ifndef _H2UTIL_H_
6 #define _H2UTIL_H_
7 
8 #include <util/list.h>
9 
10 #include "h2generic.h"
11 
12 /* net buffer utils for ACL, to be reviewed */
13 #define DEVICEFIELD type
14 #define SET_DEVICE(nbuf, hid) \
15 	(nbuf->DEVICEFIELD=(nbuf->DEVICEFIELD & 0xFFFFFF00) | (hid & 0xFF))
16 #define GET_DEVICE(nbuf) fetch_device(NULL,(nbuf->DEVICEFIELD&0xFF))
17 
18 #define COOKIEFIELD flags
19 void* nb_get_whole_buffer(net_buffer* nbuf);
20 void nb_destroy(net_buffer* nbuf);
21 size_t get_expected_size(net_buffer* nbuf);
22 
23 /* Room utils */
24 void init_room(struct list* l);
25 void* alloc_room(struct list* l, size_t size);
26 void reuse_room(struct list* l, void* room);
27 void purge_room(struct list* l);
28 
29 /* list utils */
30 #define list_purge(x) purge_room(x)
31 
32 #endif
33