OLD | NEW |
(Empty) | |
| 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
| 2 /* |
| 3 * Copyright (c) 2009 IITP RAS |
| 4 * |
| 5 * This program is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 2 as |
| 7 * published by the Free Software Foundation; |
| 8 * |
| 9 * This program is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * You should have received a copy of the GNU General Public License |
| 15 * along with this program; if not, write to the Free Software |
| 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 * |
| 18 * Author: Kirill Andreev <andreev@iitp.ru> |
| 19 */ |
| 20 |
| 21 #ifndef FLAME_RTABLE_H |
| 22 #define FLAME_RTABLE_H |
| 23 |
| 24 #include <map> |
| 25 #include "ns3/nstime.h" |
| 26 #include "ns3/object.h" |
| 27 #include "ns3/mac48-address.h" |
| 28 |
| 29 namespace ns3 { |
| 30 namespace flame { |
| 31 /** |
| 32 * \ingroup flame |
| 33 * |
| 34 * \brief Routing table for FLAME |
| 35 */ |
| 36 class FlameRtable : public Object |
| 37 { |
| 38 public: |
| 39 /// Means all interfaces |
| 40 const static uint32_t INTERFACE_ANY = 0xffffffff; |
| 41 /// Maximum (the best?) path cost |
| 42 const static uint32_t MAX_COST = 0xff; |
| 43 |
| 44 /// Route lookup result, return type of LookupXXX methods |
| 45 struct LookupResult |
| 46 { |
| 47 Mac48Address retransmitter; |
| 48 uint32_t ifIndex; |
| 49 uint8_t cost; |
| 50 uint16_t seqnum; |
| 51 LookupResult (Mac48Address r = Mac48Address::GetBroadcast (), |
| 52 uint32_t i = INTERFACE_ANY, |
| 53 uint8_t c = MAX_COST, |
| 54 uint16_t s = 0) |
| 55 : retransmitter (r), |
| 56 ifIndex (i), |
| 57 cost (c), |
| 58 seqnum (s) |
| 59 { |
| 60 } |
| 61 /// True for valid route |
| 62 bool IsValid () const; |
| 63 /// Compare route lookup results, used by tests |
| 64 bool operator==(const LookupResult & o) const; |
| 65 }; |
| 66 public: |
| 67 static TypeId GetTypeId (); |
| 68 FlameRtable (); |
| 69 ~FlameRtable (); |
| 70 void DoDispose (); |
| 71 |
| 72 /// Add path |
| 73 void AddPath ( |
| 74 const Mac48Address destination, |
| 75 const Mac48Address retransmitter, |
| 76 const uint32_t interface, |
| 77 const uint8_t cost, |
| 78 const uint16_t seqnum |
| 79 ); |
| 80 /** |
| 81 * \brief Lookup path to destination |
| 82 * \return Broadcast if not found |
| 83 */ |
| 84 LookupResult Lookup (Mac48Address destination); |
| 85 private: |
| 86 /// Routing table entry |
| 87 struct Route |
| 88 { |
| 89 Mac48Address retransmitter; |
| 90 uint32_t interface; |
| 91 uint32_t cost; |
| 92 Time whenExpire; |
| 93 uint32_t seqnum; |
| 94 }; |
| 95 /// Lifetime parameter |
| 96 Time m_lifetime; |
| 97 /// List of routes |
| 98 std::map<Mac48Address, Route> m_routes; |
| 99 }; |
| 100 |
| 101 } //namespace flame |
| 102 } //namespace ns3 |
| 103 #endif /* FLAME_PROTOCOL_H */ |
OLD | NEW |