00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __OLSR_RTABLE_H__
00029 #define __OLSR_RTABLE_H__
00030
00031 #include "ns3/ipv4.h"
00032 #include <map>
00033
00034
00035 namespace ns3 { namespace olsr {
00036
00037
00038 struct RoutingTableEntry
00039 {
00040 Ipv4Address destAddr;
00041 Ipv4Address nextAddr;
00042 uint32_t interface;
00043 uint32_t distance;
00044
00045 RoutingTableEntry () :
00046 destAddr (), nextAddr (),
00047 interface (0), distance (0) {};
00048 };
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061 class RoutingTable : public Ipv4RoutingProtocol
00062 {
00063 std::map<Ipv4Address, RoutingTableEntry> m_table;
00064 Ptr<Ipv4> m_ipv4;
00065
00066 Ipv4Address m_mainAddress;
00067
00068 void DoDispose ()
00069 {
00070 m_ipv4 = 0;
00071 Ipv4RoutingProtocol::DoDispose ();
00072 }
00073
00074 public:
00075
00076 RoutingTable () {}
00077
00078 void SetIpv4 (Ptr<Ipv4> ipv4);
00079 void SetMainAddress (Ipv4Address mainAddress);
00080
00081 ~RoutingTable () {}
00082
00083 void Clear ();
00084 uint32_t GetSize () const { return m_table.size (); }
00085 std::vector<RoutingTableEntry> GetEntries () const;
00086 void RemoveEntry (const Ipv4Address &dest);
00087 void AddEntry (const Ipv4Address &dest,
00088 const Ipv4Address &next,
00089 uint32_t interface,
00090 uint32_t distance);
00091 void AddEntry (const Ipv4Address &dest,
00092 const Ipv4Address &next,
00093 const Ipv4Address &interfaceAddress,
00094 uint32_t distance);
00095 bool Lookup (const Ipv4Address &dest,
00096 RoutingTableEntry &outEntry) const;
00097 bool FindSendEntry (const RoutingTableEntry &entry,
00098 RoutingTableEntry &outEntry) const;
00099
00100
00101 virtual bool RequestRoute (uint32_t ifIndex,
00102 const Ipv4Header &ipHeader,
00103 Ptr<Packet> packet,
00104 RouteReplyCallback routeReply);
00105 virtual bool RequestIfIndex (Ipv4Address destination,
00106 uint32_t& ifIndex);
00107
00108 };
00109
00110 }};
00111
00112 #endif