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

DRTable Class Reference

#include <flowstruct.h>

Collaboration diagram for DRTable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DRTable (int size_=FLOW_TABLE_SIZE)
 ~DRTable ()
bool find (nsaddr_t src, nsaddr_t dst, u_int16_t &flow)
void insert (nsaddr_t src, nsaddr_t dst, u_int16_t flow)
void flush (nsaddr_t src, nsaddr_t dst)

Private Member Functions

void grow ()

Private Attributes

int size
int maxSize
DRTabEnttable

Constructor & Destructor Documentation

DRTable::DRTable int  size_ = FLOW_TABLE_SIZE  ) 
 

Definition at line 170 of file flowstruct.cc.

References maxSize, size, and table.

00170                           {
00171         assert (size_ > 0);
00172         size = 0;
00173         maxSize = size_;
00174         table = new DRTabEnt[size_];
00175 }

DRTable::~DRTable  ) 
 

Definition at line 177 of file flowstruct.cc.

References table.

00177                   {
00178         delete table;
00179 }


Member Function Documentation

bool DRTable::find nsaddr_t  src,
nsaddr_t  dst,
u_int16_t flow
 

Definition at line 181 of file flowstruct.cc.

References size, DRTabEnt::src, and table.

Referenced by checkDefaultFlow(), and FlowTable::defaultFlow().

00181                                                               {
00182         for (int i = 0; i < size; i++)
00183                 if (src == table[i].src && dst == table[i].dst) {
00184                         flow = table[i].fid;
00185                         return true;
00186                 }
00187         return false;
00188 }

void DRTable::flush nsaddr_t  src,
nsaddr_t  dst
 

Definition at line 224 of file flowstruct.cc.

References size, DRTabEnt::src, and table.

Referenced by checkDefaultFlow().

00224                                               {
00225         for (int i = 0; i < size; i++)
00226                 if (src == table[i].src && dst == table[i].dst) {
00227                         table[i].src = table[size-1].src;
00228                         table[i].dst = table[size-1].dst;
00229                         table[i].fid = table[size-1].fid;
00230                         size--;
00231                         return;
00232                 }
00233         assert(0);
00234 }

void DRTable::grow  )  [private]
 

Definition at line 190 of file flowstruct.cc.

References maxSize, and table.

Referenced by insert().

00190                    {
00191         assert(0);
00192         DRTabEnt *temp;
00193         if (!(temp = new DRTabEnt[maxSize*2]))
00194                 return;
00195         bcopy(table, temp, sizeof(DRTabEnt)*maxSize);
00196         delete table;
00197         maxSize *= 2;
00198         table = temp;
00199 }

void DRTable::insert nsaddr_t  src,
nsaddr_t  dst,
u_int16_t  flow
 

Definition at line 201 of file flowstruct.cc.

References DRTabEnt::dst, DRTabEnt::fid, grow(), maxSize, size, DRTabEnt::src, and table.

Referenced by FlowTable::createEntry().

00201                                                                {
00202         assert(flow & 1);
00203         for (int i = 0; i < size; i++) {
00204                 if (src == table[i].src && dst == table[i].dst) {
00205                         if ((short)((flow) - (table[i].fid)) > 0) {
00206                                 table[i].fid = flow;
00207                         } else {
00208                         }
00209                         return;
00210                 }
00211         }
00212 
00213         if (size == maxSize)
00214                 grow();
00215 
00216         assert(size != maxSize);
00217 
00218         table[size].src = src;
00219         table[size].dst = dst;
00220         table[size].fid = flow;
00221         size++;
00222 }

Here is the call graph for this function:


Member Data Documentation

int DRTable::maxSize [private]
 

Definition at line 81 of file flowstruct.h.

Referenced by DRTable(), grow(), and insert().

int DRTable::size [private]
 

Definition at line 80 of file flowstruct.h.

Referenced by DRTable(), find(), flush(), and insert().

DRTabEnt* DRTable::table [private]
 

Definition at line 82 of file flowstruct.h.

Referenced by DRTable(), find(), flush(), grow(), insert(), and ~DRTable().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:39:33 2004 for NS2.26SourcesOriginal by doxygen 1.3.3