00001 /* 00002 Copyright (c) 1997, 1998 Carnegie Mellon University. All Rights 00003 Reserved. 00004 00005 Redistribution and use in source and binary forms, with or without 00006 modification, are permitted provided that the following conditions are met: 00007 00008 1. Redistributions of source code must retain the above copyright notice, 00009 this list of conditions and the following disclaimer. 00010 2. Redistributions in binary form must reproduce the above copyright notice, 00011 this list of conditions and the following disclaimer in the documentation 00012 and/or other materials provided with the distribution. 00013 3. The name of the author may not be used to endorse or promote products 00014 derived from this software without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00017 IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00018 OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 00019 IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00020 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00021 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 00022 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 00023 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 00025 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 00027 The AODV code developed by the CMU/MONARCH group was optimized and tuned by Samir Das and Mahesh Marina, University of Cincinnati. The work was partially done in Sun Microsystems. 00028 */ 00029 00036 #ifndef _AODV_RT_TABLE_ 00037 #define _AODV_RT_TABLE_ 00038 00039 #include <mrcl-address.h> 00040 00041 struct AddrList 00042 { 00043 char addr[MRCL_ADDRESS_MAX_LEN]; 00044 int id; 00045 double expire; 00046 AddrList *next; 00047 AddrList *prev; 00048 }; 00049 00050 #define INFINITY2 0x7fffffff 00051 //#define INFINITY2 999 00052 00053 #define RTF_DOWN 0 00054 #define RTF_UP 1 00055 #define RTF_IN_REPAIR 2 00056 00057 #define MAX_HISTORY 3 00058 00059 class Aodv_rt_entry 00060 { 00061 public: 00062 Aodv_rt_entry(); 00063 ~Aodv_rt_entry(); 00064 00065 void nb_insert(char *addr); 00066 AddrList *nb_lookup(char *addr); 00067 00068 void pc_insert(char *addr); 00069 AddrList *pc_lookup(char *addr); 00070 void pc_delete(char *addr); 00071 void pc_delete(); 00072 void pc_show(); 00073 int pc_empty(); 00074 Aodv_rt_entry *getNext(); 00075 Aodv_rt_entry *getPrev(); 00076 void setNext(Aodv_rt_entry *e); 00077 void setPrev(Aodv_rt_entry *e); 00078 void setDst(char *addr); 00079 char *getDst(); 00080 00081 void setSeqno(int sn); 00082 void incrSeqno(); 00083 int getSeqno(); 00084 00085 void setHops(int h); 00086 int getHops(); 00087 00088 void setLastHopCount(int lh); 00089 int getLastHopCount(); 00090 00091 void setNexthop(char *addr); 00092 void resetNexthop(); 00093 char *getNexthop(); 00094 00095 void setExpire(double e); 00096 double getExpire(); 00097 00098 void setFlags(char f); 00099 char getFlags(); 00100 00101 void setReqLastTtl(int lt); 00102 int getReqLastTtl(); 00103 00104 void setDiscLatency(int i, double val); 00105 double getDiscLatency(int i); 00106 00107 char getHistIndx(); 00108 void setHistIndx(char val); 00109 00110 double rt_req_timeout; 00111 char rt_req_cnt; 00112 protected: 00113 Aodv_rt_entry *next_; 00114 Aodv_rt_entry *prev_; 00115 00116 char rt_dst_[MRCL_ADDRESS_MAX_LEN]; 00117 int rt_seqno_; 00118 int rt_hops_; 00119 int rt_last_hop_count_; 00120 char nexthop_[MRCL_ADDRESS_MAX_LEN]; 00121 AddrList *rt_pclist_; 00122 double expire_; 00123 char rt_flags_; 00124 double rt_disc_latency_[MAX_HISTORY]; 00125 char hist_indx_; 00126 int rt_req_last_ttl_; 00127 AddrList *rt_nblist_; 00128 }; 00129 00130 00131 class Aodv_rtable 00132 { 00133 public: 00134 Aodv_rtable(); 00135 Aodv_rt_entry *head(); 00136 Aodv_rt_entry *rt_add(char *addr); 00137 void rt_delete(char *addr); 00138 Aodv_rt_entry *rt_lookup(char *addr); 00139 Aodv_rt_entry *next(Aodv_rt_entry *addr); 00140 protected: 00141 Aodv_rt_entry *rt_head_; 00142 }; 00143 00144 #endif 00145