INET Framework for OMNeT++/OMNEST
VLANTable Class Reference

#include <vlanTable.h>

List of all members.

Classes

struct  s_port_vid
struct  s_vid_port
struct  s_vid_record

Public Types

enum  e_tag_action { REMOVE = 0, INCLUDE = 1, NONE = -1 }
typedef enum
VLANTable::e_tag_action 
tTagAction
typedef struct
VLANTable::s_vid_port 
tVIDPort
typedef std::vector< tVIDPorttVIDPortList
typedef struct
VLANTable::s_vid_record 
tVIDRecord
typedef struct
VLANTable::s_port_vid 
tPortVIDRecord
typedef std::vector< tVIDRecordVIDTable
typedef std::vector
< tPortVIDRecord
PortVIDTable

Public Member Functions

 VLANTable ()
 ~VLANTable ()
const VIDTablegetTaggedTable ()
const PortVIDTablegetUntaggedTable ()
tVIDPortList getPorts (int VID)
int getVID (int Port)
bool isAllowed (int VID, int _port)
tTagAction getTag (int VID, int _port)
void add (int VID, tVIDPortList &_portList)
void addTagged (int VID, std::vector< int > &ports)
void addUntagged (int VID, std::vector< int > &ports)
void setVLANName (int, std::string &)
void addPortVID (int _port, int _VID)
void setPortVID (int _port, int _VID)
void delPort (int _port, int _VID)
void regVLAN (unsigned int)
std::vector< unsigned int > getVLANList ()
void initDefault ()
void extendTable (int VLAN)

Protected Member Functions

virtual void initialize (int stage)
virtual int numInitStages () const
virtual void finish ()

Private Attributes

VIDTable vidTable
PortVIDTable portVIDTable
tVIDPortList empty
tVIDRecord emptyVID
std::vector< unsigned int > vlanList
int portCount

Detailed Description

Definition at line 38 of file vlanTable.h.


Member Typedef Documentation

Definition at line 74 of file vlanTable.h.

typedef std::vector<tVIDPort> VLANTable::tVIDPortList

Definition at line 58 of file vlanTable.h.

typedef std::vector<tVIDRecord> VLANTable::VIDTable

Definition at line 73 of file vlanTable.h.


Member Enumeration Documentation

Enumerator:
REMOVE 
INCLUDE 
NONE 

Definition at line 47 of file vlanTable.h.

                            {
          REMOVE = 0,
          INCLUDE = 1,
          NONE = -1,
  } tTagAction;

Constructor & Destructor Documentation

Definition at line 10 of file vlanTable.cc.

                     {
  return;
}

Definition at line 13 of file vlanTable.cc.

                      {
  return;
}

Member Function Documentation

void VLANTable::add ( int  VID,
tVIDPortList _portList 
)

Definition at line 97 of file vlanTable.cc.

                                                    {
        vidTable.at(VID).VID = VID;
        vidTable.at(VID).portList = _portList;
}
void VLANTable::addPortVID ( int  _port,
int  _VID 
)

Definition at line 154 of file vlanTable.cc.

Referenced by initDefault(), and VLANTableXMLparser::parseInterfaces().

                                              {
        portVIDTable.at(_port).port = _port;
        portVIDTable.at(_port).VID = _VID;

        std::vector<int> tmp;
        tmp.push_back(_port);
        extendTable(_VID);
        addUntagged(_VID, tmp);

}
void VLANTable::addTagged ( int  VID,
std::vector< int > &  ports 
)

Definition at line 102 of file vlanTable.cc.

Referenced by VLANTableXMLparser::parseVLANs().

                                                        {
        tVIDPortList& currentList = vidTable.at(VID).portList;
        vidTable.at(VID).VID = VID;

        tVIDPort tmpPort;
        tmpPort.action = INCLUDE;

        unsigned int i;
        unsigned int c;
        for(i = 0; i < ports.size(); i++) { // for all input port number
                for(c = 0; c < currentList.size(); c++) { // search through whole port vector
                        if (currentList.at(c).port == ports.at(i)) { // if port number match
                                currentList.at(c).action = INCLUDE; // modify action
                                break;
                        }
                }
                if (c == currentList.size()) { // if port record not found
                        tmpPort.port = ports.at(i); // set temporary port number
                        currentList.push_back(tmpPort); // insert new
                }

        }
}
void VLANTable::addUntagged ( int  VID,
std::vector< int > &  ports 
)

Definition at line 126 of file vlanTable.cc.

Referenced by addPortVID(), and VLANTableXMLparser::parseVLANs().

                                                          {
        tVIDPortList& currentList = vidTable.at(VID).portList;
        vidTable.at(VID).VID = VID;

        tVIDPort tmpPort;
        tmpPort.action = REMOVE;

        unsigned int i;
        unsigned int c;
        for(i = 0; i < ports.size(); i++) { // for all input port number
                for(c = 0; c < currentList.size(); c++) { // search through whole port vector
                        if (currentList.at(c).port == ports.at(i)) { // if port number match
                                currentList.at(c).action = REMOVE; // modify action
                                break;
                        }
                }
                if (c == currentList.size()) { // if port record not found
                        tmpPort.port = ports.at(i); // set temporary port number
                        currentList.push_back(tmpPort); // insert new
                }

        }
}
void VLANTable::delPort ( int  _port,
int  _VID 
)

Definition at line 170 of file vlanTable.cc.

Referenced by VLANTableXMLparser::parseVLANs().

                                           {
        tVIDPortList::iterator it;
        for (it = vidTable.at(_VID).portList.begin(); it != vidTable.at(_VID).portList.end(); it++) {
                if (it->port == _port) {
                        vidTable.at(_VID).portList.erase(it);
                        return;
                }
        }
}
void VLANTable::extendTable ( int  VLAN)

Definition at line 232 of file vlanTable.cc.

Referenced by addPortVID(), initDefault(), and VLANTableXMLparser::parseVLANs().

                                    {

        EV <<"KECYYYYYY !!!!!!!!!!!!!!!!!!" << "\n";
        while (vidTable.size() < (unsigned int) VLAN+2) { // +1 is for index compensation
                vidTable.push_back(emptyVID);

        }
        EV << VLAN << "/" << vidTable.size() << "\n";
}
void VLANTable::finish ( ) [protected, virtual]

Definition at line 216 of file vlanTable.cc.

                       {

}

Definition at line 36 of file vlanTable.cc.

Referenced by ANSASwitchCore::relay().

                                                 {
        if (vidTable.size() < VID+1) {
                return empty;
        }
        if (vidTable.at(VID).VID != VID) {// VLAN is not active
                return empty;
        }
        return vidTable.at(VID).portList;
}
VLANTable::tTagAction VLANTable::getTag ( int  VID,
int  _port 
)

Definition at line 76 of file vlanTable.cc.

                                                        {
        tVIDRecord tmp = vidTable.at(VID);
        if (tmp.VID != VID) { // VLAN is not active
                error("query for includeTag on non active vlan");
                simulation.endRun();
                return NONE;
        }

        for (unsigned int i = 0; i < tmp.portList.size(); i++) {
                if (tmp.portList.at(i).port == _port) {
                        return tmp.portList.at(i).action;
                }
        }

        error("query for includeTag on non existing (VID, PORT)");
        simulation.endRun();
        return NONE;
}

Definition at line 20 of file vlanTable.cc.

                                                    {
        return &vidTable;
}

Definition at line 23 of file vlanTable.cc.

                                                         {
        return &portVIDTable;
}
int VLANTable::getVID ( int  Port)

Definition at line 46 of file vlanTable.cc.

Referenced by ANSASwitchCore::ingress().

                              {
        if (Port < 0) {
                error("negative port number");
                simulation.endRun();
        }
        if (Port > portCount) {
                error("Portnumber is exceeds port count in getVID");
                simulation.endRun();
        }
        return portVIDTable.at(Port).VID;
}
std::vector< unsigned int > VLANTable::getVLANList ( )

Definition at line 228 of file vlanTable.cc.

Referenced by Stp::initialize().

                                               {
        return vlanList;
}

Definition at line 27 of file vlanTable.cc.

Referenced by initialize(), and VLANTableXMLparser::parse().

                            {
        regVLAN(1);
        extendTable(1);
        for (unsigned int i = 0; i < (unsigned int)portCount; i++) {
                addPortVID(i,1);
        }
}
void VLANTable::initialize ( int  stage) [protected, virtual]

Definition at line 183 of file vlanTable.cc.

                                    {
        if (stage == 0) {
                portCount = par("portCount"); //TODO from CFG/simulation

                emptyVID.VID = 0;

                tPortVIDRecord empty2;
                empty2.port = 0;
                empty2.VID = 0;

                //vidTable.insert(vidTable.begin(), VLANCOUNT, empty);
                portVIDTable.insert(portVIDTable.begin(), portCount, empty2);



                const char *filename = par("configFile");
                const char *switchID = par("switchID");

                if (*filename == '\0' || *switchID == '\0') {
                        EV << "Warning: " << this->getParentModule()->getName() << ": Could not config, config filename or switchID is not set, using Default." << std::endl;
                        initDefault();
                } else {
                        VLANTableXMLparser config(this);
                        config.parse(filename, switchID);
                }

                WATCH(portCount);
                WATCH_VECTOR(vidTable);
                WATCH_VECTOR(portVIDTable);
        }

}
bool VLANTable::isAllowed ( int  VID,
int  _port 
)

Definition at line 58 of file vlanTable.cc.

Referenced by ANSASwitchCore::egress(), and ANSASwitchCore::ingress().

                                            {
        if (vidTable.size() < VID+1) {
                return false;
        }
        tVIDRecord tmp = vidTable.at(VID);
        if (tmp.VID != VID) { // VLAN is not active
                return false;
        }

        for (unsigned int i = 0; i < tmp.portList.size(); i++) {
                if (tmp.portList.at(i).port == _port) {
                        return true;
                }
        }

        return false;
}
virtual int VLANTable::numInitStages ( ) const [inline, protected, virtual]

Definition at line 121 of file vlanTable.h.

{return 1;}
void VLANTable::regVLAN ( unsigned int  _vlan)

Definition at line 220 of file vlanTable.cc.

Referenced by initDefault(), and VLANTableXMLparser::parseVLANs().

                                          {
        for (unsigned int i = 0; i < vlanList.size(); i++) {
                if (vlanList.at(i) == _vlan) {
                        return;
                }
        }
        vlanList.push_back(_vlan);
}
void VLANTable::setPortVID ( int  _port,
int  _VID 
)

Definition at line 165 of file vlanTable.cc.

                                              {
        portVIDTable.at(_port).port = _port;
        portVIDTable.at(_port).VID = _VID;
}
void VLANTable::setVLANName ( int  _VID,
std::string &  _name 
)

Definition at line 150 of file vlanTable.cc.

Referenced by VLANTableXMLparser::parseVLANs().

                                                      {
        vidTable.at(_VID).name = _name;
}

Member Data Documentation

Definition at line 109 of file vlanTable.h.

Referenced by getPorts().

Definition at line 111 of file vlanTable.h.

Referenced by extendTable(), and initialize().

int VLANTable::portCount [private]

Definition at line 115 of file vlanTable.h.

Referenced by getVID(), initDefault(), and initialize().

std::vector<unsigned int> VLANTable::vlanList [private]

Definition at line 113 of file vlanTable.h.

Referenced by getVLANList(), and regVLAN().


The documentation for this class was generated from the following files: