INET Framework for OMNeT++/OMNEST
ipSplitter.cc
Go to the documentation of this file.
00001 //
00002 // Marek Cerny, 2MSK
00003 // FIT VUT 2011
00004 //
00005 // This program is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU Lesser General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 // 
00010 // This program is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 // GNU Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public License
00016 // along with this program.  If not, see http://www.gnu.org/licenses/.
00017 // 
00018 
00019 #include "ipSplitter.h"
00020 
00021 Define_Module(IpSplitter);
00022 
00023 void IpSplitter::initialize(){
00024 
00025 }
00026 
00027 void IpSplitter::handleMessage(cMessage *msg){
00028 
00029         cGate* gate = msg->getArrivalGate();
00030         std::string gateName = gate->getBaseName();
00031         int gateIndex = gate->getIndex();
00032 
00033         // packet coming from network layer modules within the router
00034         if (gateName == "ipv4In" || gateName == "ipv6In" || gateName == "isisIn")
00035         {
00036 
00037                 // send packet to out interface
00038                 this->send(msg, "ifOut", gateIndex);
00039 
00040         // packet coming from in interfaces
00041         }
00042         else
00043         {
00044 
00045                 // IPv6 datagram, send it to networkLayer6 via ipv6Out
00046                 if (dynamic_cast<IPv6Datagram *>(msg))
00047                 {
00048                         this->send(msg, "ipv6Out", gateIndex);
00049                 }
00050                 else
00051                 {
00052                     if(dynamic_cast<ISISMessage *>(msg))
00053                     {
00054                         this->send(msg, "isisOut", gateIndex);
00055                     }
00056 
00057                     // other (IPv4), send it to networkLayer via ipv4Out
00058                     else
00059                     {
00060                         this->send(msg, "ipv4Out", gateIndex);
00061                     }
00062                 }
00063         }
00064 }