diff options
Diffstat (limited to 'etc/inc')
-rw-r--r-- | etc/inc/filter.inc | 10 | ||||
-rw-r--r-- | etc/inc/interfaces.inc | 86 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 6 |
3 files changed, 101 insertions, 1 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 98320d6..dd44010 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -394,7 +394,15 @@ function filter_generate_aliases() { if($opt_carp_ints) $aliases .= $opt_carp_ints; } - $aliases .= " }\"\n"; + $aliases .= " }\"\n"; + /* XXX TODO: below comment and subsequent two lines of code from + Adam Lebsack <adam at holonyx dot com> + I'm not sure what it means, marking this to look into. cmb@ + + add an alias, since much of the filter code is broken when it comes to + finding out the real interface */ + if(preg_match("/^ppp_(.+)$/", $config['interfaces'][$ifname]['if'], $matches)) + $aliases .= "{$config['interfaces'][$ifname]['if']} = \"ppp0\"\n"; } $aliases .= "# User Aliases \n"; /* Setup pf groups */ diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 4da9013..81d8708 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -278,6 +278,10 @@ function interfaces_optional_configure_if($opti) { if (is_array($optcfg['wireless'])) interfaces_wireless_configure($optcfg['if'], $optcfg['wireless']); + /* PPP configuration */ + if (isset($optcfg['pointtopoint'])) + interfaces_ppp_configure_if($optcfg); + /* MAC spoofing? */ if ($optcfg['spoofmac']) { mwexec("/sbin/ifconfig " . escapeshellarg($optcfg['if']) . @@ -368,6 +372,74 @@ function interfaces_optional_configure_if($opti) { return 0; } +function interfaces_ppp_configure_if($ifcfg) { + global $config; + + if(file_exists("/var/run/ppp0.pid")) { + $pid = file_get_contents("/var/run/ppp0.pid"); + mwexec('kill $pid'); + } + + mwexec("/sbin/ifconfig ppp0 down destroy"); + + $peerfile = "lcp-echo-failure 0\n"; + $peerfile .= "lcp-echo-interval 0\n"; + $peerfile .= "connect /etc/ppp/peers/ppp0-connect-chat\n"; + //$peerfile .= "disconnect /etc/ppp/peers/ppp0-disconnect-chat\n"; + $peerfile .= "/dev/{$ifcfg['serialport']}\n"; + $peerfile .= "crtscts\n"; + $peerfile .= "local\n"; + $peerfile .= ":{$ifcfg['gateway']}\n"; + $peerfile .= "noipdefault\n"; + $peerfile .= "ipcp-accept-local\n"; + $peerfile .= "novj\n"; + $peerfile .= "nobsdcomp\n"; + $peerfile .= "novjccomp\n"; + $peerfile .= "nopcomp\n"; + $peerfile .= "noaccomp\n"; + $peerfile .= "noauth\n"; + $peerfile .= "persist\n"; + $peerfile .= "debug\n"; + // KD - test + //$peerfile .= "defaultroute\n"; + //$peerfile .= "nodetach\n"; + // KD - so I know where to look! + $peerfile .= "# created by /etc/inc/interfaces.inc\n"; + file_put_contents("/etc/ppp/peers/ppp0", $peerfile); + + // Added single quotes to some strings below: + // the \rAT is *always* going to need it + // and the phone number on a GSM connection ends in a # char + // Kevin Dawson, 22 Jan 2008 + // Refer Andrew Curtis + + $chatfile = "#!/bin/sh\n"; + $chatfile .= "exec chat \\\n"; + $chatfile .= "TIMEOUT 5 \\\n"; + $chatfile .= "ECHO ON \\\n"; + $chatfile .= "ABORT '\\nBUSY\\r' \\\n"; + $chatfile .= "ABORT '\\nERROR\\r' \\\n"; + $chatfile .= "ABORT '\\nNO ANSWER\\r' \\\n"; + $chatfile .= "ABORT '\\nNO CARRIER\\r' \\\n"; + $chatfile .= "ABORT '\\nNO DIALTONE\\r' \\\n"; + $chatfile .= "ABORT '\\nRINGING\\r\\n\\r\\nRINGING\\r' \\\n"; + // KD + $chatfile .= "'' '\\rAT' \\\n"; + $chatfile .= "TIMEOUT 12 \\\n"; + $chatfile .= "OK ATH \\\n"; + $chatfile .= "OK ATE1 \\\n"; + $chatfile .= "OK 'AT+CGDCONT=1,\"IP\",\"{$ifcfg['ap']}\"' \\\n"; + // KD + $chatfile .= "OK 'ATD{$ifcfg['phone']}' \\\n"; + $chatfile .= "TIMEOUT 22 \\\n"; + $chatfile .= "CONNECT \"\" \\\n"; + $chatfile .= "SAY \"\\nConnected.\"\n"; + file_put_contents("/etc/ppp/peers/ppp0-connect-chat", $chatfile); + chmod("/etc/ppp/peers/ppp0-connect-chat", 0755); + mwexec("/sbin/ifconfig ppp0 create"); + return 0; +} + function interfaces_carp_configure() { global $g, $config, $debugging; $balanacing = ""; @@ -1637,6 +1709,20 @@ function get_number_of_vlan_interfaces() { return "{$vlans_total}"; } +function get_number_of_ppp_interfaces() { + $ppps_total = 0; + $ppps = split("\n", `/sbin/ifconfig -a | /usr/bin/grep ppp | grep flags`); + foreach($ppps as $bridge) { + $match_array = ""; + preg_match_all("/ppp(.*):/",$bridge,$match_array); + if($match_array[1][0] <> "") { + if($match_array[1][0] > $ppps_total) + $ppps_total = $match_array[1][0]; + } + } + return "{$ppps_total}"; +} + function get_next_available_bridge_interface() { $bridges_total = get_number_of_bridged_interfaces(); $interfaces = `/sbin/ifconfig -l`; diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 5cae4d5..d162854 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -1464,6 +1464,8 @@ function guess_interface_from_ip($ipaddress) { function filter_opt_interface_to_real($opt) { global $config; + if(isset($config['interfaces'][$opt]['pointtopoint'])) + return "ppp0"; return $config['interfaces'][$opt]['if']; } @@ -1509,6 +1511,8 @@ function find_ip_interface($ip) { */ function filter_translate_type_to_real_interface($interface) { global $config; + if(isset($config['interfaces'][$interface]['pointtopoint'])) + return "ppp0"; if($config['interfaces'][$interface]['if'] <> "") { return $config['interfaces'][$interface]['if']; } else { @@ -1780,6 +1784,8 @@ function convert_friendly_interface_to_real_interface_name($interface) { global $config; if($config['interfaces'][$interface]['ipaddr'] == "pppoe") return "ng0"; + if(isset($config['interfaces'][$interface]['pointtopoint'])) + return "ppp0"; $lc_interface = strtolower($interface); if($lc_interface == "lan") return $config['interfaces']['lan']['if']; |