57 : PacketHeaderClass(
"PacketHeader/UWIP", sizeof(
hdr_uwip))
71 : TclClass(
"Module/UW/IP")
85 , addr_type_inet(true)
94 Tcl &tcl = Tcl::instance();
96 if (strcasecmp(argv[1],
"addr") == 0) {
99 }
else if (strcasecmp(argv[1],
"setaddrinet") == 0) {
102 }
else if (strcasecmp(argv[1],
"setaddrilink") == 0) {
105 }
else if (strcasecmp(argv[1],
"addr-string") == 0) {
108 }
else if (strcasecmp(argv[1],
"getipheadersize") == 0) {
111 }
else if (strcasecmp(argv[1],
"printidspkts") == 0) {
115 }
else if (argc == 3) {
116 if (strcasecmp(argv[1],
"addr") == 0) {
117 int addr = std::atoi(argv[2]);
118 if (addr <= 0 || addr > 255) {
119 tcl.resultf(
"invalid IP address: %d", addr);
123 ipAddr_ =
static_cast<uint8_t
>(addr);
127 return Module::command(argc, argv);
133 hdr_cmn *ch = HDR_CMN(p);
136 if (ch->direction() == hdr_cmn::UP) {
140 }
else if ((ch->next_hop() & 0x000000ff) == (
ipAddr_ & 0x000000ff) ||
141 (ch->next_hop() & 0x000000ff) ==
143 (iph->
daddr() & 0x000000ff) == (
ipAddr_ & 0x000000ff) ||
152 }
else if (ch->direction() == hdr_cmn::DOWN) {
161 if (iph->
saddr() == 0)
164 if (ch->prev_hop_ == 0)
167 if (iph->
daddr() == 0) {
172 if (ch->next_hop() == 0 && iph->
daddr() != 0) {
173 printOnLog(Logger::LogLevel::ERROR,
175 "recv(Packet *)::packet sent with next_hop equals to 0");
177 ch->next_hop() = iph->
daddr();
198 return Module::recvSyncClMsg(m);
204 std::stringstream out;
205 out << ((ip_ & 0xff000000) >> 24);
207 out << ((ip_ & 0x00ff0000) >> 16);
209 out << ((ip_ & 0x0000ff00) >> 8);
211 out << ((ip_ & 0x000000ff));
218 std::stringstream out;
219 out << ((ip_ & 0xff000000) >> 24);
221 out << ((ip_ & 0x00ff0000) >> 16);
223 out << ((ip_ & 0x0000ff00) >> 8);
225 out << ((ip_ & 0x000000ff));
ClMessage_t UWIP_CLMSG_SEND_ADDR
Class used to answer to UWIPClMsgReqAddr cross layer messages.
void setAddr(nsaddr_t addr)
Adds the module for UWIPModuleClass in ns2.
TclObject * create(int, const char *const *)
UWIPModule class is used to define the Internet Protocol (IP) layer of a node.
bool addr_type_inet
true if the addressing type is INET, false if it is ILINK.
int debug_
Flag to enable or disable dirrefent levels of debug.
static const string printIP(const nsaddr_t &)
Returns a string with an IP in the classic form "x.x.x.x" converting an ns2 nsaddr_t address.
virtual void recv(Packet *p)
Performs the reception of packets from upper and lower layers.
static uint8_t lastIP
Used to set a default IP address.
static int getIpHeaderSize()
Returns the size in byte of a hdr_sun_data packet header.
virtual int command(int argc, const char *const *argv)
TCL command interpreter.
UWIPModule()
Constructor of UWIPModule class.
virtual int recvSyncClMsg(ClMessage *m)
Cross-Layer messages synchronous interpreter.
void printIdsPkts() const
Prints the IDs of the packet's headers defined by UWIP.
uint8_t ipAddr_
IP address of the node.
Adds the header for hdr_uwip packets in ns2.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
uint8_t & saddr()
Reference to the saddr_ variable.
static int offset_
Required by the PacketHeaderManager.
Cross layer messages definition for the UWIP Module.
UwIpPktClass class_uwip_pkt
UWIPModuleClass class_uwipmodule
Provides the UWIP packets header description. Definition of the class that define the network layer.
static const uint8_t UWIP_BROADCAST
Variable used to represent a broadcast UWIP.
#define ORIGINATED_BY_ME
Reason for a drop in a UWIP module.
#define NOT_FOR_ME_REASON
Reason for a drop in a UWIP module.
#define INVALID_DESTINATION_ADDR
Reason for a drop in a UWIP module.
#define DESTINATION_ADDR_UNSET
Reason for a drop in a UWIP module.