• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/mpls/ldp.h

00001 // -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
00002 
00003 /*
00004  * ldp.h
00005  * Copyright (C) 2000 by the University of Southern California
00006  * $Id: ldp.h,v 1.4 2005/08/25 18:58:09 johnh Exp $
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License,
00010  * version 2, as published by the Free Software Foundation.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00020  *
00021  *
00022  * The copyright of this module includes the following
00023  * linking-with-specific-other-licenses addition:
00024  *
00025  * In addition, as a special exception, the copyright holders of
00026  * this module give you permission to combine (via static or
00027  * dynamic linking) this module with free software programs or
00028  * libraries that are released under the GNU LGPL and with code
00029  * included in the standard release of ns-2 under the Apache 2.0
00030  * license or under otherwise-compatible licenses with advertising
00031  * requirements (or modified versions of such code, with unchanged
00032  * license).  You may copy and distribute such a system following the
00033  * terms of the GNU GPL for this module and the licenses of the
00034  * other code concerned, provided that you include the source code of
00035  * that other code when and as the GNU GPL requires distribution of
00036  * source code.
00037  *
00038  * Note that people who make modified versions of this module
00039  * are not obligated to grant this special exception for their
00040  * modified versions; it is their choice whether to do so.  The GNU
00041  * General Public License gives permission to release a modified
00042  * version without this exception; this exception also makes it
00043  * possible to release a modified version which carries forward this
00044  * exception.
00045  *
00046  */
00047 
00048 // Other copyrights might apply to parts of this software and are so
00049 // noted when applicable.
00050 //
00051 // Original source contributed by Gaeil Ahn. See below.
00052 //
00053 // $Header: /cvsroot/nsnam/ns-2/mpls/ldp.h,v 1.4 2005/08/25 18:58:09 johnh Exp $
00054 
00055 /**************************************************************************
00056 * Copyright (c) 2000 by Gaeil Ahn                                         *
00057 * Everyone is permitted to copy and distribute this software.             *
00058 * Please send mail to fog1@ce.cnu.ac.kr when you modify or distribute     *
00059 * this sources.                                                           *
00060 **************************************************************************/
00061 
00062 /***********************************************************
00063 *                                                          *
00064 *    File: Header File for LDP & CR-LDP protocol           *
00065 *    Author: Gaeil Ahn (fog1@ce.cnu.ac.kr), Jan. 2000      *
00066 *                                                          *
00067 ***********************************************************/
00068 
00069 #ifndef ns_ldp_h
00070 #define ns_ldp_h
00071 
00072 #include "agent.h"
00073 #include "tclcl.h"
00074 #include "packet.h"
00075 #include "address.h"
00076 #include "ip.h"
00077 
00078 const int LDP_MaxMSGTEntryNB = 100;
00079 
00080 /* LDP msg types */
00081 const int LDP_NotificationMSG = 0x0001;
00082 const int LDP_MappingMSG =      0x0400;
00083 const int LDP_RequestMSG =      0x0401;
00084 const int LDP_WithdrawMSG =     0x0402;
00085 const int LDP_ReleaseMSG =      0x0403;
00086 
00087 const int LDP_LoopDetected =    0x000B;
00088 const int LDP_NoRoute =         0x000D;
00089 
00090 const int LDP_LabelALLOC =      0;
00091 const int LDP_LabelPASS =       1;
00092 const int LDP_LabelSTACK =      2;
00093 
00094 struct hdr_ldp {
00095         int  msgtype;
00096         int  msgid;     // request msg id (mapping msg triggered by request 
00097                         // msg). if (msgid > -1): by request, else:  no 
00098         int  fec;
00099         int  label;
00100         
00101         int  reqmsgid;
00102         int  status;      // for Notification
00103 
00104         // XXX This is VERY BAD behavior! Should NEVER put a pointer
00105         // in a packet header!!
00106 
00107         char *pathvec; 
00108         // The following is for CR-LSP
00109         char *er;
00110 
00111         int  lspid;
00112         int  rc;
00113 
00114         // Header access methods
00115         static int offset_; // required by PacketHeaderManager
00116         inline static int& offset() { return offset_; }
00117         inline static hdr_ldp* access(const Packet* p) {
00118                 return (hdr_ldp*)p->access(offset_);
00119         }
00120 };
00121 
00122 // Used for supporting ordered distribuiton mode (Explicit LSP)
00123 struct MsgTable {
00124         int  MsgID;
00125         int  FEC;
00126         int  LspID;
00127         int  Src;
00128         int  PMsgID;    // previsou msg-id
00129         int  LabelOp;   // LabelALLOC, LabelPASS, or LabelSTACK
00130         int  ERLspID;
00131 };
00132 
00133 struct MsgT {
00134         MsgTable Entry[LDP_MaxMSGTEntryNB];
00135         int      NB;
00136 };
00137 
00138 
00139 class LDPAgent : public Agent {
00140 public:
00141         LDPAgent();
00142 
00143         virtual int command(int argc, const char*const* argv);
00144         virtual void recv(Packet*, Handler*);
00145 
00146         virtual void delay_bind_init_all();
00147         virtual int delay_bind_dispatch(const char *, const char *, 
00148                                         TclObject *);
00149   
00150         inline int peer() const { return peer_; }
00151         inline void turn_on_trace() { trace_ldp_ = 1; }
00152 
00153         void PKTinit(hdr_ldp *hdrldp, int msgtype, const char *pathvec, 
00154                      const char *er);
00155         int  PKTsize(const char *pathvec, const char *er);
00156         
00157         int  MSGTinsert(int MsgID, int FEC, int LspID, int Src, int PMsgID);
00158         void MSGTdelete(int entrynb);
00159         int  MSGTlocate(int MsgID);
00160         int  MSGTlocate(int FEC,int LspID,int Src);
00161         void MSGTlookup(int entrynb, int &MsgID, int &FEC, int &LspID, 
00162                         int &src, int &PMsgID, int &LabelOp);
00163         void MSGTdump();
00164    
00165 protected:
00166         int    new_msgid_;
00167         int    trace_ldp_;
00168         int    peer_;
00169         void   trace(ns_addr_t src, hdr_ldp *hdrldp);
00170   
00171         char* parse_msgtype(int msgtype, int lspid);
00172         char* parse_status(int status);
00173   
00174         MsgT  MSGT_;
00175 };
00176 
00177 #endif

Generated on Tue Aug 10 2010 16:16:07 for ns-2.33 by  doxygen 1.7.1