diff options
Diffstat (limited to 'etc/inc/interfaces.inc')
-rw-r--r-- | etc/inc/interfaces.inc | 134 |
1 files changed, 67 insertions, 67 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 021d76d..9156815 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -47,7 +47,7 @@ require_once("cmd_chain.inc"); function interfaces_bring_up($interface) { if(!$interface) { - log_error("interfaces_bring_up() was called but no variable defined."); + log_error(gettext("interfaces_bring_up() was called but no variable defined.")); log_error( "Backtrace: " . debug_backtrace() ); return; } @@ -86,19 +86,19 @@ function does_interface_exist($interface) { function interfaces_loopback_configure() { if($g['booting']) - echo "Configuring loopback interface..."; + echo gettext("Configuring loopback interface..."); pfSense_interface_setaddress("lo0", "127.0.0.1"); interfaces_bring_up("lo0"); exec("/sbin/route add 127.0.0.2 127.0.0.1"); if($g['booting']) - echo "done.\n"; + echo gettext("done.") . "\n"; return 0; } function interfaces_vlan_configure() { global $config, $g; if($g['booting']) - echo "Configuring VLAN interfaces..."; + echo gettext("Configuring VLAN interfaces..."); if (is_array($config['vlans']['vlan']) && count($config['vlans']['vlan'])) { foreach ($config['vlans']['vlan'] as $vlan) { if(empty($vlan['vlanif'])) @@ -108,14 +108,14 @@ function interfaces_vlan_configure() { } } if($g['booting']) - echo "done.\n"; + echo gettext("done.") . "\n"; } function interface_vlan_configure(&$vlan) { global $config, $g; if (!is_array($vlan)) { - log_error("VLAN: called with wrong options. Problems with config!"); + log_error(gettext("VLAN: called with wrong options. Problems with config!")); return; } $if = $vlan['if']; @@ -123,7 +123,7 @@ function interface_vlan_configure(&$vlan) { $tag = $vlan['tag']; if (empty($if)) { - log_error("interface_vlan_confgure called with if undefined."); + log_error(gettext("interface_vlan_confgure called with if undefined.")); return; } @@ -157,14 +157,14 @@ function interface_qinq_configure(&$vlan, $fd = NULL) { global $config, $g; if (!is_array($vlan)) { - log_error("QinQ compat VLAN: called with wrong options. Problems with config!\n"); + log_error(sprintf(gettext("QinQ compat VLAN: called with wrong options. Problems with config!%s"), "\n")); return; } $qinqif = $vlan['if']; $tag = $vlan['tag']; if(empty($qinqif)) { - log_error("interface_qinq_confgure called with if undefined.\n"); + log_error(sprintf(gettext("interface_qinq_confgure called with if undefined.%s"), "\n")); return; } $vlanif = interface_vlan_configure($vlan); @@ -225,7 +225,7 @@ function interface_qinq_configure(&$vlan, $fd = NULL) { function interfaces_qinq_configure() { global $config, $g; if($g['booting']) - echo "Configuring QinQ interfaces..."; + echo gettext("Configuring QinQ interfaces..."); if (is_array($config['qinqs']['qinqentry']) && count($config['qinqs']['qinqentry'])) { foreach ($config['qinqs']['qinqentry'] as $qinq) { /* XXX: Maybe we should report any errors?! */ @@ -233,14 +233,14 @@ function interfaces_qinq_configure() { } } if($g['booting']) - echo "done.\n"; + echo gettext( "done.") . "\n"; } function interface_qinq2_configure(&$qinq, $fd, $macaddr) { global $config, $g; if (!is_array($qinq)) { - log_error("QinQ compat VLAN: called with wrong options. Problems with config!\n"); + log_error(sprintf(gettext("QinQ compat VLAN: called with wrong options. Problems with config!%s"), "\n")); return; } @@ -248,7 +248,7 @@ function interface_qinq2_configure(&$qinq, $fd, $macaddr) { $tag = $qinq['tag']; $vlanif = "{$if}_{$tag}"; if(empty($if)) { - log_error("interface_qinq_confgure called with if undefined.\n"); + log_error(sprintf(gettext("interface_qinq_confgure called with if undefined.%s"), "\n")); return; } @@ -269,7 +269,7 @@ function interfaces_create_wireless_clones() { global $config; if($g['booting']) - echo "Creating other wireless clone interfaces..."; + echo gettext("Creating other wireless clone interfaces..."); if (is_array($config['wireless']['clone']) && count($config['wireless']['clone'])) { foreach ($config['wireless']['clone'] as $clone) { if(empty($clone['cloneif'])) @@ -283,7 +283,7 @@ function interfaces_create_wireless_clones() { } } if($g['booting']) - echo " done.\n"; + echo " " . gettext("done.") . "\n"; } function interfaces_bridge_configure() { @@ -308,7 +308,7 @@ function interface_bridge_configure(&$bridge) { return -1; if (empty($bridge['members'])) { - log_error("No members found on {$bridge['bridgeif']}"); + log_error(sprintf(gettext("No members found on %s"), $bridge['bridgeif'])); return -1; } @@ -349,7 +349,7 @@ function interface_bridge_configure(&$bridge) { /* make sure the parent interface is up */ pfSense_interface_mtu($realif, $smallermtu); if(!$realif) - log_error("realif not defined in interfaces bridge - up"); + log_error(gettext("realif not defined in interfaces bridge - up")); interfaces_bring_up($realif1); mwexec("/sbin/ifconfig {$bridgeif} addm {$realif}"); } @@ -457,7 +457,7 @@ function interface_bridge_configure(&$bridge) { if($bridgeif) interfaces_bring_up($bridgeif); else - log_error("bridgeif not defined -- could not bring interface up"); + log_error(gettext("bridgeif not defined -- could not bring interface up")); return $bridgeif; } @@ -492,7 +492,7 @@ function interfaces_lagg_configure() { global $config, $g; if($g['booting']) - echo "Configuring LAGG interfaces..."; + echo gettext("Configuring LAGG interfaces..."); $i = 0; if (is_array($config['laggs']['lagg']) && count($config['laggs']['lagg'])) { foreach ($config['laggs']['lagg'] as $lagg) { @@ -504,7 +504,7 @@ function interfaces_lagg_configure() } } if($g['booting']) - echo "done.\n"; + echo gettext("done.") . "\n"; } function interface_lagg_configure(&$lagg) { @@ -603,7 +603,7 @@ function interface_gre_configure(&$gre) { if($greif) interfaces_bring_up($greif); else - log_error("Could not bring greif up -- variable not defined."); + log_error(gettext("Could not bring greif up -- variable not defined.")); if (isset($gre['link1']) && $gre['link1']) mwexec("/sbin/route add {$gre['tunnel-remote-addr']}/{$gre['tunnel-remote-net']} {$gre['tunnel-local-addr']}"); @@ -639,7 +639,7 @@ function interface_gif_configure(&$gif) { if($realif) interfaces_bring_up($realif); else - log_error("could not bring realif up -- variable not defined -- interface_gif_configure()"); + log_error(gettext("could not bring realif up -- variable not defined -- interface_gif_configure()")); if ($g['booting'] || !(empty($gif['gifif']))) { pfSense_interface_destroy($gif['gifif']); @@ -658,7 +658,7 @@ function interface_gif_configure(&$gif) { if($gifif) interfaces_bring_up($gifif); else - log_error("could not bring gifif up -- variable not defined"); + log_error(gettext("could not bring gifif up -- variable not defined")); /* XXX: Needed?! */ //mwexec("/sbin/route add {$gif['tunnel-remote-addr']}/{$gif['tunnel-remote-net']} -iface {$gifif}"); @@ -700,12 +700,12 @@ function interfaces_configure() { $delayed_list[$if] = $ifname; else { if ($g['booting']) - echo "Configuring {$ifname} interface..."; + printf(gettext("Configuring %s interface..."), $ifname); if($g['debug']) - log_error("Configuring {$ifname}"); + log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); if ($g['booting']) - echo "done.\n"; + echo gettext( "done.") . "\n"; } } @@ -720,14 +720,14 @@ function interfaces_configure() { foreach ($delayed_list as $if => $ifname) { if ($g['booting']) - echo "Configuring {$ifname} interface..."; + printf(gettext("Configuring %s interface..."), $ifname); if ($g['debug']) - log_error("Configuring {$ifname}"); + log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); if ($g['booting']) - echo "done.\n"; + echo gettext("done.") . "\n"; } /* set up BRIDGe virtual interfaces */ @@ -735,14 +735,14 @@ function interfaces_configure() { foreach ($bridge_list as $if => $ifname) { if ($g['booting']) - echo "Configuring {$ifname} interface..."; + printf(gettext("Configuring %s interface..."), $ifname); if($g['debug']) - log_error("Configuring {$ifname}"); + log_error(sprintf(gettext("Configuring %s"), $ifname)); interface_configure($if, $reload); if ($g['booting']) - echo "done.\n"; + echo gettext("done.") . "\n"; } /* bring up vip interfaces */ @@ -1030,7 +1030,7 @@ function interface_ppps_configure($interface) { } } if (!$ppp || $ifcfg['if'] != $ppp['if']){ - log_error("Can't find PPP config for {$ifcfg['if']} in interface_ppps_configure()."); + log_error(sprintf(gettext("Can't find PPP config for %s in interface_ppps_configure()."), $ifcfg['if'])); return 0; } $pppif = $ifcfg['if']; @@ -1077,7 +1077,7 @@ function interface_ppps_configure($interface) { $localips[$pid] = get_interface_ip($port); // try to get the interface IP from the port if(!is_ipaddr($localips[$pid])){ - log_error("Could not get a Local IP address for PPTP/L2TP link on {$port} in interfaces_ppps_configure."); + log_error(sprintf(gettext("Could not get a Local IP address for PPTP/L2TP link on %s in interfaces_ppps_configure."), $port)); return 0; } /* XXX: This needs to go away soon! [It's commented out!] */ @@ -1092,18 +1092,18 @@ function interface_ppps_configure($interface) { */ } if(!is_ipaddr($gateways[$pid])){ - log_error("Could not get a PPTP/L2TP Remote IP address from {$dhcp_gateway} for {$gway} in interfaces_ppps_configure."); + log_error(sprintf(gettext("Could not get a PPTP/L2TP Remote IP address from %s for %s in interfaces_ppps_configure."), $dhcp_gateway, $gway)); return 0; } break; case "ppp": if (!file_exists("{$port}")) { - log_error("Device {$port} does not exist. PPP link cannot start without the modem device."); + log_error(sprintf(gettext("Device %s does not exist. PPP link cannot start without the modem device."), $port)); return 0; } break; default: - log_error("Unkown {$type} configured as ppp interface."); + log_error(sprintf(gettext("Unkown %s configured as ppp interface."), $type)); break; } } @@ -1368,7 +1368,7 @@ EOD; else { $fd = fopen("{$g['varetc_path']}/mpd_{$interface}.conf", "w"); if (!$fd) { - log_error("Error: cannot open mpd_{$interface}.conf in interface_ppps_configure().\n"); + log_error(sprintf(gettext("Error: cannot open mpd_%s.conf in interface_ppps_configure().%s"), $interface, "\n")); return 0; } // Write out mpd_ppp.conf @@ -1420,7 +1420,7 @@ function interfaces_carp_setup() { $cmdchain = new CmdCHAIN(); if ($g['booting']) { - echo "Configuring CARP settings..."; + echo gettext("Configuring CARP settings..."); mute_kernel_msgs(); } @@ -1440,14 +1440,14 @@ function interfaces_carp_setup() { unset($pfsyncenabled); } - $cmdchain->add("Allow CARP", "/sbin/sysctl net.inet.carp.allow=1", true); + $cmdchain->add(gettext("Allow CARP"), "/sbin/sysctl net.inet.carp.allow=1", true); if($balanacing) { - $cmdchain->add("Enable CARP ARP-balancing", "/sbin/sysctl net.inet.carp.arpbalance=1", true); - $cmdchain->add("Disallow CARP preemption", "/sbin/sysctl net.inet.carp.preempt=0", true); + $cmdchain->add(gettext("Enable CARP ARP-balancing"), "/sbin/sysctl net.inet.carp.arpbalance=1", true); + $cmdchain->add(gettext("Disallow CARP preemption"), "/sbin/sysctl net.inet.carp.preempt=0", true); } else - $cmdchain->add("Enable CARP preemption", "/sbin/sysctl net.inet.carp.preempt=1", true); + $cmdchain->add(gettext("Enable CARP preemption"), "/sbin/sysctl net.inet.carp.preempt=1", true); - $cmdchain->add("Enable CARP logging", "/sbin/sysctl net.inet.carp.log=2", true); + $cmdchain->add(gettext("Enable CARP logging"), "/sbin/sysctl net.inet.carp.log=2", true); if (!empty($pfsyncinterface)) $carp_sync_int = get_real_interface($pfsyncinterface); @@ -1463,22 +1463,22 @@ function interfaces_carp_setup() { fclose($fd); mwexec("/sbin/pfctl -f {$g['tmp_path']}/rules.boot"); } else - log_error("Could not create rules.boot file!"); + log_error(gettext("Could not create rules.boot file!")); } /* setup pfsync interface */ if($carp_sync_int and $pfsyncenabled) { if (is_ipaddr($pfsyncpeerip)) - $cmdchain->add("Bring up pfsync0 syncpeer", "/sbin/ifconfig pfsync0 syncdev {$carp_sync_int} syncpeer {$pfsyncpeerip} up", false); + $cmdchain->add(gettext("Bring up pfsync0 syncpeer"), "/sbin/ifconfig pfsync0 syncdev {$carp_sync_int} syncpeer {$pfsyncpeerip} up", false); else - $cmdchain->add("Bring up pfsync0 syncdev", "/sbin/ifconfig pfsync0 syncdev {$carp_sync_int} up", false); + $cmdchain->add(gettext("Bring up pfsync0 syncdev"), "/sbin/ifconfig pfsync0 syncdev {$carp_sync_int} up", false); } else - $cmdchain->add("Bring up pfsync0", "/sbin/ifconfig pfsync0 syncdev lo0 up", false); + $cmdchain->add(gettext("Bring up pfsync0"), "/sbin/ifconfig pfsync0 syncdev lo0 up", false); if($config['virtualip']['vip']) - $cmdchain->add("Allow CARP.", "/sbin/sysctl net.inet.carp.allow=1", true); + $cmdchain->add(gettext("Allow CARP."), "/sbin/sysctl net.inet.carp.allow=1", true); else - $cmdchain->add("Disallow CARP.", "/sbin/sysctl net.inet.carp.allow=0", true); + $cmdchain->add(gettext("Disallow CARP."), "/sbin/sysctl net.inet.carp.allow=0", true); if($g['debug']) $cmdchain->setdebug(); // optional for verbose logging @@ -1488,7 +1488,7 @@ function interfaces_carp_setup() { if ($g['booting']) { unmute_kernel_msgs(); - echo "done.\n"; + echo gettext("done.") . "\n"; } } @@ -1665,7 +1665,7 @@ function interface_carp_configure(&$vip) { */ $realif = get_real_interface($vip['interface']); if (!does_interface_exist($realif)) { - file_notice("CARP", "Interface specified for the virtual IP address {$vip['subnet']} does not exist. Skipping this VIP.", "Firewall: Virtual IP", ""); + file_notice("CARP", sprintf(gettext("Interface specified for the virtual IP address %s does not exist. Skipping this VIP."), $vip['subnet']), "Firewall: Virtual IP", ""); return; } @@ -1673,7 +1673,7 @@ function interface_carp_configure(&$vip) { $ww_subnet_ip = find_interface_ip($realif); $ww_subnet_bits = find_interface_subnet($realif); if (!ip_in_subnet($vip['subnet'], gen_subnet($ww_subnet_ip, $ww_subnet_bits) . "/" . $ww_subnet_bits)) { - file_notice("CARP", "Sorry but we could not find a matching real interface subnet for the virtual IP address {$vip['subnet']}.", "Firewall: Virtual IP", ""); + file_notice("CARP", sprintf(gettext("Sorry but we could not find a matching real interface subnet for the virtual IP address %s."), $vip['subnet']), "Firewall: Virtual IP", ""); return; } @@ -1708,7 +1708,7 @@ function interface_carpdev_configure(&$vip) { if($vip['password'] != "") $password = " pass \"" . $vip_password . "\""; - log_error("Found carpdev interface {$vip['interface']} on top of interface {$interface}"); + log_error(sprintf(gettext("Found carpdev interface %s on top of interface %s"), $vip['interface'], $interface)); if (empty($vip['interface'])) return; @@ -1720,7 +1720,7 @@ function interface_carpdev_configure(&$vip) { * prevents a panic if the interface is missing or invalid */ if (!does_interface_exist($realif)) { - file_notice("CARP", "Interface specified for the virtual IP address {$vip['subnet']} does not exist. Skipping this VIP.", "Firewall: Virtual IP", ""); + file_notice("CARP", sprintf(gettext("Interface specified for the virtual IP address %s does not exist. Skipping this VIP."), $vip['subnet']), "Firewall: Virtual IP", ""); return; } @@ -1766,7 +1766,7 @@ EOD; /* fire up dhclient */ mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$vipif}.conf {$vipif} > {$g['tmp_path']}/{$vipif}_output > {$g['tmp_path']}/{$vipif}_error_output", false); } else { - log_error("Error: cannot open dhclient_{$vipif}.conf in interfaces_carpdev_configure() for writing.\n"); + log_error(sprintf(gettext("Error: cannot open dhclient_%s.conf in interfaces_carpdev_configure() for writing.%s"), $vipif, "\n")); mwexec("/sbin/dhclient -b {$vipif}"); } @@ -1799,15 +1799,15 @@ function interface_wireless_clone($realif, $wlcfg) { exec("/sbin/ifconfig {$realif}", $output, $ret); $ifconfig_str = implode($output); if(($wlcfg_mode == "hostap") && (! preg_match("/hostap/si", $ifconfig_str))) { - log_error("Interface {$realif} changed to hostap mode"); + log_error(sprintf(gettext("Interface %s changed to hostap mode"), $realif)); $needs_clone = true; } if(($wlcfg_mode == "adhoc") && (! preg_match("/adhoc/si", $ifconfig_str))) { - log_error("Interface {$realif} changed to adhoc mode"); + log_error(sprintf(gettext("Interface %s changed to adhoc mode"), $realif)); $needs_clone = true; } if(($wlcfg_mode == "bss") && (preg_match("/hostap|adhoc/si", $ifconfig_str))) { - log_error("Interface {$realif} changed to infrastructure mode"); + log_error(sprintf(gettext("Interface %s changed to infrastructure mode"), $realif)); $needs_clone = true; } } else { @@ -1819,12 +1819,12 @@ function interface_wireless_clone($realif, $wlcfg) { if(does_interface_exist($realif)) pfSense_interface_destroy($realif); - log_error("Cloning new wireless interface {$realif}"); + log_error(sprintf(gettext("Cloning new wireless interface %s"), $realif)); // Create the new wlan interface. FreeBSD returns the new interface name. // example: wlan2 exec("/sbin/ifconfig wlan create wlandev {$baseif} {$mode} bssid 2>&1", $out, $ret); if($ret <> 0) { - log_error("Failed to clone interface {$baseif} with error code {$ret}, output {$out[0]}"); + log_error(sprintf(gettext("Failed to clone interface %s with error code %s, output %s"), $baseif, $ret, $out[0])); return false; } $newif = trim($out[0]); @@ -2335,13 +2335,13 @@ function interface_configure($interface = "wan", $reloadall = false) { /* this is not a valid mac address. generate a * temporary mac address so the machine can get online. */ - echo "Generating new MAC address."; + echo gettext("Generating new MAC address."); $random_mac = generate_random_mac_address(); mwexec("/sbin/ifconfig " . escapeshellarg(get_real_interface($wancfg['if'])) . " link " . escapeshellarg($random_mac)); $wancfg['spoofmac'] = $random_mac; write_config(); - file_notice("MAC Address altered", "The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface {$realif} has been automatically replaced with {$random_mac}", "Interfaces"); + file_notice("MAC Address altered", sprintf(gettext("The INVALID MAC address (ff:ff:ff:ff:ff:ff) on interface %s has been automatically replaced with %s"), $realif, $random_mac), "Interfaces"); } } @@ -2464,7 +2464,7 @@ function interface_carpdev_dhcp_configure($interface = "wan") { if($wanif) interfaces_bring_up($wanif); else - log_error("Could not bring wanif up in terface_carpdev_dhcp_configure()"); + log_error(gettext("Could not bring wanif up in terface_carpdev_dhcp_configure()")); return 0; } @@ -2479,7 +2479,7 @@ function interface_dhcp_configure($interface = "wan") { /* generate dhclient_wan.conf */ $fd = fopen("{$g['varetc_path']}/dhclient_{$interface}.conf", "w"); if (!$fd) { - printf("Error: cannot open dhclient_{$interface}.conf in interfaces_wan_dhcp_configure() for writing.\n"); + printf(printf(gettext("Error: cannot open dhclient_%s.conf in interfaces_wan_dhcp_configure() for writing.%s"), $interface, "\n")); return 1; } @@ -2492,7 +2492,7 @@ function interface_dhcp_configure($interface = "wan") { $wanif = get_real_interface($interface); if (empty($wanif)) { - log_error("Invalid interface \"{$interface}\" in interface_dhcp_configure()"); + log_error(sprintf(gettext("Invalid interface \"%s\" in interface_dhcp_configure()"), $interface)); return 0; } $dhclientconf = ""; @@ -2527,7 +2527,7 @@ EOD; if($wanif) interfaces_bring_up($wanif); else - log_error("Could not bring up {$wanif} interface in interface_dhcp_configure()"); + log_error(printf(gettext("Could not bring up %s interface in interface_dhcp_configure()"), $wanif)); /* fire up dhclient */ mwexec("/sbin/dhclient -c {$g['varetc_path']}/dhclient_{$interface}.conf {$wanif} > {$g['tmp_path']}/{$wanif}_output > {$g['tmp_path']}/{$wanif}_error_output"); |