Contiki 2.5
queuebuf.h
Go to the documentation of this file.
1 /**
2  * \addtogroup rime
3  * @{
4  */
5 
6 /**
7  * \defgroup rimequeuebuf Rime queue buffer management
8  * @{
9  *
10  * The queuebuf module handles buffers that are queued.
11  *
12  */
13 
14 /*
15  * Copyright (c) 2006, Swedish Institute of Computer Science.
16  * All rights reserved.
17  *
18  * Redistribution and use in source and binary forms, with or without
19  * modification, are permitted provided that the following conditions
20  * are met:
21  * 1. Redistributions of source code must retain the above copyright
22  * notice, this list of conditions and the following disclaimer.
23  * 2. Redistributions in binary form must reproduce the above copyright
24  * notice, this list of conditions and the following disclaimer in the
25  * documentation and/or other materials provided with the distribution.
26  * 3. Neither the name of the Institute nor the names of its contributors
27  * may be used to endorse or promote products derived from this software
28  * without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
31  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
32  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
34  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
35  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
36  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
37  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
38  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
39  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40  * SUCH DAMAGE.
41  *
42  * This file is part of the Contiki operating system.
43  *
44  * $Id: queuebuf.h,v 1.4 2010/11/25 08:43:59 adamdunkels Exp $
45  */
46 
47 /**
48  * \file
49  * Header file for the Rime queue buffer management
50  * \author
51  * Adam Dunkels <adam@sics.se>
52  */
53 
54 #ifndef __QUEUEBUF_H__
55 #define __QUEUEBUF_H__
56 
57 #include "net/packetbuf.h"
58 
59 #ifdef QUEUEBUF_CONF_NUM
60 #define QUEUEBUF_NUM QUEUEBUF_CONF_NUM
61 #else
62 #define QUEUEBUF_NUM 8
63 #endif
64 
65 #ifdef QUEUEBUF_CONF_DEBUG
66 #define QUEUEBUF_DEBUG QUEUEBUF_CONF_DEBUG
67 #else /* QUEUEBUF_CONF_DEBUG */
68 #define QUEUEBUF_DEBUG 0
69 #endif /* QUEUEBUF_CONF_DEBUG */
70 
71 struct queuebuf;
72 
73 void queuebuf_init(void);
74 
75 #if QUEUEBUF_DEBUG
76 struct queuebuf *queuebuf_new_from_packetbuf_debug(const char *file, int line);
77 #define queuebuf_new_from_packetbuf() queuebuf_new_from_packetbuf_debug(__FILE__, __LINE__)
78 #else /* QUEUEBUF_DEBUG */
79 struct queuebuf *queuebuf_new_from_packetbuf(void);
80 #endif /* QUEUEBUF_DEBUG */
81 void queuebuf_update_attr_from_packetbuf(struct queuebuf *b);
82 
83 void queuebuf_to_packetbuf(struct queuebuf *b);
84 void queuebuf_free(struct queuebuf *b);
85 
86 void *queuebuf_dataptr(struct queuebuf *b);
87 int queuebuf_datalen(struct queuebuf *b);
88 
89 rimeaddr_t *queuebuf_addr(struct queuebuf *b, uint8_t type);
90 packetbuf_attr_t queuebuf_attr(struct queuebuf *b, uint8_t type);
91 
92 void queuebuf_debug_print(void);
93 
94 #endif /* __QUEUEBUF_H__ */
95 
96 /** @} */
97 /** @} */