AccessNet.h

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2006 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #ifndef __ACCESSNET_H__
00025 #define __ACCESSNET_H__
00026 
00027 #include <omnetpp.h>
00028 
00029 #include <InitStages.h>
00030 #include <IPvXAddress.h>
00031 
00032 class IInterfaceTable;
00033 class InterfaceEntry;
00034 class IRoutingTable;
00035 class RoutingTable6;
00036 class IPRoute;
00037 class IPv6Route;
00038 
00042 struct IPv6Words
00043 {
00044 public:
00045     uint32 d0, d1, d2, d3;
00046 
00047     IPv6Words(IPvXAddress addr) {
00048         const uint32* words = addr.words();
00049         d0 = words[0];
00050         d1 = words[1];
00051         d2 = words[2];
00052         d3 = words[3];
00053     }
00054 
00055     IPv6Words() {
00056             d0 = 0;
00057             d1 = 0;
00058             d2 = 0;
00059             d3 = 0;
00060         }
00061 };
00062 
00066 class NodeInfo
00067 {
00068 public:
00069     IPvXAddress IPAddress; 
00070     cModule* module; 
00071     IInterfaceTable* interfaceTable; 
00072     IRoutingTable* routingTable; 
00073     RoutingTable6* routingTable6;
00074     simtime_t createdAt; 
00075 
00083     friend std::ostream& operator<<(std::ostream& os, NodeInfo& n);
00084 };
00085 
00089 class TerminalInfo : public NodeInfo
00090 {
00091 public:
00092     cModule* PPPInterface; 
00093     cModule* remotePPPInterface; 
00094     InterfaceEntry* interfaceEntry; 
00095     InterfaceEntry* remoteInterfaceEntry; 
00096     IInterfaceTable* remoteInterfaceTable; 
00097     IPRoute* remoteRoutingEntry; 
00098     IPRoute* routingEntry; 
00099     IPv6Route* remoteIpv6RoutingEntry; 
00100     IPv6Route* ipv6routingEntry; 
00101 };
00102 
00106 class AccessNet : public cSimpleModule
00107 {
00108 public:
00109 
00115     virtual int size()
00116     {
00117         return overlayTerminal.size();
00118     }
00119 
00125     virtual cModule* getAccessNode()
00126     {
00127         return router.module;
00128     }
00129 
00138     virtual IPvXAddress addOverlayNode(cModule* overlayNode, bool migrate = false);
00139 
00143     int getRandomNodeId();
00144 
00148     virtual cModule* removeOverlayNode(int ID);
00149 
00156     virtual cModule* getOverlayNode(int ID);
00157 
00164     void selectChannel(const std::string& typeRx, const std::string &typeTx)
00165     {
00166         channelTypeRxStr = typeRx;
00167         channelTypeTxStr = typeTx;
00168     }
00169 
00170 protected:
00171 
00172     NodeInfo router; 
00173     std::vector<TerminalInfo> overlayTerminal; 
00174     std::vector<IPvXAddress> returnedIPs; 
00175 
00176     IPvXAddress getAssignedPrefix(IInterfaceTable* ift);
00182     virtual int numInitStages() const
00183     {
00184         return MAX_STAGE_UNDERLAY + 1;
00185     }
00186 
00190     virtual void initialize(int stage);
00191 
00197     virtual void handleMessage(cMessage* msg);
00198 
00202     virtual void updateDisplayString();
00203 
00204     uint32_t lastIP; 
00205     bool useIPv6; 
00206 
00207     std::vector<std::string> channelTypesRx; 
00208     std::string channelTypeRxStr; 
00209     std::vector<std::string> channelTypesTx; 
00210     std::string channelTypeTxStr; 
00211 
00212     // statistics
00213     cOutVector lifetimeVector; 
00214 };
00215 
00223 cGate* firstUnusedGate(cModule* owner, const char* name, cGate::Type type = cGate::NONE);
00224 
00225 
00226 
00227 #endif