# verify that user is logged in
$User->check_user_session();
# snmp class
$Snmp = new phpipamSNMP();
# scan disabled
if ($User->settings->enableSNMP != "1") {
    $Result->show("danger", "SNMP module disbled", true, $ajax_loaded);
}
# section check
if (!is_numeric($_POST['sectionId'])) {
    $Result->show("danger", "Invalid section Id", true, $ajax_loaded);
}
if (!is_numeric($_POST['subnetId'])) {
    $Result->show("danger", "Invalid subnet Id", true, $ajax_loaded);
}
$section = $Subnets->fetch_object("sections", "id", $_POST['sectionId']);
if ($section === false) {
    $Result->show("danger", "Invalid section Id", true, $ajax_loaded);
}
# check section permissions
if ($Subnets->check_permission($User->user, $_POST['sectionId']) != 3) {
    $Result->show("danger", _('You do not have permissions to add new subnet in this section') . "!", true, $ajax_loaded);
}
// no errors
error_reporting(E_ERROR);
# fetch devices that use get_routing_table query
$devices_used = $Tools->fetch_multiple_objects("devices", "snmp_queries", "%get_routing_table%", "id", true, true);
# recolaculate ids for info
foreach ($devices_used as $d) {
    $devices_info[$d->id] = $d;
}