|
@@ -613,13 +613,20 @@ struct SubnetSubnetIdIndexTag { };
|
|
|
/// @brief Tag for the index for searching by subnet prefix.
|
|
|
struct SubnetPrefixIndexTag { };
|
|
|
|
|
|
-/// @brief Multi index container holding subnets.
|
|
|
+/// @brief Tag for the index for searching by server identifier.
|
|
|
+struct SubnetServerIdIndexTag { };
|
|
|
+
|
|
|
+/// @brief A collection of @c Subnet4 objects
|
|
|
+///
|
|
|
+/// This container provides a set of indexes which can be used to retrieve
|
|
|
+/// subnets by various properties.
|
|
|
///
|
|
|
-/// This multi index container can hold pointers to @ref Subnet4 or
|
|
|
-/// @ref Subnet6 objects representing subnets. It provides indexes for
|
|
|
-/// subnet lookups using subnet properties such as: subnet identifier
|
|
|
-/// or subnet prefix. It also provides a random access index which
|
|
|
-/// allows for using the container like a vector.
|
|
|
+/// This multi index container can hold pointers to @ref Subnet4
|
|
|
+/// objects representing subnets. It provides indexes for subnet lookups
|
|
|
+/// using subnet properties such as: subnet identifier,
|
|
|
+/// subnet prefix or server identifier specified for a subnet. It also
|
|
|
+/// provides a random access index which allows for using the container
|
|
|
+/// like a vector.
|
|
|
///
|
|
|
/// The random access index is used by the DHCP servers which perform
|
|
|
/// a full scan on subnets to find the one that matches some specific
|
|
@@ -632,12 +639,9 @@ struct SubnetPrefixIndexTag { };
|
|
|
/// @todo We should consider optimizing subnet selection by leveraging
|
|
|
/// the indexing capabilities of this container, e.g. searching for
|
|
|
/// a subnet by interface name, relay address etc.
|
|
|
-///
|
|
|
-/// @tparam SubnetType Type of the subnet: @ref Subnet4 or @ref Subnet6.
|
|
|
-template<typename SubnetType>
|
|
|
-using SubnetCollection = boost::multi_index_container<
|
|
|
+typedef boost::multi_index_container<
|
|
|
// Multi index container holds pointers to the subnets.
|
|
|
- boost::shared_ptr<SubnetType>,
|
|
|
+ Subnet4Ptr,
|
|
|
// The following holds all indexes.
|
|
|
boost::multi_index::indexed_by<
|
|
|
// First is the random access index allowing for accessing
|
|
@@ -654,21 +658,61 @@ using SubnetCollection = boost::multi_index_container<
|
|
|
boost::multi_index::ordered_unique<
|
|
|
boost::multi_index::tag<SubnetPrefixIndexTag>,
|
|
|
boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
|
|
|
+ >,
|
|
|
+
|
|
|
+ // Fourth index allows for searching using an output from getServerId
|
|
|
+ boost::multi_index::ordered_non_unique<
|
|
|
+ boost::multi_index::tag<SubnetServerIdIndexTag>,
|
|
|
+ boost::multi_index::const_mem_fun<Network4, asiolink::IOAddress,
|
|
|
+ &Network4::getServerId>
|
|
|
>
|
|
|
>
|
|
|
->;
|
|
|
-
|
|
|
-/// @brief A collection of @c Subnet4 objects
|
|
|
-///
|
|
|
-/// This container provides a set of indexes which can be used to retrieve
|
|
|
-/// subnets by various properties.
|
|
|
-typedef SubnetCollection<Subnet4> Subnet4Collection;
|
|
|
+> Subnet4Collection;
|
|
|
|
|
|
/// @brief A collection of @c Subnet6 objects
|
|
|
///
|
|
|
/// This container provides a set of indexes which can be used to retrieve
|
|
|
/// subnets by various properties.
|
|
|
-typedef SubnetCollection<Subnet6> Subnet6Collection;
|
|
|
+///
|
|
|
+/// This multi index container can hold pointers to @ref Subnet6 objects
|
|
|
+/// representing subnets. It provides indexes for subnet lookups using
|
|
|
+/// subnet properties such as: subnet identifier or subnet prefix. It
|
|
|
+/// also provides a random access index which allows for using the
|
|
|
+/// container like a vector.
|
|
|
+///
|
|
|
+/// The random access index is used by the DHCP servers which perform
|
|
|
+/// a full scan on subnets to find the one that matches some specific
|
|
|
+/// criteria for subnet selection.
|
|
|
+///
|
|
|
+/// The remaining indexes are used for searching for a specific subnet
|
|
|
+/// as a result of receiving a command over the control API, e.g.
|
|
|
+/// when 'subnet-get' command is received.
|
|
|
+///
|
|
|
+/// @todo We should consider optimizing subnet selection by leveraging
|
|
|
+/// the indexing capabilities of this container, e.g. searching for
|
|
|
+/// a subnet by interface name, relay address etc.
|
|
|
+typedef boost::multi_index_container<
|
|
|
+ // Multi index container holds pointers to the subnets.
|
|
|
+ Subnet6Ptr,
|
|
|
+ // The following holds all indexes.
|
|
|
+ boost::multi_index::indexed_by<
|
|
|
+ // First is the random access index allowing for accessing
|
|
|
+ // objects just like we'd do with a vector.
|
|
|
+ boost::multi_index::random_access<
|
|
|
+ boost::multi_index::tag<SubnetRandomAccessIndexTag>
|
|
|
+ >,
|
|
|
+ // Second index allows for searching using subnet identifier.
|
|
|
+ boost::multi_index::ordered_unique<
|
|
|
+ boost::multi_index::tag<SubnetSubnetIdIndexTag>,
|
|
|
+ boost::multi_index::const_mem_fun<Subnet, SubnetID, &Subnet::getID>
|
|
|
+ >,
|
|
|
+ // Third index allows for searching using an output from toText function.
|
|
|
+ boost::multi_index::ordered_unique<
|
|
|
+ boost::multi_index::tag<SubnetPrefixIndexTag>,
|
|
|
+ boost::multi_index::const_mem_fun<Subnet, std::string, &Subnet::toText>
|
|
|
+ >
|
|
|
+ >
|
|
|
+> Subnet6Collection;
|
|
|
|
|
|
//@}
|
|
|
|