Esempio n. 1
0
function delete_static_route($id)
{
    global $config, $a_routes, $changedesc_prefix;
    if (!isset($a_routes[$id])) {
        return;
    }
    $targets = array();
    if (is_alias($a_routes[$id]['network'])) {
        foreach (filter_expand_alias_array($a_routes[$id]['network']) as $tgt) {
            if (is_ipaddrv4($tgt)) {
                $tgt .= "/32";
            } else {
                if (is_ipaddrv6($tgt)) {
                    $tgt .= "/128";
                }
            }
            if (!is_subnet($tgt)) {
                continue;
            }
            $targets[] = $tgt;
        }
    } else {
        $targets[] = $a_routes[$id]['network'];
    }
    foreach ($targets as $tgt) {
        $family = is_subnetv6($tgt) ? "-inet6" : "-inet";
        mwexec("/sbin/route delete {$family} " . escapeshellarg($tgt));
    }
    unset($targets);
}
Esempio n. 2
0
             $tgt .= "/32";
         }
         if (!is_subnet($tgt)) {
             continue;
         }
         $new_targets[] = $tgt;
     }
 }
 if (!isset($id)) {
     $id = count($a_routes);
 }
 $oroute = $a_routes[$id];
 if (!empty($oroute)) {
     $old_targets = array();
     if (is_alias($oroute['network'])) {
         foreach (filter_expand_alias_array($oroute['network']) as $tgt) {
             if (is_ipaddr($tgt)) {
                 $tgt .= "/32";
             }
             if (!is_subnet($tgt)) {
                 continue;
             }
             $old_targets[] = $tgt;
         }
     } else {
         $old_targets[] = $oroute['network'];
     }
 }
 $overlaps = array_intersect($current_targets, $new_targets);
 $overlaps = array_diff($overlaps, $old_targets);
 if (count($overlaps)) {