51 : TclClass(
"Module/UW/StaticRouting")
75 return Module::recvSyncClMsg(m);
87 if (dst == 0 || next == 0) {
88 std::cerr <<
"You are trying to insert an invalid entry in the routing "
89 "table with destination: "
90 <<
static_cast<uint32_t
>(dst)
91 <<
" and next hop: " <<
static_cast<uint32_t
>(next)
95 std::map<uint8_t, uint8_t>::iterator it =
routing_table.find(dst);
101 routing_table.insert(std::pair<uint8_t, uint8_t>(dst, next));
104 std::cerr <<
"The routing table is full!" << std::endl;
113 Tcl &tcl = Tcl::instance();
115 if (strcasecmp(argv[1],
"numroutes") == 0) {
119 if (strcasecmp(argv[1],
"clearroutes") == 0) {
123 }
else if (argc == 3) {
124 if (strcasecmp(argv[1],
"defaultGateway") == 0) {
125 if (
static_cast<uint8_t
>(atoi(argv[2])) != 0) {
128 std::cerr <<
"You are trying to set an invalid address as "
129 "default gateway. Exiting ..."
136 }
else if (argc == 4) {
137 if (strcasecmp(argv[1],
"addroute") == 0) {
138 addRoute(
static_cast<uint8_t
>(atoi(argv[2])),
139 static_cast<uint8_t
>(atoi(argv[3])));
143 return Module::command(argc, argv);
149 hdr_cmn *ch = HDR_CMN(p);
153 std::cout << NOW <<
"::UWSTATICROUTING::RECV"
154 <<
"::NEXT_HOP::" << ch->next_hop()
155 <<
"::DESTINATION_IP::" << (uint)uwiph->
daddr()
159 if (ch->direction() == hdr_cmn::UP) {
161 if (uwiph->
daddr() == ch->next_hop() ||
169 ch->direction() = hdr_cmn::DOWN;
171 if (ch->next_hop() == 0) {
178 if (ch->next_hop() == 0) {
196 std::map<uint8_t, uint8_t>::const_iterator it =
routing_table.find(dst);
int debug_
Flag to enable or disable dirrefent levels of debug.
Adds the module for UwStaticRoutingModuleClass in ns2.
TclObject * create(int, const char *const *)
UwStaticRoutingModuleClass()
UwStaticRoutingModule class implements basic routing functionalities.
virtual void clearRoutes()
Removes all the routing information.
virtual void addRoute(const uint8_t &, const uint8_t &)
Adds a new entry in the routing table.
std::map< uint8_t, uint8_t > routing_table
Routing table: destination - next hop.
UwStaticRoutingModule()
Constructor of UwStaticRoutingModule class.
virtual int recvSyncClMsg(ClMessage *)
Cross-Layer messages synchronous interpreter.
virtual uint8_t getNextHop(const Packet *) const
Returns the next hop address of a packet passed as input.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
virtual ~UwStaticRoutingModule()
Destructor of UwStaticRoutingModule class.
uint8_t default_gateway
Default gateway.
virtual int command(int, const char *const *)
TCL command interpreter.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
static const uint8_t UWIP_BROADCAST
Variable used to represent a broadcast UWIP.
UwStaticRoutingModuleClass class_uwstaticrouting_module
Provides basic routing functionalities.
#define DROP_DEST_NO_ROUTE
Reason for a drop in a UWVBR module.