Contiki 2.6

uaodv-def.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2005, Swedish Institute of Computer Science.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  * 3. Neither the name of the Institute nor the names of its contributors
00014  *    may be used to endorse or promote products derived from this software
00015  *    without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
00018  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
00021  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00022  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00023  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00024  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00025  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00026  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00027  * SUCH DAMAGE.
00028  *
00029  * This file is part of the Contiki operating system.
00030  *
00031  * $Id: uaodv-def.h,v 1.5 2007/05/28 16:33:19 bg- Exp $
00032  */
00033 
00034 /**
00035  * \file
00036  *         Definitions for the micro implementation of the AODV ad hoc routing protocol
00037  * \author
00038  *         Adam Dunkels <adam@sics.se>
00039  */
00040 
00041 #ifndef __UAODV_DEF_H__
00042 #define __UAODV_DEF_H__
00043 
00044 #include "net/uip.h"
00045 
00046 #define NUM_PRECURSORS 4
00047 
00048 
00049 #define UAODV_UDPPORT 654
00050 
00051 #if 0
00052 /* AODV routing table entry */
00053 struct uaodv_rtentry {
00054   uip_ipaddr_t dest_addr;
00055   uip_ipaddr_t next_hop;
00056   uip_ipaddr_t precursors[NUM_PRECURSORS];
00057   uint32_t dest_seqno;  
00058   uint16_t lifetime;
00059   uint8_t dest_seqno_flag;
00060   uint8_t route_flags;
00061   uint8_t hop_count;
00062 };
00063 #endif
00064 
00065 /* Generic AODV message */
00066 struct uaodv_msg {
00067   uint8_t type;
00068 };
00069 
00070 /* AODV RREQ message */
00071 #define UAODV_RREQ_TYPE     1
00072 #define UAODV_RREQ_JOIN     (1 << 7)
00073 #define UAODV_RREQ_REPAIR   (1 << 6)
00074 #define UAODV_RREQ_GRATIOUS (1 << 5)
00075 #define UAODV_RREQ_DESTONLY (1 << 4)
00076 #define UAODV_RREQ_UNKSEQNO (1 << 3)
00077 
00078 struct uaodv_msg_rreq {
00079   uint8_t type;
00080   uint8_t flags;
00081   uint8_t reserved;
00082   uint8_t hop_count;
00083   uint32_t rreq_id;
00084   uip_ipaddr_t dest_addr;
00085   uint32_t dest_seqno;
00086   uip_ipaddr_t orig_addr;
00087   uint32_t orig_seqno;
00088 };
00089 
00090 /* AODV RREP message */
00091 #define UAODV_RREP_TYPE     2
00092 #define UAODV_RREP_REPAIR  (1 << 7)
00093 #define UAODV_RREP_ACK     (1 << 6)
00094 
00095 struct uaodv_msg_rrep {
00096   uint8_t type;
00097   uint8_t flags;
00098   uint8_t prefix_sz;            /* prefix_sz:5 */
00099   uint8_t hop_count;
00100   uip_ipaddr_t dest_addr;
00101   uint32_t dest_seqno;
00102   uip_ipaddr_t orig_addr;
00103   uint32_t lifetime;
00104 };
00105 
00106 /* AODV RERR message */
00107 #define UAODV_RERR_TYPE     3
00108 #define UAODV_RERR_NODELETE (1 << 7)
00109 #define UAODV_RERR_UNKNOWN  (1 << 6) /* Non standard extension /bg. */
00110 
00111 struct uaodv_msg_rerr {
00112   uint8_t type;
00113   uint8_t flags;
00114   uint8_t reserved;
00115   uint8_t dest_count;
00116   struct {
00117     uip_ipaddr_t addr;
00118     uint32_t seqno;
00119   } unreach[1];
00120 };
00121 
00122 /* AODV RREP-ACK message */
00123 #define UAODV_RREP_ACK_TYPE     4
00124 
00125 struct uaodv_msg_rrep_ack {
00126   uint8_t type;
00127   uint8_t reserved;
00128 };
00129 
00130 #define RREP_HELLO_INTERVAL_EXT 1 /* Per RFC 3561. */
00131 #define RREQ_BAD_HOP_EXT 101    /* Non standard extension /bg */
00132 
00133 struct uaodv_extension {
00134   uint8_t type;
00135   uint8_t length;
00136   /* uint8_t value[length]; */
00137 };
00138 
00139 struct uaodv_bad_hop_ext {
00140   uint8_t type;
00141   uint8_t length;
00142   uint8_t unused1, unused2;
00143   uip_ipaddr_t addrs[1];
00144 };
00145 
00146 #endif /* __UAODV_DEF_H__ */