Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

ldp.h

Go to the documentation of this file.
00001 // -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
00002 //
00003 // Time-stamp: <2000-09-08 17:14:21 haoboy>
00004 //
00005 // Copyright (c) 2000 by the University of Southern California
00006 // All rights reserved.
00007 //
00008 // Permission to use, copy, modify, and distribute this software and its
00009 // documentation in source and binary forms for non-commercial purposes
00010 // and without fee is hereby granted, provided that the above copyright
00011 // notice appear in all copies and that both the copyright notice and
00012 // this permission notice appear in supporting documentation. and that
00013 // any documentation, advertising materials, and other materials related
00014 // to such distribution and use acknowledge that the software was
00015 // developed by the University of Southern California, Information
00016 // Sciences Institute.  The name of the University may not be used to
00017 // endorse or promote products derived from this software without
00018 // specific prior written permission.
00019 //
00020 // THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about
00021 // the suitability of this software for any purpose.  THIS SOFTWARE IS
00022 // PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
00023 // INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00024 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 //
00026 // Other copyrights might apply to parts of this software and are so
00027 // noted when applicable.
00028 //
00029 // Original source contributed by Gaeil Ahn. See below.
00030 //
00031 // $Header: /nfs/jade/vint/CVSROOT/ns-2/mpls/ldp.h,v 1.3 2000/09/14 18:19:26 haoboy Exp $
00032 
00033 /**************************************************************************
00034 * Copyright (c) 2000 by Gaeil Ahn                                         *
00035 * Everyone is permitted to copy and distribute this software.             *
00036 * Please send mail to fog1@ce.cnu.ac.kr when you modify or distribute     *
00037 * this sources.                                                           *
00038 **************************************************************************/
00039 
00040 /***********************************************************
00041 *                                                          *
00042 *    File: Header File for LDP & CR-LDP protocol           *
00043 *    Author: Gaeil Ahn (fog1@ce.cnu.ac.kr), Jan. 2000      *
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 /* LDP msg types */
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;     // request msg id (mapping msg triggered by request 
00075                         // msg). if (msgid > -1): by request, else:  no 
00076         int  fec;
00077         int  label;
00078         
00079         int  reqmsgid;
00080         int  status;      // for Notification
00081 
00082         // XXX This is VERY BAD behavior! Should NEVER put a pointer
00083         // in a packet header!!
00084 
00085         char *pathvec; 
00086         // The following is for CR-LSP
00087         char *er;
00088 
00089         int  lspid;
00090         int  rc;
00091 
00092         // Header access methods
00093         static int offset_; // required by PacketHeaderManager
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 // Used for supporting ordered distribuiton mode (Explicit LSP)
00101 struct MsgTable {
00102         int  MsgID;
00103         int  FEC;
00104         int  LspID;
00105         int  Src;
00106         int  PMsgID;    // previsou msg-id
00107         int  LabelOp;   // LabelALLOC, LabelPASS, or LabelSTACK
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

Generated on Tue Apr 20 12:14:21 2004 for NS2.26SourcesOriginal by doxygen 1.3.3