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