HierClassifier Class Reference

#include <classifier-hier.h>

Inheritance diagram for HierClassifier:

Classifier NsObject TclObject Handler Collaboration diagram for HierClassifier:

Collaboration graph
[legend]

Detailed Description

Definition at line 58 of file classifier-hier.h.

Public Types

enum  classify_ret { ONCE = -2, TWICE = -1 }

Public Member Functions

int allocPort (NsObject *)
virtual int classify (Packet *)
virtual void clear (int slot)
virtual int command (int argc, const char *const *argv)
virtual void debug (const char *fmt,...)
virtual int delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer)
virtual void delay_bind_init_all ()
virtual void do_install (char *dst, NsObject *target)
virtual NsObjectfind (Packet *)
 HierClassifier ()
virtual void install (int slot, NsObject *)
int install_next (NsObject *node)
int isdebug () const
int maxslot () const
int mshift (int val)
virtual void recv (Packet *p, const char *s)
virtual void recv (Packet *p, Handler *h)
virtual void recvOnly (Packet *)
void set_default_target (NsObject *obj)
void set_table_size (int nn)
void set_table_size (int level, int csize)
NsObjectslot (int slot)
virtual ~HierClassifier ()

Protected Member Functions

void alloc (int)
virtual int getnxt (NsObject *)
void handle (Event *)
virtual void reset ()

Protected Attributes

int debug_
NsObjectdefault_target_
int mask_
int maxslot_
int nsize_
int nslot_
int offset_
int shift_
NsObject ** slot_

Private Attributes

Classifier ** clsfr_


Member Enumeration Documentation

enum Classifier::classify_ret [inherited]
 

Enumerator:
ONCE 
TWICE 

Definition at line 64 of file classifier.h.

00064 {ONCE= -2, TWICE= -1};


Constructor & Destructor Documentation

HierClassifier::HierClassifier  )  [inline]
 

Definition at line 60 of file classifier-hier.h.

References clsfr_, AddrParamsClass::hlevel(), and AddrParamsClass::instance().

00060                      : Classifier() {
00061         clsfr_ = new Classifier*[AddrParamsClass::instance().hlevel()];
00062     }

Here is the call graph for this function:

virtual HierClassifier::~HierClassifier  )  [inline, virtual]
 

Definition at line 63 of file classifier-hier.h.

References clsfr_.

00063                               {
00064         // Deletion of contents (classifiers) is done in otcl
00065         delete []clsfr_;
00066     }


Member Function Documentation

void Classifier::alloc int   )  [protected, inherited]
 

Definition at line 79 of file classifier.cc.

References Classifier::nsize_, Classifier::nslot_, and Classifier::slot_.

Referenced by ReservePortClassifier::command(), ReserveAddressClassifier::command(), Classifier::getnxt(), ReservePortClassifier::getnxt(), ReserveAddressClassifier::getnxt(), and Classifier::install().

00080 {
00081     NsObject** old = slot_;
00082     int n = nslot_;
00083     if (old == 0) 
00084         if (nsize_ != 0) {
00085             //printf("classifier %x set to %d....%dth visit\n", this, nsize_, i++);
00086             nslot_ = nsize_;
00087         }
00088         else {
00089             //printf("classifier %x set to 32....%dth visit\n", this, j++);
00090             nslot_ = 32;
00091         }
00092     while (nslot_ <= slot) 
00093         nslot_ <<= 1;
00094     slot_ = new NsObject*[nslot_];
00095     memset(slot_, 0, nslot_ * sizeof(NsObject*));
00096     for (int i = 0; i < n; ++i)
00097         slot_[i] = old[i];
00098     delete [] old;
00099 }

int Classifier::allocPort NsObject  )  [inherited]
 

Definition at line 120 of file classifier.cc.

References Classifier::getnxt().

00121 {
00122     return getnxt (nullagent);
00123 }

Here is the call graph for this function:

int Classifier::classify Packet  )  [virtual, inherited]
 

Reimplemented in AddressClassifier, ReserveAddressClassifier, MCastBSTClassifier, HashClassifier, DestHashClassifier, MCastClassifier, MultiPathForwarder, PortClassifier, VirtualClassifier, LmsClassifier, Replicator, and MPLSAddressClassifier.

Definition at line 64 of file classifier.cc.

References Packet::access(), Classifier::mshift(), and Classifier::offset_.

Referenced by Classifier::find(), and LanRouter::next_hop().

00065 {
00066     return (mshift(*((int*) p->access(offset_))));
00067 }

Here is the call graph for this function:

void Classifier::clear int  slot  )  [virtual, inherited]
 

Reimplemented in ReserveAddressClassifier, and ReservePortClassifier.

Definition at line 111 of file classifier.cc.

References Classifier::maxslot_, and Classifier::slot_.

Referenced by Classifier::command(), and command().

00112 {
00113     slot_[slot] = 0;
00114     if (slot == maxslot_) {
00115         while (--maxslot_ >= 0 && slot_[maxslot_] == 0)
00116             ;
00117     }
00118 }

int HierClassifier::command int  argc,
const char *const *  argv
[virtual]
 

Reimplemented from Classifier.

Definition at line 55 of file classifier-hier.cc.

References Classifier::clear(), clsfr_, Classifier::command(), AddrParamsClass::hlevel(), AddrParamsClass::instance(), Classifier::set_default_target(), and Classifier::slot().

00056 {
00057     Tcl& tcl = Tcl::instance();
00058     if (argc == 3) {
00059         if (strcmp(argv[1], "classifier") == 0) {
00060             // XXX Caller must guarantee that the supplied level
00061             // is within range, i.e., 0 < n <= level_
00062             tcl.resultf("%s", clsfr_[atoi(argv[2])-1]->name());
00063             return TCL_OK;
00064         } else if (strcmp(argv[1], "defaulttarget") == 0) {
00065             NsObject *o = (NsObject *)TclObject::lookup(argv[2]);
00066             for (int i = 0; 
00067                  i < AddrParamsClass::instance().hlevel(); i++)
00068                 clsfr_[i]->set_default_target(o);
00069             return (TCL_OK);
00070         } else if (strcmp(argv[1], "clear") == 0) {
00071             int slot = atoi(argv[2]);
00072             for (int i = 0; 
00073                  i < AddrParamsClass::instance().hlevel(); i++)
00074                 clsfr_[i]->clear(slot);
00075             return (TCL_OK);
00076         }
00077     } else if (argc == 4) {
00078         if (strcmp(argv[1], "add-classifier") == 0) {
00079             int n = atoi(argv[2]) - 1;
00080             Classifier *c=(Classifier*)TclObject::lookup(argv[3]);
00081             clsfr_[n] = c;
00082             return (TCL_OK);
00083         }
00084     }
00085     return Classifier::command(argc, argv);
00086 }

Here is the call graph for this function:

void NsObject::debug const char *  fmt,
  ...
[virtual, inherited]
 

Definition at line 102 of file object.cc.

References NsObject::debug_.

00103 {
00104     if (!debug_)
00105         return;
00106     va_list ap;
00107     va_start(ap, fmt);
00108     vprintf(fmt, ap);
00109 }

int NsObject::delay_bind_dispatch const char *  varName,
const char *  localName,
TclObject tracer
[virtual, inherited]
 

Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, HbAfterRtoSctpAgent, MfrHbAfterRtoSctpAgent, MfrTimestampSctpAgent, MultipleFastRtxSctpAgent, NewRenoSctpAgent, TimestampSctpAgent, SctpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, VegasTcpAgent, XcpAgent, and XcpSink.

Definition at line 63 of file object.cc.

References NsObject::debug_.

Referenced by MPLSAddressClassifier::delay_bind_dispatch(), and Agent::delay_bind_dispatch().

00064 {
00065     if (delay_bind_bool(varName, localName, "debug_", &debug_, tracer)) 
00066         return TCL_OK;
00067     return TclObject::delay_bind_dispatch(varName, localName, tracer);
00068 }

void NsObject::delay_bind_init_all  )  [virtual, inherited]
 

Reimplemented in BayFullTcpAgent, Agent, MPLSAddressClassifier, LDPAgent, HbAfterRtoSctpAgent, MfrHbAfterRtoSctpAgent, MfrTimestampSctpAgent, MultipleFastRtxSctpAgent, NewRenoSctpAgent, TimestampSctpAgent, SctpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, VegasTcpAgent, XcpAgent, and XcpSink.

Definition at line 57 of file object.cc.

Referenced by MPLSAddressClassifier::delay_bind_init_all(), and Agent::delay_bind_init_all().

00058 {
00059     delay_bind_init_one("debug_");
00060 }

void HierClassifier::do_install char *  dst,
NsObject target
[virtual]
 

Reimplemented from Classifier.

Definition at line 88 of file classifier-hier.cc.

References clsfr_, Classifier::install(), RouteLogic::ns_strtok(), and TINY_LEN.

00088                                                            {
00089     int istr[TINY_LEN], n=0, len=0;
00090     while(n < TINY_LEN) 
00091         istr[n++] = 0;
00092         
00093     RouteLogic::ns_strtok(dst, istr);
00094     
00095     while(istr[len] > 0) {
00096         istr[len] = istr[len] - 1;
00097         len++;
00098     }
00099     for (int i=1; i<len; i++) 
00100         clsfr_[i-1]->install(istr[i-1], clsfr_[i]);
00101     clsfr_[len-1]->install(istr[len-1], target);
00102 }

Here is the call graph for this function:

NsObject * Classifier::find Packet  )  [virtual, inherited]
 

Reimplemented in BcastAddressClassifier, QSClassifier, NixClassifier, and SRClassifier.

Definition at line 159 of file classifier.cc.

References Classifier::classify(), Classifier::default_target_, Classifier::nslot_, Classifier::slot_, and Classifier::TWICE.

Referenced by FlowMon::drop(), FlowMon::edrop(), FlowMon::find(), FlowMon::in(), Tagger::in(), FlowMon::mon_edrop(), FlowMon::out(), MIPDecapsulator::recv(), Classifier::recv(), MacClassifier::recv(), MCastBSTClassifier::recv(), and SctpAgent::SetSource().

00160 {
00161     NsObject* node = NULL;
00162     int cl = classify(p);
00163     if (cl < 0 || cl >= nslot_ || (node = slot_[cl]) == 0) { 
00164         if (default_target_) 
00165             return default_target_;
00166         /*
00167          * Sigh.  Can't pass the pkt out to tcl because it's
00168          * not an object.
00169          */
00170         Tcl::instance().evalf("%s no-slot %ld", name(), cl);
00171         if (cl == TWICE) {
00172             /*
00173              * Try again.  Maybe callback patched up the table.
00174              */
00175             cl = classify(p);
00176             if (cl < 0 || cl >= nslot_ || (node = slot_[cl]) == 0)
00177                 return (NULL);
00178         }
00179     }
00180     return (node);
00181 }

Here is the call graph for this function:

int Classifier::getnxt NsObject  )  [protected, virtual, inherited]
 

Reimplemented in ReserveAddressClassifier, and ReservePortClassifier.

Definition at line 125 of file classifier.cc.

References Classifier::alloc(), Classifier::nslot_, and Classifier::slot_.

Referenced by Classifier::allocPort(), Classifier::command(), and DestHashClassifier::do_install().

00126 {
00127     int i;
00128     for (i=0; i < nslot_; i++)
00129         if (slot_[i]==0 || slot_[i]==nullagent)
00130             return i;
00131     i=nslot_;
00132     alloc(nslot_);
00133     return i;
00134 }

Here is the call graph for this function:

void NsObject::handle Event  )  [protected, virtual, inherited]
 

Implements Handler.

Reimplemented in LinkDelay, LL, AckRecons, and Snoop.

Definition at line 91 of file object.cc.

References NsObject::recv().

00092 {
00093     recv((Packet*)e);
00094 }

Here is the call graph for this function:

void Classifier::install int  slot,
NsObject
[virtual, inherited]
 

Reimplemented in MPLSAddressClassifier.

Definition at line 102 of file classifier.cc.

References Classifier::alloc(), Classifier::maxslot_, Classifier::nslot_, and Classifier::slot_.

Referenced by Classifier::command(), Classifier::do_install(), do_install(), DestHashClassifier::do_install(), MPLSAddressClassifier::install(), and Classifier::install_next().

00103 {
00104     if (slot >= nslot_)
00105         alloc(slot);
00106     slot_[slot] = p;
00107     if (slot >= maxslot_)
00108         maxslot_ = slot;
00109 }

Here is the call graph for this function:

int Classifier::install_next NsObject node  )  [inherited]
 

Definition at line 183 of file classifier.cc.

References Classifier::install(), Classifier::maxslot_, and Classifier::slot().

Referenced by ManualRoutingModule::add_route(), and Classifier::command().

00183                                            {
00184     int slot = maxslot_ + 1;
00185     install(slot, node);
00186     return (slot);
00187 }

Here is the call graph for this function:

int NsObject::isdebug  )  const [inline, inherited]
 

Definition at line 61 of file object.h.

References NsObject::debug_.

00061 { return debug_; }

int Classifier::maxslot  )  const [inline, inherited]
 

Definition at line 49 of file classifier.h.

References Classifier::maxslot_.

Referenced by FlowMon::dumpflows(), Tagger::dumpflows(), FlowMon::flow_list(), and Tagger::flow_list().

00049 { return maxslot_; }

int Classifier::mshift int  val  )  [inline, inherited]
 

Definition at line 55 of file classifier.h.

References Classifier::mask_, and Classifier::shift_.

Referenced by Classifier::classify(), VirtualClassifier::classify(), AddressClassifier::classify(), DestHashClassifier::hashkey(), SrcDestHashClassifier::hashkey(), SrcDestFidHashClassifier::hashkey(), and HashClassifier::lookup().

00055 { return ((val >> shift_) & mask_); }

void NsObject::recv Packet p,
const char *  s
[virtual, inherited]
 

Reimplemented in CMUTrace.

Definition at line 96 of file object.cc.

References Packet::free().

00097 {
00098     Packet::free(p);
00099 }

Here is the call graph for this function:

virtual void HierClassifier::recv Packet p,
Handler h
[inline, virtual]
 

Reimplemented from Classifier.

Definition at line 67 of file classifier-hier.h.

References clsfr_, and Classifier::recv().

00067                                                     {
00068         clsfr_[0]->recv(p, h);
00069     }

Here is the call graph for this function:

virtual void NsObject::recvOnly Packet  )  [inline, virtual, inherited]
 

Reimplemented in Agent, and Trace.

Definition at line 56 of file object.h.

Referenced by Trace::recvOnly().

00056 {};

void NsObject::reset  )  [protected, virtual, inherited]
 

Reimplemented in BayFullTcpAgent, HashClassifier, IvsSource, dsREDQueue, DiffusionRate, SinkAgent, DiffusionAgent, FloodingAgent, OmniMcastAgent, LinkDelay, CBQueue, DropTail, ErrorModel, PIQueue, Queue< T >, RedPDQueue, REDQueue, REMQueue, RIOQueue, Snoop, FackTcpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, Sack1TcpAgent, TcpSink, DelAckSink, TcpAgent, VegasTcpAgent, toraAgent, Queue< T >, and XcpSink.

Definition at line 70 of file object.cc.

Referenced by NsObject::command().

00071 {
00072 }

void Classifier::set_default_target NsObject obj  )  [inline, inherited]
 

Definition at line 56 of file classifier.h.

References Classifier::default_target_.

Referenced by command().

00056                                                   { 
00057         default_target_ = obj;
00058     }

void Classifier::set_table_size int  nn  )  [inherited]
 

Reimplemented in HashClassifier.

Definition at line 74 of file classifier.cc.

References Classifier::nsize_.

Referenced by RoutingModule::set_table_size(), and set_table_size().

00075 {
00076     nsize_ = nn;
00077 }

void HierClassifier::set_table_size int  level,
int  csize
[virtual]
 

Reimplemented from Classifier.

Definition at line 104 of file classifier-hier.cc.

References clsfr_, and Classifier::set_table_size().

00105 {
00106     if (clsfr_[level-1])
00107         clsfr_[level-1]->set_table_size(size);
00108 }

Here is the call graph for this function:

NsObject* Classifier::slot int  slot  )  [inline, inherited]
 

Definition at line 50 of file classifier.h.

References Classifier::nslot_, and Classifier::slot_.

Referenced by DestHashClassifier::classify(), HashClassifier::classify(), Classifier::command(), MCastClassifier::command(), command(), HashClassifier::command(), MPLSAddressClassifier::command(), Classifier::do_install(), DestHashClassifier::do_install(), FlowMon::dumpflows(), Tagger::dumpflows(), FlowMon::flow_list(), Tagger::flow_list(), and Classifier::install_next().

00050                                     {
00051         if ((slot >= 0) && (slot < nslot_))
00052             return slot_[slot];
00053         return 0;
00054     }


Field Documentation

Classifier** HierClassifier::clsfr_ [private]
 

Definition at line 74 of file classifier-hier.h.

Referenced by command(), do_install(), HierClassifier(), recv(), set_table_size(), and ~HierClassifier().

int NsObject::debug_ [protected, inherited]
 

Reimplemented in FECModel, FloodAgent, and LandmarkAgent.

Definition at line 66 of file object.h.

Referenced by REDQueue::command(), RedPDQueue::command(), PushbackQueue::command(), NsObject::debug(), NsObject::delay_bind_dispatch(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), SctpAgent::Reset(), REDQueue::reset(), DropTail::shrink_queue(), and Delayer::try_send().

NsObject* Classifier::default_target_ [protected, inherited]
 

Definition at line 88 of file classifier.h.

Referenced by Classifier::Classifier(), Classifier::command(), Classifier::find(), BcastAddressClassifier::find(), and Classifier::set_default_target().

int Classifier::mask_ [protected, inherited]
 

Definition at line 87 of file classifier.h.

Referenced by Classifier::Classifier(), and Classifier::mshift().

int Classifier::maxslot_ [protected, inherited]
 

Definition at line 84 of file classifier.h.

Referenced by MultiPathForwarder::classify(), DestHashClassifier::classify(), HashClassifier::classify(), Classifier::clear(), ReservePortClassifier::clear(), ReserveAddressClassifier::clear(), Replicator::command(), ReservePortClassifier::command(), HashClassifier::command(), ReserveAddressClassifier::command(), Classifier::install(), Classifier::install_next(), Classifier::maxslot(), Replicator::recv(), and MacClassifier::recv().

int Classifier::nsize_ [protected, inherited]
 

Definition at line 89 of file classifier.h.

Referenced by Classifier::alloc(), and Classifier::set_table_size().

int Classifier::nslot_ [protected, inherited]
 

Definition at line 83 of file classifier.h.

Referenced by Classifier::alloc(), Classifier::command(), Classifier::find(), BcastAddressClassifier::find(), MCastClassifier::findslot(), Classifier::getnxt(), ReservePortClassifier::getnxt(), ReserveAddressClassifier::getnxt(), Classifier::install(), MPLSAddressClassifier::install(), and Classifier::slot().

int Classifier::offset_ [protected, inherited]
 

Definition at line 85 of file classifier.h.

Referenced by Classifier::Classifier(), and Classifier::classify().

int Classifier::shift_ [protected, inherited]
 

Definition at line 86 of file classifier.h.

Referenced by Classifier::Classifier(), and Classifier::mshift().

NsObject** Classifier::slot_ [protected, inherited]
 

Definition at line 82 of file classifier.h.

Referenced by Classifier::alloc(), MultiPathForwarder::classify(), Classifier::clear(), ReservePortClassifier::clear(), ReserveAddressClassifier::clear(), Replicator::command(), Classifier::command(), MCastClassifier::command(), HashClassifier::command(), Classifier::find(), SRClassifier::find(), QSClassifier::find(), BcastAddressClassifier::find(), MCastClassifier::findslot(), Classifier::getnxt(), ReservePortClassifier::getnxt(), ReserveAddressClassifier::getnxt(), Classifier::install(), MPLSAddressClassifier::install(), Replicator::recv(), MacClassifier::recv(), Classifier::slot(), and Classifier::~Classifier().


The documentation for this class was generated from the following files:
Generated on Tue Mar 6 17:10:33 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6