55 : PacketHeaderClass(
"PacketHeader/UWIP", sizeof(
hdr_uwip))
69 : TclClass(
"Module/UW/IP")
83 , addr_type_inet(true)
96 Tcl &tcl = Tcl::instance();
98 if (strcasecmp(argv[1],
"addr") == 0) {
101 }
else if (strcasecmp(argv[1],
"setaddrinet") == 0) {
104 }
else if (strcasecmp(argv[1],
"setaddrilink") == 0) {
107 }
else if (strcasecmp(argv[1],
"addr-string") == 0) {
108 tcl.resultf(
"%d.%d.%d.%d",
114 }
else if (strcasecmp(argv[1],
"getipheadersize") == 0) {
117 }
else if (strcasecmp(argv[1],
"printidspkts") == 0) {
121 }
else if (argc == 3) {
122 if (strcasecmp(argv[1],
"addr") == 0) {
123 ipAddr_ =
static_cast<uint8_t
>(atoi(argv[2]));
125 fprintf(stderr,
"0 is not a valid IP address");
131 return Module::command(argc, argv);
137 hdr_cmn *ch = HDR_CMN(p);
140 if (ch->direction() == hdr_cmn::UP) {
144 }
else if ((ch->next_hop() & 0x000000ff) == (
ipAddr_ & 0x000000ff) ||
145 (ch->next_hop() & 0x000000ff) ==
147 (iph->
daddr() & 0x000000ff) == (
ipAddr_ & 0x000000ff) ||
148 (iph->
daddr() & 0x000000ff) ==
157 }
else if (ch->direction() == hdr_cmn::DOWN) {
165 ch->addr_type() = NS_AF_INET;
167 ch->addr_type() = NS_AF_ILINK;
172 if (iph->
saddr() == 0) {
176 if (ch->prev_hop_ == 0) {
180 if (iph->
daddr() == 0) {
185 if (ch->next_hop() == 0 && iph->
daddr() != 0) {
188 <<
":Warning:Packet sent with next_hop equals to 0"
190 ch->next_hop() = iph->
daddr();
211 return Module::recvSyncClMsg(m);
218 out << ((ip_ & 0xff000000) >> 24);
220 out << ((ip_ & 0x00ff0000) >> 16);
222 out << ((ip_ & 0x0000ff00) >> 8);
224 out << ((ip_ & 0x000000ff));
231 std::stringstream out;
232 out << ((ip_ & 0xff000000) >> 24);
234 out << ((ip_ & 0x00ff0000) >> 16);
236 out << ((ip_ & 0x0000ff00) >> 8);
238 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 ~UWIPModule()
Destructor of UWIPModule class.
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.