Contiki-NG
Toggle main menu visibility
Loading...
Searching...
No Matches
queuebuf.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2006, Swedish Institute of Computer Science.
3
* All rights reserved.
4
*
5
* Redistribution and use in source and binary forms, with or without
6
* modification, are permitted provided that the following conditions
7
* are met:
8
* 1. Redistributions of source code must retain the above copyright
9
* notice, this list of conditions and the following disclaimer.
10
* 2. Redistributions in binary form must reproduce the above copyright
11
* notice, this list of conditions and the following disclaimer in the
12
* documentation and/or other materials provided with the distribution.
13
* 3. Neither the name of the Institute nor the names of its contributors
14
* may be used to endorse or promote products derived from this software
15
* without specific prior written permission.
16
*
17
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
* SUCH DAMAGE.
28
*
29
* This file is part of the Contiki operating system.
30
*
31
*/
32
33
/**
34
* \file
35
* Header file for the Packet queue buffer management
36
* \author
37
* Adam Dunkels <adam@sics.se>
38
*/
39
40
/**
41
* \addtogroup net
42
* @{
43
*/
44
45
/**
46
* \defgroup queuebuf Packet buffer queue
47
* @{
48
*
49
* The queuebuf module handles buffers that are queued.
50
*
51
*/
52
53
#ifndef QUEUEBUF_H_
54
#define QUEUEBUF_H_
55
56
#include "
net/packetbuf.h
"
57
#include <stddef.h>
58
59
#ifdef QUEUEBUF_CONF_ENABLED
60
#define QUEUEBUF_ENABLED QUEUEBUF_CONF_ENABLED
61
#else
/* QUEUEBUF_CONF_ENABLED */
62
#define QUEUEBUF_ENABLED 1
63
#endif
/* QUEUEBUF_CONF_ENABLED */
64
65
/* QUEUEBUF_NUM is the total number of queuebuf */
66
#ifdef QUEUEBUF_CONF_NUM
67
#define QUEUEBUF_NUM QUEUEBUF_CONF_NUM
68
#else
69
#define QUEUEBUF_NUM 8
70
#endif
71
72
/* QUEUEBUFRAM_NUM is the number of queuebufs stored in RAM.
73
If QUEUEBUFRAM_CONF_NUM is set lower than QUEUEBUF_NUM,
74
swapping is enabled and queuebufs are stored either in RAM of CFS.
75
If QUEUEBUFRAM_CONF_NUM is unset or >= to QUEUEBUF_NUM, all
76
queuebufs are in RAM and swapping is disabled. */
77
#ifdef QUEUEBUFRAM_CONF_NUM
78
#if QUEUEBUFRAM_CONF_NUM>QUEUEBUF_NUM
79
#error "QUEUEBUFRAM_CONF_NUM cannot be greater than QUEUEBUF_NUM"
80
#else
81
#define QUEUEBUFRAM_NUM QUEUEBUFRAM_CONF_NUM
82
#define WITH_SWAP (QUEUEBUFRAM_NUM < QUEUEBUF_NUM)
83
#endif
84
#else
/* QUEUEBUFRAM_CONF_NUM */
85
#define QUEUEBUFRAM_NUM QUEUEBUF_NUM
86
#define WITH_SWAP 0
87
#endif
/* QUEUEBUFRAM_CONF_NUM */
88
89
#ifdef QUEUEBUF_CONF_DEBUG
90
#define QUEUEBUF_DEBUG QUEUEBUF_CONF_DEBUG
91
#else
/* QUEUEBUF_CONF_DEBUG */
92
#define QUEUEBUF_DEBUG 0
93
#endif
/* QUEUEBUF_CONF_DEBUG */
94
95
struct
queuebuf;
96
97
void
queuebuf_init(
void
);
98
99
#if QUEUEBUF_DEBUG
100
struct
queuebuf *queuebuf_new_from_packetbuf_debug(
const
char
*file,
int
line);
101
#define queuebuf_new_from_packetbuf() queuebuf_new_from_packetbuf_debug(__FILE__, __LINE__)
102
#else
/* QUEUEBUF_DEBUG */
103
struct
queuebuf *queuebuf_new_from_packetbuf(
void
);
104
#endif
/* QUEUEBUF_DEBUG */
105
void
queuebuf_update_attr_from_packetbuf(
struct
queuebuf *b);
106
void
queuebuf_update_from_packetbuf(
struct
queuebuf *b);
107
108
void
queuebuf_to_packetbuf(
struct
queuebuf *b);
109
void
queuebuf_free(
struct
queuebuf *b);
110
111
void
*queuebuf_dataptr(
struct
queuebuf *b);
112
int
queuebuf_datalen(
struct
queuebuf *b);
113
114
linkaddr_t *queuebuf_addr(
struct
queuebuf *b, uint8_t type);
115
packetbuf_attr_t queuebuf_attr(
struct
queuebuf *b, uint8_t type);
116
117
void
queuebuf_debug_print(
void
);
118
119
size_t
queuebuf_numfree(
void
);
120
121
#endif
/* __QUEUEBUF_H__ */
122
123
/** @} */
124
/** @} */
packetbuf.h
Header file for the Packet buffer (packetbuf) management.
os
net
queuebuf.h
Generated on
for Contiki-NG by
1.17.0