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

VARPTable Class Reference

#include <varp.h>

Inheritance diagram for VARPTable:

Inheritance graph
[legend]
Collaboration diagram for VARPTable:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 VARPTable (void)
 ~VARPTable (void)
int command (int argc, const char *const *argv)
int arpresolve (int IP, Packet *p)

Private Member Functions

void sizeinit (int n)

Private Attributes

int * maddr_
int size_

Constructor & Destructor Documentation

VARPTable::VARPTable void   ) 
 

Definition at line 50 of file varp.cc.

00050                          : TclObject(), maddr_(0), size_(0)
00051 {}

VARPTable::~VARPTable void   ) 
 

Definition at line 54 of file varp.cc.

References maddr_.

00055 {
00056         delete [] maddr_;
00057 }


Member Function Documentation

int VARPTable::arpresolve int  IP,
Packet p
 

Definition at line 91 of file varp.cc.

References HDR_MAC, maddr_, and size_.

Referenced by LL::sendDown().

00091                                                {
00092         if (IPaddr > size_)
00093                 return 1;
00094         int ma = maddr_[IPaddr];
00095         if (ma >= 0) {
00096                 HDR_MAC(p)->macDA_ = ma;
00097                 return 0;
00098         }
00099         return 1;
00100 }

int VARPTable::command int  argc,
const char *const *  argv
 

Definition at line 77 of file varp.cc.

References maddr_, size_, and sizeinit().

00077                                                        {
00078         if (argc == 4) {
00079                 if (strcmp(argv[1], "mac-addr") == 0) {
00080                         int n = atoi(argv[2]);
00081                         if(!(n < size_))
00082                                 sizeinit(n);
00083                         
00084                         maddr_[n] = atoi(argv[3]);
00085                         return (TCL_OK);
00086                 }
00087         }
00088         return TclObject::command(argc, argv);
00089 }

Here is the call graph for this function:

void VARPTable::sizeinit int  n  )  [private]
 

Definition at line 59 of file varp.cc.

References maddr_, and size_.

Referenced by command().

00060 {
00061         int *temp = maddr_;
00062         int osize = size_;
00063         int i; 
00064         
00065         if (size_ == 0)
00066                 size_ = 10;
00067         while(!(n < size_))
00068                         size_ = 2*size_;
00069         maddr_ = new int[size_];
00070         for (i=0;i<osize;i++)
00071                 maddr_[i] = temp[i];
00072         for (i=osize;i<size_;i++)
00073                 maddr_[i] = -1;
00074         delete [] temp;
00075 }


Member Data Documentation

int* VARPTable::maddr_ [private]
 

Definition at line 57 of file varp.h.

Referenced by arpresolve(), command(), sizeinit(), and ~VARPTable().

int VARPTable::size_ [private]
 

Definition at line 59 of file varp.h.

Referenced by arpresolve(), command(), and sizeinit().


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