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

DestHashClassifier Class Reference

#include <classifier-hash.h>

Inheritance diagram for DestHashClassifier:

Inheritance graph
[legend]
Collaboration diagram for DestHashClassifier:

Collaboration graph
[legend]
List of all members.

Public Types

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

Public Member Functions

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

Protected Member Functions

const char * hashkey (nsaddr_t, nsaddr_t dst, int)
int lookup (nsaddr_t src, nsaddr_t dst, int fid)
int newflow (Packet *pkt)
void reset ()
int set_hash (nsaddr_t src, nsaddr_t dst, int fid, int slot)
int get_hash (nsaddr_t src, nsaddr_t dst, int fid)
virtual int getnxt (NsObject *)
void alloc (int)
void handle (Event *)

Protected Attributes

int default_
Tcl_HashTable ht_
hkey buf_
int keylen_
NsObject ** slot_
int nslot_
int maxslot_
int offset_
int shift_
int mask_
NsObjectdefault_target_
int nsize_
int debug_

Member Enumeration Documentation

enum Classifier::classify_ret [inherited]
 

Enumeration values:
ONCE 
TWICE 

Definition at line 64 of file classifier.h.

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


Constructor & Destructor Documentation

DestHashClassifier::DestHashClassifier  )  [inline]
 

Definition at line 172 of file classifier-hash.h.

00172 : HashClassifier(TCL_ONE_WORD_KEYS) {}


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 DestHashClassifier::classify Packet p  )  [virtual]
 

Reimplemented from HashClassifier.

Definition at line 182 of file classifier-hash.cc.

References HashClassifier::default_, HashClassifier::lookup(), Classifier::maxslot_, and Classifier::slot().

00183 {
00184         int slot= lookup(p);
00185         if (slot >= 0 && slot <=maxslot_)
00186                 return (slot);
00187         else if (default_ >= 0)
00188                 return (default_);
00189         return -1;
00190 } // HashClassifier::classify

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 HierClassifier::command().

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

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

Reimplemented from HashClassifier.

Definition at line 200 of file classifier-hash.cc.

References HashClassifier::command(), do_install(), and SMALL_LEN.

00201 {
00202         if (argc == 4) {
00203                 // $classifier install $dst $node
00204                 if (strcmp(argv[1], "install") == 0) {
00205                         char dst[SMALL_LEN];
00206                         strcpy(dst, argv[2]);
00207                         NsObject *node = (NsObject*)TclObject::lookup(argv[3]);
00208                         //nsaddr_t dst = atoi(argv[2]);
00209                         do_install(dst, node); 
00210                         return TCL_OK;
00211                         //int slot = getnxt(node);
00212                         //install(slot, node);
00213                         //if (set_hash(0, dst, 0, slot) >= 0)
00214                         //return TCL_OK;
00215                         //else
00216                         //return TCL_ERROR;
00217                 } // if
00218         }
00219         return(HashClassifier::command(argc, argv));
00220 } // command

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, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

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, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

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 DestHashClassifier::do_install char *  dst,
NsObject target
[virtual]
 

Reimplemented from Classifier.

Definition at line 192 of file classifier-hash.cc.

References Classifier::getnxt(), Classifier::install(), nsaddr_t, HashClassifier::set_hash(), and Classifier::slot().

Referenced by command().

00192                                                                {
00193         nsaddr_t d = atoi(dst);
00194         int slot = getnxt(target);
00195         install(slot, target); 
00196         if (set_hash(0, d, 0, slot) < 0)
00197                 fprintf(stderr, "DestHashClassifier::set_hash from within DestHashClassifier::do_install returned value < 0");
00198 }

Here is the call graph for this function:

int HashClassifier::do_set_hash nsaddr_t  src,
nsaddr_t  dst,
int  fid,
int  slot
[inline, inherited]
 

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

References HashClassifier::set_hash().

Referenced by ManualRoutingModule::add_route().

00067                                                                        {
00068                 return (set_hash(src,dst,fid,slot));
00069         }

Here is the call graph for this function:

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

Reimplemented in BcastAddressClassifier, QSClassifier, NixClassifier, and SRClassifier.

Definition at line 154 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(), QSAgent::recv(), MIPDecapsulator::recv(), Classifier::recv(), MacClassifier::recv(), and MCastBSTClassifier::recv().

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

Here is the call graph for this function:

int HashClassifier::get_hash nsaddr_t  src,
nsaddr_t  dst,
int  fid
[inline, protected, inherited]
 

Definition at line 116 of file classifier-hash.h.

References HashClassifier::hashkey(), and HashClassifier::ht_.

Referenced by HashClassifier::command(), and HashClassifier::lookup().

00116                                                           {
00117                 Tcl_HashEntry *ep= Tcl_FindHashEntry(&ht_, 
00118                                                      hashkey(src, dst, fid)); 
00119                 if (ep)
00120                         return (int)Tcl_GetHashValue(ep);
00121                 return -1;
00122         }

Here is the call graph for this function:

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

Reimplemented in ReserveAddressClassifier, and ReservePortClassifier.

Definition at line 120 of file classifier.cc.

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

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

00121 {
00122         int i;
00123         for (i=0; i < nslot_; i++)
00124                 if (slot_[i]==0 || slot_[i]==nullagent)
00125                         return i;
00126         i=nslot_;
00127         alloc(nslot_);
00128         return i;
00129 }

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:

const char* DestHashClassifier::hashkey nsaddr_t  ,
nsaddr_t  dst,
int 
[inline, protected, virtual]
 

Implements HashClassifier.

Definition at line 177 of file classifier-hash.h.

References Classifier::mshift().

00177                                                          {
00178                 return (const char*) mshift(dst);
00179         }

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(), HierClassifier::do_install(), 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 178 of file classifier.cc.

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

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

00178                                            {
00179         int slot = maxslot_ + 1;
00180         install(slot, node);
00181         return (slot);
00182 }

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 HashClassifier::lookup nsaddr_t  src,
nsaddr_t  dst,
int  fid
[inline, protected, inherited]
 

Definition at line 88 of file classifier-hash.h.

References HashClassifier::get_hash().

00088                                                         {
00089                 return get_hash(src, dst, fid);
00090         }

Here is the call graph for this function:

virtual int HashClassifier::lookup Packet p  )  [inline, virtual, inherited]
 

Definition at line 54 of file classifier-hash.h.

References hdr_ip::access(), hdr_ip::daddr(), hdr_ip::flowid(), HashClassifier::get_hash(), Classifier::mshift(), and hdr_ip::saddr().

Referenced by classify(), HashClassifier::classify(), HashClassifier::newflow(), and HashClassifier::unknown().

00054                                       {
00055                 hdr_ip* h = hdr_ip::access(p);
00056                 return get_hash(mshift(h->saddr()), mshift(h->daddr()), 
00057                                 h->flowid());
00058         }

Here is the call graph for this function:

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(), hashkey(), SrcDestHashClassifier::hashkey(), SrcDestFidHashClassifier::hashkey(), and HashClassifier::lookup().

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

int HashClassifier::newflow Packet pkt  )  [inline, protected, inherited]
 

Definition at line 91 of file classifier-hash.h.

References hdr_ip::access(), hdr_ip::daddr(), hdr_ip::flowid(), HashClassifier::lookup(), and hdr_ip::saddr().

00091                                  {
00092                 hdr_ip* h = hdr_ip::access(pkt);
00093                 Tcl::instance().evalf("%s unknown-flow %u %u %u",
00094                                       name(), h->saddr(), h->daddr(),
00095                                       h->flowid()); 
00096                 return lookup(pkt);
00097         };

Here is the call graph for this function:

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:

void Classifier::recv Packet p,
Handler h
[virtual, inherited]
 

Implements NsObject.

Reimplemented in MCastBSTClassifier, HierClassifier, MacClassifier, VirtualClassifier, Replicator, and MIPDecapsulator.

Definition at line 135 of file classifier.cc.

References Classifier::find(), Packet::free(), and NsObject::recv().

Referenced by QSAgent::recv(), ErrorModule::recv(), DumbAgent::recv(), and HierClassifier::recv().

00136 {
00137         NsObject* node = find(p);
00138         if (node == NULL) {
00139                 /*
00140                  * XXX this should be "dropped" somehow.  Right now,
00141                  * these events aren't traced.
00142                  */
00143                 Packet::free(p);
00144                 return;
00145         }
00146         node->recv(p,h);
00147 }

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 HashClassifier::reset  )  [inline, protected, virtual, inherited]
 

Reimplemented from NsObject.

Definition at line 98 of file classifier-hash.h.

References HashClassifier::ht_, and HashClassifier::keylen_.

00098                      {
00099                 Tcl_DeleteHashTable(&ht_);
00100                 Tcl_InitHashTable(&ht_, keylen_);
00101         }

void HashClassifier::set_default int  slot  )  [inline, inherited]
 

Definition at line 66 of file classifier-hash.h.

References HashClassifier::default_.

Referenced by ManualRoutingModule::add_route().

00066 { default_ = slot; } 

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

Definition at line 56 of file classifier.h.

References Classifier::default_target_.

Referenced by HierClassifier::command().

00056                                                       { 
00057                 default_target_ = obj;
00058         }

int HashClassifier::set_hash nsaddr_t  src,
nsaddr_t  dst,
int  fid,
int  slot
[inline, protected, inherited]
 

Definition at line 105 of file classifier-hash.h.

References HashClassifier::hashkey(), and HashClassifier::ht_.

Referenced by HashClassifier::command(), do_install(), and HashClassifier::do_set_hash().

00105                                                                     {
00106                 int newEntry;
00107                 Tcl_HashEntry *ep= Tcl_CreateHashEntry(&ht_,
00108                                                        hashkey(src, dst, fid),
00109                                                        &newEntry); 
00110                 if (ep) {
00111                         Tcl_SetHashValue(ep, slot);
00112                         return slot;
00113                 }
00114                 return -1;
00115         }

Here is the call graph for this function:

virtual void Classifier::set_table_size int  level,
int  nn
[inline, virtual, inherited]
 

Reimplemented in HierClassifier.

Definition at line 75 of file classifier.h.

00075 {}

void HashClassifier::set_table_size int  nn  )  [inline, inherited]
 

Reimplemented from Classifier.

Definition at line 70 of file classifier-hash.h.

00070 {}

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

Definition at line 50 of file classifier.h.

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

Referenced by classify(), HashClassifier::classify(), Classifier::command(), MCastClassifier::command(), HierClassifier::command(), HashClassifier::command(), MPLSAddressClassifier::command(), 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         }

virtual int HashClassifier::unknown Packet p  )  [inline, virtual, inherited]
 

Definition at line 59 of file classifier-hash.h.

References hdr_ip::access(), hdr_ip::daddr(), hdr_ip::flowid(), HashClassifier::lookup(), and hdr_ip::saddr().

Referenced by HashClassifier::classify().

00059                                        {
00060                 hdr_ip* h = hdr_ip::access(p);
00061                 Tcl::instance().evalf("%s unknown-flow %u %u %u",
00062                                       name(), h->saddr(), h->daddr(),
00063                                       h->flowid()); 
00064                 return lookup(p);
00065         };

Here is the call graph for this function:


Member Data Documentation

hkey HashClassifier::buf_ [protected, inherited]
 

Definition at line 129 of file classifier-hash.h.

Referenced by SrcDestHashClassifier::hashkey(), and SrcDestFidHashClassifier::hashkey().

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(), RedPDQueue::enque(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), and REDQueue::reset().

int HashClassifier::default_ [protected, inherited]
 

Definition at line 127 of file classifier-hash.h.

Referenced by classify(), HashClassifier::classify(), HashClassifier::HashClassifier(), and HashClassifier::set_default().

NsObject* Classifier::default_target_ [protected, inherited]
 

Definition at line 87 of file classifier.h.

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

Tcl_HashTable HashClassifier::ht_ [protected, inherited]
 

Definition at line 128 of file classifier-hash.h.

Referenced by HashClassifier::command(), HashClassifier::get_hash(), HashClassifier::HashClassifier(), HashClassifier::reset(), HashClassifier::set_hash(), and HashClassifier::~HashClassifier().

int HashClassifier::keylen_ [protected, inherited]
 

Definition at line 130 of file classifier-hash.h.

Referenced by HashClassifier::HashClassifier(), and HashClassifier::reset().

int Classifier::mask_ [protected, inherited]
 

Definition at line 86 of file classifier.h.

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

int Classifier::maxslot_ [protected, inherited]
 

Definition at line 83 of file classifier.h.

Referenced by MultiPathForwarder::classify(), 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 88 of file classifier.h.

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

int Classifier::nslot_ [protected, inherited]
 

Definition at line 82 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 84 of file classifier.h.

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

int Classifier::shift_ [protected, inherited]
 

Definition at line 85 of file classifier.h.

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

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

Definition at line 81 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(), 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 Apr 20 12:37:59 2004 for NS2.26SourcesOriginal by doxygen 1.3.3