INET Framework for OMNeT++/OMNEST
ansaSwitchCore.h
Go to the documentation of this file.
00001 
00002 /*
00003  *
00004  * zdenek kraus
00005  *
00006  * switchCore
00007  *
00008  */
00009 //ASDF
00010 #ifndef __ANSASWITCHCORE_H__
00011 #define __ANSASWITCHCORE_H__
00012 
00013 #include <omnetpp.h>
00014 
00015 #include <map>
00016 #include <string>
00017 
00018 #include "NotificationBoard.h"
00019 #include "MACAddress.h"
00020 #include "Ethernet.h"
00021 
00022 #include "EtherFrame_m.h"
00023 #include "AnsaEtherFrame_m.h"
00024 
00025 #include "macTable.h"
00026 #include "vlanTable.h"
00027 #include "stp/stp.h"
00028 
00029 
00030 class ANSASwitchCore : public cSimpleModule
00031 {
00032   public:
00033 
00034 
00035         /* switch core frame descriptor for internal representation unpacked frame */
00036         typedef struct s_frame_descriptor {
00037           cPacket * payload; // relaying message
00038           int VID; // frame's VLAN ID
00039           int rPort; // reception port
00040           VLANTable::tVIDPortList portList; // suggested(then applied) list of destination ports
00041           MACAddress src; // source MAC address of the original frame
00042           MACAddress dest; // destination MAC address of the original frame
00043           int etherType; // EtherType from EthernetIIFrame
00044           std::string name; // for simulation frame name
00045         } tFrameDescriptor;
00046 
00047         MACAddress getBridgeAddress();
00048 
00049   private:
00050 
00051   protected:
00052   MACAddress bridgeGroupAddress;
00053   MACAddress bridgeAddress;
00054 
00055   MACTable * addrTable;
00056   VLANTable * vlanTable;
00057   Stp * spanningTree;
00058 
00059   cMessage * currentMsg;
00060 
00061   int portCount;
00062 
00063   virtual void initialize(int stage);
00064   virtual int numInitStages() const {return 1;}
00065   virtual void handleMessage(cMessage * msg);
00066   virtual void finish();
00067 
00068   bool reception(tFrameDescriptor& frame, cMessage *msg);
00069   void relay(tFrameDescriptor& frame);
00070   void dispatch(tFrameDescriptor& frame);
00071 
00072   bool ingress(tFrameDescriptor& tmp, EthernetIIFrame *frame, int rPort);
00073   bool ingress(tFrameDescriptor& tmp, AnsaEtherFrame *frame, int rPort);
00074   void egress(tFrameDescriptor& frame);
00075 
00076   void learn(tFrameDescriptor& frame);
00077 
00078   void processFrame(cMessage * msg);
00079   void handleIncomingFrame(EthernetIIFrame *frame);
00080 
00081   void handleAndDispatchFrame(EthernetIIFrame *frame, int inputport);
00082   void broadcastFrame(EthernetIIFrame *frame, int inputport);
00083 
00084   void sinkMsg(cMessage *msg);
00085   void sinkDupMsg(cMessage *msg);
00086 
00087   void dispatchBPDU(cMessage *msg, int port);
00088   void deliverBPDU(tFrameDescriptor& frame);
00089 
00090  // void tagMsg(int _vlan);
00091   AnsaEtherFrame * tagMsg(EthernetIIFrame * _frame, int _vlan);
00092   //void untagMsg();
00093   EthernetIIFrame * untagMsg(AnsaEtherFrame * _frame);
00094 
00095 };
00096 
00097 
00098 
00099 inline std::ostream& operator<<(std::ostream& os, const ANSASwitchCore::tFrameDescriptor f) {
00100         os << "---FRAME DESCRIPTOR---" << std::endl;
00101 
00102         os << " Name: " << f.name << std::endl;
00103         os << "  Src: " << f.src << std::endl;
00104         os << " Dest: " << f.dest << std::endl;
00105         os << "  VID: " << f.VID << std::endl;
00106         os << "rPort: " << f.rPort << std::endl;
00107         os << "pList: " << f.portList << std::endl;
00108         os << "eType: " << f.etherType << std::endl;
00109         os << "pLoad: " << f.payload << std::endl;
00110 
00111         os << "---END OF DESCRIPTOR---" << std::endl;
00112         return os;
00113 }
00114 
00115 
00116 
00117 
00118 
00119 
00120 #endif
00121 
00122 
00123