Contiki 2.6
|
00001 /** 00002 * \addtogroup rime 00003 * @{ 00004 */ 00005 00006 /** 00007 * \defgroup rimeabc Anonymous best-effort local area broadcast 00008 * @{ 00009 * 00010 * The abc module sends packets to all local area neighbors. The abc 00011 * module adds no headers to outgoing packets. 00012 * 00013 * \section channels Channels 00014 * 00015 * The abc module uses 1 channel. 00016 * 00017 */ 00018 00019 /* 00020 * Copyright (c) 2006, Swedish Institute of Computer Science. 00021 * All rights reserved. 00022 * 00023 * Redistribution and use in source and binary forms, with or without 00024 * modification, are permitted provided that the following conditions 00025 * are met: 00026 * 1. Redistributions of source code must retain the above copyright 00027 * notice, this list of conditions and the following disclaimer. 00028 * 2. Redistributions in binary form must reproduce the above copyright 00029 * notice, this list of conditions and the following disclaimer in the 00030 * documentation and/or other materials provided with the distribution. 00031 * 3. Neither the name of the Institute nor the names of its contributors 00032 * may be used to endorse or promote products derived from this software 00033 * without specific prior written permission. 00034 * 00035 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00036 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00037 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00038 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00039 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00040 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00041 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00042 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00043 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00044 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00045 * SUCH DAMAGE. 00046 * 00047 * This file is part of the Contiki operating system. 00048 * 00049 * $Id: abc.h,v 1.17 2010/06/14 19:19:17 adamdunkels Exp $ 00050 */ 00051 /** 00052 * \file 00053 * Header file for the Rime module Anonymous BroadCast (abc) 00054 * \author 00055 * Adam Dunkels <adam@sics.se> 00056 */ 00057 00058 #ifndef __ABC_H__ 00059 #define __ABC_H__ 00060 00061 #include "net/packetbuf.h" 00062 #include "net/rime/channel.h" 00063 00064 struct abc_conn; 00065 00066 #define ABC_ATTRIBUTES 00067 00068 /** 00069 * \brief Callback structure for abc 00070 * 00071 */ 00072 struct abc_callbacks { 00073 /** Called when a packet has been received by the abc module. */ 00074 void (* recv)(struct abc_conn *ptr); 00075 void (* sent)(struct abc_conn *ptr, int status, int num_tx); 00076 }; 00077 00078 struct abc_conn { 00079 struct channel channel; 00080 const struct abc_callbacks *u; 00081 }; 00082 00083 /** 00084 * \brief Set up an anonymous best-effort broadcast connection 00085 * \param c A pointer to a struct abc_conn 00086 * \param channel The channel on which the connection will operate 00087 * \param u A struct abc_callbacks with function pointers to functions that will be called when a packet has been received 00088 * 00089 * This function sets up an abc connection on the 00090 * specified channel. The caller must have allocated the 00091 * memory for the struct abc_conn, usually by declaring it 00092 * as a static variable. 00093 * 00094 * The struct abc_callbacks pointer must point to a structure 00095 * containing a pointer to a function that will be called 00096 * when a packet arrives on the channel. 00097 * 00098 */ 00099 void abc_open(struct abc_conn *c, uint16_t channel, 00100 const struct abc_callbacks *u); 00101 00102 /** 00103 * \brief Close an abc connection 00104 * \param c A pointer to a struct abc_conn 00105 * 00106 * This function closes an abc connection that has 00107 * previously been opened with abc_open(). 00108 * 00109 * This function typically is called as an exit handler. 00110 * 00111 */ 00112 void abc_close(struct abc_conn *c); 00113 00114 /** 00115 * \brief Send an anonymous best-effort broadcast packet 00116 * \param c The abc connection on which the packet should be sent 00117 * \retval Non-zero if the packet could be sent, zero otherwise 00118 * 00119 * This function sends an anonymous best-effort broadcast 00120 * packet. The packet must be present in the packetbuf 00121 * before this function is called. 00122 * 00123 * The parameter c must point to an abc connection that 00124 * must have previously been set up with abc_open(). 00125 * 00126 */ 00127 int abc_send(struct abc_conn *c); 00128 00129 /** 00130 * \brief Internal Rime function: Pass a packet to the abc layer 00131 * 00132 * This function is used internally by Rime to pass 00133 * packets to the abc layer. Should never be called 00134 * directly. 00135 * 00136 */ 00137 00138 void abc_input(struct channel *channel); 00139 00140 void abc_sent(struct channel *channel, int status, int num_tx); 00141 00142 #endif /* __ABC_H__ */ 00143 /** @} */ 00144 /** @} */