xref: /haiku/src/add-ons/kernel/drivers/bluetooth/h2/h2generic/h2util.h (revision 68ea01249e1e2088933cb12f9c28d4e5c5d1c9ef)
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 
9 #include <util/list.h>
10 
11 #include "h2generic.h"
12 
13 
14 /* net buffer utils for ACL, to be reviewed */
15 #define DEVICEFIELD type
16 #define SET_DEVICE(nbuf, hid) \
17 	(nbuf->DEVICEFIELD=(nbuf->DEVICEFIELD & 0xFFFFFF00) | (hid & 0xFF))
18 #define GET_DEVICE(nbuf) fetch_device(NULL, (nbuf->DEVICEFIELD&0xFF))
19 
20 
21 #define COOKIEFIELD flags
22 void* nb_get_whole_buffer(net_buffer* nbuf);
23 void nb_destroy(net_buffer* nbuf);
24 size_t get_expected_size(net_buffer* nbuf);
25 
26 /* Room utils */
27 void init_room(struct list* l);
28 void* alloc_room(struct list* l, size_t size);
29 void reuse_room(struct list* l, void* room);
30 void purge_room(struct list* l);
31 
32 /* list utils */
33 #define list_purge(x) purge_room(x)
34 
35 #endif
36