xorp

pim_scope_zone_table.hh

00001 // -*- c-basic-offset: 4; tab-width: 8; indent-tabs-mode: t -*-
00002 
00003 // Copyright (c) 2001-2011 XORP, Inc and Others
00004 //
00005 // This program is free software; you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License, Version 2, June
00007 // 1991 as published by the Free Software Foundation. Redistribution
00008 // and/or modification of this program under the terms of any other
00009 // version of the GNU General Public License is not permitted.
00010 // 
00011 // This program is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For more details,
00014 // see the GNU General Public License, Version 2, a copy of which can be
00015 // found in the XORP LICENSE.gpl file.
00016 // 
00017 // XORP Inc, 2953 Bunker Hill Lane, Suite 204, Santa Clara, CA 95054, USA;
00018 // http://xorp.net
00019 
00020 // $XORP: xorp/pim/pim_scope_zone_table.hh,v 1.15 2008/10/02 21:57:55 bms Exp $
00021 
00022 
00023 #ifndef __PIM_PIM_SCOPE_ZONE_TABLE_HH__
00024 #define __PIM_PIM_SCOPE_ZONE_TABLE_HH__
00025 
00026 
00027 //
00028 // PIM scope zone table definition.
00029 //
00030 
00031 
00032 
00033 
00034 #include "libxorp/ipvxnet.hh"
00035 #include "mrt/mifset.hh"
00036 
00037 
00038 //
00039 // Constants definitions
00040 //
00041 
00042 //
00043 // Structures/classes, typedefs and macros
00044 //
00045 
00046 class PimNode;
00047 class PimScopeZone;
00048 
00049 // The PIM Scope Zone ID
00050 class PimScopeZoneId {
00051 public:
00052     PimScopeZoneId(const IPvXNet& scope_zone_prefix, bool is_scope_zone);
00053     
00054     const IPvXNet& scope_zone_prefix() const { return (_scope_zone_prefix); }
00055     bool is_scope_zone() const { return (_is_scope_zone); }
00056     bool operator==(const PimScopeZoneId& other) const;
00057     bool is_overlap(const PimScopeZoneId& other) const;
00058     bool contains(const IPvXNet& ipvxnet) const;
00059     bool contains(const IPvX& ipvx) const;
00060     string str() const;
00061     
00062 private:
00063     IPvXNet _scope_zone_prefix; // The scope zone address prefix
00064     bool    _is_scope_zone;     // If true, this is admin. scoped zone
00065 };
00066 
00067 
00068 // PIM-specific scope zone table
00069 class PimScopeZoneTable {
00070 public:
00071     PimScopeZoneTable(PimNode& pim_node);
00072     virtual ~PimScopeZoneTable();
00073     
00074     list<PimScopeZone>& pim_scope_zone_list() { return (_pim_scope_zone_list); }
00075     void add_scope_zone(const IPvXNet& scope_zone_prefix, uint32_t vif_index);
00076     void delete_scope_zone(const IPvXNet& scope_zone_prefix,
00077                uint32_t vif_index);
00078     
00079     bool is_scoped(const IPvX& addr, uint32_t vif_index) const;
00080     bool is_scoped(const PimScopeZoneId& zone_id, uint32_t vif_index) const;
00081     bool is_zone_border_router(const IPvXNet& group_prefix) const;
00082     
00083     PimNode&    pim_node() const    { return (_pim_node);       }
00084     
00085 private:
00086     // Private functions
00087     
00088     // Private state
00089     PimNode&    _pim_node;          // The PIM node I belong to
00090     list<PimScopeZone> _pim_scope_zone_list;    // The list with scoped zones
00091 };
00092 
00093 class PimScopeZone {
00094 public:
00095     PimScopeZone(const IPvXNet& scope_zone_prefix, const Mifset& scoped_vifs);
00096 #ifdef XORP_USE_USTL
00097     PimScopeZone() { }
00098 #endif
00099     virtual ~PimScopeZone();
00100     
00101     const IPvXNet& scope_zone_prefix() const { return (_scope_zone_prefix); }
00102     void set_scoped_vif(uint32_t vif_index, bool v);
00103     
00104     bool is_empty() const { return (! _scoped_vifs.any()); }
00105     bool is_set(uint32_t vif_index) const;
00106     bool is_scoped(const IPvX& addr, uint32_t vif_index) const;
00107     bool is_scoped(const PimScopeZoneId& zone_id, uint32_t vif_index) const;
00108     bool is_same_scope_zone(const IPvXNet& scope_zone_prefix) const;
00109     
00110 private:
00111     IPvXNet _scope_zone_prefix;     // The scoped zone prefix
00112     Mifset  _scoped_vifs;           // The set of scoped vifs
00113 };
00114 
00115 //
00116 // Global variables
00117 //
00118 
00119 //
00120 // Global functions prototypes
00121 //
00122 
00123 #endif // __PIM_PIM_SCOPE_ZONE_TABLE_HH__
 All Classes Namespaces Functions Variables Typedefs Enumerations