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 #ifndef ns_ldp_h
00048 #define ns_ldp_h
00049
00050 #include "agent.h"
00051 #include "tclcl.h"
00052 #include "packet.h"
00053 #include "address.h"
00054 #include "ip.h"
00055
00056 const int LDP_MaxMSGTEntryNB = 100;
00057
00058
00059 const int LDP_NotificationMSG = 0x0001;
00060 const int LDP_MappingMSG = 0x0400;
00061 const int LDP_RequestMSG = 0x0401;
00062 const int LDP_WithdrawMSG = 0x0402;
00063 const int LDP_ReleaseMSG = 0x0403;
00064
00065 const int LDP_LoopDetected = 0x000B;
00066 const int LDP_NoRoute = 0x000D;
00067
00068 const int LDP_LabelALLOC = 0;
00069 const int LDP_LabelPASS = 1;
00070 const int LDP_LabelSTACK = 2;
00071
00072 struct hdr_ldp {
00073 int msgtype;
00074 int msgid;
00075
00076 int fec;
00077 int label;
00078
00079 int reqmsgid;
00080 int status;
00081
00082
00083
00084
00085 char *pathvec;
00086
00087 char *er;
00088
00089 int lspid;
00090 int rc;
00091
00092
00093 static int offset_;
00094 inline static int& offset() { return offset_; }
00095 inline static hdr_ldp* access(const Packet* p) {
00096 return (hdr_ldp*)p->access(offset_);
00097 }
00098 };
00099
00100
00101 struct MsgTable {
00102 int MsgID;
00103 int FEC;
00104 int LspID;
00105 int Src;
00106 int PMsgID;
00107 int LabelOp;
00108 int ERLspID;
00109 };
00110
00111 struct MsgT {
00112 MsgTable Entry[LDP_MaxMSGTEntryNB];
00113 int NB;
00114 };
00115
00116
00117 class LDPAgent : public Agent {
00118 public:
00119 LDPAgent();
00120
00121 virtual int command(int argc, const char*const* argv);
00122 virtual void recv(Packet*, Handler*);
00123
00124 virtual void delay_bind_init_all();
00125 virtual int delay_bind_dispatch(const char *, const char *,
00126 TclObject *);
00127
00128 inline int peer() const { return peer_; }
00129 inline void turn_on_trace() { trace_ldp_ = 1; }
00130
00131 void PKTinit(hdr_ldp *hdrldp, int msgtype, const char *pathvec,
00132 const char *er);
00133 int PKTsize(const char *pathvec, const char *er);
00134
00135 int MSGTinsert(int MsgID, int FEC, int LspID, int Src, int PMsgID);
00136 void MSGTdelete(int entrynb);
00137 int MSGTlocate(int MsgID);
00138 int MSGTlocate(int FEC,int LspID,int Src);
00139 void MSGTlookup(int entrynb, int &MsgID, int &FEC, int &LspID,
00140 int &src, int &PMsgID, int &LabelOp);
00141 void MSGTdump();
00142
00143 protected:
00144 int new_msgid_;
00145 int trace_ldp_;
00146 int peer_;
00147 void trace(ns_addr_t src, hdr_ldp *hdrldp);
00148
00149 char* parse_msgtype(int msgtype, int lspid);
00150 char* parse_status(int status);
00151
00152 MsgT MSGT_;
00153 };
00154
00155 #endif