|
INET Framework for OMNeT++/OMNEST
|
#include <vlanTable.h>
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< tVIDPort > | tVIDPortList |
| typedef struct VLANTable::s_vid_record | tVIDRecord |
| typedef struct VLANTable::s_port_vid | tPortVIDRecord |
| typedef std::vector< tVIDRecord > | VIDTable |
| typedef std::vector < tPortVIDRecord > | PortVIDTable |
Public Member Functions | |
| VLANTable () | |
| ~VLANTable () | |
| const VIDTable * | getTaggedTable () |
| const PortVIDTable * | getUntaggedTable () |
| 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 |
Definition at line 38 of file vlanTable.h.
| typedef std::vector<tPortVIDRecord> VLANTable::PortVIDTable |
Definition at line 74 of file vlanTable.h.
| typedef struct VLANTable::s_port_vid VLANTable::tPortVIDRecord |
| typedef enum VLANTable::e_tag_action VLANTable::tTagAction |
| typedef struct VLANTable::s_vid_port VLANTable::tVIDPort |
| typedef std::vector<tVIDPort> VLANTable::tVIDPortList |
Definition at line 58 of file vlanTable.h.
| typedef struct VLANTable::s_vid_record VLANTable::tVIDRecord |
| typedef std::vector<tVIDRecord> VLANTable::VIDTable |
Definition at line 73 of file vlanTable.h.
Definition at line 47 of file vlanTable.h.
{
REMOVE = 0,
INCLUDE = 1,
NONE = -1,
} tTagAction;
Definition at line 10 of file vlanTable.cc.
{
return;
}
Definition at line 13 of file vlanTable.cc.
{
return;
}
| void VLANTable::add | ( | int | VID, |
| tVIDPortList & | _portList | ||
| ) |
Definition at line 97 of file vlanTable.cc.
| 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().
| void VLANTable::extendTable | ( | int | VLAN | ) |
Definition at line 232 of file vlanTable.cc.
Referenced by addPortVID(), initDefault(), and VLANTableXMLparser::parseVLANs().
| void VLANTable::finish | ( | ) | [protected, virtual] |
Definition at line 216 of file vlanTable.cc.
{
}
| VLANTable::tVIDPortList VLANTable::getPorts | ( | int | VID | ) |
Definition at line 36 of file vlanTable.cc.
Referenced by ANSASwitchCore::relay().
| 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;
}
| const VLANTable::VIDTable * VLANTable::getTaggedTable | ( | ) |
Definition at line 20 of file vlanTable.cc.
{
return &vidTable;
}
| const VLANTable::PortVIDTable * VLANTable::getUntaggedTable | ( | ) |
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 | ( | ) |
| void VLANTable::initDefault | ( | ) |
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().
| 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().
| 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;
}
tVIDPortList VLANTable::empty [private] |
Definition at line 109 of file vlanTable.h.
Referenced by getPorts().
tVIDRecord VLANTable::emptyVID [private] |
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().
PortVIDTable VLANTable::portVIDTable [private] |
Definition at line 108 of file vlanTable.h.
Referenced by addPortVID(), getUntaggedTable(), getVID(), initialize(), and setPortVID().
VIDTable VLANTable::vidTable [private] |
Definition at line 107 of file vlanTable.h.
Referenced by add(), addTagged(), addUntagged(), delPort(), extendTable(), getPorts(), getTag(), getTaggedTable(), initialize(), isAllowed(), and setVLANName().
std::vector<unsigned int> VLANTable::vlanList [private] |
Definition at line 113 of file vlanTable.h.
Referenced by getVLANList(), and regVLAN().