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
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070 #ifndef ns_classifier_addr_mpls_h
00071 #define ns_classifier_addr_mpls_h
00072
00073 #include "address.h"
00074 #include "classifier-addr.h"
00075 #include "tclcl.h"
00076
00077 const int MPLS_MaxPFTEntryNB = 100;
00078 const int MPLS_MaxLIBEntryNB = 100;
00079 const int MPLS_MaxERBEntryNB = 100;
00080 const int MPLS_MINIMUM_LSPID = 1000;
00081
00082 const int MPLS_DEFAULT_PHB = -1;
00083 const int MPLS_DONTCARE = -77;
00084 const int MPLS_GOTO_L3 = -99;
00085
00086
00087 const int MPLS_DROPPACKET = 0;
00088 const int MPLS_L3FORWARDING = 1;
00089 const int MPLS_MAKENEWLSP = 2;
00090
00091 struct hdr_mpls {
00092 int label_;
00093 int bflag_;
00094 int ttl_;
00095 hdr_mpls* nexthdr_;
00096 hdr_mpls* top_;
00097
00098 int& label() { return label_; }
00099 int& bflag() { return bflag_; }
00100 int& ttl() { return ttl_; }
00101
00102
00103 static int offset_;
00104 inline static int& offset() { return offset_; }
00105 inline static hdr_mpls* access(const Packet* p) {
00106 return (hdr_mpls*)p->access(offset_);
00107 }
00108 };
00109
00110 struct PFTEntry {
00111 int FEC_;
00112 int PHB_;
00113 int LIBptr_;
00114 int aPATHptr_;
00115 };
00116
00117 struct PFT {
00118 PFTEntry Entry_[MPLS_MaxPFTEntryNB];
00119 int NB_;
00120 };
00121
00122 struct ERBEntry {
00123 int LSPid_;
00124 int FEC_;
00125 int LIBptr_;
00126 };
00127
00128 struct ERB {
00129 ERBEntry Entry_[MPLS_MaxERBEntryNB];
00130 int NB_;
00131 };
00132
00133 struct LIBEntry {
00134 int iIface_;
00135 int iLabel_;
00136 int oIface_;
00137 int oLabel_;
00138 int LIBptr_;
00139 };
00140
00141 struct LIB {
00142 LIBEntry Entry_[MPLS_MaxLIBEntryNB];
00143 int NB_;
00144 };
00145
00146 struct PktInfo
00147 {
00148 ns_addr_t dst_;
00149 int srcnode_;
00150 int phb_;
00151 hdr_mpls* shimhdr_;
00152 };
00153
00154 class MPLSAddressClassifier : public AddressClassifier {
00155 public:
00156 MPLSAddressClassifier();
00157 virtual int command(int argc, const char*const* argv);
00158
00159
00160
00161 static int ordered_control_;
00162 static int on_demand_;
00163
00164
00165 protected:
00166 virtual void install(int slot, NsObject *target);
00167
00168 virtual int classify(Packet* p);
00169 int MPLSclassify(Packet* p);
00170
00171 int processIP();
00172 int processLabelP();
00173
00174 int convertL2toL2(int iLabel, int oIface, int oLabel, int LIBptr);
00175 int convertL3toL2(int oIface, int oLabel, int LIBptr);
00176
00177 void GetIPInfo(Packet* p, ns_addr_t& dstaddr, int& phb, int& srcnode);
00178 hdr_mpls* checkTTL(hdr_mpls* shimhdr);
00179
00180 hdr_mpls* GetShimHeader(Packet* p);
00181 hdr_mpls* DelAllShimHeader(hdr_mpls* shimhdr);
00182 hdr_mpls* push(hdr_mpls* shimhdr, int oLabel);
00183 hdr_mpls* pop(hdr_mpls* shimhdr);
00184 void swap(hdr_mpls* shimhdr, int oLabel) {
00185 shimhdr->label_ = oLabel;
00186 }
00187
00188 void PFTinsert(int FEC, int PHB, int LIBptr);
00189 void PFTdelete(int entrynb);
00190 void PFTdeleteLIBptr(int LIBptr);
00191 void PFTupdate(int entrynb, int LIBptr);
00192 int PFTlocate(int FEC, int PHB, int &LIBptr);
00193 int PFTlookup(int FEC, int PHB, int &oIface,
00194 int &oLabel, int &LIBptr);
00195
00196 void ERBinsert(int LSPid, int FEC, int LIBptr);
00197 void ERBdelete(int entrynb);
00198 void ERBupdate(int entrynb, int LIBptr);
00199 int ERBlocate(int LSPid, int FEC, int &LIBptr);
00200
00201 int LIBinsert(int iIface, int iLabel, int oIface, int oLabel);
00202 int LIBisdeleted(int entrynb);
00203 void LIBupdate(int entrynb, int iIface, int iLabel,
00204 int oIface, int oLabel);
00205 int LIBlookup(int entrynb, int& oIface, int& oLabel, int& LIBptr);
00206 int LIBlookup(int iIface, int iLabel,
00207 int& oIface, int& oLabel, int& LIBptr);
00208 int LIBgetIncoming(int entrynb, int& iIface, int& iLabel);
00209
00210 int ErLspBinding(int FEC,int PHB, int erFEC, int LSPid);
00211 int ErLspStacking(int erFEC0, int erLSPid0, int erFEC, int erLSPid);
00212 int FlowAggregation(int fineFEC, int finePHB, int coarseFEC,
00213 int coarsePHB);
00214
00215 int aPathBinding(int FEC, int PHB, int erFEC,int LSPid);
00216 int aPathLookup(int FEC, int PHB,
00217 int& oIface, int& oLabel, int& LIBptr);
00218 int is_link_down(int node);
00219 int do_reroute(Packet* p);
00220
00221 void PFTdump(const char* id);
00222 void ERBdump(const char* id);
00223 void LIBdump(const char* id);
00224 void trace(char* ptype, int psize, int ilabel, char *op,
00225 int oiface, int olabel, int ttl);
00226
00227
00228 virtual void delay_bind_init_all();
00229 virtual int delay_bind_dispatch(const char*, const char*, TclObject*);
00230
00231 int size_;
00232 int ttl_;
00233 int label_;
00234 int enable_reroute_;
00235 int reroute_option_;
00236
00237 int trace_mpls_;
00238
00239 private:
00240
00241 int data_driven_;
00242 int control_driven_;
00243
00244 LIB LIB_;
00245 PFT PFT_;
00246 ERB ERB_;
00247
00248 PktInfo PI_;
00249 };
00250
00251 #endif