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
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef ns_mip_h
00060 #define ns_mip_h
00061
00062 #include <assert.h>
00063 #include "agent.h"
00064 #include "classifier-addr.h"
00065
00066 #define MIP_TIMER_SIMPLE 0
00067 #define MIP_TIMER_AGTLIST 1
00068
00069 struct hdr_ipinip {
00070 hdr_ip hdr_;
00071 struct hdr_ipinip *next_;
00072
00073
00074 static int offset_;
00075 inline static int& offset() { return offset_; }
00076 inline static hdr_ipinip* access(const Packet* p) {
00077 return (hdr_ipinip*) p->access(offset_);
00078 }
00079 };
00080
00081 typedef enum {
00082 MIPT_REG_REQUEST, MIPT_REG_REPLY, MIPT_ADS, MIPT_SOL
00083 } MipRegType;
00084
00085 struct hdr_mip {
00086 int haddr_;
00087 int ha_;
00088 int coa_;
00089 MipRegType type_;
00090 double lifetime_;
00091 int seqno_;
00092
00093
00094 static int offset_;
00095 inline static int& offset() { return offset_; }
00096 inline static hdr_mip* access(const Packet* p) {
00097 return (hdr_mip*) p->access(offset_);
00098 }
00099 };
00100
00101 class MIPEncapsulator : public Connector {
00102 public:
00103 MIPEncapsulator();
00104 void recv(Packet *p, Handler *h);
00105 protected:
00106 ns_addr_t here_;
00107 int mask_;
00108 int shift_;
00109 int defttl_;
00110 };
00111
00112 class MIPDecapsulator : public AddressClassifier {
00113 public:
00114 MIPDecapsulator();
00115 void recv(Packet* p, Handler* h);
00116 };
00117
00118 class SimpleTimer : public TimerHandler {
00119 public:
00120 SimpleTimer(Agent *a) : TimerHandler() { a_ = a; }
00121 protected:
00122 inline void expire(Event *) { a_->timeout(MIP_TIMER_SIMPLE); }
00123 Agent *a_;
00124 };
00125
00126 class MIPBSAgent : public Agent {
00127 public:
00128 MIPBSAgent();
00129 virtual void recv(Packet *, Handler *);
00130 void timeout(int);
00131 protected:
00132 int command(int argc, const char*const*argv);
00133 void send_ads(int dst = -1, NsObject *target = NULL);
00134 void sendOutBCastPkt(Packet *p);
00135 double beacon_;
00136 NsObject *bcast_target_;
00137 NsObject *ragent_;
00138 SimpleTimer timer_;
00139 int mask_;
00140 int shift_;
00141 #ifndef notdef
00142 int seqno_;
00143 #endif
00144 double adlftm_;
00145 };
00146
00147 class MIPMHAgent;
00148
00149 class AgtListTimer : public TimerHandler {
00150 public:
00151 AgtListTimer(MIPMHAgent *a) : TimerHandler() { a_ = a; }
00152 protected:
00153 void expire(Event *e);
00154 MIPMHAgent *a_;
00155 };
00156
00157 typedef struct _agentList {
00158 int node_;
00159 double expire_time_;
00160 double lifetime_;
00161 struct _agentList *next_;
00162 } AgentList;
00163
00164 class MIPMHAgent : public Agent {
00165 public:
00166 MIPMHAgent();
00167 void recv(Packet *, Handler *);
00168 void timeout(int);
00169 protected:
00170 int command(int argc, const char*const*argv);
00171 void reg();
00172 void send_sols();
00173 void sendOutBCastPkt(Packet *p);
00174 int ha_;
00175 int coa_;
00176 double reg_rtx_;
00177 double beacon_;
00178 NsObject *bcast_target_;
00179 AgentList *agts_;
00180 SimpleTimer rtx_timer_;
00181 AgtListTimer agtlist_timer_;
00182 int mask_;
00183 int shift_;
00184 #ifndef notdef
00185 int seqno_;
00186 #endif
00187 double reglftm_;
00188 double adlftm_;
00189 MobileNode *node_;
00190
00191 };
00192
00193 #endif