NETWORK ATTACKS FRAMEWORK  1.0.0
A NETwork Attacks framework. Making network attacks impact evaluation easier!
NA_aodv_msg_struct.h
Go to the documentation of this file.
00001 
00002 #ifndef NA_AODV_MSG_OMNET_H
00003 #define NA_AODV_MSG_OMNET_H
00004 
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 //#include <unistd.h>
00008 //#include <sys/time.h>
00009 //#include <sys/types.h>
00010 #include "compatibility.h"
00011 
00012 #include "NA_aodv_msg_struct_m.h"
00013 
00014 // this structures are a redifinition of def.h struct for omnet
00015 
00016 typedef struct
00017 {
00018     u_int8_t type;
00019     u_int8_t length;
00020     char * pointer;
00021     /* Type specific data follows here */
00022 } AODV_ext;
00023 
00024 /* A generic AODV packet header struct... */ /* Omnet++ definition */
00025 struct AODV_msg : public cPacket
00026 {
00027     u_int8_t type;
00028     uint8_t ttl;
00029     bool prevFix;
00030   private:
00031     AODV_ext *extension;
00032     int extensionsize;
00033     /* NS_PORT: Additions for the AODVUU packet type in ns-2 */
00034 
00035   public:
00036     //explicit AODV_msg(const char *name="AodvMgs") : cPacket(name) {extensionsize=0;extension=NULL;}
00037     explicit AODV_msg(const char *name=NULL) : cPacket(name) {extensionsize=0; extension=NULL;}
00038     ~AODV_msg ();
00039     AODV_msg (const AODV_msg  &m);
00040     AODV_msg &  operator= (const AODV_msg &m);
00041     virtual AODV_msg *dup() const {return new AODV_msg(*this);}
00042     uint8_t getType() const {return type;}
00043     uint8_t getTtl() const {return ttl;}
00044     bool getPrevFix() const {return prevFix;}
00045     AODV_ext *  addExtension(int,int,char *);
00046     void clearExtension();
00047     AODV_ext * getExtension(int i) {return &extension[i];}
00048     AODV_ext& getExtensionRef(int i) {return extension[i];}
00049     AODV_ext * getFirstExtension () {return extension;}
00050     AODV_ext * getNexExtension(AODV_ext*);
00051     int getNumExtension() {return extensionsize;}
00052   private:
00053     void copy(const AODV_msg& other);
00054 };
00055 typedef AODV_msg hdr_aodvuu;    // Name convention for headers
00056 
00057 #define HDR_AODVUU(p) ((hdr_aodvuu *) hdr_aodvuu::access(p))
00058 #define AODV_EXT_HDR_SIZE 2
00059 #define AODV_EXT_DATA(ext) ((char *)ext->pointer)
00060 #define AODV_EXT_NEXT(ext) ((AODV_ext *) (ext+1))
00061 #define AODV_EXT_SIZE(ext) (AODV_EXT_HDR_SIZE+ext->length)
00062 
00063 /* Extra unreachable destinations... */
00064 typedef struct
00065 {
00066     // u_int32_t dest_addr;
00067     ManetAddress dest_addr;
00068     u_int32_t dest_seqno;
00069 } RERR_udest;
00070 //#define RERR_UDEST_SIZE sizeof(RERR_udest)
00071 #define RERR_UDEST_SIZE 8
00072 
00073 #ifdef RERR
00074 #undef RERR
00075 #endif
00076 
00077 struct RERR : public AODV_msg
00078 {
00079     unsigned short res1;
00080     unsigned short n;
00081     unsigned short res2;
00082     u_int8_t dest_count;
00083     RERR_udest *   _udest;
00084   public:
00085     explicit RERR(const char *name="RERRAodvMsg") : AODV_msg (name) {setBitLength(12*8); dest_count=0; _udest=NULL;}
00086     ~RERR ();
00087     RERR (const RERR &m);
00088     unsigned short getRes1() const {return res1;}
00089     unsigned short getN() const {return n;}
00090     unsigned short getRes2() const {return res2;}
00091     int getUdestArraySize() {return dest_count;}
00092     void addUdest(const ManetAddress &,unsigned int);
00093     void clearUdest();
00094     RERR_udest *getUdest(int);
00095     RERR_udest& getUdestRef(int i) {return *getUdest(i);}
00096     RERR &  operator= (const RERR &m);
00097     virtual RERR *dup() const {return new RERR(*this);}
00098   private:
00099     void copy(const RERR& other);
00100 };
00101 
00102 #define RERR_UDEST_FIRST(rerr) (rerr->getUdest(0))
00103 #define RERR_UDEST_NEXT(udest) ((RERR_udest *)((char *)udest + sizeof(RERR_udest)))
00104 #define RERR_SIZE 12
00105 #define RERR_CALC_SIZE(rerr) (rerr->getByteLength())
00106 
00107 struct RREP : public AODV_msg
00108 {
00109     u_int16_t res1;
00110     u_int16_t a;
00111     u_int16_t r;
00112     u_int16_t prefix;
00113     u_int16_t res2;
00114     u_int8_t hcnt;
00115 //  u_int32_t dest_addr;
00116     ManetAddress dest_addr;
00117     u_int32_t dest_seqno;
00118 //  u_int32_t orig_addr;
00119     ManetAddress orig_addr;
00120     u_int32_t lifetime;
00121     uint32_t cost;
00122     uint8_t  hopfix;
00123     AODV_ext *extension;
00124 
00125   public:
00126     explicit RREP (const char *name="RREPAodvMsg") : AODV_msg (name) {setBitLength(20*8);}
00127     RREP (const RREP &m);
00128     RREP &  operator= (const RREP &m);
00129     virtual RREP *dup() const {return new RREP(*this);}
00130     virtual std::string detailedInfo() const;
00131     uint16_t getRes1() const {return res1;}
00132     uint16_t getA() const {return a;}
00133     uint16_t getR() const {return r;}
00134     uint16_t getPrefix() const {return prefix;}
00135     uint16_t getRes2() const {return res2;}
00136     uint8_t getHcnt() const {return hcnt;}
00137     //uint32_t getDest_addr() const {return dest_addr;}
00138     const ManetAddress& getDest_addr() const {return dest_addr;}
00139     uint32_t getDest_seqno() const {return dest_seqno;}
00140     //u_int32_t getOrig_addr() const {return orig_addr;}
00141     const ManetAddress& getOrig_addr() const {return orig_addr;}
00142     uint32_t getLifetime() const {return lifetime;}
00143     uint32_t getCost() const {return cost;}
00144     uint8_t  getHopfix() const {return hopfix;}
00145     AODV_ext& getExtension(int i) const {return extension[i];}
00146     int getExtensionArraySize() const {return 0;} //FIXME!!!!!!
00147   private:
00148     void copy(const RREP& other);
00149 } ;
00150 #define RREP_SIZE 20
00151 
00152 struct RREP_ack : public AODV_msg
00153 {
00154     u_int8_t reserved;
00155   public:
00156     explicit RREP_ack (const char *name="RREPAckAodvMsg") : AODV_msg (name) {setBitLength(2*8);}
00157     RREP_ack (const RREP_ack  &m);
00158     RREP_ack &  operator= (const RREP_ack &m);
00159     virtual RREP_ack *dup() const {return new RREP_ack(*this);}
00160     uint8_t getReserved() const {return reserved;}
00161   private:
00162     void copy(const RREP_ack& other) { reserved = other.reserved; }
00163 } ;
00164 #define RREP_ACK_SIZE 2
00165 
00166 struct RREQ : public AODV_msg
00167 {
00168     u_int8_t j;     /* Join flag (multicast) */
00169     u_int8_t r;     /* Repair flag */
00170     u_int8_t g;     /* Gratuitous RREP flag */
00171     u_int8_t d;     /* Destination only respond */
00172     u_int8_t res1;
00173     u_int8_t res2;
00174     u_int8_t hcnt;
00175     u_int32_t rreq_id;
00176 //  u_int32_t dest_addr;
00177     ManetAddress dest_addr;
00178     u_int32_t dest_seqno;
00179 //  u_int32_t orig_addr;
00180     ManetAddress orig_addr;
00181     u_int32_t orig_seqno;
00182     uint32_t   cost;
00183     uint8_t  hopfix;
00184 
00185   public:
00186     explicit RREQ(const char *name="RREQAodvMsg") : AODV_msg (name) {setBitLength(24*8);}
00187     RREQ (const RREQ &m);
00188     RREQ &  operator= (const RREQ &m);
00189     virtual RREQ *dup() const {return new RREQ(*this);}
00190     virtual std::string detailedInfo() const;
00191     uint8_t getJ() const {return j;}
00192     uint8_t getR() const {return r;}
00193     uint8_t getG() const {return g;}
00194     uint8_t getD() const {return d;}
00195     uint8_t getRes1() const {return res1;}
00196     uint8_t getRes2() const {return res2;}
00197     uint8_t getHcnt() const {return hcnt;}
00198     uint32_t getRreq_id() const {return rreq_id;}
00199     //uint32_t getDest_addr() const {return dest_addr;}
00200     const ManetAddress& getDest_addr() const {return dest_addr;}
00201     uint32_t getDest_seqno() const {return dest_seqno;}
00202     //u_int32_t getOrig_addr() const {return orig_addr;}
00203     const ManetAddress& getOrig_addr() const {return orig_addr;}
00204     uint32_t getOrig_seqno() const {return orig_seqno;}
00205     uint32_t getCost() const {return cost;}
00206     uint8_t getHopfix() const {return hopfix;}
00207   private:
00208     void copy(const RREQ& other);
00209 };
00210 
00211 #define RREQ_SIZE 24
00212 #endif
00213 
 All Classes Files Functions Variables Typedefs Enumerator Defines