" },"
" {"
" \"subnet\": \"2001:db8:2::/64\","
- " \"id\": 10,"
+ " \"id\": 11,"
" \"interface-id\": \"vlan10\","
" \"pools\": ["
" {"
- " \"pool\": \"2001:db8:2::20 - 2001:db8:2::20\""
+ " \"pool\": \"2001:db8:2::10 - 2001:db8:2::10\""
" }"
" ]"
" }"
" ],"
" \"subnet6\": ["
" {"
- " \"subnet\": \"2001:db8:2::/64\","
+ " \"subnet\": \"2001:db8:2::1/64\","
" \"id\": 1000,"
" \"interface-id\": \"vlan1000\","
" \"pools\": ["
/// boost::shared_ptr<Pkt4> pkt2(new Pkt4(...));
/// // Add new packet to the container, it will be available through
/// // both indexes
- /// packets_collection.push_back(pkt1);
+ /// static_cast<void>(packets_collection.push_back(pkt1));
/// // Here is another way to add packet to the container. The result
/// // is exactly the same as previously.
- /// packets_collection.template get<0>().push_back(pkt2);
+ /// static_cast<void>(packets_collection.template get<0>().push_back(pkt2));
/// \endcode
///
+ /// @note The multi index has no unique index so insertion should never
+ /// fail and there is no need to check the return of push_back().
+ ///
/// Example 2: Access elements through sequential index
/// \code
/// PktList packets_collection();
if (!packet) {
isc_throw(BadValue, "Packet is null");
}
+ static_cast<void>(sent_packets_.template get<0>().push_back(packet));
++sent_packets_num_;
- sent_packets_.template get<0>().push_back(packet);
}
/// \brief Add new packet to list of received packets.
if (!packet) {
isc_throw(BadValue, "Packet is null");
}
- rcvd_packets_.push_back(packet);
+ static_cast<void>(rcvd_packets_.push_back(packet));
}
/// \brief Update delay counters.
// move it to list of archived packets. List of
// archived packets may be used for diagnostics
// when test is completed.
- archived_packets_.push_back(*it);
+ static_cast<void>(archived_packets_.push_back(*it));
}
// get<0>() template returns sequential index to
// container.
last_subnet->setServerTag(out_bindings[53]->getString());
// Subnet ready. Add it to the list.
- subnets.push_back(last_subnet);
+ auto ret = subnets.push_back(last_subnet);
+
+ // subnets is a multi index container with unique indexes
+ // but these indexes are unique too in the database,
+ // so this is for sanity only.
+ if (!ret.second) {
+ isc_throw(Unexpected, "add subnet failed");
+ }
}
// If the row contains information about the pool and it appears to be
// server_tag
last_network->setServerTag(out_bindings[32]->getString());
- shared_networks.push_back(last_network);
+ // Add the shared network.
+ auto ret = shared_networks.push_back(last_network);
+
+ // shared_networks is a multi index container with an unique
+ // index but this index is unique too in the database,
+ // so this is for sanity only.
+ if (!ret.second) {
+ isc_throw(Unexpected, "add shared network failed");
+ }
}
// Parse option.
last_subnet->setServerTag(out_bindings[69]->getString());
// Subnet ready. Add it to the list.
- subnets.push_back(last_subnet);
+ auto ret = subnets.push_back(last_subnet);
+
+ // subnets is a multi index container with unique indexes
+ // but these indexes are unique too in the database,
+ // so this is for sanity only.
+ if (!ret.second) {
+ isc_throw(Unexpected, "add subnet failed");
+ }
}
// Pool is between 15 and 19
// server_tag
last_network->setServerTag(out_bindings[31]->getString());
- shared_networks.push_back(last_network);
+ // Add the shared network.
+ auto ret = shared_networks.push_back(last_network);
+
+ // shared_networks is a multi index container with an unique
+ // index but this index is unique too in the database,
+ // so this is for sanity only.
+ if (!ret.second) {
+ isc_throw(Unexpected, "add shared network failed");
+ }
}
// Parse option from 14 to 26.
last_def->setServerTag(out_bindings[10]->getString());
// Store created option definition.
- option_defs.push_back(last_def);
+ auto ret = option_defs.push_back(last_def);
+ if (!ret.second) {
+ // option_defs is a multi-index container so push_back()
+ // can in theory fails. Now it has no unique indexes...
+ isc_throw(Unexpected, "can't store the option definition");
+ }
}
});
}
if (desc) {
// server_tag for the global option
desc->setServerTag(out_bindings[12]->getString());
- options.push_back(*desc);
+ static_cast<void>(options.push_back(*desc));
}
}
});
defs->clear();
throw;
}
- defs->push_back(definition);
+
+ auto ret = defs->push_back(definition);
+ if (!ret.second) {
+ // defs points to a multi index container with only not unique
+ // indexes so this is for sanity only.
+ isc_throw(isc::Unexpected, "can't store option definition");
+ }
}
}
/// @param option_space name or vendor-id of the option space
void addItem(const ItemType& item, const Selector& option_space) {
ItemsContainerPtr items = getItems(option_space);
- items->push_back(item);
+ // Assume that the push_back() can't fail even when the
+ // ContainerType is a multi index container, i.e., assume
+ // there is no unique index which can raise a conflict.
+ static_cast<void>(items->push_back(item));
option_space_map_[option_space] = items;
}
"' found in the configuration");
}
- networks_.push_back(network);
+ static_cast<void>(networks_.push_back(network));
}
/// @brief Deletes shared network from the configuration.
(*other_network)->getCfgOption()->createOptions(cfg_def);
// Add the new/updated nework.
- networks_.push_back(*other_network);
+ static_cast<void>(networks_.push_back(*other_network));
}
}
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_CFGMGR_ADD_SUBNET4)
.arg(subnet->toText());
- subnets_.push_back(subnet);
+ static_cast<void>(subnets_.push_back(subnet));
}
Subnet4Ptr
}
// Add the "other" subnet to the our collection of subnets.
- subnets_.push_back(*other_subnet);
+ static_cast<void>(subnets_.push_back(*other_subnet));
// If it belongs to a shared network, find the network and
// add the subnet to it
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE, DHCPSRV_CFGMGR_ADD_SUBNET6)
.arg(subnet->toText());
- subnets_.push_back(subnet);
+ static_cast<void>(subnets_.push_back(subnet));
}
Subnet6Ptr
}
// Add the "other" subnet to the our collection of subnets.
- subnets_.push_back(*other_subnet);
+ static_cast<void>(subnets_.push_back(*other_subnet));
// If it belongs to a shared network, find the network and
// add the subnet to it
Subnet4Ptr subnet = parser.parse(subnet_json);
if (subnet) {
try {
- subnets.push_back(subnet);
+ auto ret = subnets.push_back(subnet);
+ if (!ret.second) {
+ isc_throw(Unexpected,
+ "can't store subnet because of conflict");
+ }
++cnt;
} catch (const std::exception& ex) {
isc_throw(DhcpConfigError, ex.what() << " ("
Subnet6ConfigParser parser;
Subnet6Ptr subnet = parser.parse(subnet_json);
- try {
- subnets.push_back(subnet);
- ++cnt;
- } catch (const std::exception& ex) {
- isc_throw(DhcpConfigError, ex.what() << " ("
- << subnet_json->getPosition() << ")");
+ if (subnet) {
+ try {
+ auto ret = subnets.push_back(subnet);
+ if (!ret.second) {
+ isc_throw(Unexpected,
+ "can't store subnet because of conflict");
+ }
+ ++cnt;
+ } catch (const std::exception& ex) {
+ isc_throw(DhcpConfigError, ex.what() << " ("
+ << subnet_json->getPosition() << ")");
+ }
}
}
return (cnt);
}
// Add a subnet to the collection of subnets for this shared network.
- subnets.push_back(subnet);
+ static_cast<void>(subnets.push_back(subnet));
}
/// @brief Replaces IPv4 subnet in a shared network.