Contiki 2.6
|
00001 /** 00002 * \addtogroup rime 00003 * @{ 00004 */ 00005 00006 /** 00007 * \defgroup rimequeuebuf Rime queue buffer management 00008 * @{ 00009 * 00010 * The queuebuf module handles buffers that are queued. 00011 * 00012 */ 00013 00014 /* 00015 * Copyright (c) 2006, Swedish Institute of Computer Science. 00016 * All rights reserved. 00017 * 00018 * Redistribution and use in source and binary forms, with or without 00019 * modification, are permitted provided that the following conditions 00020 * are met: 00021 * 1. Redistributions of source code must retain the above copyright 00022 * notice, this list of conditions and the following disclaimer. 00023 * 2. Redistributions in binary form must reproduce the above copyright 00024 * notice, this list of conditions and the following disclaimer in the 00025 * documentation and/or other materials provided with the distribution. 00026 * 3. Neither the name of the Institute nor the names of its contributors 00027 * may be used to endorse or promote products derived from this software 00028 * without specific prior written permission. 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00031 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00032 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00033 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00034 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00035 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00036 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00037 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00038 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00039 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00040 * SUCH DAMAGE. 00041 * 00042 * This file is part of the Contiki operating system. 00043 * 00044 * $Id: queuebuf.h,v 1.4 2010/11/25 08:43:59 adamdunkels Exp $ 00045 */ 00046 00047 /** 00048 * \file 00049 * Header file for the Rime queue buffer management 00050 * \author 00051 * Adam Dunkels <adam@sics.se> 00052 */ 00053 00054 #ifndef __QUEUEBUF_H__ 00055 #define __QUEUEBUF_H__ 00056 00057 #include "net/packetbuf.h" 00058 00059 /* QUEUEBUF_NUM is the total number of queuebuf */ 00060 #ifdef QUEUEBUF_CONF_NUM 00061 #define QUEUEBUF_NUM QUEUEBUF_CONF_NUM 00062 #else 00063 #define QUEUEBUF_NUM 8 00064 #endif 00065 00066 /* QUEUEBUFRAM_NUM is the number of queuebufs stored in RAM. 00067 If QUEUEBUFRAM_CONF_NUM is set lower than QUEUEBUF_NUM, 00068 swapping is enabled and queuebufs are stored either in RAM of CFS. 00069 If QUEUEBUFRAM_CONF_NUM is unset or >= to QUEUEBUF_NUM, all 00070 queuebufs are in RAM and swapping is disabled. */ 00071 #ifdef QUEUEBUFRAM_CONF_NUM 00072 #if QUEUEBUFRAM_CONF_NUM>QUEUEBUF_NUM 00073 #error "QUEUEBUFRAM_CONF_NUM cannot be greater than QUEUEBUF_NUM" 00074 #else 00075 #define QUEUEBUFRAM_NUM QUEUEBUFRAM_CONF_NUM 00076 #define WITH_SWAP (QUEUEBUFRAM_NUM < QUEUEBUF_NUM) 00077 #endif 00078 #else /* QUEUEBUFRAM_CONF_NUM */ 00079 #define QUEUEBUFRAM_NUM QUEUEBUF_NUM 00080 #define WITH_SWAP 0 00081 #endif /* QUEUEBUFRAM_CONF_NUM */ 00082 00083 #ifdef QUEUEBUF_CONF_DEBUG 00084 #define QUEUEBUF_DEBUG QUEUEBUF_CONF_DEBUG 00085 #else /* QUEUEBUF_CONF_DEBUG */ 00086 #define QUEUEBUF_DEBUG 0 00087 #endif /* QUEUEBUF_CONF_DEBUG */ 00088 00089 struct queuebuf; 00090 00091 void queuebuf_init(void); 00092 00093 #if QUEUEBUF_DEBUG 00094 struct queuebuf *queuebuf_new_from_packetbuf_debug(const char *file, int line); 00095 #define queuebuf_new_from_packetbuf() queuebuf_new_from_packetbuf_debug(__FILE__, __LINE__) 00096 #else /* QUEUEBUF_DEBUG */ 00097 struct queuebuf *queuebuf_new_from_packetbuf(void); 00098 #endif /* QUEUEBUF_DEBUG */ 00099 void queuebuf_update_attr_from_packetbuf(struct queuebuf *b); 00100 00101 void queuebuf_to_packetbuf(struct queuebuf *b); 00102 void queuebuf_free(struct queuebuf *b); 00103 00104 void *queuebuf_dataptr(struct queuebuf *b); 00105 int queuebuf_datalen(struct queuebuf *b); 00106 00107 rimeaddr_t *queuebuf_addr(struct queuebuf *b, uint8_t type); 00108 packetbuf_attr_t queuebuf_attr(struct queuebuf *b, uint8_t type); 00109 00110 void queuebuf_debug_print(void); 00111 00112 #endif /* __QUEUEBUF_H__ */ 00113 00114 /** @} */ 00115 /** @} */