";
$form .= " GetEnabled() == "on")
$form .= " CHECKED";
- $form .= " > Enable/disable discipline and its children";
+ $form .= " > " . gettext("Enable/disable discipline and its children") . "";
$form .= "
";
- $form .= "
Name
";
+ $form .= "
" . gettext("Name") . "
";
$form .= "
";
$form .= "".$this->GetQname()."";
$form .= "
";
- $form .= "
Scheduler Type ";
+ $form .= "
" . gettext("Scheduler Type ");
$form .= "
";
$form .= "
";
$form .= "";
$form .= " ";
- $form .= "NOTE: Changing this changes all child queues!";
- $form .= " Beware you can lose information.";
+ $form .= gettext("NOTE: Changing this changes all child queues!");
+ $form .= gettext(" Beware you can lose information.");
$form .= "";
$form .= "
";
- $form .= "
Bandwidth";
+ $form .= "
" . gettext("Bandwidth");
$form .= "
";
$form .= "GetBandwidth() . "\">";
@@ -680,9 +680,9 @@ class altq_root_queue {
$form .= $this->GetTbrConfig();
$form .= "\">";
$form .= " ";
- $form .= "Adjusts the size, in bytes, of the token bucket regulator. ";
- $form .= "If not specified, heuristics based on the interface ";
- $form .= "bandwidth are used to determine the size.";
+ $form .= gettext("Adjusts the size, in bytes, of the token bucket regulator. "
+ . "If not specified, heuristics based on the interface "
+ . "bandwidth are used to determine the size.");
$form .= "
";
$form .= "GetInterface() . "\">";
@@ -828,7 +828,7 @@ class priq_queue {
}
function SetDefault($value = false) {
$this->qdefault = $value;
- altq_set_default_queue($this->GetInterface(), "true");
+ altq_set_default_queue($this->GetInterface(), $value);
}
function GetRed() {
return $this->qred;
@@ -924,7 +924,7 @@ class priq_queue {
function delete_queue() {
unref_on_altq_queue_list($this->GetQname());
if ($this->GetDefault())
- altq_set_default_queue($this->GetInterface(), "false");
+ altq_set_default_queue($this->GetInterface(), false);
cleanup_queue_from_rules($this->GetQname());
unset_object_by_reference($this->GetLink());
}
@@ -950,7 +950,7 @@ class priq_queue {
function validate_input($data, &$input_errors) {
$reqdfields[] = "name";
- $reqdfieldsn[] = "Name";
+ $reqdfieldsn[] = gettext("Name");
shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors);
if ($data['bandwidth'] && (!is_numeric($data['bandwidth'])))
@@ -963,16 +963,16 @@ class priq_queue {
$input_errors[] = "Qlimit must be an positive.";
if ($data['priority'] && (!is_numeric($data['priority'])
|| ($data['priority'] < 1) || ($data['priority'] > 15))) {
- $input_errors[] = "The priority must be an integer between 1 and 15.";
+ $input_errors[] = gettext("The priority must be an integer between 1 and 15.");
}
if ($data['qlimit'] && (!is_numeric($data['qlimit'])))
- $input_errors[] = "Queue limit must be an integer";
+ $input_errors[] = gettext("Queue limit must be an integer");
if ($data['qlimit'] < 0)
- $input_errors[] = "Queue limit must be positive";
+ $input_errors[] = gettext("Queue limit must be positive");
if (!empty($data['newname']) && !preg_match("/^[a-zA-Z0-9_-]*$/", $data['newname']))
- $input_errors[] = "Queue names must be alphanumeric and _ or - only.";
+ $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only.");
if (!empty($data['name']) && !preg_match("/^[a-zA-Z0-9_-]*$/", $data['name']))
- $input_errors[] = "Queue names must be alphanumeric and _ or - only.";
+ $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only.");
}
@@ -1104,69 +1104,71 @@ class priq_queue {
*/
function build_form() {
$form = "
";
$form .= " GetEnabled() == "on")
$form .= " CHECKED";
- $form .= " > Enable/Disable queue and its children";
+ $form .= " > " . gettext("Enable/Disable queue and its children") . "";
$form .= "
";
$form .= "
";
$form .= "
";
- $form .= "Queue Name
";
+ $form .= gettext("Queue Name") . "
";
$form .= "GetQname());
$form .= "\">";
$form .= "GetQname());
$form .= "\">";
- $form .= " Enter the name of the queue here. Do not use spaces and limit the size to 15 characters.";
+ $form .= " " . gettext("Enter the name of the queue here. Do not use spaces and limit the size to 15 characters.");
$form .= "
";
$form .= "
";
- $form .= "
Priority
";
+ $form .= "
" . gettext("Priority") . "
";
$form .= "
GetQpriority());
$form .= "\">";
- $form .= " For hfsc, the range is 0 to 7. The default is 1. Hfsc queues with a higher priority are preferred in the case of overload.
";
+ $form .= " " . gettext("For hfsc, the range is 0 to 7. The default is 1. Hfsc queues with a higher priority are preferred in the case of overload.") . "";
$form .= "
";
$form .= "
";
- $form .= "
Queue limit
";
+ $form .= "
" . gettext("Queue limit") . "
";
$form .= "
GetQlimit());
$form .= "\">";
- $form .= " Queue limit in packets per second.";
+ $form .= " " . gettext("Queue limit in packets per second.");
$form .= "
";
+ $form .= " width=\"17\" height=\"17\" border=\"0\" title=\"" . gettext("Delete queue from interface") . "\">";
+ $form .= "" . gettext("Delete queue from interface") . "";
return $form;
@@ -1494,7 +1496,7 @@ class hfsc_queue extends priq_queue {
unref_on_altq_queue_list($this->GetQname());
$tmpvalue = $this->GetDefault();
if (!empty($tmpvalue))
- altq_set_default_queue($this->GetInterface(), "false");
+ altq_set_default_queue($this->GetInterface(), false);
cleanup_queue_from_rules($this->GetQname());
$parent =& $this->GetParent();
foreach ($this->subqueues as $q) {
@@ -1532,22 +1534,22 @@ class hfsc_queue extends priq_queue {
parent::validate_input($data, $input_errors);
$reqdfields[] = "bandwidth";
- $reqdfieldsn[] = "Bandwidth";
+ $reqdfieldsn[] = gettext("Bandwidth");
$reqdfields[] = "bandwidthtype";
- $reqdfieldsn[] = "Bandwidthtype";
+ $reqdfieldsn[] = gettext("Bandwidthtype");
shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors);
if (isset($data['linkshare3']) && $data['linkshare3'] <> "") {
if ($data['bandwidth'] && (!is_numeric($data['bandwidth'])))
- $input_errors[] = "Bandwidth must be an integer.";
+ $input_errors[] = gettext("Bandwidth must be an integer.");
- if ($data['bandwidth'] < 0)
- $input_errors[] = "Bandwidth cannot be negative.";
+ if ($data['bandwidth'] < 0)
+ $input_errors[] = gettext("Bandwidth cannot be negative.");
if ($data['bandwidthtype'] == "%") {
if ($data['bandwidth'] > 100 || $data['bandwidth'] < 0)
- $input_errors[] = "Bandwidth in percentage should be between 1 and 100 bounds.";
+ $input_errors[] = gettext("Bandwidth in percentage should be between 1 and 100 bounds.");
}
/*
$parent =& $this->GetParent();
@@ -1564,15 +1566,15 @@ class hfsc_queue extends priq_queue {
}
if ($data['upperlimit1'] <> "" && $data['upperlimit2'] == "")
- $input_errors[] = ("upperlimit service curve defined but missing (d) value");
+ $input_errors[] = gettext("upperlimit service curve defined but missing (d) value");
if ($data['upperlimit2'] <> "" && $data['upperlimit1'] == "")
- $input_errors[] = ("upperlimit service curve defined but missing initial bandwidth (m1) value");
+ $input_errors[] = gettext("upperlimit service curve defined but missing initial bandwidth (m1) value");
if ($data['upperlimit1'] <> "" && !is_valid_shaperbw($data['upperlimit1']))
- $input_errors[] = ("upperlimit m1 value needs to be Kb, Mb, Gb, or %");
+ $input_errors[] = gettext("upperlimit m1 value needs to be Kb, Mb, Gb, or %");
if ($data['upperlimit2'] <> "" && !is_numeric($data['upperlimit2']))
- $input_errors[] = ("upperlimit d value needs to be numeric");
+ $input_errors[] = gettext("upperlimit d value needs to be numeric");
if ($data['upperlimit3'] <> "" && !is_valid_shaperbw($data['upperlimit3']))
- $input_errors[] = ("upperlimit m2 value needs to be Kb, Mb, Gb, or %");
+ $input_errors[] = gettext("upperlimit m2 value needs to be Kb, Mb, Gb, or %");
/*
if (isset($data['upperlimit']) && $data['upperlimit3'] <> "" && $data['upperlimit1'] <> "") {
@@ -1586,19 +1588,19 @@ class hfsc_queue extends priq_queue {
}
*/
if ($data['linkshare1'] <> "" && $data['linkshare2'] == "")
- $input_errors[] = ("linkshare service curve defined but missing (d) value");
+ $input_errors[] = gettext("linkshare service curve defined but missing (d) value");
if ($data['linkshare2'] <> "" && $data['linkshare1'] == "")
- $input_errors[] = ("linkshare service curve defined but missing initial bandwidth (m1) value");
+ $input_errors[] = gettext("linkshare service curve defined but missing initial bandwidth (m1) value");
if ($data['linkshare1'] <> "" && !is_valid_shaperbw($data['linkshare1']))
- $input_errors[] = ("linkshare m1 value needs to be Kb, Mb, Gb, or %");
+ $input_errors[] = gettext("linkshare m1 value needs to be Kb, Mb, Gb, or %");
if ($data['linkshare2'] <> "" && !is_numeric($data['linkshare2']))
- $input_errors[] = ("linkshare d value needs to be numeric");
+ $input_errors[] = gettext("linkshare d value needs to be numeric");
if ($data['linkshare3'] <> "" && !is_valid_shaperbw($data['linkshare3']))
- $input_errors[] = ("linkshare m2 value needs to be Kb, Mb, Gb, or %");
+ $input_errors[] = gettext("linkshare m2 value needs to be Kb, Mb, Gb, or %");
if ($data['realtime1'] <> "" && $data['realtime2'] == "")
- $input_errors[] = ("realtime service curve defined but missing (d) value");
+ $input_errors[] = gettext("realtime service curve defined but missing (d) value");
if ($data['realtime2'] <> "" && $data['realtime1'] == "")
- $input_errors[] = ("realtime service curve defined but missing initial bandwidth (m1) value");
+ $input_errors[] = gettext("realtime service curve defined but missing initial bandwidth (m1) value");
/*
if (isset($data['linkshare']) && $data['linkshare3'] <> "" && $data['linkshare1'] <> "" && 0) {
@@ -1613,11 +1615,11 @@ class hfsc_queue extends priq_queue {
*/
if ($data['realtime1'] <> "" && !is_valid_shaperbw($data['realtime1']))
- $input_errors[] = ("realtime m1 value needs to be Kb, Mb, Gb, or %");
+ $input_errors[] = gettext("realtime m1 value needs to be Kb, Mb, Gb, or %");
if ($data['realtime2'] <> "" && !is_numeric($data['realtime2']))
- $input_errors[] = ("realtime d value needs to be numeric");
+ $input_errors[] = gettext("realtime d value needs to be numeric");
if ($data['realtime3'] <> "" && !is_valid_shaperbw($data['realtime3']))
- $input_errors[] = ("realtime m2 value needs to be Kb, Mb, Gb, or %");
+ $input_errors[] = gettext("realtime m2 value needs to be Kb, Mb, Gb, or %");
/*
if (isset($data['realtime']) && $data['realtime3'] <> "" && $data['realtime1'] <> "" && 0) {
@@ -1839,7 +1841,7 @@ class hfsc_queue extends priq_queue {
function build_form() {
$form = parent::build_form();
$form .= "
The bandwidth share of a backlogged queue - this overrides priority.
";
+ $form .= ">
" . gettext("The bandwidth share of a backlogged queue - this overrides priority.") . "
";
$form .= "
";
- $form .= "The format for service curve specifications is (m1, d, m2). m2 controls";
- $form .= "the bandwidth assigned to the queue. m1 and d are optional and can be";
- $form .= "used to control the initial bandwidth assignment. For the first d milliseconds the queue gets the bandwidth given as m1, afterwards the value";
- $form .= "given in m2.";
+ $form .= gettext("The format for service curve specifications is (m1, d, m2). m2 controls "
+ . "the bandwidth assigned to the queue. m1 and d are optional and can be "
+ . "used to control the initial bandwidth assignment. For the first d milliseconds the queue gets the bandwidth given as m1, afterwards the value "
+ . "given in m2.");
$form .= "
";
$form .= "
";
@@ -2168,7 +2170,7 @@ class cbq_queue extends priq_queue {
function delete_queue() {
unref_on_altq_queue_list($this->GetQname());
if ($this->GetDefault())
- altq_set_default_queue($this->GetInterface(), "false");
+ altq_set_default_queue($this->GetInterface(), false);
cleanup_queue_from_rules($this->GetQname());
foreach ($this->subqueues as $q) {
$this->SetAvailableBandwidth($this->GetAvailableBandwidth() + $q->GetAvailableBandwidth());
@@ -2181,24 +2183,24 @@ class cbq_queue extends priq_queue {
parent::validate_input($data, $input_errors);
if ($data['priority'] > 7)
- $input_errors[] = "Priority must be an integer between 1 and 7.";
+ $input_errors[] = gettext("Priority must be an integer between 1 and 7.");
$reqdfields[] = "bandwidth";
- $reqdfieldsn[] = "Bandwidth";
+ $reqdfieldsn[] = gettext("Bandwidth");
$reqdfields[] = "bandwidthtype";
- $reqdfieldsn[] = "Bandwidthtype";
+ $reqdfieldsn[] = gettext("Bandwidthtype");
shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors);
if ($data['bandwidth'] && !is_numeric($data['bandwidth']))
- $input_errors[] = "Bandwidth must be an integer.";
+ $input_errors[] = gettext("Bandwidth must be an integer.");
if ($data['bandwidth'] < 0)
- $input_errors[] = "Bandwidth cannot be negative.";
+ $input_errors[] = gettext("Bandwidth cannot be negative.");
if ($data['bandwidthtype'] == "%") {
if ($data['bandwidth'] > 100 || $data['bandwidth'] < 0)
- $input_errors[] = "Bandwidth in percentage should be between 1 and 100 bounds.";
+ $input_errors[] = gettext("Bandwidth in percentage should be between 1 and 100 bounds.");
}
/*
@@ -2317,7 +2319,7 @@ class cbq_queue extends priq_queue {
function build_form() {
$form = parent::build_form();
$form .= "
GetHogs());
if(!empty($tmpvalue))
$form .= $this->GetHogs();
- $form .= "\"> Bandwidth limit for hosts to not saturate link.
";
+ $form .= "\"> " . gettext("Bandwidth limit for hosts to not saturate link.") . " ";
$form .= "
";
return $form;
}
@@ -2779,26 +2781,26 @@ class dummynet_class {
function validate_input($data, &$input_errors) {
$reqdfields[] = "bandwidth";
- $reqdfieldsn[] = "Bandwidth";
+ $reqdfieldsn[] = gettext("Bandwidth");
$reqdfields[] = "bandwidthtype";
- $reqdfieldsn[] = "Bandwidthtype";
+ $reqdfieldsn[] = gettext("Bandwidthtype");
$reqdfields[] = "newname";
- $reqdfieldsn[] = "Name";
+ $reqdfieldsn[] = gettext("Name");
shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors);
if ($data['plr'] && ((!is_numeric($data['plr'])) ||
($data['plr'] <= 0 && $data['plr'] > 1)))
- $input_errors[] = "Plr must be an integer between 1 and 100.";
+ $input_errors[] = gettext("Plr must be an integer between 1 and 100.");
if (($data['buckets'] && (!is_numeric($data['buckets']))) ||
($data['buckets'] < 1 && $data['buckets'] > 100))
- $input_errors[] = "Buckets must be an integer between 16 and 65535.";
+ $input_errors[] = gettext("Buckets must be an integer between 16 and 65535.");
if ($data['qlimit'] && (!is_numeric($data['qlimit'])))
- $input_errors[] = "Queue limit must be an integer";
+ $input_errors[] = gettext("Queue limit must be an integer");
if (!empty($data['newname']) && !preg_match("/^[a-zA-Z0-9_-]+$/", $data['newname']))
- $input_errors[] = "Queue names must be alphanumeric and _ or - only.";
+ $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only.");
if (!empty($data['name']) && !preg_match("/^[a-zA-Z0-9_-]+$/", $data['name']))
- $input_errors[] = "Queue names must be alphanumeric and _ or - only.";
+ $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only.");
}
}
@@ -2892,10 +2894,10 @@ class dnpipe_class extends dummynet_class {
parent::validate_input($data, $input_errors);
if ($data['bandwidth'] && (!is_numeric($data['bandwidth'])))
- $input_errors[] = "Bandwidth must be an integer.";
+ $input_errors[] = gettext("Bandwidth must be an integer.");
if ($data['delay'] && (!is_numeric($data['delay'])))
- $input_errors[] = "Delay must be an integer.";
- }
+ $input_errors[] = gettext("Delay must be an integer.");
+ }
function ReadConfig(&$q) {
if (!empty($q['name']) && !empty($q['newname']) && $q['name'] != $q['newname']) {
@@ -3001,21 +3003,21 @@ class dnpipe_class extends dummynet_class {
function build_form() {
$form = "
";
$form .= "";
$form .= " ";
- $form .= "If 'source' or 'destination' is chosen, \n";
- $form .= "a dynamic pipe with the bandwidth, delay, packet loss and queue size given above will \n";
- $form .= "be created for each source/destination IP address encountered, \n";
- $form .= "respectively. This makes it possible to easily specify bandwidth \n";
- $form .= "limits per host.";
+ $form .= "" . gettext("If 'source' or 'destination' is chosen, \n"
+ . "a dynamic pipe with the bandwidth, delay, packet loss and queue size given above will \n"
+ . "be created for each source/destination IP address encountered, \n"
+ . "respectively. This makes it possible to easily specify bandwidth \n"
+ . "limits per host.") . "";
$form .= "
";
- $form .= "
Description
";
+ $form .= "
" . gettext("Description") . "
";
$form .= "
";
$form .= "GetDescription();
$form .= "\">";
$form .= " ";
- $form .= "You may enter a description here ";
- $form .= "for your reference (not parsed).";
+ $form .= gettext("You may enter a description here for your reference (not parsed).") . "";
$form .= "
";
$form .= "GetDelay() . "\">";
- $form .= " ms Hint: in most cases, you ";
- $form .= "should specify 0 here (or leave the field empty)";
+ $form .= " ms " . gettext("Hint: in most cases, you "
+ . "should specify 0 here (or leave the field empty)") . "";
$form .= "
";
$form .= "
";
- $form .= "
Packet loss rate
";
+ $form .= "
" . gettext("Packet loss rate") . "
";
$form .= "
";
$form .= "GetPlr() . "\">";
- $form .= " Hint: in most cases, you ";
- $form .= "should specify 0 here (or leave the field empty).";
- $form .= "A value of 0.001 means one packet in 1000 gets dropped";
+ $form .= " " . gettext("Hint: in most cases, you "
+ . "should specify 0 here (or leave the field empty). "
+ . "A value of 0.001 means one packet in 1000 gets dropped") . "";
$form .= "
";
$form .= "
";
- $form .= "
Queue Size
";
+ $form .= "
" . gettext("Queue Size") . "
";
$form .= "
";
$form .= "GetQlimit() . "\">";
$form .= " slots ";
- $form .= "Hint: in most cases, you ";
- $form .= "should leave the field empty. All packets in this pipe are placed into a fixed-size queue first,";
- $form .= "then they are delayed by value specified in the Delay field, and then they ";
- $form .= "are delivered to their destination.";
+ $form .= "" . gettext("Hint: in most cases, you "
+ . "should leave the field empty. All packets in this pipe are placed into a fixed-size queue first, "
+ . "then they are delayed by value specified in the Delay field, and then they "
+ . "are delivered to their destination.") . "";
$form .= "
";
$form .= "
";
- $form .= "
Bucket Size
";
+ $form .= "
" . gettext("Bucket Size") . "
";
$form .= "
";
$form .= "GetBuckets() . "\">";
$form .= " slots ";
- $form .= "Hint: in most cases, you ";
- $form .= "should leave the field empty. It increases the hash size set.";
+ $form .= "" . gettext("Hint: in most cases, you "
+ . "should leave the field empty. It increases the hash size set.");
$form .= "
";
return $form;
@@ -3169,7 +3170,7 @@ class dnqueue_class extends dummynet_class {
if ($data['weight'] && ((!is_numeric($data['weight'])) ||
($data['weight'] < 1 && $data['weight'] > 100)))
- $input_errors[] = "Weight must be an integer between 1 and 100.";
+ $input_errors[] = gettext("Weight must be an integer between 1 and 100.");
}
/*
@@ -3262,42 +3263,42 @@ class dnqueue_class extends dummynet_class {
function build_form() {
$form = "
";
$form .= "";
$form .= " slots ";
- $form .= "If 'source' or 'destination' is chosen, \n";
- $form .= "a dynamic pipe with the bandwidth, delay, packet loss and queue size given above will \n";
- $form .= "be created for each source/destination IP address encountered, \n";
- $form .= "respectively. This makes it possible to easily specify bandwidth \n";
- $form .= "limits per host.";
+ $form .= "" . gettext("If 'source' or 'destination' is chosen, \n"
+ . "a dynamic pipe with the bandwidth, delay, packet loss and queue size given above will \n"
+ . "be created for each source/destination IP address encountered, \n"
+ . "respectively. This makes it possible to easily specify bandwidth \n"
+ . "limits per host.") . "";
$form .= "
";
$form .= "
Description
";
$form .= "
";
@@ -3305,51 +3306,50 @@ class dnqueue_class extends dummynet_class {
$form .= $this->GetDescription();
$form .= "\">";
$form .= " ";
- $form .= "You may enter a description here ";
- $form .= "for your reference (not parsed).";
+ $form .= gettext("You may enter a description here for your reference (not parsed).") . "";
$form .= "
";
$form .= "GetWeight() . "\">";
- $form .= " ms Hint: For queues under the same parent ";
- $form .= "this specifies the share that a queue gets(values range from 1 to 100, you can leave it blank otherwise)";
+ $form .= " ms " . gettext("Hint: For queues under the same parent "
+ . "this specifies the share that a queue gets(values range from 1 to 100, you can leave it blank otherwise)") . "";
$form .= "
";
$form .= "
";
- $form .= "
Packet loss rate
";
+ $form .= "
" . gettext("Packet loss rate") . "
";
$form .= "
";
$form .= "GetPlr() . "\">";
- $form .= " Hint: in most cases, you ";
- $form .= "should specify 0 here (or leave the field empty).";
- $form .= "A value of 0.001 means one packet in 1000 gets dropped";
+ $form .= " " . gettext("Hint: in most cases, you "
+ . "should specify 0 here (or leave the field empty). "
+ . "A value of 0.001 means one packet in 1000 gets dropped") . "";
$form .= "
";
$form .= "
";
- $form .= "
Queue Size
";
+ $form .= "
" . gettext("Queue Size") . "
";
$form .= "
";
$form .= "GetQlimit() . "\">";
$form .= " slots ";
- $form .= "Hint: in most cases, you ";
- $form .= "should leave the field empty. All packets in this pipe are placed into a fixed-size queue first, ";
- $form .= "then they are delayed by value specified in the Delay field, and then they ";
- $form .= "are delivered to their destination.";
+ $form .= "" . gettext("Hint: in most cases, you "
+ . "should leave the field empty. All packets in this pipe are placed into a fixed-size queue first, "
+ . "then they are delayed by value specified in the Delay field, and then they "
+ . "are delivered to their destination.") . "";
$form .= "
";
$form .= "
";
- $form .= "
Bucket Size
";
+ $form .= "
" . gettext("Bucket Size") . "
";
$form .= "
";
$form .= "GetBuckets() . "\">";
- $form .= " slots ";
- $form .= "Hint: in most cases, you ";
- $form .= "should leave the field empty. It increases the hash size set.";
+ $form .= " " . gettext("slots") . " ";
+ $form .= "" . gettext("Hint: in most cases, you "
+ . "should leave the field empty. It increases the hash size set.");
$form .= "
";
$form .= "GetRDescription();
$form .= "\">";
$form .= " ";
- $form .= "You may enter a description here ";
- $form .= "for your reference (not parsed).";
+ $form .= gettext("You may enter a description here for your reference (not parsed).") . "";
$form .= "
";
return $form;
@@ -3563,12 +3562,12 @@ class layer7 {
function validate_input($data, &$input_errors) {
$reqdfields[] = "container";
- $reqdfieldsn[] = "Name";
+ $reqdfieldsn[] = gettext("Name");
shaper_do_input_validation($data, $reqdfields, $reqdfieldsn, $input_errors);
if (!preg_match("/^[a-zA-Z0-9_-]+$/", $data['container']))
- $input_errors[] = "Queue names must be alphanumeric and _ or - only.";
+ $input_errors[] = gettext("Queue names must be alphanumeric and _ or - only.");
}
function delete_l7c() {
@@ -3739,7 +3738,7 @@ function layer7_start_l7daemon() {
/* Only reread the configuration rather than restart to avoid loosing information. */
exec("/bin/pgrep -f 'ipfw-classifyd .* -p ". $l7rules->GetRPort() . "'", $l7pid);
if (count($l7pid) > 0) {
- log_error("Sending HUP signal to {$l7pid[0]}");
+ log_error(sprintf(gettext("Sending HUP signal to %s"), $l7pid[0]));
mwexec("/bin/kill -HUP {$l7pid[0]}");
} else {
// XXX: Hardcoded number of packets to garbage collect and queue length..
@@ -3822,22 +3821,18 @@ function altq_set_default_queue($interface, $value) {
global $altq_list_queues;
$altq_tmp =& $altq_list_queues[$interface];
- if ($altq_tmp) {
- if ($value) {
- $altq_tmp->SetDefaultQueuePresent("true");
- }
- else {
- $altq_tmp->SetDefaultQueuePresent("false");
- }
- }
+ if ($altq_tmp)
+ $altq_tmp->SetDefaultQueuePresent($value);
}
function altq_get_default_queue($interface) {
global $altq_list_queues;
$altq_tmp = $altq_list_queues[$interface];
- if ($altq_tmp)
+ if ($altq_tmp)
return $altq_tmp->GetDefaultQueuePresent();
+ else
+ return false;
}
function altq_check_default_queues() {
@@ -4059,7 +4054,7 @@ function build_iface_without_this_queue($iface, $qname) {
$form .= "";
- $form .= " Clone shaper/queue on this interface";
+ $form .= gettext(" Clone shaper/queue on this interface") . "";
return $form;
@@ -4067,16 +4062,16 @@ function build_iface_without_this_queue($iface, $qname) {
$default_shaper_msg = "
";
-$default_shaper_msg .= "
Welcome to the {$g['product_name']} Traffic Shaper. ";
-$default_shaper_msg .= "The tree on the left helps you navigate through the queues ";
-$default_shaper_msg .= "buttons at the bottom represent queue actions and are activated accordingly.";
+$default_shaper_msg .= "
" . sprintf(gettext("Welcome to the %s Traffic Shaper."), $g['product_name']) . " ";
+$default_shaper_msg .= gettext("The tree on the left helps you navigate through the queues "
+ . "buttons at the bottom represent queue actions and are activated accordingly.");
$default_shaper_msg .= "
";
$default_shaper_msg .= "
";
$dn_default_shaper_msg = "
";
-$dn_default_shaper_msg .= "
Welcome to the {$g['product_name']} Traffic Shaper. ";
-$dn_default_shaper_msg .= "The tree on the left helps you navigate through the queues ";
-$dn_default_shaper_msg .= "buttons at the bottom represent queue actions and are activated accordingly.";
+$dn_default_shaper_msg .= "
" . sprintf(gettext("Welcome to the %s Traffic Shaper."), $g['product_name']) . " ";
+$dn_default_shaper_msg .= gettext("The tree on the left helps you navigate through the queues "
+ . "buttons at the bottom represent queue actions and are activated accordingly.");
$dn_default_shaper_msg .= "
";
$dn_default_shaper_msg .= "
";
diff --git a/etc/inc/smtp.inc b/etc/inc/smtp.inc
index 4f396820fd..1f371f6154 100644
--- a/etc/inc/smtp.inc
+++ b/etc/inc/smtp.inc
@@ -89,10 +89,10 @@ class smtp_class
{
$status=socket_get_status($this->connection);
if($status["timed_out"])
- $this->error.=": data access time out";
+ $this->error.=gettext(": data access time out");
elseif($status["eof"])
{
- $this->error.=": the server disconnected";
+ $this->error.=gettext(": the server disconnected");
$this->disconnected_error=1;
}
}
@@ -104,13 +104,13 @@ class smtp_class
{
if(feof($this->connection))
{
- $this->error="reached the end of data while reading from the SMTP server conection";
+ $this->error=gettext("reached the end of data while reading from the SMTP server conection");
return("");
}
if(GetType($data=@fgets($this->connection,100))!="string"
|| strlen($data)==0)
{
- $this->SetDataAccessError("it was not possible to read line from the SMTP server");
+ $this->SetDataAccessError(gettext("it was not possible to read line from the SMTP server"));
return("");
}
$line.=$data;
@@ -132,7 +132,7 @@ class smtp_class
$this->OutputDebug("C $line");
if(!@fputs($this->connection,"$line\r\n"))
{
- $this->SetDataAccessError("it was not possible to send a line to the SMTP server");
+ $this->SetDataAccessError(gettext("it was not possible to send a line to the SMTP server"));
return(0);
}
return(1);
@@ -146,7 +146,7 @@ class smtp_class
$this->OutputDebug("C $data");
if(!@fputs($this->connection,$data))
{
- $this->SetDataAccessError("it was not possible to send data to the SMTP server");
+ $this->SetDataAccessError(gettext("it was not possible to send data to the SMTP server"));
return(0);
}
}
@@ -218,10 +218,10 @@ class smtp_class
$version=explode(".",function_exists("phpversion") ? phpversion() : "3.0.7");
$php_version=intval($version[0])*1000000+intval($version[1])*1000+intval($version[2]);
if($php_version<4003000)
- return("establishing SSL connections requires at least PHP version 4.3.0");
+ return(gettext("establishing SSL connections requires at least PHP version 4.3.0"));
if(!function_exists("extension_loaded")
|| !extension_loaded("openssl"))
- return("establishing SSL connections requires the OpenSSL extension enabled");
+ return(gettext("establishing SSL connections requires the OpenSSL extension enabled"));
}
if(ereg('^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$',$domain))
$ip=$domain;
@@ -230,30 +230,30 @@ class smtp_class
if($this->debug)
$this->OutputDebug($resolve_message);
if(!strcmp($ip=@gethostbyname($domain),$domain))
- return("could not resolve host \"".$domain."\"");
+ return(sprintf(gettext("could not resolve host \"%s\""), $domain));
}
if(strlen($this->exclude_address)
&& !strcmp(@gethostbyname($this->exclude_address),$ip))
- return("domain \"".$domain."\" resolved to an address excluded to be valid");
+ return(sprintf(gettext("domain \"%s\" resolved to an address excluded to be valid"), $domain));
if($this->debug)
- $this->OutputDebug("Connecting to host address \"".$ip."\" port ".$port."...");
+ $this->OutputDebug(sprintf(gettext('Connecting to host address "%1$s" port %2$s...'), $ip, $port));
if(($this->connection=($this->timeout ? @fsockopen(($this->ssl ? "ssl://" : "").$ip,$port,$errno,$error,$this->timeout) : @fsockopen(($this->ssl ? "ssl://" : "").$ip,$port))))
return("");
$error=($this->timeout ? strval($error) : "??");
switch($error)
{
case "-3":
- return("-3 socket could not be created");
+ return(gettext("-3 socket could not be created"));
case "-4":
- return("-4 dns lookup on hostname \"".$domain."\" failed");
+ return(sprintf(gettext("-4 dns lookup on hostname \"%s\" failed"), $domain));
case "-5":
- return("-5 connection refused or timed out");
+ return(gettext("-5 connection refused or timed out"));
case "-6":
- return("-6 fdopen() call failed");
+ return(gettext("-6 fdopen() call failed"));
case "-7":
- return("-7 setvbuf() call failed");
+ return(gettext("-7 setvbuf() call failed"));
}
- return("could not connect to the host \"".$domain."\": ".$error);
+ return(sprintf(gettext('could not connect to the host "%1$s": %2$s'), $domain, $error));
}
Function SASLAuthenticate($mechanisms, $credentials, &$authenticated, &$mechanism)
@@ -262,7 +262,7 @@ class smtp_class
if(!function_exists("class_exists")
|| !class_exists("sasl_client_class"))
{
- $this->error="it is not possible to authenticate using the specified mechanism because the SASL library class is not loaded";
+ $this->error=gettext("it is not possible to authenticate using the specified mechanism because the SASL library class is not loaded");
return(0);
}
$sasl=new sasl_client_class;
@@ -286,19 +286,19 @@ class smtp_class
case SASL_NOMECH:
if(strlen($this->authentication_mechanism))
{
- $this->error="authenticated mechanism ".$this->authentication_mechanism." may not be used: ".$sasl->error;
+ $this->error=printf(gettext('authenticated mechanism %1$s may not be used: %2$s'), $this->authentication_mechanism, $sasl->error);
return(0);
}
break;
default:
- $this->error="Could not start the SASL authentication client: ".$sasl->error;
+ $this->error=gettext("Could not start the SASL authentication client:") . " ".$sasl->error;
return(0);
}
if(strlen($mechanism=$sasl->mechanism))
{
if($this->PutLine("AUTH ".$sasl->mechanism.(IsSet($message) ? " ".base64_encode($message) : ""))==0)
{
- $this->error="Could not send the AUTH command";
+ $this->error=gettext("Could not send the AUTH command");
return(0);
}
if(!$this->VerifyResultLines(array("235","334"),$responses))
@@ -313,7 +313,7 @@ class smtp_class
$response=base64_decode($responses[0]);
break;
default:
- $this->error="Authentication error: ".$responses[0];
+ $this->error=gettext("Authentication error:") . " ".$responses[0];
return(0);
}
for(;!$authenticated;)
@@ -328,7 +328,7 @@ class smtp_class
case SASL_CONTINUE:
if($this->PutLine(base64_encode($message))==0)
{
- $this->error="Could not send the authentication step message";
+ $this->error=gettext("Could not send the authentication step message");
return(0);
}
if(!$this->VerifyResultLines(array("235","334"),$responses))
@@ -343,12 +343,12 @@ class smtp_class
$response=base64_decode($responses[0]);
break;
default:
- $this->error="Authentication error: ".$responses[0];
+ $this->error=gettext("Authentication error:") . " ".$responses[0];
return(0);
}
break;
default:
- $this->error="Could not process the SASL authentication step: ".$sasl->error;
+ $this->error=gettext("Could not process the SASL authentication step:") . " ".$sasl->error;
return(0);
}
}
@@ -362,7 +362,7 @@ class smtp_class
{
if(strcmp($this->state,"Disconnected"))
{
- $this->error="connection is already established";
+ $this->error=gettext("connection is already established");
return(0);
}
$this->disconnected_error=0;
@@ -400,24 +400,24 @@ class smtp_class
$user=$this->user;
if(strlen($user)==0)
{
- $this->error="it was not specified the POP3 authentication user";
+ $this->error=gettext("it was not specified the POP3 authentication user");
return(0);
}
$password=$this->password;
if(strlen($password)==0)
{
- $this->error="it was not specified the POP3 authentication password";
+ $this->error=gettext("it was not specified the POP3 authentication password");
return(0);
}
$domain=$this->pop3_auth_host;
- $this->error=$this->ConnectToHost($domain, $this->pop3_auth_port, "Resolving POP3 authentication host \"".$domain."\"...");
+ $this->error=$this->ConnectToHost($domain, $this->pop3_auth_port, sprintf(gettext("Resolving POP3 authentication host \"%s\"..."), $domain));
if(strlen($this->error))
return(0);
if(strlen($response=$this->GetLine())==0)
return(0);
if(strcmp($this->Tokenize($response," "),"+OK"))
{
- $this->error="POP3 authentication server greeting was not found";
+ $this->error=gettext("POP3 authentication server greeting was not found");
return(0);
}
if(!$this->PutLine("USER ".$this->user)
@@ -425,7 +425,7 @@ class smtp_class
return(0);
if(strcmp($this->Tokenize($response," "),"+OK"))
{
- $this->error="POP3 authentication user was not accepted: ".$this->Tokenize("\r\n");
+ $this->error=gettext("POP3 authentication user was not accepted:") . " ".$this->Tokenize("\r\n");
return(0);
}
if(!$this->PutLine("PASS ".$password)
@@ -433,7 +433,7 @@ class smtp_class
return(0);
if(strcmp($this->Tokenize($response," "),"+OK"))
{
- $this->error="POP3 authentication password was not accepted: ".$this->Tokenize("\r\n");
+ $this->error=gettext("POP3 authentication password was not accepted:") . " ".$this->Tokenize("\r\n");
return(0);
}
fclose($this->connection);
@@ -442,13 +442,13 @@ class smtp_class
}
if(count($hosts)==0)
{
- $this->error="could not determine the SMTP to connect";
+ $this->error=gettext("could not determine the SMTP to connect");
return(0);
}
for($host=0, $error="not connected";strlen($error) && $hostConnectToHost($domain, $this->host_port, "Resolving SMTP server domain \"$domain\"...");
+ $error=$this->ConnectToHost($domain, $this->host_port, sprintf(gettext("Resolving SMTP server domain \"%s\"..."), $domain));
}
if(strlen($error))
{
@@ -460,7 +460,7 @@ class smtp_class
&& function_exists("socket_set_timeout"))
socket_set_timeout($this->connection,$timeout,0);
if($this->debug)
- $this->OutputDebug("Connected to SMTP server \"".$domain."\".");
+ $this->OutputDebug(sprintf(gettext("Connected to SMTP server \"%s\"."), $domain));
if(!strcmp($localhost=$this->localhost,"")
&& !strcmp($localhost=getenv("SERVER_NAME"),"")
&& !strcmp($localhost=getenv("HOST"),""))
@@ -514,7 +514,7 @@ class smtp_class
{
if(!IsSet($this->esmtp_extensions["AUTH"]))
{
- $this->error="server does not require authentication";
+ $this->error=gettext("server does not require authentication");
$success=0;
}
else
@@ -578,7 +578,7 @@ class smtp_class
if($success
&& strlen($mechanism)==0)
{
- $this->error="it is not supported any of the authentication mechanisms required by the server";
+ $this->error=gettext("it is not supported any of the authentication mechanisms required by the server");
$success=0;
}
}
@@ -610,7 +610,7 @@ class smtp_class
$sender=$this->direct_sender;
break;
default:
- $this->error="direct delivery connection is already established and sender is already set";
+ $this->error=gettext("direct delivery connection is already established and sender is already set");
return(0);
}
}
@@ -618,7 +618,7 @@ class smtp_class
{
if(strcmp($this->state,"Connected"))
{
- $this->error="connection is not in the initial state";
+ $this->error=gettext("connection is not in the initial state");
return(0);
}
}
@@ -640,7 +640,7 @@ class smtp_class
if($this->direct_delivery)
{
if(GetType($at=strrpos($recipient,"@"))!="integer")
- return("it was not specified a valid direct recipient");
+ return(gettext("it was not specified a valid direct recipient"));
$domain=substr($recipient,$at+1);
switch($this->state)
{
@@ -659,12 +659,12 @@ class smtp_class
case "RecipientSet":
if(strcmp($this->connected_domain,$domain))
{
- $this->error="it is not possible to deliver directly to recipients of different domains";
+ $this->error=gettext("it is not possible to deliver directly to recipients of different domains");
return(0);
}
break;
default:
- $this->error="connection is already established and the recipient is already set";
+ $this->error=gettext("connection is already established and the recipient is already set");
return(0);
}
}
@@ -676,7 +676,7 @@ class smtp_class
case "RecipientSet":
break;
default:
- $this->error="connection is not in the recipient setting state";
+ $this->error=gettext("connection is not in the recipient setting state");
return(0);
}
}
@@ -705,7 +705,7 @@ class smtp_class
{
if(strcmp($this->state,"RecipientSet"))
{
- $this->error="connection is not in the start sending data state";
+ $this->error=gettext("connection is not in the start sending data state");
return(0);
}
$this->error="";
@@ -735,7 +735,7 @@ class smtp_class
{
if(strcmp($this->state,"SendingData"))
{
- $this->error="connection is not in the sending data state";
+ $this->error=gettext("connection is not in the sending data state");
return(0);
}
$this->error="";
@@ -746,7 +746,7 @@ class smtp_class
{
if(strcmp($this->state,"SendingData"))
{
- $this->error="connection is not in the sending data state";
+ $this->error=gettext("connection is not in the sending data state");
return(0);
}
$this->error="";
@@ -782,7 +782,7 @@ class smtp_class
{
if(!strcmp($this->state,"Disconnected"))
{
- $this->error="it was not previously established a SMTP connection";
+ $this->error=gettext("it was not previously established a SMTP connection");
return(0);
}
$this->error="";
@@ -840,4 +840,4 @@ class smtp_class
};
-?>
\ No newline at end of file
+?>
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index 0d9a9fd019..15d38e5185 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -228,6 +228,8 @@ function system_hosts_generate() {
$hostscfg = $dnsmasqcfg['hosts'];
$hosts = "127.0.0.1 localhost localhost.{$syscfg['domain']}\n";
+ $lhosts = "";
+ $dhosts = "";
if ($config['interfaces']['lan']) {
$cfgip = get_interface_ip("lan");
@@ -248,18 +250,23 @@ function system_hosts_generate() {
foreach ($hostscfg as $host) {
if ($host['host'])
- $hosts .= "{$host['ip']} {$host['host']}.{$host['domain']} {$host['host']}\n";
+ $lhosts .= "{$host['ip']} {$host['host']}.{$host['domain']} {$host['host']}\n";
else
- $hosts .= "{$host['ip']} {$host['domain']}\n";
+ $lhosts .= "{$host['ip']} {$host['domain']}\n";
}
if (isset($dnsmasqcfg['regdhcpstatic']) && is_array($config['dhcpd'])) {
foreach ($config['dhcpd'] as $dhcpif => $dhcpifconf)
if(is_array($dhcpifconf['staticmap']) && isset($dhcpifconf['enable']))
foreach ($dhcpifconf['staticmap'] as $host)
if ($host['ipaddr'] && $host['hostname'])
- $hosts .= "{$host['ipaddr']} {$host['hostname']}.{$syscfg['domain']} {$host['hostname']}\n";
+ $dhosts .= "{$host['ipaddr']} {$host['hostname']}.{$syscfg['domain']} {$host['hostname']}\n";
}
+ if (isset($dnsmasqcfg['dhcpfirst']))
+ $hosts .= $dhosts . $lhosts;
+ else
+ $hosts .= $lhosts . $dhosts;
+
/*
* Do not remove this because dhcpleases monitors with kqueue it needs to be
* killed before writing to hosts files.
@@ -324,14 +331,20 @@ function system_routing_configure($interface = "") {
echo "system_routing_configure() being called $mt\n";
}
+ /* configure gif interfaces for ipv6 tunnels */
+ // interfaces_gif_configure();
+
$gatewayip = "";
$interfacegw = "";
$foundgw = false;
+ $gatewayipv6 = "";
+ $interfacegwv6 = "";
+ $foundgwv6 = false;
/* tack on all the hard defined gateways as well */
if (is_array($config['gateways']['gateway_item'])) {
mwexec("/bin/rm {$g['tmp_path']}/*_defaultgw", true);
foreach ($config['gateways']['gateway_item'] as $gateway) {
- if (isset($gateway['defaultgw'])) {
+ if (isset($gateway['defaultgw']) && (is_ipaddrv4($gateway['gateway']))) {
if(strstr($gateway['gateway'], ":"))
break;
if ($gateway['gateway'] == "dynamic")
@@ -347,6 +360,21 @@ function system_routing_configure($interface = "") {
break;
}
}
+ foreach ($config['gateways']['gateway_item'] as $gateway) {
+ if (isset($gateway['defaultgw']) && (is_ipaddrv6($gateway['gateway']))) {
+ if ($gateway['gateway'] == "dynamic")
+ $gateway['gateway'] = get_interface_gateway_v6($gateway['interface']);
+ $gatewayipv6 = $gateway['gateway'];
+ $interfacegwv6 = $gateway['interface'];
+ if (!empty($interfacegwv6)) {
+ $defaultifv6 = get_real_interface($gateway['interface']);
+ if ($defaultifv6)
+ @file_put_contents("{$g['tmp_path']}/{$defaultifv6}_defaultgwv6", $gatewayipv6);
+ }
+ $foundgwv6 = true;
+ break;
+ }
+ }
}
if ($foundgw == false) {
$defaultif = get_real_interface("wan");
@@ -354,6 +382,12 @@ function system_routing_configure($interface = "") {
$gatewayip = get_interface_gateway("wan");
@touch("{$g['tmp_path']}/{$defaultif}_defaultgw");
}
+ if ($foundgwv6 == false) {
+ $defaultifv6 = get_real_interface("wan");
+ $interfacegwv6 = "wan";
+ $gatewayipv6 = get_interface_gateway_v6("wan");
+ @touch("{$g['tmp_path']}/{$defaultif}_defaultgwv6");
+ }
$dont_add_route = false;
/* if OLSRD is enabled, allow WAN to house DHCP. */
if($config['installedpackages']['olsrd']) {
@@ -364,7 +398,7 @@ function system_routing_configure($interface = "") {
}
}
}
- /* Create a array from the existing route table */
+ /* Create a array from the existing inet route table */
exec("/usr/bin/netstat -rnf inet", $route_str);
array_shift($route_str);
array_shift($route_str);
@@ -379,7 +413,7 @@ function system_routing_configure($interface = "") {
if ($dont_add_route == false ) {
if (!empty($interface) && $interface != $interfacegw)
;
- else if (($interfacegw <> "bgpd") && (is_ipaddr($gatewayip))) {
+ else if (($interfacegw <> "bgpd") && (is_ipaddrv4($gatewayip))) {
$action = "add";
if(isset($route_arr['default'])) {
$action = "change";
@@ -389,29 +423,60 @@ function system_routing_configure($interface = "") {
}
}
+ /* Create a array from the existing inet6 route table */
+ exec("/usr/bin/netstat -rnf inet6", $routev6_str);
+ array_shift($routev6_str);
+ array_shift($routev6_str);
+ array_shift($routev6_str);
+ array_shift($routev6_str);
+ $routev6_arr = array();
+ foreach($routev6_str as $routeline) {
+ $items = preg_split("/[ ]+/i", $routeline);
+ $routev6_arr[$items[0]] = array($items[0], $items[1], $items[5]);
+ }
+
+ if ($dont_add_route == false ) {
+ if (!empty($interface) && $interface != $interfacegwv6)
+ ;
+ else if (($interfacegwv6 <> "bgpd") && (is_ipaddrv6($gatewayipv6))) {
+ $action = "add";
+ if(isset($routev6_arr['default'])) {
+ $action = "change";
+ }
+ log_error("ROUTING: $action IPv6 default route to $gatewayipv6");
+ mwexec("/sbin/route {$action} -inet6 default " . escapeshellarg($gatewayipv6));
+ }
+ }
+
if (is_array($config['staticroutes']['route'])) {
$gateways_arr = return_gateways_array();
foreach ($config['staticroutes']['route'] as $rtent) {
$gatewayip = "";
if (empty($gateways_arr[$rtent['gateway']])) {
- log_error("Static Routes: Gateway IP could not be found for {$rtent['network']}");
+ log_error(sprintf(gettext("Static Routes: Gateway IP could not be found for %s"), $rtent['network']));
continue;
}
$gateway = $gateways_arr[$rtent['gateway']];
if (!empty($interface) && $interface != $gateway['friendlyiface'])
continue;
+
$gatewayip = $gateway['gateway'];
$interfacegw = $gateway['interface'];
$action = "add";
if (isset($route_arr[$rtent['network']]))
$action = "change";
+ if(is_ipaddrv6($gatewayip)) {
+ $inetfamily = "-inet6";
+ } else {
+ $inetfamily = "-inet";
+ }
if (is_ipaddr($gatewayip)) {
- mwexec("/sbin/route {$action} -inet " . escapeshellarg($rtent['network']) .
+ mwexec("/sbin/route {$action} {$inetfamily} " . escapeshellarg($rtent['network']) .
" " . escapeshellarg($gatewayip));
} else if (!empty($interfacegw)) {
- mwexec("/sbin/route {$action} -inet " . escapeshellarg($rtent['network']) .
+ mwexec("/sbin/route {$action} {$inetfamily} " . escapeshellarg($rtent['network']) .
" -iface " . escapeshellarg($interfacegw));
}
}
@@ -427,7 +492,9 @@ function system_routing_enable() {
echo "system_routing_enable() being called $mt\n";
}
- return mwexec("/sbin/sysctl net.inet.ip.forwarding=1");
+ mwexec("/sbin/sysctl net.inet.ip.forwarding=1");
+ mwexec("/sbin/sysctl net.inet6.ip6.forwarding=1");
+ return;
}
function system_syslogd_start() {
@@ -440,7 +507,7 @@ function system_syslogd_start() {
$syslogcfg = $config['syslog'];
if ($g['booting'])
- echo "Starting syslog...";
+ echo gettext("Starting syslog...");
else
killbypid("{$g['varrun_path']}/syslog.pid");
@@ -479,7 +546,7 @@ function system_syslogd_start() {
/* write syslog.conf */
$fd = fopen("{$g['varetc_path']}/syslog.conf", "w");
if (!$fd) {
- printf("Error: cannot open syslog.conf in system_syslogd_start().\n");
+ printf(gettext("Error: cannot open syslog.conf in system_syslogd_start().%s"), "\n");
return 1;
}
$syslogconf .= "!ntpdate,!ntpd\n";
@@ -631,6 +698,12 @@ EOD;
EOD;
}
+ if (isset($syslogcfg['zmqserver'])) {
+ $syslogconf .= << {$g['tmp_path']}/ssl.key");
mwexec("/usr/bin/openssl req -new -x509 -nodes -sha1 -days 2000 -key {$g['tmp_path']}/ssl.key > {$g['tmp_path']}/ssl.crt");
$crt = file_get_contents("{$g['tmp_path']}/ssl.crt");
@@ -727,7 +800,7 @@ function system_webgui_start() {
cert_import($cert, $crt, $key);
$a_cert[] = $cert;
$config['system']['webgui']['ssl-certref'] = $cert['refid'];
- write_config("Importing HTTPS certificate");
+ write_config(gettext("Importing HTTPS certificate"));
if(!$config['system']['webgui']['port'])
$portarg = "443";
$ca = ca_chain($cert);
@@ -757,9 +830,9 @@ function system_webgui_start() {
if ($g['booting']) {
if ($res == 0)
- echo "done.\n";
+ echo gettext("done.") . "\n";
else
- echo "failed!\n";
+ echo gettext("failed!") . "\n";
}
return $res;
@@ -912,13 +985,14 @@ EOD;
## FreeBSD!
server.event-handler = "freebsd-kqueue"
server.network-backend = "writev"
+#server.use-ipv6 = "enable"
## modules to load
server.modules = (
- {$captive_portal_module}
- "mod_access", "mod_accesslog", "mod_expire", "mod_compress", "mod_redirect",
- {$module}{$captiveportal}
- )
+ {$captive_portal_module}
+ "mod_access", "mod_accesslog", "mod_expire", "mod_compress", "mod_redirect",
+ {$module}{$captiveportal}
+)
## Unused modules
# "mod_setenv",
@@ -1025,7 +1099,41 @@ url.access-deny = ( "~", ".inc" )
######### Options that are good to be but not neccesary to be changed #######
## bind to port (default: 80)
-server.port = {$lighty_port}
+
+EOD;
+
+ if($captive_portal == true) {
+ $lighty_config .= "server.bind = \"127.0.0.1\"\n";
+ $lighty_config .= "server.port = {$lighty_port}\n";
+ $lighty_config .= "\$SERVER[\"socket\"] == \"127.0.0.1:{$lighty_port}\" { }\n";
+ $lighty_config .= "\$SERVER[\"socket\"] == \"[::1]:{$lighty_port}\" { \n";
+ if($cert <> "" and $key <> "") {
+ $lighty_config .= "\n";
+ $lighty_config .= "## ssl configuration\n";
+ $lighty_config .= "ssl.engine = \"enable\"\n";
+ $lighty_config .= "ssl.pemfile = \"{$g['varetc_path']}/{$cert_location}\"\n\n";
+ if($ca <> "")
+ $lighty_config .= "ssl.ca-file = \"{$g['varetc_path']}/{$ca_location}\"\n\n";
+ }
+ $lighty_config .= " }\n";
+ } else {
+ $lighty_config .= "server.bind = \"0.0.0.0\"\n";
+ $lighty_config .= "server.port = {$lighty_port}\n";
+ $lighty_config .= "\$SERVER[\"socket\"] == \"0.0.0.0:{$lighty_port}\" { }\n";
+ $lighty_config .= "\$SERVER[\"socket\"] == \"[::]:{$lighty_port}\" { \n";
+ if($cert <> "" and $key <> "") {
+ $lighty_config .= "\n";
+ $lighty_config .= "## ssl configuration\n";
+ $lighty_config .= "ssl.engine = \"enable\"\n";
+ $lighty_config .= "ssl.pemfile = \"{$g['varetc_path']}/{$cert_location}\"\n\n";
+ if($ca <> "")
+ $lighty_config .= "ssl.ca-file = \"{$g['varetc_path']}/{$ca_location}\"\n\n";
+ }
+ $lighty_config .= " }\n";
+ }
+
+
+ $lighty_config .= << "" and $key <> "") {
$fd = fopen("{$g['varetc_path']}/{$cert_location}", "w");
if (!$fd) {
- printf("Error: cannot open cert.pem in system_webgui_start().\n");
+ printf(gettext("Error: cannot open cert.pem in system_webgui_start().%s"), "\n");
return 1;
}
chmod("{$g['varetc_path']}/{$cert_location}", 0600);
@@ -1085,7 +1193,7 @@ EOD;
if(!(empty($ca) || (strlen(trim($ca)) == 0))) {
$fd = fopen("{$g['varetc_path']}/{$ca_location}", "w");
if (!$fd) {
- printf("Error: cannot open ca.pem in system_webgui_start().\n");
+ printf(gettext("Error: cannot open ca.pem in system_webgui_start().%s"), "\n");
return 1;
}
chmod("{$g['varetc_path']}/{$ca_location}", 0600);
@@ -1093,7 +1201,7 @@ EOD;
fclose($fd);
}
$lighty_config .= "\n";
- $lighty_config .= "## ssl configuration\n";
+ $lighty_config .= "## " . gettext("ssl configuration") . "\n";
$lighty_config .= "ssl.engine = \"enable\"\n";
$lighty_config .= "ssl.pemfile = \"{$g['varetc_path']}/{$cert_location}\"\n\n";
@@ -1120,7 +1228,7 @@ EOD;
$fd = fopen("{$filename}", "w");
if (!$fd) {
- printf("Error: cannot open {$filename} in system_generate_lighty_config().\n");
+ printf(gettext("Error: cannot open %s in system_generate_lighty_config().%s"), $filename, "\n");
return 1;
}
fwrite($fd, $lighty_config);
@@ -1140,7 +1248,7 @@ function system_timezone_configure() {
$syscfg = $config['system'];
if ($g['booting'])
- echo "Setting timezone...";
+ echo gettext("Setting timezone...");
/* extract appropriate timezone file */
$timezone = $syscfg['timezone'];
@@ -1156,7 +1264,7 @@ function system_timezone_configure() {
conf_mount_ro();
if ($g['booting'])
- echo "done.\n";
+ echo gettext("done.") . "\n";
}
function system_ntp_configure() {
@@ -1226,7 +1334,7 @@ function sync_system_time() {
global $config, $g;
if ($g['booting'])
- echo "Syncing system time before startup...";
+ echo gettext("Syncing system time before startup...");
/* foreach through servers and write out to ntpd.conf */
foreach (explode(' ', $config['system']['timeservers']) as $ts) {
@@ -1234,7 +1342,7 @@ function sync_system_time() {
}
if ($g['booting'])
- echo "done.\n";
+ echo gettext("done.") . "\n";
}
@@ -1332,7 +1440,7 @@ function system_dmesg_save() {
$fd = fopen("{$g['varlog_path']}/dmesg.boot", "w");
if (!$fd) {
- printf("Error: cannot open dmesg.boot in system_dmesg_save().\n");
+ printf(gettext("Error: cannot open dmesg.boot in system_dmesg_save().%s"), "\n");
return 1;
}
@@ -1353,7 +1461,7 @@ function system_set_harddisk_standby() {
if (isset($config['system']['harddiskstandby'])) {
if ($g['booting']) {
- echo 'Setting hard disk standby... ';
+ echo gettext('Setting hard disk standby... ');
}
$standby = $config['system']['harddiskstandby'];
@@ -1365,13 +1473,13 @@ function system_set_harddisk_standby() {
// Reinitialize ATA-drives
mwexec('/usr/local/sbin/atareinit');
if ($g['booting']) {
- echo "done.\n";
+ echo gettext("done.") . "\n";
}
} else if ($g['booting']) {
- echo "failed!\n";
+ echo gettext("failed!") . "\n";
}
} else if ($g['booting']) {
- echo "failed!\n";
+ echo gettext("failed!") . "\n";
}
}
}
@@ -1470,10 +1578,10 @@ function system_identify_specific_platform() {
global $g;
if ($g['platform'] == 'generic-pc')
- return array('name' => 'generic-pc', 'descr' => "Generic PC");
+ return array('name' => 'generic-pc', 'descr' => gettext("Generic PC"));
if ($g['platform'] == 'generic-pc-cdrom')
- return array('name' => 'generic-pc-cdrom', 'descr' => "Generic PC (CD-ROM)");
+ return array('name' => 'generic-pc-cdrom', 'descr' => gettext("Generic PC (CD-ROM)"));
/* the rest of the code only deals with 'embedded' platforms */
if ($g['platform'] != 'nanobsd')
@@ -1482,10 +1590,10 @@ function system_identify_specific_platform() {
$dmesg = system_get_dmesg_boot();
if (strpos($dmesg, "PC Engines WRAP") !== false)
- return array('name' => 'wrap', 'descr' => 'PC Engines WRAP');
+ return array('name' => 'wrap', 'descr' => gettext('PC Engines WRAP'));
if (strpos($dmesg, "PC Engines ALIX") !== false)
- return array('name' => 'alix', 'descr' => 'PC Engines ALIX');
+ return array('name' => 'alix', 'descr' => gettext('PC Engines ALIX'));
if (preg_match("/Soekris net45../", $dmesg, $matches))
return array('name' => 'net45xx', 'descr' => $matches[0]);
@@ -1497,7 +1605,7 @@ function system_identify_specific_platform() {
return array('name' => 'net55xx', 'descr' => $matches[0]);
/* unknown embedded platform */
- return array('name' => 'embedded', 'descr' => 'embedded (unknown)');
+ return array('name' => 'embedded', 'descr' => gettext('embedded (unknown)'));
}
function system_get_dmesg_boot() {
diff --git a/etc/inc/upgrade_config.inc b/etc/inc/upgrade_config.inc
index c0fd8cbe3c..1abc8c57c6 100644
--- a/etc/inc/upgrade_config.inc
+++ b/etc/inc/upgrade_config.inc
@@ -110,8 +110,8 @@ function upgrade_010_to_011() {
$fr['interface'] = $ifmap[$fr['interface']];
else {
/* remove the rule */
- echo "\nWarning: filter rule removed " .
- "(interface '{$fr['interface']}' does not exist anymore).";
+ printf(gettext("%sWarning: filter rule removed " .
+ "(interface '%s' does not exist anymore)."), "\n", $fr['interface']);
unset($config['filter']['rule'][$i]);
continue;
}
@@ -122,8 +122,8 @@ function upgrade_010_to_011() {
$fr['source']['network'] = $ifmap[$fr['source']['network']];
else {
/* remove the rule */
- echo "\nWarning: filter rule removed " .
- "(source network '{$fr['source']['network']}' does not exist anymore).";
+ printf(gettext("%sWarning: filter rule removed " .
+ "(source network '%s' does not exist anymore)."), "\n", $fr['source']['network']);
unset($config['filter']['rule'][$i]);
continue;
}
@@ -135,8 +135,8 @@ function upgrade_010_to_011() {
$fr['destination']['network'] = $ifmap[$fr['destination']['network']];
else {
/* remove the rule */
- echo "\nWarning: filter rule removed " .
- "(destination network '{$fr['destination']['network']}' does not exist anymore).";
+ printf(gettext("%sWarning: filter rule removed " .
+ "(destination network '%s' does not exist anymore)."), "\n", $fr['destination']['network']);
unset($config['filter']['rule'][$i]);
continue;
}
@@ -155,8 +155,8 @@ function upgrade_010_to_011() {
$fr['interface'] = $ifmap[$fr['interface']];
else {
/* remove the rule */
- echo "\nWarning: traffic shaper rule removed " .
- "(interface '{$fr['interface']}' does not exist anymore).";
+ printf(gettext("%sWarning: traffic shaper rule removed " .
+ "(interface '%s' does not exist anymore)."), "\n", $fr['interface']);
unset($config['pfqueueing']['rule'][$i]);
continue;
}
@@ -167,8 +167,8 @@ function upgrade_010_to_011() {
$fr['source']['network'] = $ifmap[$fr['source']['network']];
else {
/* remove the rule */
- echo "\nWarning: traffic shaper rule removed " .
- "(source network '{$fr['source']['network']}' does not exist anymore).";
+ printf(gettext("%sWarning: traffic shaper rule removed " .
+ "(source network '%s' does not exist anymore)."), "\n", $fr['source']['network']);
unset($config['pfqueueing']['rule'][$i]);
continue;
}
@@ -180,8 +180,8 @@ function upgrade_010_to_011() {
$fr['destination']['network'] = $ifmap[$fr['destination']['network']];
else {
/* remove the rule */
- echo "\nWarning: traffic shaper rule removed " .
- "(destination network '{$fr['destination']['network']}' does not exist anymore).";
+ printf(gettext("%sWarning: traffic shaper rule removed " .
+ "(destination network '%s' does not exist anymore)."), "\n", $fr['destination']['network']);
unset($config['pfqueueing']['rule'][$i]);
continue;
}
@@ -330,7 +330,7 @@ function upgrade_017_to_018() {
$vip = array();
$vip['mode'] = "carp";
$vip['interface'] = "AUTO";
- $vip['descr'] = "CARP vhid {$carpent['vhid']}";
+ $vip['descr'] = sprintf(gettext("CARP vhid %s"), $carpent['vhid']);
$vip['type'] = "single";
$vip['vhid'] = $carpent['vhid'];
$vip['advskew'] = $carpent['advskew'];
@@ -507,7 +507,7 @@ function upgrade_028_to_029() {
$rule_item['type'] = "pass";
$rule_item['source']['any'] = true;
$rule_item['destination']['any'] = true;
- $rule_item['descr'] = "Permit IPsec traffic.";
+ $rule_item['descr'] = gettext("Permit IPsec traffic.");
$rule_item['statetype'] = "keep state";
$a_filter[] = $rule_item;
}
@@ -582,7 +582,7 @@ function upgrade_039_to_040() {
if (isset ($config['system']['username'])) {
$config['system']['group'] = array();
$config['system']['group'][0]['name'] = "admins";
- $config['system']['group'][0]['description'] = "System Administrators";
+ $config['system']['group'][0]['description'] = gettext("System Administrators");
$config['system']['group'][0]['scope'] = "system";
$config['system']['group'][0]['priv'] = "page-all";
$config['system']['group'][0]['home'] = "index.php";
@@ -601,19 +601,19 @@ function upgrade_039_to_040() {
$config['system']['user'][0]['priv'] = array();
$config['system']['user'][0]['priv'][0]['id'] = "lockwc";
$config['system']['user'][0]['priv'][0]['name'] = "Lock webConfigurator";
- $config['system']['user'][0]['priv'][0]['descr'] = "Indicates whether this user will lock access to the webConfigurator for other users.";
+ $config['system']['user'][0]['priv'][0]['descr'] = gettext("Indicates whether this user will lock access to the webConfigurator for other users.");
$config['system']['user'][0]['priv'][1]['id'] = "lock-ipages";
$config['system']['user'][0]['priv'][1]['name'] = "Lock individual pages";
- $config['system']['user'][0]['priv'][1]['descr'] = "Indicates whether this user will lock individual HTML pages after having accessed a particular page (the lock will be freed if the user leaves or saves the page form).";
+ $config['system']['user'][0]['priv'][1]['descr'] = gettext("Indicates whether this user will lock individual HTML pages after having accessed a particular page (the lock will be freed if the user leaves or saves the page form).");
$config['system']['user'][0]['priv'][2]['id'] = "hasshell";
$config['system']['user'][0]['priv'][2]['name'] = "Has shell access";
- $config['system']['user'][0]['priv'][2]['descr'] = "Indicates whether this user is able to login for example via SSH.";
+ $config['system']['user'][0]['priv'][2]['descr'] = gettext("Indicates whether this user is able to login for example via SSH.");
$config['system']['user'][0]['priv'][3]['id'] = "copyfiles";
$config['system']['user'][0]['priv'][3]['name'] = "Is allowed to copy files";
- $config['system']['user'][0]['priv'][3]['descr'] = "Indicates whether this user is allowed to copy files onto the {$g['product_name']} appliance via SCP/SFTP. If you are going to use this privilege, you must install scponly on the appliance (Hint: pkg_add -r scponly).";
+ $config['system']['user'][0]['priv'][3]['descr'] = sprintf(gettext("Indicates whether this user is allowed to copy files onto the %s appliance via SCP/SFTP. If you are going to use this privilege, you must install scponly on the appliance (Hint: pkg_add -r scponly)."), $g['product_name']);
$config['system']['user'][0]['priv'][4]['id'] = "isroot";
$config['system']['user'][0]['priv'][4]['name'] = "Is root user";
- $config['system']['user'][0]['priv'][4]['descr'] = "This user is associated with the UNIX root user (you should associate this privilege only with one single user).";
+ $config['system']['user'][0]['priv'][4]['descr'] = gettext("This user is associated with the UNIX root user (you should associate this privilege only with one single user).");
$config['system']['nextuid'] = "111";
$config['system']['nextgid'] = "111";
@@ -630,75 +630,75 @@ function upgrade_040_to_041() {
$config['sysctl']['item'] = array();
$config['sysctl']['item'][0]['tunable'] = "net.inet.tcp.blackhole";
- $config['sysctl']['item'][0]['descr'] = "Drop packets to closed TCP ports without returning a RST";
+ $config['sysctl']['item'][0]['descr'] = gettext("Drop packets to closed TCP ports without returning a RST");
$config['sysctl']['item'][0]['value'] = "default";
$config['sysctl']['item'][1]['tunable'] = "net.inet.udp.blackhole";
- $config['sysctl']['item'][1]['descr'] = "Do not send ICMP port unreachable messages for closed UDP ports";
+ $config['sysctl']['item'][1]['descr'] = gettext("Do not send ICMP port unreachable messages for closed UDP ports");
$config['sysctl']['item'][1]['value'] = "default";
$config['sysctl']['item'][2]['tunable'] = "net.inet.ip.random_id";
- $config['sysctl']['item'][2]['descr'] = "Randomize the ID field in IP packets (default is 0: sequential IP IDs)";
+ $config['sysctl']['item'][2]['descr'] = gettext("Randomize the ID field in IP packets (default is 0: sequential IP IDs)");
$config['sysctl']['item'][2]['value'] = "default";
$config['sysctl']['item'][3]['tunable'] = "net.inet.tcp.drop_synfin";
- $config['sysctl']['item'][3]['descr'] = "Drop SYN-FIN packets (breaks RFC1379, but nobody uses it anyway)";
+ $config['sysctl']['item'][3]['descr'] = gettext("Drop SYN-FIN packets (breaks RFC1379, but nobody uses it anyway)");
$config['sysctl']['item'][3]['value'] = "default";
$config['sysctl']['item'][4]['tunable'] = "net.inet.ip.redirect";
- $config['sysctl']['item'][4]['descr'] = "Sending of IPv4 ICMP redirects";
+ $config['sysctl']['item'][4]['descr'] = gettext("Sending of IPv4 ICMP redirects");
$config['sysctl']['item'][4]['value'] = "default";
$config['sysctl']['item'][5]['tunable'] = "net.inet6.ip6.redirect";
- $config['sysctl']['item'][5]['descr'] = "Sending of IPv6 ICMP redirects";
+ $config['sysctl']['item'][5]['descr'] = gettext("Sending of IPv6 ICMP redirects");
$config['sysctl']['item'][5]['value'] = "default";
$config['sysctl']['item'][6]['tunable'] = "net.inet.tcp.syncookies";
- $config['sysctl']['item'][6]['descr'] = "Generate SYN cookies for outbound SYN-ACK packets";
+ $config['sysctl']['item'][6]['descr'] = gettext("Generate SYN cookies for outbound SYN-ACK packets");
$config['sysctl']['item'][6]['value'] = "default";
$config['sysctl']['item'][7]['tunable'] = "net.inet.tcp.recvspace";
- $config['sysctl']['item'][7]['descr'] = "Maximum incoming TCP datagram size";
+ $config['sysctl']['item'][7]['descr'] = gettext("Maximum incoming TCP datagram size");
$config['sysctl']['item'][7]['value'] = "default";
$config['sysctl']['item'][8]['tunable'] = "net.inet.tcp.sendspace";
- $config['sysctl']['item'][8]['descr'] = "Maximum outgoing TCP datagram size";
+ $config['sysctl']['item'][8]['descr'] = gettext("Maximum outgoing TCP datagram size");
$config['sysctl']['item'][8]['value'] = "default";
$config['sysctl']['item'][9]['tunable'] = "net.inet.ip.fastforwarding";
- $config['sysctl']['item'][9]['descr'] = "Fastforwarding (see http://lists.freebsd.org/pipermail/freebsd-net/2004-January/002534.html)";
+ $config['sysctl']['item'][9]['descr'] = gettext("Fastforwarding (see http://lists.freebsd.org/pipermail/freebsd-net/2004-January/002534.html)");
$config['sysctl']['item'][9]['value'] = "default";
$config['sysctl']['item'][10]['tunable'] = "net.inet.tcp.delayed_ack";
- $config['sysctl']['item'][10]['descr'] = "Do not delay ACK to try and piggyback it onto a data packet";
+ $config['sysctl']['item'][10]['descr'] = gettext("Do not delay ACK to try and piggyback it onto a data packet");
$config['sysctl']['item'][10]['value'] = "default";
$config['sysctl']['item'][11]['tunable'] = "net.inet.udp.maxdgram";
- $config['sysctl']['item'][11]['descr'] = "Maximum outgoing UDP datagram size";
+ $config['sysctl']['item'][11]['descr'] = gettext("Maximum outgoing UDP datagram size");
$config['sysctl']['item'][11]['value'] = "default";
$config['sysctl']['item'][12]['tunable'] = "net.link.bridge.pfil_onlyip";
- $config['sysctl']['item'][12]['descr'] = "Handling of non-IP packets which are not passed to pfil (see if_bridge(4))";
+ $config['sysctl']['item'][12]['descr'] = gettext("Handling of non-IP packets which are not passed to pfil (see if_bridge(4))");
$config['sysctl']['item'][12]['value'] = "default";
$config['sysctl']['item'][13]['tunable'] = "net.link.tap.user_open";
- $config['sysctl']['item'][13]['descr'] = "Allow unprivileged access to tap(4) device nodes";
+ $config['sysctl']['item'][13]['descr'] = gettext("Allow unprivileged access to tap(4) device nodes");
$config['sysctl']['item'][13]['value'] = "default";
$config['sysctl']['item'][15]['tunable'] = "kern.randompid";
- $config['sysctl']['item'][15]['descr'] = "Randomize PID's (see src/sys/kern/kern_fork.c: sysctl_kern_randompid())";
+ $config['sysctl']['item'][15]['descr'] = gettext("Randomize PID's (see src/sys/kern/kern_fork.c: sysctl_kern_randompid())");
$config['sysctl']['item'][15]['value'] = "default";
$config['sysctl']['item'][16]['tunable'] = "net.inet.tcp.inflight.enable";
- $config['sysctl']['item'][16]['descr'] = "The system will attempt to calculate the bandwidth delay product for each connection and limit the amount of data queued to the network to just the amount required to maintain optimum throughput. ";
+ $config['sysctl']['item'][16]['descr'] = gettext("The system will attempt to calculate the bandwidth delay product for each connection and limit the amount of data queued to the network to just the amount required to maintain optimum throughput. ");
$config['sysctl']['item'][16]['value'] = "default";
$config['sysctl']['item'][17]['tunable'] = "net.inet.icmp.icmplim";
- $config['sysctl']['item'][17]['descr'] = "Set ICMP Limits";
+ $config['sysctl']['item'][17]['descr'] = gettext("Set ICMP Limits");
$config['sysctl']['item'][17]['value'] = "default";
$config['sysctl']['item'][18]['tunable'] = "net.inet.tcp.tso";
- $config['sysctl']['item'][18]['descr'] = "TCP Offload engine";
+ $config['sysctl']['item'][18]['descr'] = gettext("TCP Offload engine");
$config['sysctl']['item'][18]['value'] = "default";
$config['sysctl']['item'][19]['tunable'] = "net.inet.ip.portrange.first";
@@ -739,10 +739,10 @@ function upgrade_042_to_043() {
$config['gateways']['gateway_item'][$i] = array();
if(is_ipaddr($config['interfaces'][$ifname]['gateway'])) {
$config['gateways']['gateway_item'][$i]['gateway'] = $config['interfaces'][$ifname]['gateway'];
- $config['gateways']['gateway_item'][$i]['descr'] = "Interface $ifname Static Gateway";
+ $config['gateways']['gateway_item'][$i]['descr'] = sprintf(gettext("Interface %s Static Gateway"), $ifname);
} else {
$config['gateways']['gateway_item'][$i]['gateway'] = "dynamic";
- $config['gateways']['gateway_item'][$i]['descr'] = "Interface $ifname Dynamic Gateway";
+ $config['gateways']['gateway_item'][$i]['descr'] = sprintf(gettext("Interface %s Dynamic Gateway"), $ifname);
}
$config['gateways']['gateway_item'][$i]['interface'] = $ifname;
$config['gateways']['gateway_item'][$i]['name'] = "GW_" . strtoupper($ifname);
@@ -807,7 +807,7 @@ function upgrade_043_to_044() {
$gwmap[$sroute['gateway']] = $gateway['name'];
$gateway['gateway'] = $sroute['gateway'];
$gateway['interface'] = $sroute['interface'];
- $gateway['descr'] = "Upgraded static route for {$sroute['network']}";
+ $gateway['descr'] = sprintf(gettext("Upgraded static route for %s"), $sroute['network']);
if (!is_array($config['gateways']['gateway_item']))
$config['gateways']['gateway_item'] = array();
$config['gateways']['gateway_item'][] = $gateway;
@@ -904,7 +904,7 @@ function upgrade_045_to_046() {
$pool['type'] = 'server';
$pool['behaviour'] = 'balance';
$pool['name'] = "{$vs_a[$i]['name']}-sitedown";
- $pool['descr'] = "Sitedown pool for VS: {$vs_a[$i]['name']}";
+ $pool['descr'] = sprintf(gettext("Sitedown pool for VS: %s"), $vs_a[$i]['name']);
$pool['port'] = $pools[$vs_a[$i]['pool']]['port'];
$pool['servers'] = array();
$pool['servers'][] = $vs_a[$i]['sitedown'];
@@ -1057,7 +1057,7 @@ function upgrade_046_to_047() {
if (isset($tunnel['disabled']))
$ph1ent['disabled'] = $tunnel['disabled'];
- $ph2ent['descr'] = "phase2 for ".$tunnel['descr'];
+ $ph2ent['descr'] = sprintf(gettext("phase2 for %s"), $tunnel['descr']);
$type = "lan";
if ($tunnel['local-subnet']['network'])
@@ -1284,7 +1284,7 @@ function upgrade_047_to_048() {
$tempdyn['host'] = $config['dyndns'][0]['host'];
$tempdyn['mx'] = $config['dyndns'][0]['mx'];
$tempdyn['interface'] = "wan";
- $tempdyn['descr'] = "Upgraded Dyndns {$tempdyn['type']}";
+ $tempdyn['descr'] = sprintf(gettext("Upgraded Dyndns %s"), $tempdyn['type']);
$config['dyndnses']['dyndns'][] = $tempdyn;
}
unset($config['dyndns']);
@@ -1336,7 +1336,7 @@ function upgrade_048_to_049() {
/* setup new all users group */
$all = array();
$all['name'] = "all";
- $all['description'] = "All Users";
+ $all['description'] = gettext("All Users");
$all['scope'] = "system";
$all['gid'] = 1998;
$all['member'] = array();
@@ -1468,7 +1468,7 @@ function upgrade_050_to_051() {
if (isset($intf['bridge']) && $intf['bridge'] <> "") {
$nbridge = array();
$nbridge['members'] = "{$ifr},{$intf['bridge']}";
- $nbridge['descr'] = "Converted bridged {$ifr}";
+ $nbridge['descr'] = sprintf(gettext("Converted bridged %s"), $ifr);
$nbridge['bridgeif'] = "bridge{$i}";
$config['bridges']['bridged'][] = $nbridge;
unset($intf['bridge']);
@@ -1794,7 +1794,7 @@ function upgrade_051_to_052() {
$ovpnrule['destination'] = array();
$ovpnrule['source']['any'] = true;
$ovpnrule['destination']['any'] = true;
- $ovpnrule['descr'] = "Auto added OpenVPN rule from config upgrade.";
+ $ovpnrule['descr'] = gettext("Auto added OpenVPN rule from config upgrade.");
$config['filter']['rule'][] = $ovpnrule;
}
@@ -1964,7 +1964,7 @@ function upgrade_054_to_055() {
$xmldumpnew = "{$database}.new.xml";
if ($g['booting'])
- echo "Migrate RRD database {$database} to new format \n";
+ echo "Migrate RRD database {$database} to new format for IPv6 \n";
mwexec("$rrdtool tune {$rrddbpath}{$database} -r roundtrip:delay 2>&1");
dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
@@ -2516,8 +2516,8 @@ function upgrade_075_to_076() {
function upgrade_076_to_077() {
global $config;
foreach($config['filter']['rule'] as & $rule) {
- if (isset($rule['protocol']) && !empty($rule['protocol']))
- $rule['protocol'] = strtolower($rule['protocol']);
+ if (isset($rule['protocol']) && !empty($rule['protocol']))
+ $rule['protocol'] = strtolower($rule['protocol']);
}
}
@@ -2538,7 +2538,6 @@ function upgrade_077_to_078() {
$config['pptpd']['radius'] = $radarr;
}
}
-
function upgrade_078_to_079() {
global $g;
/* Delete old and unused RRD file */
@@ -2556,4 +2555,95 @@ function upgrade_079_to_080() {
}
}
+function upgrade_080_to_081() {
+ global $config;
+ global $g;
+
+ /* RRD files changed for quality, traffic and packets graphs */
+ /* convert traffic RRD file */
+ global $parsedcfg, $listtags;
+ $listtags = array("ds", "v", "rra", "row");
+
+ $rrddbpath = "/var/db/rrd/";
+ $rrdtool = "/usr/bin/nice -n20 /usr/local/bin/rrdtool";
+
+ $rrdinterval = 60;
+ $valid = $rrdinterval * 2;
+
+ /* Asume GigE for now */
+ $downstream = 125000000;
+ $upstream = 125000000;
+
+ /* build a list of traffic and packets databases */
+ $databases = array();
+ exec("cd $rrddbpath;/usr/bin/find *-traffic.rrd *-packets.rrd", $databases);
+ rsort($databases);
+ foreach($databases as $database) {
+ $databasetmp = "{$database}.tmp";
+ $xmldump = "{$database}.old.xml";
+ $xmldumptmp = "{$database}.tmp.xml";
+ $xmldumpnew = "{$database}.new.xml";
+
+ if ($g['booting'])
+ echo "Migrate RRD database {$database} to new format for IPv6.\n";
+
+ /* dump contents to xml and move database out of the way */
+ dump_rrd_to_xml("{$rrddbpath}/{$database}", "{$g['tmp_path']}/{$xmldump}");
+
+ /* create new rrd database file */
+ $rrdcreate = "$rrdtool create {$g['tmp_path']}/{$databasetmp} --step $rrdinterval ";
+ $rrdcreate .= "DS:inpass:COUNTER:$valid:0:$downstream ";
+ $rrdcreate .= "DS:outpass:COUNTER:$valid:0:$upstream ";
+ $rrdcreate .= "DS:inblock:COUNTER:$valid:0:$downstream ";
+ $rrdcreate .= "DS:outblock:COUNTER:$valid:0:$upstream ";
+ $rrdcreate .= "DS:inpass6:COUNTER:$valid:0:$downstream ";
+ $rrdcreate .= "DS:outpass6:COUNTER:$valid:0:$upstream ";
+ $rrdcreate .= "DS:inblock6:COUNTER:$valid:0:$downstream ";
+ $rrdcreate .= "DS:outblock6:COUNTER:$valid:0:$upstream ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:1:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:5:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:60:1000 ";
+ $rrdcreate .= "RRA:AVERAGE:0.5:720:3000 ";
+
+ create_new_rrd("$rrdcreate");
+ /* create temporary xml from new RRD */
+ dump_rrd_to_xml("{$g['tmp_path']}/{$databasetmp}", "{$g['tmp_path']}/{$xmldumptmp}");
+
+ $rrdoldxml = file_get_contents("{$g['tmp_path']}/{$xmldump}");
+ $rrdold = xml2array($rrdoldxml, 1, "tag");
+ $rrdold = $rrdold['rrd'];
+
+ $rrdnewxml = file_get_contents("{$g['tmp_path']}/{$xmldumptmp}");
+ $rrdnew = xml2array($rrdnewxml, 1, "tag");
+ $rrdnew = $rrdnew['rrd'];
+
+ /* remove any MAX RRA's. Not needed for traffic. */
+ $i = 0;
+ foreach ($rrdold['rra'] as $rra) {
+ if(trim($rra['cf']) == "MAX") {
+ unset($rrdold['rra'][$i]);
+ }
+ $i++;
+ }
+
+ $rrdxmlarray = migrate_rrd_format($rrdold, $rrdnew);
+ $rrdxml = dump_xml_config_raw($rrdxmlarray, "rrd");
+ file_put_contents("{$g['tmp_path']}/{$xmldumpnew}", $rrdxml);
+ mwexec("$rrdtool restore -f {$g['tmp_path']}/{$xmldumpnew} {$rrddbpath}/{$database} 2>&1");
+
+ }
+ enable_rrd_graphing();
+ if ($g['booting'])
+ echo "Updating configuration...";
+ foreach($config['filter']['rule'] as & $rule) {
+ if (isset($rule['protocol']) && !empty($rule['protocol']))
+ $rule['protocol'] = strtolower($rule['protocol']);
+ }
+}
+
+function upgrade_081_to_082() {
+ global $config;
+ /* enable the allow IPv6 toggle */
+ $config['system']['ipv6allow'] = true;
+}
?>
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index bcb78458ba..5582ed1e2a 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -96,7 +96,7 @@ function mark_subsystem_dirty($subsystem = "") {
global $g;
if (!file_put_contents("{$g['varrun_path']}/{$subsystem}.dirty", "DIRTY"))
- log_error("WARNING: Could not mark subsystem: {$subsytem} dirty");
+ log_error(sprintf(gettext("WARNING: Could not mark subsystem: %s dirty"), $subsystem));
}
function clear_subsystem_dirty($subsystem = "") {
@@ -116,7 +116,7 @@ function config_unlock() {
function lock($lock, $op = LOCK_SH) {
global $g, $cfglckkeyconsumers;
if (!$lock)
- die("WARNING: You must give a name as parameter to lock() function.");
+ die(gettext("WARNING: You must give a name as parameter to lock() function."));
if (!file_exists("{$g['tmp_path']}/{$lock}.lock"))
@touch("{$g['tmp_path']}/{$lock}.lock");
$cfglckkeyconsumers++;
@@ -205,7 +205,7 @@ function refcount_unreference($reference) {
$shm_data = intval($shm_data) - 1;
if ($shm_data < 0) {
//debug_backtrace();
- log_error("Reference {$reference} is going negative, not doing unreference.");
+ log_error(sprintf(gettext("Reference %s is going negative, not doing unreference."), $reference));
} else
shmop_write($shmid, $shm_data, 0);
shmop_close($shmid);
@@ -225,10 +225,18 @@ function is_module_loaded($module_name) {
function gen_subnet($ipaddr, $bits) {
if (!is_ipaddr($ipaddr) || !is_numeric($bits))
return "";
-
return long2ip(ip2long($ipaddr) & gen_subnet_mask_long($bits));
}
+/* return the subnet address given a host address and a subnet bit count */
+function gen_subnetv6($ipaddr, $bits) {
+ if (!is_ipaddrv6($ipaddr) || !is_numeric($bits))
+ return "";
+
+ $address = Net_IPv6::getNetmask($ipaddr, $bits);
+ return $address;
+}
+
/* return the highest (broadcast) address in the subnet given a host address and a subnet bit count */
function gen_subnet_max($ipaddr, $bits) {
if (!is_ipaddr($ipaddr) || !is_numeric($bits))
@@ -237,6 +245,49 @@ function gen_subnet_max($ipaddr, $bits) {
return long2ip32(ip2long($ipaddr) | ~gen_subnet_mask_long($bits));
}
+/* Generate end number for a given ipv6 subnet mask
+ * no, it does not perform math */
+function gen_subnetv6_max($ipaddr, $bits) {
+ if(!is_ipaddrv6($ipaddr))
+ return false;
+
+ $subnetstart = gen_subnetv6($ipaddr, $bits);
+ /* we should have a expanded full ipv6 subnet starting at 0.
+ * Now split those by the semicolon so we can do 16 bit math */
+ $parts = explode(":", $subnetstart);
+ if(count($parts) <> 8)
+ return false;
+
+ /* reverse the array, we start with the lsb */
+ $parts = array_reverse($parts);
+ /* set the itteration count properly */
+ $bitsleft = 128 - $bits;
+ $i = 0;
+ foreach($parts as $part) {
+ /* foreach 16 bits we go to the next part */
+ /* no this isn't proper hex math, neither does it overflow properly */
+ while($bitsleft > 0) {
+ if($part == "0") {
+ $part = "f";
+ } else {
+ $part = $part . "f";
+ }
+ $bitsleft = $bitsleft - 4;
+ $j++;
+ if($j == 4) {
+ $parts[$i] = $part;
+ $j = 0;
+ $i++;
+ continue 2;
+ }
+ }
+ $i++;
+ }
+ $parts = array_reverse($parts);
+ $subnet_end = implode(":", $parts);
+ return $subnet_end;
+}
+
/* returns a subnet mask (long given a bit count) */
function gen_subnet_mask_long($bits) {
$sm = 0;
@@ -387,8 +438,26 @@ function is_numericint($arg) {
return (preg_match("/[^0-9]/", $arg) ? false : true);
}
-/* returns true if $ipaddr is a valid dotted IPv4 address */
+
+/* returns true if $ipaddr is a valid dotted IPv4 address or a IPv6 */
function is_ipaddr($ipaddr) {
+ if(is_ipaddrv4($ipaddr)) {
+ return true;
+ }
+ if(is_ipaddrv6($ipaddr)) {
+ return true;
+ }
+ return false;
+}
+
+/* returns true if $ipaddr is a valid IPv6 address */
+function is_ipaddrv6($ipaddr) {
+ $result = Net_IPv6::checkIPv6($ipaddr);
+ return $result;
+}
+
+/* returns true if $ipaddr is a valid dotted IPv4 address */
+function is_ipaddrv4($ipaddr) {
if (!is_string($ipaddr))
return false;
@@ -843,7 +912,7 @@ function mwexec($command, $mute = false) {
$mute = false;
if(($retval <> 0) && ($mute === false)) {
$output = implode(" ", $oarr);
- log_error("The command '$command' returned exit code '$retval', the output was '$output' ");
+ log_error(sprintf(gettext("The command '%1\$s' returned exit code '%2\$d', the output was '%3\$s' "), $command, $retval, $output));
}
return $retval;
}
@@ -968,6 +1037,13 @@ function ipcmp($a, $b) {
/* return true if $addr is in $subnet, false if not */
function ip_in_subnet($addr,$subnet) {
+ if(is_ipaddrv6($addr)) {
+ $result = Net_IPv6::IsInNetmask($addr, $subnet);
+ if($result)
+ return true;
+ else
+ return false;
+ }
list($ip, $mask) = explode('/', $subnet);
$mask = (0xffffffff << (32 - $mask)) & 0xffffffff;
return ((ip2long($addr) & $mask) == (ip2long($ip) & $mask));
@@ -1041,8 +1117,9 @@ function resolve_retry($hostname, $retries = 5) {
if (is_ipaddr($hostname))
return $hostname;
- for ($i = 0; $i < $retries; $i++) {
- $ip = gethostbyname($hostname);
+ for ($i = 0; $i < $retries; $i++) {
+ // FIXME: gethostbyname does not work for AAAA hostnames, boo, hiss
+ $ip = gethostbyname($hostname);
if ($ip && $ip != $hostname) {
/* success */
diff --git a/etc/inc/voucher.inc b/etc/inc/voucher.inc
index 374ec704a2..dc95092245 100644
--- a/etc/inc/voucher.inc
+++ b/etc/inc/voucher.inc
@@ -358,7 +358,7 @@ function voucher_auth($voucher_received, $test = 0) {
list($timestamp,$minutes) = explode(",", $active_vouchers[$roll][$voucher]);
// we have an already active voucher here.
$remaining = intval((($timestamp + (60*$minutes)) - time())/60);
- $test_result[] = "$voucher ($roll/$nr) active and good for $remaining Minutes";
+ $test_result[] = sprintf(gettext('%1$s (%2$s/%3$s) active and good for %4$d Minutes'), $voucher, $roll, $nr, $remaining);
$total_minutes += $remaining;
} else {
// voucher not used. Check if ticket Id is on the roll (not too high)
@@ -395,9 +395,9 @@ function voucher_auth($voucher_received, $test = 0) {
// if this was a test call, we're done. Return the result.
if ($test) {
if ($error) {
- $test_result[] = "Access denied!";
+ $test_result[] = gettext("Access denied!");
} else {
- $test_result[] = "Access granted for $total_minutes Minutes in total.";
+ $test_result[] = sprintf(gettext("Access granted for %d Minutes in total."),$total_minutes);
}
unlock($voucherlck);
@@ -482,7 +482,7 @@ function voucher_configure($sync = false) {
/* write config file used by voucher binary to decode vouchers */
$fd = fopen("{$g['varetc_path']}/voucher.cfg", "w");
if (!$fd) {
- printf("Error: cannot write voucher.cfg\n");
+ printf(gettext("Error: cannot write voucher.cfg") . "\n");
unlock($voucherlck);
return 1;
}
@@ -535,7 +535,7 @@ function voucher_write_used_db($roll, $vdb) {
fwrite($fd, $vdb . "\n");
fclose($fd);
} else
- voucher_log(LOG_ERR, "cant write {$g['vardb_path']}/voucher_used_$roll.db");
+ voucher_log(LOG_ERR, sprintf(gettext('cant write %1$s/voucher_used_%2$s.db'), $g['vardb_path'], $roll));
}
/* return assoc array of active vouchers with activation timestamp
@@ -614,7 +614,7 @@ function voucher_read_used_db($roll) {
$vdb = trim(fgets($fd));
fclose($fd);
} else {
- voucher_log(LOG_ERR, "cant read {$g['vardb_path']}/voucher_used_$roll.db");
+ voucher_log(LOG_ERR, sprintf(gettext('cant read %1$s/voucher_used_%2$s.db'), $g['vardb_path'], $roll));
}
}
return base64_decode($vdb);
@@ -632,7 +632,7 @@ function voucher_log($priority, $message) {
define_syslog_variables();
$message = trim($message);
openlog("logportalauth", LOG_PID, LOG_LOCAL4);
- syslog($priority, "Voucher: " . $message);
+ syslog($priority, gettext("Voucher: ") . $message);
closelog();
}
diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc
index 7c08ccb225..1e6780f3ba 100644
--- a/etc/inc/vpn.inc
+++ b/etc/inc/vpn.inc
@@ -121,7 +121,7 @@ function vpn_ipsec_configure($ipchg = false)
mwexec("/sbin/sysctl net.inet.ip.ipsec_in_use=1");
if ($g['booting'])
- echo "Configuring IPsec VPN... ";
+ echo gettext("Configuring IPsec VPN... ");
/* fastforwarding is not compatible with ipsec tunnels */
mwexec("/sbin/sysctl net.inet.ip.fastforwarding=0");
@@ -138,12 +138,13 @@ function vpn_ipsec_configure($ipchg = false)
$ipsecpinghosts = "";
/* step through each phase1 entry */
+ $ipsecpinghosts = "";
foreach ($a_phase1 as $ph1ent) {
if (isset($ph1ent['disabled']))
continue;
$ep = ipsec_get_phase1_src($ph1ent);
- if (!$ep)
+ if (!is_ipaddr($ep))
continue;
if(!in_array($ep,$ipmap))
@@ -182,27 +183,43 @@ function vpn_ipsec_configure($ipchg = false)
if ($ikeid != $ph1ent['ikeid'])
continue;
+ $ph2ent['localid']['mode'] = $ph2ent['mode'];
/* add an ipsec pinghosts entry */
if ($ph2ent['pinghost']) {
$iflist = get_configured_interface_list();
foreach ($iflist as $ifent => $ifname) {
- $interface_ip = get_interface_ip($ifent);
- $local_subnet = ipsec_idinfo_to_cidr($ph2ent['localid'], true);
- if (ip_in_subnet($interface_ip, $local_subnet)) {
- $srcip = $interface_ip;
- break;
+ if(is_ipaddrv6($ph2ent['pinghost'])) {
+ $interface_ip = get_interface_ipv6($ifent);
+ if(!is_ipaddrv6($interface_ip))
+ continue;
+ $local_subnet = ipsec_idinfo_to_cidr($ph2ent['localid'], true);
+ if (ip_in_subnet($interface_ip, $local_subnet)) {
+ $srcip = $interface_ip;
+ break;
+ }
+ } else {
+ $interface_ip = get_interface_ip($ifent);
+ if(!is_ipaddrv4($interface_ip))
+ continue;
+ $local_subnet = ipsec_idinfo_to_cidr($ph2ent['localid'], true);
+ if (ip_in_subnet($interface_ip, $local_subnet)) {
+ $srcip = $interface_ip;
+ break;
+ }
}
}
$dstip = $ph2ent['pinghost'];
+ if(is_ipaddrv6($dstip)) {
+ $family = "inet6";
+ } else {
+ $family = "inet";
+ }
if (is_ipaddr($srcip))
- $ipsecpinghosts .= "{$srcip}|{$dstip}|3\n";
+ $ipsecpinghosts[] = "{$srcip}|{$dstip}|3|||||{$family}|\n";
+
}
}
- $pfd = fopen("{$g['vardb_path']}/ipsecpinghosts", "w");
- if ($pfd) {
- fwrite($pfd, $ipsecpinghosts);
- fclose($pfd);
- }
+ file_put_contents("{$g['vardb_path']}/ipsecpinghosts", $ipsecpinghosts);
}
}
@@ -211,18 +228,18 @@ function vpn_ipsec_configure($ipchg = false)
if (is_array($config['ca']) && count($config['ca'])) {
foreach ($config['ca'] as $ca) {
if (!isset($ca['crt'])) {
- log_error("Error: Invalid certificate info for {$ca['descr']}");
+ log_error(sprintf(gettext("Error: Invalid certificate info for %s"), $ca['descr']));
continue;
}
$cert = base64_decode($ca['crt']);
$x509cert = openssl_x509_parse(openssl_x509_read($cert));
if (!is_array($x509cert) || !isset($x509cert['hash'])) {
- log_error("Error: Invalid certificate hash info for {$ca['descr']}");
+ log_error(sprintf(gettext("Error: Invalid certificate hash info for %s"), $ca['descr']));
continue;
}
$fname = $g['varetc_path']."/".$x509cert['hash'].".0";
if (!file_put_contents($fname, $cert)) {
- log_error("Error: Cannot write IPsec CA file for {$ca['descr']}");
+ log_error(sprintf(gettext("Error: Cannot write IPsec CA file for %s"), $ca['descr']));
continue;
}
}
@@ -231,7 +248,7 @@ function vpn_ipsec_configure($ipchg = false)
/* generate psk.txt */
$fd = fopen("{$g['varetc_path']}/psk.txt", "w");
if (!$fd) {
- printf("Error: cannot open psk.txt in vpn_ipsec_configure().\n");
+ printf(gettext("Error: cannot open psk.txt in vpn_ipsec_configure().") . "\n");
return 1;
}
@@ -294,7 +311,7 @@ function vpn_ipsec_configure($ipchg = false)
$fd = fopen("{$g['varetc_path']}/racoon.conf", "w");
if (!$fd) {
- printf("Error: cannot open racoon.conf in vpn_ipsec_configure().\n");
+ printf(gettext("Error: cannot open racoon.conf in vpn_ipsec_configure().") . "\n");
return 1;
}
@@ -386,7 +403,7 @@ function vpn_ipsec_configure($ipchg = false)
$fn = "{$g['varetc_path']}/racoon.motd";
$fd1 = fopen($fn, "w");
if (!$fd1) {
- printf("Error: cannot open server{$fn} in vpn.\n");
+ printf(gettext("Error: cannot open server %s in vpn.%s"). $fn, "\n");
return 1;
}
@@ -437,7 +454,7 @@ function vpn_ipsec_configure($ipchg = false)
case "dyn_dns":
$myid_type = "address";
- $myid_data = gethostbyname($ph1ent['myid_data']);
+ $myid_data = resolve_retry($ph1ent['myid_data']);
break;
case "address";
@@ -517,7 +534,7 @@ function vpn_ipsec_configure($ipchg = false)
if (!$cert)
{
- log_error("Error: Invalid phase1 certificate reference for {$ph1ent['name']}");
+ log_error(sprintf(gettext("Error: Invalid phase1 certificate reference for %s"), $ph1ent['name']));
continue;
}
@@ -526,7 +543,7 @@ function vpn_ipsec_configure($ipchg = false)
if (!file_put_contents($certpath, base64_decode($cert['crt'])))
{
- log_error("Error: Cannot write phase1 certificate file for {$ph1ent['name']}");
+ log_error(sprintf(gettext("Error: Cannot write phase1 certificate file for %s"), $ph1ent['name']));
continue;
}
@@ -537,7 +554,7 @@ function vpn_ipsec_configure($ipchg = false)
if (!file_put_contents($keypath, base64_decode($cert['prv'])))
{
- log_error("Error: Cannot write phase1 key file for {$ph1ent['name']}");
+ log_error(sprintf(gettext("Error: Cannot write phase1 key file for %s"), $ph1ent['name']));
continue;
}
@@ -550,7 +567,7 @@ function vpn_ipsec_configure($ipchg = false)
if (!file_put_contents($capath, base64_decode($ca['crt'])))
{
- log_error("Error: Cannot write phase1 CA certificate file for {$ph1ent['name']}");
+ log_error(sprintf(gettext("Error: Cannot write phase1 CA certificate file for %s"), $ph1ent['name']));
continue;
}
@@ -637,9 +654,10 @@ EOD;
if (isset($ph2ent['mobile']) && !isset($a_client['enable']))
continue;
- if ($ph2ent['mode'] == 'tunnel') {
+ if (($ph2ent['mode'] == 'tunnel') or ($ph2ent['mode'] == 'tunnel6')) {
$localid_type = $ph2ent['localid']['type'];
+ $ph2ent['localid']['mode'] = $ph2ent['mode'];
$localid_data = ipsec_idinfo_to_cidr($ph2ent['localid']);
/* Do not print localid in some cases, such as a pure-psk or psk/xauth single phase2 mobile tunnel */
if (($localid_type == "none") ||
@@ -782,7 +800,7 @@ EOD;
/* generate spd.conf */
$fd = fopen("{$g['varetc_path']}/spd.conf", "w");
if (!$fd) {
- printf("Error: cannot open spd.conf in vpn_ipsec_configure().\n");
+ printf(gettext("Error: cannot open spd.conf in vpn_ipsec_configure().") . "\n");
return 1;
}
@@ -791,11 +809,18 @@ EOD;
/* Try to prevent people from locking themselves out of webgui. Just in case. */
if ($config['interfaces']['lan']) {
$lanip = get_interface_ip("lan");
- if (!empty($lanip) && is_ipaddr($lanip)) {
+ if (!empty($lanip) && is_ipaddrv4($lanip)) {
$lansn = get_interface_subnet("lan");
$lansa = gen_subnet($lanip, $lansn);
- $spdconf .= "spdadd {$lanip}/32 {$lansa}/{$lansn} any -P out none;\n";
- $spdconf .= "spdadd {$lansa}/{$lansn} {$lanip}/32 any -P in none;\n";
+ $spdconf .= "spdadd -4 {$lanip}/32 {$lansa}/{$lansn} any -P out none;\n";
+ $spdconf .= "spdadd -4 {$lansa}/{$lansn} {$lanip}/32 any -P in none;\n";
+ }
+ $lanipv6 = get_interface_ipv6("lan");
+ if (!empty($lanipv6) && is_ipaddrv6($lanipv6)) {
+ $lansnv6 = get_interface_subnetv6("lan");
+ $lansav6 = gen_subnetv6($lanipv6, $lansnv6);
+ $spdconf .= "spdadd -6 {$lanipv6}/128 {$lansav6}/{$lansnv6} any -P out none;\n";
+ $spdconf .= "spdadd -6 {$lansav6}/{$lansnv6} {$lanipv6}/128 any -P in none;\n";
}
}
@@ -821,15 +846,20 @@ EOD;
if(!is_ipaddr($rgip))
continue;
+ $ph2ent['localid']['mode'] = $ph2ent['mode'];
$localid = ipsec_idinfo_to_cidr($ph2ent['localid'],true);
$remoteid = ipsec_idinfo_to_cidr($ph2ent['remoteid'],true);
- if($ph2ent['mode'] == "tunnel") {
+ if(($ph2ent['mode'] == "tunnel") or ($ph2ent['mode'] == 'tunnel6')) {
+ if($ph2ent['mode'] == "tunnel6")
+ $family = "-6";
+ else
+ $family = "-4";
- $spdconf .= "spdadd {$localid} {$remoteid} any -P out ipsec " .
+ $spdconf .= "spdadd {$family} {$localid} {$remoteid} any -P out ipsec " .
"{$ph2ent['protocol']}/tunnel/{$ep}-{$rgip}/unique;\n";
- $spdconf .= "spdadd {$remoteid} {$localid} any -P in ipsec " .
+ $spdconf .= "spdadd {$family} {$remoteid} {$localid} any -P in ipsec " .
"{$ph2ent['protocol']}/tunnel/{$rgip}-{$ep}/unique;\n";
} else {
@@ -955,7 +985,7 @@ function vpn_ipsec_force_reload() {
/* if ipsec is enabled, start up again */
if (isset($ipseccfg['enable'])) {
- log_error("Forcefully reloading IPsec racoon daemon");
+ log_error(gettext("Forcefully reloading IPsec racoon daemon"));
vpn_ipsec_configure();
}
@@ -994,7 +1024,7 @@ function vpn_pptpd_configure() {
if (!$pptpdcfg['mode'] || ($pptpdcfg['mode'] == "off"))
return 0;
- echo "Configuring PPTP VPN service... ";
+ echo gettext("Configuring PPTP VPN service... ");
} else {
/* kill mpd */
killbypid("{$g['varrun_path']}/pptp-vpn.pid");
@@ -1004,7 +1034,7 @@ function vpn_pptpd_configure() {
if (is_process_running("mpd -b")) {
killbypid("{$g['varrun_path']}/pptp-vpn.pid");
- log_error("Could not kill mpd within 3 seconds. Trying again.");
+ log_error(gettext("Could not kill mpd within 3 seconds. Trying again."));
}
/* remove mpd.conf, if it exists */
@@ -1022,7 +1052,7 @@ function vpn_pptpd_configure() {
/* write mpd.conf */
$fd = fopen("{$g['varetc_path']}/pptp-vpn/mpd.conf", "w");
if (!$fd) {
- printf("Error: cannot open mpd.conf in vpn_pptpd_configure().\n");
+ printf(gettext("Error: cannot open mpd.conf in vpn_pptpd_configure().") . "\n");
return 1;
}
@@ -1135,7 +1165,7 @@ EOD;
/* write mpd.links */
$fd = fopen("{$g['varetc_path']}/pptp-vpn/mpd.links", "w");
if (!$fd) {
- printf("Error: cannot open mpd.links in vpn_pptpd_configure().\n");
+ printf(gettext("Error: cannot open mpd.links in vpn_pptpd_configure().") . "\n");
return 1;
}
@@ -1159,7 +1189,7 @@ EOD;
/* write mpd.secret */
$fd = fopen("{$g['varetc_path']}/pptp-vpn/mpd.secret", "w");
if (!$fd) {
- printf("Error: cannot open mpd.secret in vpn_pptpd_configure().\n");
+ printf(gettext("Error: cannot open mpd.secret in vpn_pptpd_configure().") . "\n");
return 1;
}
@@ -1213,7 +1243,7 @@ function vpn_pppoe_configure(&$pppoecfg) {
if (!$pppoecfg['mode'] || ($pppoecfg['mode'] == "off"))
return 0;
- echo "Configuring PPPoE VPN service... ";
+ echo gettext("Configuring PPPoE VPN service... ");
} else {
/* kill mpd */
killbypid("{$g['varrun_path']}/pppoe{$pppoecfg['pppoeid']}-vpn.pid");
@@ -1237,7 +1267,7 @@ function vpn_pppoe_configure(&$pppoecfg) {
/* write mpd.conf */
$fd = fopen("{$g['varetc_path']}/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.conf", "w");
if (!$fd) {
- printf("Error: cannot open mpd.conf in vpn_pppoe_configure().\n");
+ printf(gettext("Error: cannot open mpd.conf in vpn_pppoe_configure().") . "\n");
return 1;
}
$mpdconf = "\n\n";
@@ -1340,7 +1370,7 @@ EOD;
/* write mpd.links */
$fd = fopen("{$g['varetc_path']}/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.links", "w");
if (!$fd) {
- printf("Error: cannot open mpd.links in vpn_pppoe_configure().\n");
+ printf(gettext("Error: cannot open mpd.links in vpn_pppoe_configure().") . "\n");
return 1;
}
@@ -1366,7 +1396,7 @@ EOD;
/* write mpd.secret */
$fd = fopen("{$g['varetc_path']}/pppoe{$pppoecfg['pppoeid']}-vpn/mpd.secret", "w");
if (!$fd) {
- printf("Error: cannot open mpd.secret in vpn_pppoe_configure().\n");
+ printf(gettext("Error: cannot open mpd.secret in vpn_pppoe_configure().") . "\n");
return 1;
}
@@ -1394,7 +1424,7 @@ EOD;
}
if ($g['booting'])
- echo "done\n";
+ echo gettext("done") . "\n";
return 0;
}
@@ -1413,7 +1443,7 @@ function vpn_l2tp_configure() {
if (!$l2tpcfg['mode'] || ($l2tpcfg['mode'] == "off"))
return 0;
- echo "Configuring l2tp VPN service... ";
+ echo gettext("Configuring l2tp VPN service... ");
} else {
/* kill mpd */
killbypid("{$g['varrun_path']}/l2tp-vpn.pid");
@@ -1438,7 +1468,7 @@ function vpn_l2tp_configure() {
/* write mpd.conf */
$fd = fopen("{$g['varetc_path']}/l2tp-vpn/mpd.conf", "w");
if (!$fd) {
- printf("Error: cannot open mpd.conf in vpn_l2tp_configure().\n");
+ printf(gettext("Error: cannot open mpd.conf in vpn_l2tp_configure().") . "\n");
return 1;
}
$mpdconf = "\n\n";
@@ -1531,7 +1561,7 @@ EOD;
/* write mpd.links */
$fd = fopen("{$g['varetc_path']}/l2tp-vpn/mpd.links", "w");
if (!$fd) {
- printf("Error: cannot open mpd.links in vpn_l2tp_configure().\n");
+ printf(gettext("Error: cannot open mpd.links in vpn_l2tp_configure().") . "\n");
return 1;
}
@@ -1556,7 +1586,7 @@ EOD;
/* write mpd.secret */
$fd = fopen("{$g['varetc_path']}/l2tp-vpn/mpd.secret", "w");
if (!$fd) {
- printf("Error: cannot open mpd.secret in vpn_l2tp_configure().\n");
+ printf(gettext("Error: cannot open mpd.secret in vpn_l2tp_configure().") . "\n");
return 1;
}
@@ -1673,6 +1703,7 @@ function reload_tunnel_spd_policy($phase1, $phase2, $old_phase1, $old_phase2) {
$sad_arr = ipsec_dump_sad();
$ep = ipsec_get_phase1_src($phase1);
+ $phase2['localid']['mode'] = $phase2['mode'];
$local_subnet = ipsec_idinfo_to_cidr($phase2['localid']);
$remote_subnet = ipsec_idinfo_to_cidr($phase2['remoteid']);
@@ -1680,6 +1711,7 @@ function reload_tunnel_spd_policy($phase1, $phase2, $old_phase1, $old_phase2) {
$old_gw = trim($old_phase1['remote-gateway']);
$old_ep = ipsec_get_phase1_src($old_phase1);
+ $old_phase2['localid']['mode'] = $old_phase2['mode'];
$old_local_subnet = ipsec_idinfo_to_cidr($old_phase2['localid']);
$old_remote_subnet = ipsec_idinfo_to_cidr($old_phase2['remoteid']);
@@ -1701,25 +1733,30 @@ function reload_tunnel_spd_policy($phase1, $phase2, $old_phase1, $old_phase2) {
$rgip = $phase1['remote-gateway'];
}
if (!$ep) {
- log_error("Could not determine VPN endpoint for '{$phase1['descr']}'");
+ log_error(sprintf(gettext("Could not determine VPN endpoint for '%s'"), $phase1['descr']));
return false;
}
if((!is_ipaddr($old_ep)) || (! is_ipaddr($ep))) {
- log_error("IPSEC: ERROR: One of the endpoints is not a IP address. Old EP '{$old_ep}' new EP '{$ep}'");
+ log_error(sprintf(gettext("IPSEC: ERROR: One of the endpoints is not a IP address. Old EP '%1\$s' new EP '%2\$s'"), $old_ep, $ep));
}
if((! is_ipaddr($rgip)) || (! is_ipaddr($old_gw))) {
- log_error("IPSEC: ERROR: One of the remote endpoints is not a IP address. Old RG '{$old_gw}' new RG '{$rgip}'");
+ log_error(sprintf(gettext("IPSEC: ERROR: One of the remote endpoints is not a IP address. Old RG '%1\$s' new RG '%2\$s'"), $old_gw, $rgip));
}
$spdconf = "";
/* Delete old SPD policies if there are changes between the old and new */
if(($phase1 != $old_phase1) || ($phase2 != $old_phase2)) {
- $spdconf .= "spddelete {$old_local_subnet} " .
+ if($old_phase2['mode'] == "tunnel6")
+ $family = "-6";
+ else
+ $family = "-4";
+
+ $spdconf .= "spddelete {$family} {$old_local_subnet} " .
"{$old_remote_subnet} any -P out ipsec " .
"{$old_phase2['protocol']}/tunnel/{$old_ep}-" .
"{$old_gw}/unique;\n";
- $spdconf .= "spddelete {$old_remote_subnet} " .
+ $spdconf .= "spddelete {$family} {$old_remote_subnet} " .
"{$old_local_subnet} any -P in ipsec " .
"{$old_phase2['protocol']}/tunnel/{$old_gw}-" .
"{$old_ep}/unique;\n";
@@ -1727,35 +1764,40 @@ function reload_tunnel_spd_policy($phase1, $phase2, $old_phase1, $old_phase2) {
/* zap any existing SA entries */
foreach($sad_arr as $sad) {
if(($sad['dst'] == $old_ep) && ($sad['src'] == $old_gw)) {
- $spdconf .= "delete {$old_ep} {$old_gw} {$old_phase2['protocol']} 0x{$sad['spi']};\n";
+ $spdconf .= "delete {$family} {$old_ep} {$old_gw} {$old_phase2['protocol']} 0x{$sad['spi']};\n";
}
if(($sad['src'] == $oldep) && ($sad['dst'] == $old_gw)) {
- $spdconf .= "delete {$old_gw} {$old_ep} {$old_phase2['protocol']} 0x{$sad['spi']};\n";
+ $spdconf .= "delete {$family} {$old_gw} {$old_ep} {$old_phase2['protocol']} 0x{$sad['spi']};\n";
}
}
}
+ if($phase2['mode'] == "tunnel6")
+ $family = "-6";
+ else
+ $family = "-4";
+
/* Create new SPD entries for the new configuration */
/* zap any existing SA entries beforehand */
foreach($sad_arr as $sad) {
if(($sad['dst'] == $ep) && ($sad['src'] == $rgip)) {
- $spdconf .= "delete {$rgip} {$ep} {$phase2['protocol']} 0x{$sad['spi']};\n";
+ $spdconf .= "delete {$family} {$rgip} {$ep} {$phase2['protocol']} 0x{$sad['spi']};\n";
}
if(($sad['src'] == $ep) && ($sad['dst'] == $rgip)) {
- $spdconf .= "delete {$ep} {$rgip} {$phase2['protocol']} 0x{$sad['spi']};\n";
+ $spdconf .= "delete {$family} {$ep} {$rgip} {$phase2['protocol']} 0x{$sad['spi']};\n";
}
}
/* add new SPD policies to replace them */
- $spdconf .= "spdadd {$local_subnet} " .
+ $spdconf .= "spdadd {$family} {$local_subnet} " .
"{$remote_subnet} any -P out ipsec " .
"{$phase2['protocol']}/tunnel/{$ep}-" .
"{$rgip}/unique;\n";
- $spdconf .= "spdadd {$remote_subnet} " .
+ $spdconf .= "spdadd {$family} {$remote_subnet} " .
"{$local_subnet} any -P in ipsec " .
"{$phase2['protocol']}/tunnel/{$rgip}-" .
"{$ep}/unique;\n";
- log_error("Reloading IPsec tunnel '{$phase1['descr']}'. Previous IP '{$old_gw}', current IP '{$rgip}'. Reloading policy");
+ log_error(sprintf(gettext("Reloading IPsec tunnel '%1\$s'. Previous IP '%2\$s', current IP '%3\$s'. Reloading policy"), $phase1['descr'], $old_gw, $rgip));
$now = time();
$spdfile = tempnam("{$g['tmp_path']}", "spd.conf.reload.{$now}.");
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index 5fa51c384b..49ebb0ea10 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -82,7 +82,7 @@ function startElement($parser, $name, $attrs) {
} else if (isset($ptr)) {
/* multiple entries not allowed for this element, bail out */
- die(sprintf("XML error: %s at line %d cannot occur more than once\n",
+ die(sprintf(gettext('XML error: %1$s at line %2$d cannot occur more than once') . "\n",
$name,
xml_get_current_line_number($parser)));
}
@@ -173,13 +173,13 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1);
if (!($fp = fopen($cffile, "r"))) {
- log_error("Error: could not open XML input\n");
+ log_error(gettext("Error: could not open XML input") . "\n");
return -1;
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
- log_error(sprintf("XML error: %s at line %d in %s\n",
+ log_error(sprintf(gettext('XML error: %1$s at line %2$d in %3$s') . "\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser),
$cffile));
@@ -195,7 +195,7 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
break;
if (!$parsedcfg[$rootobj_name]) {
- log_error("XML error: no $rootobj_name object found!\n");
+ log_error(sprintf(gettext("XML error: no %s object found!") . "\n", $rootobj));
return -1;
}
diff --git a/etc/inc/xmlparse_attr.inc b/etc/inc/xmlparse_attr.inc
index 802d335346..933caba696 100644
--- a/etc/inc/xmlparse_attr.inc
+++ b/etc/inc/xmlparse_attr.inc
@@ -75,7 +75,7 @@ function startElement_attr($parser, $name, $attrs) {
} else if (isset($ptr)) {
/* multiple entries not allowed for this element, bail out */
- die(sprintf("XML error: %s at line %d cannot occur more than once\n",
+ die(sprintf(gettext('XML error: %1$s at line %2$d cannot occur more than once') . "\n",
$name,
xml_get_current_line_number($parser)));
} else if (isset($writeattrs)) {
@@ -184,7 +184,7 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst
xml_parser_set_option($xml_parser,XML_OPTION_SKIP_WHITE, 1);
if (!($fp = fopen($cffile, "r"))) {
- log_error("Error: could not open XML input\n");
+ log_error(gettext("Error: could not open XML input") . "\n");
if (isset($parsed_attributes)) {
$parsed_attributes = array();
unset($parsedattrs);
@@ -194,7 +194,7 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
- log_error(sprintf("XML error: %s at line %d\n",
+ log_error(sprintf(gettext('XML error: %1$s at line %2$d') . "\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
if (isset($parsed_attributes)) {
@@ -207,7 +207,7 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst
xml_parser_free($xml_parser);
if (!$parsedcfg[$rootobj]) {
- log_error("XML error: no $rootobj object found!\n");
+ log_error(sprintf(gettext("XML error: no %s object found!") . "\n", $rootobj));
if (isset($parsed_attributes)) {
$parsed_attributes = array();
unset($parsedattrs);
@@ -224,4 +224,4 @@ function parse_xml_config_raw_attr($cffile, $rootobj, &$parsed_attributes, $isst
return $parsedcfg[$rootobj];
}
-?>
\ No newline at end of file
+?>
diff --git a/etc/inc/xmlreader.inc b/etc/inc/xmlreader.inc
index ce0289bb55..1caa6eac59 100644
--- a/etc/inc/xmlreader.inc
+++ b/etc/inc/xmlreader.inc
@@ -126,7 +126,7 @@ function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
add_elements($parsedcfg, $par);
$par->close();
} else
- log_error("Error returned while trying to parse {$cffile}");
+ log_error(sprintf(gettext("Error returned while trying to parse %s"), $cffile));
if (!is_array($rootobj))
$rootobj = array($rootobj);
diff --git a/etc/inc/xmlrpc_client.inc b/etc/inc/xmlrpc_client.inc
index 8b8a9a21bd..a192815b80 100644
--- a/etc/inc/xmlrpc_client.inc
+++ b/etc/inc/xmlrpc_client.inc
@@ -10,35 +10,18 @@
*
* PHP versions 4 and 5
*
- * LICENSE: License is granted to use or modify this software
- * ("XML-RPC for PHP") for commercial or non-commercial use provided the
- * copyright of the author is preserved in any distributed or derivative work.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESSED OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
* @category Web Services
* @package XML_RPC
* @author Edd Dumbill
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version CVS: $Id$
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version SVN: $Id: RPC.php 300961 2010-07-03 02:17:34Z danielc $
* @link http://pear.php.net/package/XML_RPC
*/
-/*
- pfSense_MODULE: utils
-*/
if (!function_exists('xml_parser_create')) {
include_once 'PEAR.inc';
@@ -166,13 +149,13 @@ $GLOBALS['XML_RPC_err'] = array(
* @global array $GLOBALS['XML_RPC_str']
*/
$GLOBALS['XML_RPC_str'] = array(
- 'unknown_method' => 'Unknown method',
- 'invalid_return' => 'Invalid return payload: enable debugging to examine incoming payload',
- 'incorrect_params' => 'Incorrect parameters passed to method',
- 'introspect_unknown' => 'Can\'t introspect: method unknown',
- 'http_error' => 'Didn\'t receive 200 OK from remote server.',
- 'not_response_object' => 'The requested method didn\'t return an XML_RPC_Response object.',
- 'invalid_request' => 'Invalid request payload',
+ 'unknown_method' => gettext("Unknown method"),
+ 'invalid_return' => gettext("Invalid return payload: enable debugging to examine incoming payload"),
+ 'incorrect_params' => gettext("Incorrect parameters passed to method"),
+ 'introspect_unknown' => gettext("Can't introspect: method unknown"),
+ 'http_error' => gettext("Didn't receive 200 OK from remote server."),
+ 'not_response_object' => gettext("The requested method didn't return an XML_RPC_Response object."),
+ 'invalid_request' => gettext("Invalid request payload"),
);
@@ -202,27 +185,6 @@ $GLOBALS['XML_RPC_errxml'] = 100;
$GLOBALS['XML_RPC_backslash'] = chr(92) . chr(92);
-/**#@+
- * Which functions to use, depending on whether mbstring is enabled or not.
- */
-if (function_exists('mb_ereg')) {
- /** @global string $GLOBALS['XML_RPC_func_ereg'] */
- $GLOBALS['XML_RPC_func_ereg'] = 'mb_eregi';
- /** @global string $GLOBALS['XML_RPC_func_ereg_replace'] */
- $GLOBALS['XML_RPC_func_ereg_replace'] = 'mb_eregi_replace';
- /** @global string $GLOBALS['XML_RPC_func_split'] */
- $GLOBALS['XML_RPC_func_split'] = 'mb_split';
-} else {
- /** @ignore */
- $GLOBALS['XML_RPC_func_ereg'] = 'eregi';
- /** @ignore */
- $GLOBALS['XML_RPC_func_ereg_replace'] = 'eregi_replace';
- /** @ignore */
- $GLOBALS['XML_RPC_func_split'] = 'split';
-}
-/**#@-*/
-
-
/**
* Should we automatically base64 encode strings that contain characters
* which can cause PHP's SAX-based XML parser to break?
@@ -295,15 +257,15 @@ function XML_RPC_se($parser_resource, $name, $attrs)
if (count($XML_RPC_xh[$parser]['stack']) == 0) {
if ($name != 'METHODRESPONSE' && $name != 'METHODCALL') {
$XML_RPC_xh[$parser]['isf'] = 2;
- $XML_RPC_xh[$parser]['isf_reason'] = 'missing top level xmlrpc element';
+ $XML_RPC_xh[$parser]['isf_reason'] = gettext('missing top level xmlrpc element');
return;
}
} else {
// not top level element: see if parent is OK
if (!in_array($XML_RPC_xh[$parser]['stack'][0], $XML_RPC_valid_parents[$name])) {
- $name = $GLOBALS['XML_RPC_func_ereg_replace']('[^a-zA-Z0-9._-]', '', $name);
+ $name = preg_replace('@[^a-zA-Z0-9._-]@', '', $name);
$XML_RPC_xh[$parser]['isf'] = 2;
- $XML_RPC_xh[$parser]['isf_reason'] = "xmlrpc element $name cannot be child of {$XML_RPC_xh[$parser]['stack'][0]}";
+ $XML_RPC_xh[$parser]['isf_reason'] = sprintf(gettext('xmlrpc element %1$s cannot be child of %2$s'), $name, $XML_RPC_xh[$parser]['stack'][0]);
return;
}
}
@@ -465,8 +427,8 @@ function XML_RPC_ee($parser_resource, $name)
} else {
// we have an I4, INT or a DOUBLE
// we must check that only 0123456789-. are characters here
- if (!$GLOBALS['XML_RPC_func_ereg']("^[+-]?[0123456789 \t\.]+$", $XML_RPC_xh[$parser]['ac'])) {
- XML_RPC_Base::raiseError('Non-numeric value received in INT or DOUBLE',
+ if (!preg_match("@^[+-]?[0123456789 \t\.]+$@", $XML_RPC_xh[$parser]['ac'])) {
+ XML_RPC_Base::raiseError(gettext('Non-numeric value received in INT or DOUBLE'),
XML_RPC_ERROR_NON_NUMERIC_FOUND);
$XML_RPC_xh[$parser]['value'] = XML_RPC_ERROR_NON_NUMERIC_FOUND;
} else {
@@ -529,7 +491,7 @@ function XML_RPC_ee($parser_resource, $name)
case 'METHODNAME':
case 'RPCMETHODNAME':
- $XML_RPC_xh[$parser]['method'] = $GLOBALS['XML_RPC_func_ereg_replace']("^[\n\r\t ]+", '',
+ $XML_RPC_xh[$parser]['method'] = preg_replace("@^[\n\r\t ]+@", '',
$XML_RPC_xh[$parser]['ac']);
break;
}
@@ -581,8 +543,9 @@ function XML_RPC_cd($parser_resource, $data)
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version Release: 1.5.1
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version Release: @package_version@
* @link http://pear.php.net/package/XML_RPC
*/
class XML_RPC_Base {
@@ -626,8 +589,9 @@ class XML_RPC_Base {
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version Release: 1.5.1
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version Release: @package_version@
* @link http://pear.php.net/package/XML_RPC
*/
class XML_RPC_Client extends XML_RPC_Base {
@@ -765,7 +729,7 @@ class XML_RPC_Client extends XML_RPC_Base {
$this->proxy_user = $proxy_user;
$this->proxy_pass = $proxy_pass;
- $GLOBALS['XML_RPC_func_ereg']('^(http://|https://|ssl://)?(.*)$', $server, $match);
+ preg_match('@^(http://|https://|ssl://)?(.*)$@', $server, $match);
if ($match[1] == '') {
if ($port == 443) {
$this->server = $match[2];
@@ -793,7 +757,7 @@ class XML_RPC_Client extends XML_RPC_Base {
}
if ($proxy) {
- $GLOBALS['XML_RPC_func_ereg']('^(http://|https://|ssl://)?(.*)$', $proxy, $match);
+ preg_match('@^(http://|https://|ssl://)?(.*)$@', $proxy, $match);
if ($match[1] == '') {
if ($proxy_port == 443) {
$this->proxy = $match[2];
@@ -889,8 +853,10 @@ class XML_RPC_Client extends XML_RPC_Base {
function send($msg, $timeout = 0)
{
if (!is_a($msg, 'XML_RPC_Message')) {
- $this->errstr = 'send()\'s $msg parameter must be an'
- . ' XML_RPC_Message object.';
+ $this->errstr = sprintf(
+ gettext(
+ "send()'s %s parameter must be an XML_RPC_Message object."
+ ), $msg);
$this->raiseError($this->errstr, XML_RPC_ERROR_PROGRAMMING);
return 0;
}
@@ -923,6 +889,26 @@ class XML_RPC_Client extends XML_RPC_Base {
function sendPayloadHTTP10($msg, $server, $port, $timeout = 0,
$username = '', $password = '')
{
+ // Pre-emptive BC hacks for fools calling sendPayloadHTTP10() directly
+ if ($username != $this->username) {
+ $this->setCredentials($username, $password);
+ }
+
+ // Only create the payload if it was not created previously
+ if (empty($msg->payload)) {
+ $msg->createPayload();
+ }
+ $this->createHeaders($msg);
+
+ $op = $this->headers . "\r\n\r\n";
+ $op .= $msg->payload;
+
+ if ($this->debug) {
+ print "\n
---SENT---\n";
+ print $op;
+ print "\n---END---
\n";
+ }
+
/*
* If we're using a proxy open a socket to the proxy server
* instead to the xml-rpc server
@@ -960,15 +946,15 @@ class XML_RPC_Client extends XML_RPC_Base {
* but keep it here for backwards compatibility.
*/
if (!$fp && $this->proxy) {
- $this->raiseError('Connection to proxy server '
+ $this->raiseError(gettext('Connection to proxy server ')
. $this->proxy . ':' . $this->proxy_port
- . ' failed. ' . $this->errstr,
+ . gettext(' failed. ') . $this->errstr,
XML_RPC_ERROR_CONNECTION_FAILED);
return 0;
} elseif (!$fp) {
- $this->raiseError('Connection to RPC server '
+ $this->raiseError(gettext('Connection to RPC server ')
. $server . ':' . $port
- . ' failed. ' . $this->errstr,
+ . gettext(' failed. ') . $this->errstr,
XML_RPC_ERROR_CONNECTION_FAILED);
return 0;
}
@@ -981,20 +967,6 @@ class XML_RPC_Client extends XML_RPC_Base {
socket_set_timeout($fp, $timeout);
}
- // Pre-emptive BC hacks for fools calling sendPayloadHTTP10() directly
- if ($username != $this->username) {
- $this->setCredentials($username, $password);
- }
-
- // Only create the payload if it was not created previously
- if (empty($msg->payload)) {
- $msg->createPayload();
- }
- $this->createHeaders($msg);
-
- $op = $this->headers . "\r\n\r\n";
- $op .= $msg->payload;
-
if (!fputs($fp, $op, strlen($op))) {
$this->errstr = 'Write error';
return 0;
@@ -1068,8 +1040,9 @@ class XML_RPC_Client extends XML_RPC_Base {
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version Release: 1.5.1
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version Release: @package_version@
* @link http://pear.php.net/package/XML_RPC
*/
class XML_RPC_Response extends XML_RPC_Base
@@ -1159,8 +1132,9 @@ class XML_RPC_Response extends XML_RPC_Base
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version Release: 1.5.1
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version Release: @package_version@
* @link http://pear.php.net/package/XML_RPC
*/
class XML_RPC_Message extends XML_RPC_Base
@@ -1297,9 +1271,9 @@ class XML_RPC_Message extends XML_RPC_Base
$this->payload .= "\n";
$this->payload .= $this->xml_footer();
if ($this->remove_extra_lines) {
- $this->payload = $GLOBALS['XML_RPC_func_ereg_replace']("[\r\n]+", "\r\n", $this->payload);
+ $this->payload = preg_replace("@[\r\n]+@", "\r\n", $this->payload);
} else {
- $this->payload = $GLOBALS['XML_RPC_func_ereg_replace']("\r\n|\n|\r|\n\r", "\r\n", $this->payload);
+ $this->payload = preg_replace("@\r\n|\n|\r|\n\r@", "\r\n", $this->payload);
}
if ($this->convert_payload_encoding) {
$this->payload = mb_convert_encoding($this->payload, $this->send_encoding);
@@ -1351,7 +1325,7 @@ class XML_RPC_Message extends XML_RPC_Base
if (isset($this->params[$i])) {
return $this->params[$i];
} else {
- $this->raiseError('The submitted request did not contain this parameter',
+ $this->raiseError(gettext('The submitted request did not contain this parameter'),
XML_RPC_ERROR_INCORRECT_PARAMS);
return new XML_RPC_Response(0, $XML_RPC_err['incorrect_params'],
$XML_RPC_str['incorrect_params']);
@@ -1382,7 +1356,7 @@ class XML_RPC_Message extends XML_RPC_Base
function setConvertPayloadEncoding($in)
{
if ($in && !function_exists('mb_convert_encoding')) {
- return $this->raiseError('mb_convert_encoding() is not available',
+ return $this->raiseError(gettext('mb_convert_encoding() is not available'),
XML_RPC_ERROR_PROGRAMMING);
}
$this->convert_payload_encoding = $in;
@@ -1421,7 +1395,7 @@ class XML_RPC_Message extends XML_RPC_Base
{
global $XML_RPC_defencoding;
- if ($GLOBALS['XML_RPC_func_ereg']('<\?xml[^>]*[:space:]*encoding[:space:]*=[:space:]*[\'"]([^"\']*)[\'"]',
+ if (preg_match('@<\?xml[^>]*\s*encoding\s*=\s*[\'"]([^"\']*)[\'"]@',
$data, $match))
{
$match[1] = trim(strtoupper($match[1]));
@@ -1486,12 +1460,12 @@ class XML_RPC_Message extends XML_RPC_Base
// See if response is a 200 or a 100 then a 200, else raise error.
// But only do this if we're using the HTTP protocol.
- if ($GLOBALS['XML_RPC_func_ereg']('^HTTP', $data) &&
- !$GLOBALS['XML_RPC_func_ereg']('^HTTP/[0-9\.]+ 200 ', $data) &&
- !$GLOBALS['XML_RPC_func_ereg']('^HTTP/[0-9\.]+ 10[0-9]([A-Z ]+)?[\r\n]+HTTP/[0-9\.]+ 200', $data))
+ if (preg_match('@^HTTP@', $data) &&
+ !preg_match('@^HTTP/[0-9\.]+ 200 @', $data) &&
+ !preg_match('@^HTTP/[0-9\.]+ 10[0-9]([A-Z ]+)?[\r\n]+HTTP/[0-9\.]+ 200@', $data))
{
$errstr = substr($data, 0, strpos($data, "\n") - 1);
- error_log('HTTP error, got response: ' . $errstr);
+ error_log(gettext("HTTP error, got response: ") . $errstr);
$r = new XML_RPC_Response(0, $XML_RPC_err['http_error'],
$XML_RPC_str['http_error'] . ' (' .
$errstr . ')');
@@ -1517,7 +1491,7 @@ class XML_RPC_Message extends XML_RPC_Base
if (!xml_parse($parser_resource, $data, sizeof($data))) {
// thanks to Peter Kocks
if (xml_get_current_line_number($parser_resource) == 1) {
- $errstr = 'XML error at line 1, check URL';
+ $errstr = gettext("XML error at line 1, check URL");
} else {
$errstr = sprintf('XML error: %s at line %d',
xml_error_string(xml_get_error_code($parser_resource)),
@@ -1558,7 +1532,7 @@ class XML_RPC_Message extends XML_RPC_Base
$r = new XML_RPC_Response($v);
}
}
- $r->hdrs = split("\r?\n", $XML_RPC_xh[$parser]['ha'][1]);
+ $r->hdrs = preg_split("@\r?\n@", $XML_RPC_xh[$parser]['ha'][1]);
return $r;
}
}
@@ -1572,8 +1546,9 @@ class XML_RPC_Message extends XML_RPC_Base
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version Release: 1.5.1
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version Release: @package_version@
* @link http://pear.php.net/package/XML_RPC
*/
class XML_RPC_Value extends XML_RPC_Base
@@ -1611,14 +1586,15 @@ class XML_RPC_Value extends XML_RPC_Base
function addScalar($val, $type = 'string')
{
if ($this->mytype == 1) {
- $this->raiseError('Scalar can have only one value',
+ $this->raiseError(gettext('Scalar can have only one value'),
XML_RPC_ERROR_INVALID_TYPE);
return 0;
}
$typeof = $GLOBALS['XML_RPC_Types'][$type];
if ($typeof != 1) {
- $this->raiseError("Not a scalar type (${typeof})",
- XML_RPC_ERROR_INVALID_TYPE);
+ $this->raiseError(
+ sprintf(gettext("Not a scalar type (%s)"), $typeof),
+ XML_RPC_ERROR_INVALID_TYPE);
return 0;
}
@@ -1653,7 +1629,7 @@ class XML_RPC_Value extends XML_RPC_Base
{
if ($this->mytype != 0) {
$this->raiseError(
- 'Already initialized as a [' . $this->kindOf() . ']',
+ sprintf(gettext('Already initialized as a [%s]'), $this->kindOf()),
XML_RPC_ERROR_ALREADY_INITIALIZED);
return 0;
}
@@ -1669,7 +1645,7 @@ class XML_RPC_Value extends XML_RPC_Base
{
if ($this->mytype != 0) {
$this->raiseError(
- 'Already initialized as a [' . $this->kindOf() . ']',
+ sprintf(gettext('Already initialized as a [%s]'), $this->kindOf()),
XML_RPC_ERROR_ALREADY_INITIALIZED);
return 0;
}
@@ -1731,7 +1707,7 @@ class XML_RPC_Value extends XML_RPC_Base
$rs .= "\n";
reset($val);
foreach ($val as $key2 => $val2) {
- $rs .= "${key2}\n";
+ $rs .= "" . htmlspecialchars($key2) . "\n";
$rs .= $this->serializeval($val2);
$rs .= "\n";
}
@@ -1741,8 +1717,8 @@ class XML_RPC_Value extends XML_RPC_Base
case 2:
// array
$rs .= "\n\n";
- for ($i = 0; $i < sizeof($val); $i++) {
- $rs .= $this->serializeval($val[$i]);
+ foreach ($val as $value) {
+ $rs .= $this->serializeval($value);
}
$rs .= "\n";
break;
@@ -1953,7 +1929,7 @@ function XML_RPC_iso8601_encode($timet, $utc = 0)
function XML_RPC_iso8601_decode($idate, $utc = 0)
{
$t = 0;
- if ($GLOBALS['XML_RPC_func_ereg']('([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})', $idate, $regs)) {
+ if (preg_match('@([0-9]{4})([0-9]{2})([0-9]{2})T([0-9]{2}):([0-9]{2}):([0-9]{2})@', $idate, $regs)) {
if ($utc) {
$t = gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]);
} else {
@@ -2042,10 +2018,10 @@ function XML_RPC_encode($php_val)
case 'string':
case 'NULL':
- if ($GLOBALS['XML_RPC_func_ereg']('^[0-9]{8}\T{1}[0-9]{2}\:[0-9]{2}\:[0-9]{2}$', $php_val)) {
+ if (preg_match('@^[0-9]{8}\T{1}[0-9]{2}\:[0-9]{2}\:[0-9]{2}$@', $php_val)) {
$XML_RPC_val->addScalar($php_val, $GLOBALS['XML_RPC_DateTime']);
} elseif ($GLOBALS['XML_RPC_auto_base64']
- && $GLOBALS['XML_RPC_func_ereg']("[^ -~\t\r\n]", $php_val))
+ && preg_match("@[^ -~\t\r\n]@", $php_val))
{
// Characters other than alpha-numeric, punctuation, SP, TAB,
// LF and CR break the XML parser, encode value via Base 64.
diff --git a/etc/inc/xmlrpc_server.inc b/etc/inc/xmlrpc_server.inc
index 8887bdfc66..10b8bebea0 100644
--- a/etc/inc/xmlrpc_server.inc
+++ b/etc/inc/xmlrpc_server.inc
@@ -10,35 +10,18 @@
*
* PHP versions 4 and 5
*
- * LICENSE: License is granted to use or modify this software
- * ("XML-RPC for PHP") for commercial or non-commercial use provided the
- * copyright of the author is preserved in any distributed or derivative work.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESSED OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
* @category Web Services
* @package XML_RPC
* @author Edd Dumbill
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version CVS: $Id$
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version SVN: $Id: Server.php 300961 2010-07-03 02:17:34Z danielc $
* @link http://pear.php.net/package/XML_RPC
*/
-/*
- pfSense_MODULE: utils
-*/
/**
* Pull in the XML_RPC class
@@ -62,8 +45,8 @@ $GLOBALS['XML_RPC_Server_listMethods_sig'] = array(
* docstring for system.listMethods
* @global string $GLOBALS['XML_RPC_Server_listMethods_doc']
*/
-$GLOBALS['XML_RPC_Server_listMethods_doc'] = 'This method lists all the'
- . ' methods that the XML-RPC server knows how to dispatch';
+$GLOBALS['XML_RPC_Server_listMethods_doc'] = gettext('This method lists all the'
+ . ' methods that the XML-RPC server knows how to dispatch');
/**
* signature for system.methodSignature: return = array,
@@ -80,10 +63,10 @@ $GLOBALS['XML_RPC_Server_methodSignature_sig'] = array(
* docstring for system.methodSignature
* @global string $GLOBALS['XML_RPC_Server_methodSignature_doc']
*/
-$GLOBALS['XML_RPC_Server_methodSignature_doc'] = 'Returns an array of known'
+$GLOBALS['XML_RPC_Server_methodSignature_doc'] = gettext('Returns an array of known'
. ' signatures (an array of arrays) for the method name passed. If'
. ' no signatures are known, returns a none-array (test for type !='
- . ' array to detect missing signature)';
+ . ' array to detect missing signature)');
/**
* signature for system.methodHelp: return = string,
@@ -100,8 +83,8 @@ $GLOBALS['XML_RPC_Server_methodHelp_sig'] = array(
* docstring for methodHelp
* @global string $GLOBALS['XML_RPC_Server_methodHelp_doc']
*/
-$GLOBALS['XML_RPC_Server_methodHelp_doc'] = 'Returns help text if defined'
- . ' for the method passed, otherwise returns an empty string';
+$GLOBALS['XML_RPC_Server_methodHelp_doc'] = gettext('Returns help text if defined'
+ . ' for the method passed, otherwise returns an empty string');
/**
* dispatch map for the automatically declared XML-RPC methods.
@@ -272,8 +255,9 @@ function XML_RPC_Server_debugmsg($m)
* @author Stig Bakken
* @author Martin Jansen
* @author Daniel Convissor
- * @copyright 1999-2001 Edd Dumbill, 2001-2006 The PHP Group
- * @version Release: 1.5.1
+ * @copyright 1999-2001 Edd Dumbill, 2001-2010 The PHP Group
+ * @license http://www.php.net/license/3_01.txt PHP License
+ * @version Release: @package_version@
* @link http://pear.php.net/package/XML_RPC
*/
class XML_RPC_Server
@@ -377,7 +361,7 @@ class XML_RPC_Server
if ($XML_RPC_Server_debuginfo != '') {
return "\n";
} else {
return '';
@@ -434,9 +418,9 @@ class XML_RPC_Server
* that someone composed a single header with multiple lines, which
* the RFCs allow.
*/
- $this->server_headers = $GLOBALS['XML_RPC_func_ereg_replace']("[\r\n]+[ \t]+",
+ $this->server_headers = preg_replace("@[\r\n]+[ \t]+@",
' ', trim($this->server_headers));
- $headers = $GLOBALS['XML_RPC_func_split']("[\r\n]+", $this->server_headers);
+ $headers = preg_split("@[\r\n]+@", $this->server_headers);
foreach ($headers as $header)
{
header($header);
@@ -685,4 +669,4 @@ class XML_RPC_Server
* End:
*/
-?>
\ No newline at end of file
+?>
diff --git a/etc/inc/zeromq.inc b/etc/inc/zeromq.inc
index 3cb18436a6..fe39e82224 100644
--- a/etc/inc/zeromq.inc
+++ b/etc/inc/zeromq.inc
@@ -306,4 +306,4 @@ function get_notices_zeromq($raw_params) {
return serialize($toreturn);
}
-?>
\ No newline at end of file
+?>
diff --git a/etc/rc.banner b/etc/rc.banner
index 6f81cb99a2..2e016ceb87 100755
--- a/etc/rc.banner
+++ b/etc/rc.banner
@@ -70,15 +70,21 @@
break;
}
$ipaddr = get_interface_ip($ifname);
+ $subnet = get_interface_subnet($ifname);
+ $ipaddr6 = get_interface_ipv6($ifname);
+ $subnet6 = get_interface_subnetv6($ifname);
$realif = get_real_interface($ifname);
$tobanner = "{$friendly} ({$ifname})";
- printf("\n %-25s -> %-10s -> %s %s",
+ printf("\n %-15s -> %-10s -> %s/%s\t%s/%s %s",
$tobanner,
$realif,
$ipaddr ? $ipaddr : "NONE",
+ $subnet ? $subnet : "NONE",
+ $ipaddr6 ? $ipaddr6 : "NONE",
+ $subnet6 ? $subnet6 : "NONE",
$class
);
}
-?>
\ No newline at end of file
+?>
diff --git a/etc/rc.filter_synchronize b/etc/rc.filter_synchronize
index fe8a30f2e4..c64acd4b4d 100755
--- a/etc/rc.filter_synchronize
+++ b/etc/rc.filter_synchronize
@@ -272,7 +272,7 @@ global $g;
if (file_exists("{$g['varrun_path']}/booting") || $g['booting'])
return;
-if (is_array($config['installedpackages']['carpsettings']['config'])) {
+if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])) {
update_filter_reload_status("Building CARP sync information");
foreach($config['installedpackages']['carpsettings']['config'] as $carp) {
if (empty($carp['synchronizetoip'])) {
@@ -297,6 +297,8 @@ if (is_array($config['installedpackages']['carpsettings']['config'])) {
$port = "443";
}
+ if(is_ipaddrv6($carp['synchronizetoip']))
+ $carp['synchronizetoip'] = "[{$carp['synchronizetoip']}]";
$synchronizetoip .= $carp['synchronizetoip'];
if ($carp['synchronizerules'] != "") {
if (!is_array($config['filter']))
diff --git a/etc/rc.initial.firmware_update b/etc/rc.initial.firmware_update
index 8d16098869..f4363c6497 100755
--- a/etc/rc.initial.firmware_update
+++ b/etc/rc.initial.firmware_update
@@ -93,7 +93,7 @@ switch ($command) {
exec("fetch -1 -w15 -a -v -o /root/firmware.tgz.md5 \"$url.md5\"");
} else {
echo "\n\nWARNING.\n";
- echo "\nCould not locate a MD5 file. We cannot verify the download once its done.\n\n";
+ echo "\nCould not locate a MD5 file. We cannot verify the download once completed.\n\n";
sleep(15);
}
if(file_exists("/root/firmware.tgz.md5")) {
diff --git a/etc/rc.newwanipv6 b/etc/rc.newwanipv6
new file mode 100755
index 0000000000..f5d1eaa83a
--- /dev/null
+++ b/etc/rc.newwanipv6
@@ -0,0 +1,156 @@
+#!/usr/local/bin/php -f
+.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* parse the configuration and include all functions used below */
+require_once("globals.inc");
+require_once("config.inc");
+require_once("functions.inc");
+require_once("filter.inc");
+require_once("shaper.inc");
+require_once("ipsec.inc");
+require_once("vpn.inc");
+require_once("openvpn.inc");
+require_once("IPv6.inc");
+
+// Do not process while booting
+if($g['booting'])
+ exit;
+
+
+// echo print_r($_ENV, true);
+/*Array
+(
+ [REASON] => NBI
+ [new_domain_name_servers] => 2001:470:20::2
+ [new_domain_name] => domain.nl.
+)
+*/
+
+function restart_packages() {
+ global $oldip, $curwanipi, $g;
+
+ /* restart packages */
+ system_ntp_configure();
+ log_error("{$g['product_name']} package system has detected an ip change $oldip -> $curwanip ... Restarting packages.");
+ mwexec_bg("/etc/rc.start_packages");
+}
+
+log_error("rc.newwanipv6: Informational is starting.");
+
+$curwanip = get_interface_ipv6();
+$interface = "wan";
+$interface_real = get_real_interface();
+
+if(is_ipaddr(trim($_ENV['new_domain_name_servers']))) {
+ echo "DNS {$_ENV['new_domain_name_servers']}\n";
+ file_put_contents("{$g['varetc_path']}/nameserver_v6{$interface}", trim($_ENV['new_domain_name_servers']));
+}
+if(!empty($_ENV['new_domain_name'])) {
+ file_put_contents("{$g['varetc_path']}/searchdomain_v6{$interface}", $_ENV['new_domain_name']);
+}
+
+log_error("rc.newwanipv6: on (IP address: {$curwanipv6}) (interface: {$interface}) (real interface: {$interface_real}).");
+
+if($curwanipv6 == "" || !is_ipaddrv6($curwanipv6)) {
+ log_error("rc.newwanipv6: Failed to update {$interface} IP, restarting...");
+ send_event("interface reconfigure {$interface}");
+ exit;
+}
+
+if (empty($interface)) {
+ filter_configure();
+ restart_packages();
+ exit;
+}
+
+$oldip = "";
+if (file_exists("{$g['vardb_path']}/{$interface}_cacheipv6"))
+ $oldipv6 = file_get_contents("{$g['vardb_path']}/{$interface}_cacheipv6");
+
+$grouptmp = link_interface_to_group($interface);
+if (!empty($grouptmp))
+ array_walk($grouptmp, 'interface_group_add_member');
+
+/* regenerate resolv.conf if DNS overrides are allowed */
+system_resolvconf_generate(true);
+
+/* write current WAN IP to file */
+file_put_contents("{$g['vardb_path']}/{$interface}_ipv6", $curwanipv6);
+
+/* reconfigure static routes (kernel may have deleted them) */
+system_routing_configure($interface);
+
+/* reconfigure our gateway monitor */
+setup_gateways_monitor();
+
+/* signal filter reload */
+filter_configure();
+
+if (is_ipaddr($oldipv6) && $curwanipv6 == $oldipv6) {
+ // Still need to sync VPNs on PPPoE and such, as even with the same IP the VPN software is unhappy with the IP disappearing.
+ if (in_array($config['interfaces'][$interface]['ipaddr'], array('pppoe', 'pptp', 'ppp'))) {
+ /* reconfigure IPsec tunnels */
+ vpn_ipsec_force_reload();
+
+ /* start OpenVPN server & clients */
+ openvpn_resync_all($interface);
+ }
+ exit;
+}
+
+file_put_contents("{$g['vardb_path']}/{$interface}_cacheipv6", $curwanipv6);
+
+/* perform RFC 2136 DNS update */
+services_dnsupdate_process($interface);
+
+/* signal dyndns update */
+services_dyndns_configure($interface);
+
+/* reconfigure IPsec tunnels */
+vpn_ipsec_force_reload();
+
+/* start OpenVPN server & clients */
+if (substr($interface_real, 0, 4) != "ovpn")
+ openvpn_resync_all($interface);
+
+/* reload graphing functions */
+enable_rrd_graphing();
+
+/* reload igmpproxy */
+services_igmpproxy_configure();
+
+restart_packages();
+
+services_rtadvd_configure();
+
+?>
diff --git a/etc/rc.php_ini_setup b/etc/rc.php_ini_setup
index 7dfcdddf28..dcc562f787 100755
--- a/etc/rc.php_ini_setup
+++ b/etc/rc.php_ini_setup
@@ -117,8 +117,8 @@ PHPMODULES="$PHPMODULES ssh2"
# pfSense extensions
PHPMODULES="$PHPMODULES pfSense"
-PHP_ZEND_MODULES=""
-PHP_ZEND_MODULES_TS=""
+PHP_ZEND_MODULES="ioncube_loader_fre_5.2"
+PHP_ZEND_MODULES_TS="ioncube_loader_fre_5.2_ts"
# Modules previously included.
# can be turned on by touching
@@ -192,7 +192,7 @@ fi
# Read in dynamodules
if [ -d /etc/php_dynamodules ]; then
- DYNA_MODULES=`/bin/ls /etc/php_dynamodules/`
+ DYNA_MODULES=`/bin/ls -Utr /etc/php_dynamodules/`
PHPMODULES="$PHPMODULES $DYNA_MODULES"
fi
@@ -230,7 +230,7 @@ done
for EXT in $PHP_ZEND_MODULES; do
# Ensure extension exists before adding.
if [ -f "${EXTENSIONSDIR}${EXT}.so" ]; then
- echo "zend_extension=${EXTENSIONSDIR}/${EXT}.so" >> /usr/local/lib/php.ini
+ echo "zend_extension=${EXTENSIONSDIR}${EXT}.so" >> /usr/local/lib/php.ini
fi
done
diff --git a/etc/rc.stop_packages b/etc/rc.stop_packages
old mode 100644
new mode 100755
diff --git a/etc/rc.update_bogons.sh b/etc/rc.update_bogons.sh
index 52cfc1abf3..52ec92f151 100755
--- a/etc/rc.update_bogons.sh
+++ b/etc/rc.update_bogons.sh
@@ -28,6 +28,15 @@ if [ ! -f /tmp/bogons ]; then
exit
fi
+/usr/bin/fetch -q -o /tmp/bogonsv6 "http://files.pfsense.org/mirrors/fullbogons-ipv6.txt"
+if [ ! -f /tmp/bogonsv6 ]; then
+ echo "Could not download http://files.pfsense.org/mirrors/fullbogons-ipv6.txt" | logger
+ # Relaunch and sleep
+ sh /etc/rc.update_bogons.sh &
+ exit
+fi
+
+
BOGON_MD5=`/usr/bin/fetch -q -o - "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5" | awk '{ print $4 }'`
ON_DISK_MD5=`md5 /tmp/bogons | awk '{ print $4 }'`
if [ "$BOGON_MD5" = "$ON_DISK_MD5" ]; then
@@ -42,5 +51,19 @@ else
sh /etc/rc.update_bogons.sh &
fi
+BOGON_MD5=`/usr/bin/fetch -q -o - "http://files.pfsense.org/mirrors/fullbogons-ipv6.txt.md5" | awk '{ print $4 }'`
+ON_DISK_MD5=`md5 /tmp/bogonsv6 | awk '{ print $4 }'`
+if [ "$BOGON_MD5" = "$ON_DISK_MD5" ]; then
+ egrep -v "^#" /tmp/bogonsv6 > /etc/bogonsv6
+ /etc/rc.conf_mount_ro
+ RESULT=`/sbin/pfctl -t bogonsv6 -T replace -f /etc/bogonsv6 2>&1`
+ rm /tmp/bogons
+ echo "Bogons files downloaded: $RESULT" | logger
+else
+ echo "Could not download http://files.pfsense.org/mirrors/fullbogons-ipv6.txt.md5 (md5 mismatch)" | logger
+ # Relaunch and sleep
+ sh /etc/rc.update_bogons.sh &
+fi
+
echo "rc.update_bogons.sh is ending the update cycle." | logger
diff --git a/etc/version b/etc/version
index e5517e4c5b..91b8825ff8 100644
--- a/etc/version
+++ b/etc/version
@@ -1 +1 @@
-HEAD
\ No newline at end of file
+2.1-DEVELOPMENT
diff --git a/usr/local/bin/ping_hosts.sh b/usr/local/bin/ping_hosts.sh
index 97629c45de..c0de5a15fc 100755
--- a/usr/local/bin/ping_hosts.sh
+++ b/usr/local/bin/ping_hosts.sh
@@ -13,6 +13,7 @@
# Field 5: Script to run once service is restored
# Field 6: Ping time threshold
# Field 7: Wan ping time threshold
+# Field 8: Address family
# Read in ipsec ping hosts and check the CARP status
if [ -f /var/db/ipsecpinghosts ]; then
@@ -66,9 +67,15 @@ for TOPING in $PINGHOSTS ; do
SERVICERESTOREDSCRIPT=`echo $TOPING | cut -d"|" -f5`
THRESHOLD=`echo $TOPING | cut -d"|" -f6`
WANTHRESHOLD=`echo $TOPING | cut -d"|" -f7`
+ AF=`echo $TOPING | cut -d"|" -f8`
+ if [ "$AF" == "inet6" ]; then
+ PINGCMD=ping6
+ else
+ PINGCMD=ping
+ fi
echo Processing $DSTIP
# Look for a service being down
- ping -c $COUNT -S $SRCIP $DSTIP
+ $PINGCMD -c $COUNT -S $SRCIP $DSTIP
if [ $? -eq 0 ]; then
# Host is up
# Read in previous status
@@ -97,7 +104,7 @@ for TOPING in $PINGHOSTS ; do
fi
echo "Checking ping time $DSTIP"
# Look at ping values themselves
- PINGTIME=`ping -c 1 -S $SRCIP $DSTIP | awk '{ print $7 }' | grep time | cut -d "=" -f2`
+ PINGTIME=`$PINGCMD -c 1 -S $SRCIP $DSTIP | awk '{ print $7 }' | grep time | cut -d "=" -f2`
echo "Ping returned $?"
echo $PINGTIME > /var/db/pingmsstatus/$DSTIP
if [ "$THRESHOLD" != "" ]; then
diff --git a/usr/local/captiveportal/radius_accounting.inc b/usr/local/captiveportal/radius_accounting.inc
index 2e189791dd..704c2293ae 100644
--- a/usr/local/captiveportal/radius_accounting.inc
+++ b/usr/local/captiveportal/radius_accounting.inc
@@ -56,7 +56,7 @@ function RADIUS_ACCOUNTING_START($ruleno, $username, $sessionid, $radiusservers,
$retvalue = array();
$nas_mac = mac_format(get_interface_mac("wan"));
$clientmac = mac_format($clientmac);
- $nas_port = $ruleno;
+ $nas_port = intval($ruleno);
$radiusvendor = $config['captiveportal']['radiusvendor'] ? $config['captiveportal']['radiusvendor'] : null;
switch($radiusvendor) {
@@ -171,7 +171,7 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
$retvalue = array();
$nas_mac = mac_format(get_interface_mac("wan"));
$clientmac = mac_format($clientmac);
- $nas_port = $ruleno;
+ $nas_port = intval($ruleno);
$radiusvendor = $config['captiveportal']['radiusvendor'] ? $config['captiveportal']['radiusvendor'] : null;
$stop_time = (empty($stop_time)) ? time() : $stop_time;
$session_time = $stop_time - $start_time;
@@ -233,7 +233,7 @@ function RADIUS_ACCOUNTING_STOP($ruleno,$username,$sessionid,$start_time,$radius
// Default attributes
$racct->putAttribute(RADIUS_SERVICE_TYPE, RADIUS_LOGIN);
$racct->putAttribute(RADIUS_NAS_PORT_TYPE, RADIUS_ETHERNET);
- $racct->putAttribute(RADIUS_NAS_PORT, $nas_port);
+ $racct->putAttribute(RADIUS_NAS_PORT, $nas_port, 'integer');
$racct->putAttribute(RADIUS_ACCT_SESSION_ID, $sessionid);
// Extra data to identify the client and nas
diff --git a/usr/local/sbin/ppp-linkdown b/usr/local/sbin/ppp-linkdown
index a20d96638a..4c1ad15bd3 100755
--- a/usr/local/sbin/ppp-linkdown
+++ b/usr/local/sbin/ppp-linkdown
@@ -6,10 +6,10 @@ fi
if [ -f "/tmp/${interface}_defaultgw" ]; then
route delete default $4
fi
-/sbin/pfctl -k 0.0.0.0/0 -k $3
-/sbin/pfctl -k $3
-pfctl -K $3
-/sbin/pfctl -b 0.0.0.0/32 -b $4
+/sbin/pfctl -k 0.0.0.0/0 -k $3/32
+/sbin/pfctl -k $3/32
+pfctl -K $3/32
+/sbin/pfctl -b 0.0.0.0/32 -b $4/32
# delete the node just in case mpd cannot do that
/usr/sbin/ngctl shutdown $1:
if [ -f "/var/etc/nameserver_$1" ]; then
diff --git a/usr/local/sbin/vpn-linkdown b/usr/local/sbin/vpn-linkdown
index 1d533cbc0c..ac9ea2a353 100755
--- a/usr/local/sbin/vpn-linkdown
+++ b/usr/local/sbin/vpn-linkdown
@@ -2,4 +2,4 @@
# record logout
/usr/bin/logger -p local3.info "logout,$1,$4,$5"
-# /sbin/pfctl -b $3 -b $4
+/sbin/pfctl -b $3/32 -b $4/32
diff --git a/usr/local/www/diag_logs_filter.php b/usr/local/www/diag_logs_filter.php
index 5fb94cff68..8b1222eebc 100755
--- a/usr/local/www/diag_logs_filter.php
+++ b/usr/local/www/diag_logs_filter.php
@@ -150,18 +150,25 @@ include("head.inc");
[{$ph1ent['descr']}]: $2$3$4";
}
/* collect all our own ip addresses */
-exec("/sbin/ifconfig | /usr/bin/awk '/inet / {print $2}'", $ip_address_list);
+exec("/sbin/ifconfig | /usr/bin/awk '/inet/ {print $2}'", $ip_address_list);
foreach($ip_address_list as $address) {
$search[] = "/(racoon: )(INFO[:].*?)({$address}\[[0-9].+\])/i";
$search[] = "/(racoon: )(\[{$address}\]|{$address})(.*)/i";
@@ -79,7 +79,6 @@ $replace[] = "$1 [Check Phase 1 settings, lifetime, algorithm]"
$replace[] = "$1 [Check Phase 2 settings, networks]";
$replace[] = "$1 [Check Phase 2 settings, algorithm]";
-
$nentries = $config['syslog']['nentries'];
if (!$nentries)
$nentries = 50;
diff --git a/usr/local/www/diag_ndp.php b/usr/local/www/diag_ndp.php
new file mode 100755
index 0000000000..c99da4e005
--- /dev/null
+++ b/usr/local/www/diag_ndp.php
@@ -0,0 +1,163 @@
+
+ Copyright (C) 2011 Seth Mos
+
+
+ originally part of m0n0wall (http://m0n0.ch/wall)
+ Copyright (C) 2005 Paul Taylor (paultaylor@winndixie.com) and Manuel Kasper .
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/*
+ pfSense_BUILDER_BINARIES: /bin/cat /usr/sbin/arp
+ pfSense_MODULE: arp
+*/
+
+##|+PRIV
+##|*IDENT=page-diagnostics-ndptable
+##|*NAME=Diagnostics: NDP Table page
+##|*DESCR=Allow access to the 'Diagnostics: NDP Table' page.
+##|*MATCH=diag_ndp.php*
+##|-PRIV
+
+@ini_set('zlib.output_compression', 0);
+@ini_set('implicit_flush', 1);
+
+require("guiconfig.inc");
+
+exec("/usr/sbin/ndp -na", $rawdata);
+
+$i = 0;
+
+/* if list */
+$ifdescrs = get_configured_interface_with_descr();
+
+foreach ($ifdescrs as $key =>$interface) {
+ $hwif[$config['interfaces'][$key]['if']] = $interface;
+}
+
+/* Array ( [0] => Neighbor [1] => Linklayer [2] => Address
+[3] => Netif [4] => Expire [5] => S
+[6] => Flags ) */
+$data = array();
+array_shift($rawdata);
+foreach ($rawdata as $line) {
+ $elements = preg_split('/[ ]+/', $line);
+
+ $ndpent = array();
+ $ndpent['ipv6'] = trim($elements[0]);
+ $ndpent['mac'] = trim($elements[1]);
+ $ndpent['interface'] = trim($elements[2]);
+ $data[] = $ndpent;
+}
+
+/* FIXME: Not ipv6 compatible dns resolving. PHP needs fixing */
+function _getHostName($mac,$ip)
+{
+ if(is_ipaddr($ip)) {
+ if(gethostbyaddr($ip) <> "" and gethostbyaddr($ip) <> $ip)
+ return gethostbyaddr($ip);
+ else
+ return "";
+ }
+}
+
+// Resolve hostnames and replace Z_ with "". The intention
+// is to sort the list by hostnames, alpha and then the non
+// resolvable addresses will appear last in the list.
+foreach ($data as &$entry) {
+ $dns = trim(_getHostName($entry['mac'], $entry['ipv6']));
+ if(trim($dns))
+ $entry['dnsresolve'] = "$dns";
+ else
+ $entry['dnsresolve'] = "Z_ ";
+}
+
+// Sort the data alpha first
+$data = msort($data, "dnsresolve");
+
+$pgtitle = array(gettext("Diagnostics"),gettext("NDP Table"));
+include("head.inc");
+
+?>
+
+
+
+
+
+