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
00036 #ifndef _MRCL_ADDRESS_
00037 #define _MRCL_ADDRESS_
00038
00039 #include <packet.h>
00040
00041 #define MRCL_ADDRESS_MAX_LEN 288
00042
00043 #define MRCL_ADDRESS_MAX_ROUTING_TREE_DEPTH 10
00044
00045 #define HDR_ROUTING(p) (RoutingHdr::access(p))
00046
00047 typedef struct RoutingHdr {
00048 char saddr_[MRCL_ADDRESS_MAX_LEN];
00049 char daddr_[MRCL_ADDRESS_MAX_LEN];
00050 char nexthop_[MRCL_ADDRESS_MAX_LEN];
00051 int moduleRoute_[MRCL_ADDRESS_MAX_ROUTING_TREE_DEPTH];
00052 int moduleRouteCount_;
00053 int sendup_;
00054 int ttl_;
00055
00056 inline char *saddr() { return saddr_; }
00057 inline char *daddr() { return daddr_; }
00058 inline char *nexthop() { return nexthop_; }
00059 inline int &ttl() { return ttl_; }
00060 inline void addModuleRoute(int i, int val)
00061 {
00062 assert(i < MRCL_ADDRESS_MAX_ROUTING_TREE_DEPTH);
00063 moduleRoute_[i] = val;
00064 if(i >= moduleRouteCount_)
00065 moduleRouteCount_ = i + 1;
00066 }
00067 inline int moduleRouteCount() { return moduleRouteCount_; }
00068 inline int getModuleRoute(int i) { return moduleRoute_[i]; }
00069 inline void clearModuleRoute()
00070 {
00071 moduleRouteCount_ = 0;
00072 memset(moduleRoute_, 0, sizeof(int) * MRCL_ADDRESS_MAX_ROUTING_TREE_DEPTH);
00073 sendup_ = 0;
00074 }
00075 inline int sendup() { return sendup_; }
00076 inline void setSendup() { sendup_ = 1; }
00077
00078
00079 static int offset_;
00080 inline static int& offset() { return offset_; }
00081 inline static struct RoutingHdr* access(const Packet* p) {
00082 return (struct RoutingHdr*)p->access(offset_);
00083 }
00084 } RoutingHdr;
00085
00086
00087 class MrclAddress : public TclObject
00088 {
00089 public:
00090 MrclAddress();
00091 MrclAddress(char *addr);
00092 virtual ~MrclAddress();
00093
00110 virtual int command(int argc, const char*const* argv);
00118 virtual int toString(char *str, int strlen) = 0;
00122 virtual int strlen() = 0;
00123
00129 virtual void setAddress(const char *addr) = 0;
00130
00131 void setAddr(void *addr, int addrlen);
00132
00133 void getAddr(void *addr, int addrle = MRCL_ADDRESS_MAX_LEN - sizeof(int), int offset = 0);
00134
00135 char *getAddr();
00136
00137 void write(void *addr, int addrlen);
00138
00139 bool operator==(const MrclAddress &a);
00140
00141 int isEqual(char *addr);
00142
00143 static int areEqual(char *addr1, char *addr2);
00144 static void storeAddr(char *dst, char *addr);
00145 private:
00146 char addr_[MRCL_ADDRESS_MAX_LEN];
00147 };
00148
00149 #endif
00150
00151