Contiki 2.6

rudolph2.h

Go to the documentation of this file.
00001 /**
00002  * \addtogroup rime
00003  * @{
00004  */
00005 
00006 /**
00007  * \defgroup rudolph2 Single-hop reliable bulk data transfer
00008  * @{
00009  *
00010  * The rudolph2 module implements a single-hop reliable bulk data
00011  * transfer mechanism.
00012  *
00013  * \section channels Channels
00014  *
00015  * The rudolph2 module uses 2 channels; one for data packets and one
00016  * for NACK and repair packets.
00017  *
00018  */
00019 
00020 /*
00021  * Copyright (c) 2007, Swedish Institute of Computer Science.
00022  * All rights reserved.
00023  *
00024  * Redistribution and use in source and binary forms, with or without
00025  * modification, are permitted provided that the following conditions
00026  * are met:
00027  * 1. Redistributions of source code must retain the above copyright
00028  *    notice, this list of conditions and the following disclaimer.
00029  * 2. Redistributions in binary form must reproduce the above copyright
00030  *    notice, this list of conditions and the following disclaimer in the
00031  *    documentation and/or other materials provided with the distribution.
00032  * 3. Neither the name of the Institute nor the names of its contributors
00033  *    may be used to endorse or promote products derived from this software
00034  *    without specific prior written permission.
00035  *
00036  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00037  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00038  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00039  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00040  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00041  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00042  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00043  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00044  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00045  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00046  * SUCH DAMAGE.
00047  *
00048  * This file is part of the Contiki operating system.
00049  *
00050  * $Id: rudolph2.h,v 1.5 2010/06/18 08:28:56 nifi Exp $
00051  */
00052 
00053 /**
00054  * \file
00055  *         Header file for the single-hop reliable bulk data transfer module
00056  * \author
00057  *         Adam Dunkels <adam@sics.se>
00058  */
00059 
00060 #ifndef __RUDOLPH2_H__
00061 #define __RUDOLPH2_H__
00062 
00063 #include "net/rime/polite.h"
00064 #include "sys/ctimer.h"
00065 
00066 struct rudolph2_conn;
00067 
00068 enum {
00069   RUDOLPH2_FLAG_NONE,
00070   RUDOLPH2_FLAG_NEWFILE,
00071   RUDOLPH2_FLAG_LASTCHUNK,
00072 };
00073 
00074 struct rudolph2_callbacks {
00075   void (* write_chunk)(struct rudolph2_conn *c, int offset, int flag,
00076                        uint8_t *data, int len);
00077   int (* read_chunk)(struct rudolph2_conn *c, int offset, uint8_t *to,
00078                      int maxsize);
00079 };
00080 
00081 #define RUDOLPH2_DATASIZE 64
00082 
00083 struct rudolph2_conn {
00084   struct polite_conn c;
00085   const struct rudolph2_callbacks *cb;
00086   struct ctimer t;
00087   uint16_t snd_nxt, rcv_nxt;
00088   uint16_t version;
00089   uint8_t hops_from_base;
00090   uint8_t nacks;
00091   uint8_t flags;
00092 };
00093 
00094 void rudolph2_open(struct rudolph2_conn *c, uint16_t channel,
00095                    const struct rudolph2_callbacks *cb);
00096 void rudolph2_close(struct rudolph2_conn *c);
00097 void rudolph2_send(struct rudolph2_conn *c, clock_time_t interval);
00098 void rudolph2_stop(struct rudolph2_conn *c);
00099 
00100 void rudolph2_set_version(struct rudolph2_conn *c, int version);
00101 int rudolph2_version(struct rudolph2_conn *c);
00102 
00103 #endif /* __RUDOLPH2_H__ */
00104 /** @} */
00105 /** @} */
00106