• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/routing/rtmodule.h

00001 // -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- 
00002 
00003 /*
00004  * Copyright (C) 2000 by the University of Southern California
00005  * $Id: rtmodule.h,v 1.15 2005/08/25 18:58:12 johnh Exp $
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License,
00009  * version 2, as published by the Free Software Foundation.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License along
00017  * with this program; if not, write to the Free Software Foundation, Inc.,
00018  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00019  *
00020  *
00021  * The copyright of this module includes the following
00022  * linking-with-specific-other-licenses addition:
00023  *
00024  * In addition, as a special exception, the copyright holders of
00025  * this module give you permission to combine (via static or
00026  * dynamic linking) this module with free software programs or
00027  * libraries that are released under the GNU LGPL and with code
00028  * included in the standard release of ns-2 under the Apache 2.0
00029  * license or under otherwise-compatible licenses with advertising
00030  * requirements (or modified versions of such code, with unchanged
00031  * license).  You may copy and distribute such a system following the
00032  * terms of the GNU GPL for this module and the licenses of the
00033  * other code concerned, provided that you include the source code of
00034  * that other code when and as the GNU GPL requires distribution of
00035  * source code.
00036  *
00037  * Note that people who make modified versions of this module
00038  * are not obligated to grant this special exception for their
00039  * modified versions; it is their choice whether to do so.  The GNU
00040  * General Public License gives permission to release a modified
00041  * version without this exception; this exception also makes it
00042  * possible to release a modified version which carries forward this
00043  * exception.
00044  *
00045  */
00046 
00047 /*
00048  * $Header: /cvsroot/nsnam/ns-2/routing/rtmodule.h,v 1.15 2005/08/25 18:58:12 johnh Exp $
00049  *
00050  * Definition of RoutingModule, base class for all extensions to routing 
00051  * functionality in a Node. These modules are meant to be "plugin", and 
00052  * should be configured via node-config{} interface in tcl/lib/ns-lib.tcl.
00053  */
00054 
00055 #ifndef ns_rtmodule_h
00056 #define ns_rtmodule_h
00057 
00058 #include <tclcl.h>
00059 #include "addr-params.h"
00060 #include "classifier.h"
00061 #include "classifier-hash.h"
00062 #include "classifier-hier.h"
00063 
00064 
00065 
00066 class NsObject;
00067 class Node;
00068 class VirtualClassifier;
00069 class DestHashClassifier;
00070 
00071 
00072 class RoutingModule : public TclObject {
00073 public:
00074         RoutingModule(); 
00075         /*
00076          * Returns the node to which this module is attached.
00077          */ 
00078         inline Node* node() { return n_; }
00079         /*
00080          * Node-related module-specific initialization can be done here.
00081          * However: (1) RoutingModule::attach() must be called from derived
00082          * class so the value of n_ is setup, (2) module-specific 
00083          * initialization that does not require knowledge of Node should 
00084          * always stay in the module constructor.
00085          *
00086          * Return TCL_ERROR if initialization fails.
00087          */
00088         virtual int attach(Node *n) { n_ = n; return TCL_OK; }
00089         virtual int command(int argc, const char*const* argv);
00090         virtual const char* module_name() const { return NULL; }
00091 
00092         /* support for populating rtg table */
00093         void route_notify(RoutingModule *rtm);
00094         void unreg_route_notify(RoutingModule *rtm);
00095         virtual void add_route(char *dst, NsObject *target); 
00096         virtual void delete_route(char *dst, NsObject *nullagent);
00097         void set_table_size(int nn);
00098         void set_table_size(int level, int csize);
00099         RoutingModule *next_rtm_;
00100         
00101 protected:
00102         Node *n_;
00103         Classifier *classifier_;
00104 };
00105 
00106 class BaseRoutingModule : public RoutingModule {
00107 public:
00108         BaseRoutingModule() : RoutingModule() {}
00109         virtual const char* module_name() const { return "Base"; }
00110         virtual int command(int argc, const char*const* argv);
00111 protected:
00112         DestHashClassifier *classifier_;
00113 };
00114 
00115 class McastRoutingModule : public RoutingModule {
00116 public:
00117         McastRoutingModule() : RoutingModule() {}
00118         virtual const char* module_name() const { return "Mcast"; }
00119         virtual int command(int argc, const char*const* argv);
00120 protected:
00121         DestHashClassifier *classifier_;        
00122 };
00123 
00124 class HierRoutingModule : public RoutingModule {
00125 public:
00126         HierRoutingModule() : RoutingModule() {}
00127         virtual const char* module_name() const { return "Hier"; }
00128         virtual int command(int argc, const char*const* argv);
00129 protected:
00130         HierClassifier *classifier_;
00131 };
00132 
00133 class ManualRoutingModule : public RoutingModule {
00134 public:
00135         ManualRoutingModule() : RoutingModule() {}
00136         virtual const char* module_name() const { return "Manual"; }
00137         virtual int command(int argc, const char*const* argv);
00138         void add_route(char *dst, NsObject *target);
00139 protected:
00140         DestHashClassifier *classifier_;
00141 };
00142 
00143 class SourceRoutingModule : public RoutingModule {
00144 public:
00145         SourceRoutingModule() : RoutingModule() {}
00146         virtual const char* module_name() const { return "Source"; }
00147         virtual int command(int argc, const char*const* argv);
00148 };
00149 
00150 class QSRoutingModule : public RoutingModule {
00151 public:
00152         QSRoutingModule() : RoutingModule() {}
00153         virtual const char* module_name() const { return "QS"; }
00154                 virtual int command(int argc, const char*const* argv);
00155 };
00156 
00157 class VcRoutingModule : public RoutingModule {
00158 public:
00159         VcRoutingModule() : RoutingModule() {}
00160         virtual const char* module_name() const { return "VC"; }
00161         virtual int command(int argc, const char*const* argv);
00162         virtual void add_route(char *, NsObject *);
00163 };
00164 
00165 
00166 
00167 class PgmRoutingModule : public RoutingModule {
00168 public:
00169         PgmRoutingModule() : RoutingModule() {}
00170         virtual const char* module_name() const { return "PGM"; }
00171 };
00172 
00173 class LmsRoutingModule : public RoutingModule {
00174 public:
00175         LmsRoutingModule() : RoutingModule() {}
00176         virtual const char* module_name() const { return "LMS"; }
00177         // virtual int command(int argc, const char*const* argv);
00178         virtual void add_route(char *dst, NsObject *target){}
00179 };
00180 
00181 #endif //  ns_rtmodule_h

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