Contiki 2.6
|
00001 /** 00002 * \addtogroup rime 00003 * @{ 00004 */ 00005 00006 /** 00007 * \defgroup rimestunicast Stubborn unicast 00008 * @{ 00009 * 00010 * The stubborn single-hop unicast primitive (stunicast) repeatedly 00011 * sends a packet to a single-hop neighbor using the unicast 00012 * primitive. The stunicast primitive sends and resends the packet 00013 * until an upper layer primitive or protocol cancels the 00014 * transmission. While it is possible for applications and protocols 00015 * that use Rime to use the stubborn single-hop unicast primitive 00016 * directly, the stunicast primitive is primarily used by the reliable 00017 * single-hop unicast (runicast) primitive. 00018 * 00019 * Before the stunicast primitive sends a packet, it allocates a queue 00020 * buffer, to which the application data and packet attributes is 00021 * copied, and sets a timer. When the timer expires, the stunicast 00022 * primitive copies the queue buffer to the Rime buffer and sends the 00023 * packet using the unicast primitive. The stunicast primitive sets the 00024 * number of retransmissions for a packet as a packet attribute on 00025 * outgoing packets. 00026 * 00027 * \section channels Channels 00028 * 00029 * The stunicast module uses 1 channel. 00030 * 00031 */ 00032 00033 /* 00034 * Copyright (c) 2006, Swedish Institute of Computer Science. 00035 * All rights reserved. 00036 * 00037 * Redistribution and use in source and binary forms, with or without 00038 * modification, are permitted provided that the following conditions 00039 * are met: 00040 * 1. Redistributions of source code must retain the above copyright 00041 * notice, this list of conditions and the following disclaimer. 00042 * 2. Redistributions in binary form must reproduce the above copyright 00043 * notice, this list of conditions and the following disclaimer in the 00044 * documentation and/or other materials provided with the distribution. 00045 * 3. Neither the name of the Institute nor the names of its contributors 00046 * may be used to endorse or promote products derived from this software 00047 * without specific prior written permission. 00048 * 00049 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 00050 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00051 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00052 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 00053 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00054 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00055 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00056 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00057 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00058 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00059 * SUCH DAMAGE. 00060 * 00061 * This file is part of the Contiki operating system. 00062 * 00063 * $Id: stunicast.h,v 1.7 2010/06/14 19:19:17 adamdunkels Exp $ 00064 */ 00065 00066 /** 00067 * \file 00068 * Stubborn unicast header file 00069 * \author 00070 * Adam Dunkels <adam@sics.se> 00071 */ 00072 00073 #ifndef __STUNICAST_H__ 00074 #define __STUNICAST_H__ 00075 00076 #include "sys/ctimer.h" 00077 #include "net/rime/unicast.h" 00078 #include "net/queuebuf.h" 00079 00080 struct stunicast_conn; 00081 00082 #define STUNICAST_ATTRIBUTES UNICAST_ATTRIBUTES 00083 00084 struct stunicast_callbacks { 00085 void (* recv)(struct stunicast_conn *c, const rimeaddr_t *from); 00086 void (* sent)(struct stunicast_conn *c, int status, int num_tx); 00087 }; 00088 00089 struct stunicast_conn { 00090 struct unicast_conn c; 00091 struct ctimer t; 00092 struct queuebuf *buf; 00093 const struct stunicast_callbacks *u; 00094 rimeaddr_t receiver; 00095 }; 00096 00097 void stunicast_open(struct stunicast_conn *c, uint16_t channel, 00098 const struct stunicast_callbacks *u); 00099 void stunicast_close(struct stunicast_conn *c); 00100 00101 int stunicast_send_stubborn(struct stunicast_conn *c, const rimeaddr_t *receiver, 00102 clock_time_t rxmittime); 00103 void stunicast_cancel(struct stunicast_conn *c); 00104 00105 int stunicast_send(struct stunicast_conn *c, const rimeaddr_t *receiver); 00106 00107 void stunicast_set_timer(struct stunicast_conn *c, clock_time_t t); 00108 00109 rimeaddr_t *stunicast_receiver(struct stunicast_conn *c); 00110 00111 #endif /* __STUNICAST_H__ */ 00112 /** @} */ 00113 /** @} */