INET Framework for OMNeT++/OMNEST
ansaOspfArea6.h
Go to the documentation of this file.
00001 //
00002 // This program is free software: you can redistribute it and/or modify
00003 // it under the terms of the GNU Lesser General Public License as published by
00004 // the Free Software Foundation, either version 3 of the License, or
00005 // (at your option) any later version.
00006 // 
00007 // This program is distributed in the hope that it will be useful,
00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 // GNU Lesser General Public License for more details.
00011 // 
00012 // You should have received a copy of the GNU Lesser General Public License
00013 // along with this program.  If not, see http://www.gnu.org/licenses/.
00014 // 
00015 
00016 #ifndef ANSAOSPFAREA6_H_
00017 #define ANSAOSPFAREA6_H_
00018 
00019 #include "ansaLsa6.h"
00020 #include "ansaOspfCommon6.h"
00021 #include "ansaOspfInterface6.h"
00022 #include "ansaOspfRoutingTableEntry6.h"
00023 
00024 namespace AnsaOspf6 {
00025 
00026 class Router;
00027 
00028 class Area : public cPolymorphic{
00029 private:
00030    AreaID                                                      areaID;
00031    std::map<IPv6AddressPrefix, bool, IPv6AddressPrefix_Less>   advertiseAddressPrefixes;
00032    std::vector<IPv6AddressPrefix>                              areaAddressPrefixes;
00033    std::vector<Interface*>                                     associatedInterfaces;
00034    std::vector<HostRouteParameters>                            hostRoutes;
00035    std::map<LinkStateID, RouterLsa*>                           routerLSAsByID;
00036    std::vector<RouterLsa*>                                     routerLSAs;
00037    std::map<LinkStateID, NetworkLsa*>                          networkLSAsByID;
00038    std::vector<NetworkLsa*>                                    networkLSAs;
00039    std::map<LinkStateID, InterAreaPrefixLsa*>                  interAreaPrefixLSAsByID;
00040    std::vector<InterAreaPrefixLsa*>                            interAreaPrefixLSAs;
00041    std::map<LinkStateID, InterAreaRouterLsa*>                  interAreaRouterLSAsByID;
00042    std::vector<InterAreaRouterLsa*>                            interAreaRouterLSAs;
00043    std::map<LinkStateID, IntraAreaPrefixLsa*>                  intraAreaPrefixLSAsByID;
00044    std::vector<IntraAreaPrefixLsa*>                            intraAreaPrefixLSAs;
00045    bool                                                        transitCapability;
00046    bool                                                        externalRoutingCapability;
00047    Metric                                                      stubDefaultCost;
00048    RouterLsa*                                                  spfTreeRoot;
00049                                                                // FIXME is it still RouterLSA, or
00050                                                                // some new LSA with IPv6 prefixes?
00051 
00052    Router*                                                     parentRouter;
00053 
00054 public:
00055             Area(AreaID id = BackboneAreaID);
00056    virtual ~Area(void);
00057 
00058    void                SetAreaID                       (AreaID id)                                     { areaID = id; }
00059    AreaID              GetAreaID                       (void) const                                    { return areaID; }
00060    void                AddAddressPrefix                (IPv6AddressPrefix prefix, bool advertise)      { areaAddressPrefixes.push_back(prefix); advertiseAddressPrefixes[prefix] = advertise; }
00061    unsigned int        GetAddressPrefixCount           (void) const                                    { return areaAddressPrefixes.size(); }
00062    IPv6AddressPrefix   GetAddressPrefix                (unsigned int index) const                      { return areaAddressPrefixes[index]; }
00063    void                AddHostRoute                    (HostRouteParameters& hostRouteParameters)      { hostRoutes.push_back(hostRouteParameters); }
00064    void                SetTransitCapability            (bool transit)                                  { transitCapability = transit; }
00065    bool                GetTransitCapability            (void) const                                    { return transitCapability; }
00066    void                SetExternalRoutingCapability    (bool flooded)                                  { externalRoutingCapability = flooded; }
00067    bool                GetExternalRoutingCapability    (void) const                                    { return externalRoutingCapability; }
00068    void                SetSPFTreeRoot                  (RouterLsa* root)                               { spfTreeRoot = root; }
00069    RouterLsa*          GetSPFTreeRoot                  (void)                                          { return spfTreeRoot; }
00070    const RouterLsa*    GetSPFTreeRoot                  (void) const                                    { return spfTreeRoot; }
00071 
00072    void                SetRouter                       (Router* router)                                { parentRouter = router; }
00073    Router*             GetRouter                       (void)                                          { return parentRouter; }
00074    const Router*       GetRouter                       (void) const                                    { return parentRouter; }
00075 
00076    unsigned long              GetRouterLSACount             (void) const               { return routerLSAs.size(); }
00077    RouterLsa*                 GetRouterLSA                  (unsigned long i)          { return routerLSAs[i]; }
00078    const RouterLsa*           GetRouterLSA                  (unsigned long i) const    { return routerLSAs[i]; }
00079    unsigned long              GetNetworkLSACount            (void) const               { return networkLSAs.size(); }
00080    NetworkLsa*                GetNetworkLSA                 (unsigned long i)          { return networkLSAs[i]; }
00081    const NetworkLsa*          GetNetworkLSA                 (unsigned long i) const    { return networkLSAs[i]; }
00082    unsigned long              GetInterAreaPrefixLSACount    (void) const               { return interAreaPrefixLSAs.size(); }
00083    InterAreaPrefixLsa*        GetInterAreaPrefixLSA         (unsigned long i)          { return interAreaPrefixLSAs[i]; }
00084    const InterAreaPrefixLsa*  GetInterAreaPrefixLSA         (unsigned long i) const    { return interAreaPrefixLSAs[i]; }
00085    unsigned long              GetInterAreaRouterLSACount    (void) const               { return interAreaRouterLSAs.size(); }
00086    InterAreaRouterLsa*        GetInterAreaRouterLSA         (unsigned long i)          { return interAreaRouterLSAs[i]; }
00087    const InterAreaRouterLsa*  GetInterAreaRouterLSA         (unsigned long i) const    { return interAreaRouterLSAs[i]; }
00088    unsigned long              GetIntraAreaPrefixLSACount    (void) const               { return intraAreaPrefixLSAs.size(); }
00089    IntraAreaPrefixLsa*        GetIntraAreaPrefixLSA         (unsigned long i)          { return intraAreaPrefixLSAs[i]; }
00090    const IntraAreaPrefixLsa*  GetIntraAreaPrefixLSA         (unsigned long i) const    { return intraAreaPrefixLSAs[i]; }
00091 
00092    bool                ContainsAddress             (IPv6Address address) const;
00093    bool                HasAddressPrefix            (IPv6AddressPrefix prefix) const;
00094    IPv6AddressPrefix   GetContainingAddressRange   (IPv6AddressPrefix prefix, bool* advertise = NULL) const;
00095    void                AddInterface                (Interface* intf);
00096    unsigned int        GetNumberOfInterfaces       (void)                              { return associatedInterfaces.size(); }
00097    Interface*          GetInterfaceByIndex         (unsigned int index);
00098    Interface*          GetInterface                (unsigned char ifIndex);
00099    Interface*          GetInterface                (IPv6Address address);
00100    bool                HasVirtualLink              (AreaID withTransitArea) const;
00101    Interface*          FindVirtualLink             (RouterID routerID);
00102 
00103 
00104    bool                       InstallRouterLSA                (OspfRouterLsa6* lsa);
00105    bool                       InstallNetworkLSA               (OspfNetworkLsa6* lsa);
00106    bool                       InstallInterAreaPrefixLSA       (OspfInterAreaPrefixLsa6* lsa);
00107    bool                       InstallInterAreaRouterLSA       (OspfInterAreaRouterLsa6* lsa);
00108    bool                       InstallIntraAreaPrefixLSA       (OspfIntraAreaPrefixLsa6* lsa);
00109    RouterLsa*                 FindRouterLSA                   (LinkStateID linkStateID);
00110    const RouterLsa*           FindRouterLSA                   (LinkStateID linkStateID) const;
00111    NetworkLsa*                FindNetworkLSA                  (LinkStateID linkStateID);
00112    const NetworkLsa*          FindNetworkLSA                  (LinkStateID linkStateID) const;
00113    InterAreaPrefixLsa*        FindInterAreaPrefixLSA          (LinkStateID linkStateID);
00114    const InterAreaPrefixLsa*  FindInterAreaPrefixLSA          (LinkStateID linkStateID) const;
00115    InterAreaRouterLsa*        FindInterAreaRouterLSA          (LinkStateID linkStateID);
00116    const InterAreaRouterLsa*  FindInterAreaRouterLSA          (LinkStateID linkStateID) const;
00117    IntraAreaPrefixLsa*        FindIntraAreaPrefixLSA          (LinkStateID linkStateID);
00118    const IntraAreaPrefixLsa*  FindIntraAreaPrefixLSA          (LinkStateID linkStateID) const;
00119    void                       AgeDatabase                     (void);
00120    void                       RemoveParentFromRoutingInfo     (OspfLsa6* parent);
00121    bool                       HasAnyNeighborInStates          (int states) const;
00122    void                       RemoveFromAllRetransmissionLists(LsaKeyType6 lsaKey);
00123    bool                       IsOnAnyRetransmissionList       (LsaKeyType6 lsaKey) const;
00124    bool                       FloodLSA                        (OspfLsa6* lsa, Interface* intf = NULL, Neighbor* neighbor = NULL);
00125    bool                       IsLocalAddress                  (IPv6Address address) const;
00126    RouterLsa*                 OriginateRouterLSA              (void);
00127    NetworkLsa*                OriginateNetworkLSA             (const Interface* intf);
00128    InterAreaPrefixLsa*        OriginateInterAreaPrefixLSA     (void); // FIXME
00129    InterAreaRouterLsa*        OriginateInterAreaRouterLSA     (void); // FIXME
00130    IntraAreaPrefixLsa*        OriginateIntraAreaPrefixLSA     (void); // FIXME
00131    void                       CalculateShortestPathTree       (std::vector<RoutingTableEntry*>& newRoutingTable);
00132    void                       CalculateInterAreaRoutes        (std::vector<RoutingTableEntry*>& newRoutingTable);
00133 
00134    // FIXME
00135    // void                       ReCheckSummaryLSAs                  (std::vector<RoutingTableEntry*>& newRoutingTable);
00136 
00137    void        info(char* buffer);
00138    std::string detailedInfo(void) const;
00139 
00140 private:
00141 
00142 };
00143 
00144 }
00145 
00146 inline std::ostream& operator<<(std::ostream& ostr, AnsaOspf6::Area& area) {
00147    ostr << area.detailedInfo();
00148    return ostr;
00149 }
00150 
00151 #endif /* ANSAOSPFAREA6_H_ */