Project

General

Profile

« Previous | Next » 

Revision 9a18ac7a

Added by Luiz Souza over 7 years ago

Rename the variables on the rest of DHCP functions.

View differences:

src/etc/inc/interfaces.inc
4800 4800
	return 0;
4801 4801
}
4802 4802

  
4803
function DHCP_Config_File_Advanced($interface, $wancfg, $wanif) {
4803
function DHCP_Config_File_Advanced($interface, $ifcfg, $realif) {
4804 4804

  
4805 4805
	$hostname = "";
4806
	if ($wancfg['dhcphostname'] != '') {
4807
		$hostname = "\tsend host-name \"{$wancfg['dhcphostname']}\";\n";
4806
	if ($ifcfg['dhcphostname'] != '') {
4807
		$hostname = "\tsend host-name \"{$ifcfg['dhcphostname']}\";\n";
4808 4808
	}
4809 4809

  
4810 4810
	/* DHCP Protocol Timings */
......
4812 4812
	foreach ($protocol_timings as $Protocol_Timing => $PT_Name) {
4813 4813
		$pt_variable = "{$Protocol_Timing}";
4814 4814
		${$pt_variable} = "";
4815
		if ($wancfg[$Protocol_Timing] != "") {
4816
			${$pt_variable} = "{$PT_Name} {$wancfg[$Protocol_Timing]};\n";
4815
		if ($ifcfg[$Protocol_Timing] != "") {
4816
			${$pt_variable} = "{$PT_Name} {$ifcfg[$Protocol_Timing]};\n";
4817 4817
		}
4818 4818
	}
4819 4819

  
4820 4820
	$send_options = "";
4821
	if ($wancfg['adv_dhcp_send_options'] != '') {
4822
		$options = DHCP_Config_Option_Split($wancfg['adv_dhcp_send_options']);
4821
	if ($ifcfg['adv_dhcp_send_options'] != '') {
4822
		$options = DHCP_Config_Option_Split($ifcfg['adv_dhcp_send_options']);
4823 4823
		foreach ($options as $option) {
4824 4824
			$send_options .= "\tsend " . trim($option) . ";\n";
4825 4825
		}
4826 4826
	}
4827 4827

  
4828 4828
	$request_options = "";
4829
	if ($wancfg['adv_dhcp_request_options'] != '') {
4830
		$request_options = "\trequest {$wancfg['adv_dhcp_request_options']};\n";
4829
	if ($ifcfg['adv_dhcp_request_options'] != '') {
4830
		$request_options = "\trequest {$ifcfg['adv_dhcp_request_options']};\n";
4831 4831
	}
4832 4832

  
4833 4833
	$required_options = "";
4834
	if ($wancfg['adv_dhcp_required_options'] != '') {
4835
		$required_options = "\trequire {$wancfg['adv_dhcp_required_options']};\n";
4834
	if ($ifcfg['adv_dhcp_required_options'] != '') {
4835
		$required_options = "\trequire {$ifcfg['adv_dhcp_required_options']};\n";
4836 4836
	}
4837 4837

  
4838 4838
	$option_modifiers = "";
4839
	if ($wancfg['adv_dhcp_option_modifiers'] != '') {
4840
		$modifiers = DHCP_Config_Option_Split($wancfg['adv_dhcp_option_modifiers']);
4839
	if ($ifcfg['adv_dhcp_option_modifiers'] != '') {
4840
		$modifiers = DHCP_Config_Option_Split($ifcfg['adv_dhcp_option_modifiers']);
4841 4841
		foreach ($modifiers as $modifier) {
4842 4842
			$option_modifiers .= "\t" . trim($modifier) . ";\n";
4843 4843
		}
4844 4844
	}
4845 4845

  
4846
	$dhclientconf  = "interface \"{$wanif}\" {\n";
4846
	$dhclientconf  = "interface \"{$realif}\" {\n";
4847 4847
	$dhclientconf .= "\n";
4848 4848
	$dhclientconf .= "# DHCP Protocol Timing Values\n";
4849 4849
	$dhclientconf .= "{$adv_dhcp_pt_timeout}";
......
4860 4860
	$dhclientconf .= "{$required_options}";
4861 4861
	$dhclientconf .= "{$option_modifiers}";
4862 4862
	$dhclientconf .= "\n";
4863
	if (is_ipaddrv4($wancfg['dhcprejectfrom'])) {
4864
		$dhclientconf .= "reject {$wancfg['dhcprejectfrom']};\n";
4863
	if (is_ipaddrv4($ifcfg['dhcprejectfrom'])) {
4864
		$dhclientconf .= "reject {$ifcfg['dhcprejectfrom']};\n";
4865 4865
	}
4866 4866
	$dhclientconf .= "\tscript \"/usr/local/sbin/pfSense-dhclient-script\";\n";
4867 4867
	$dhclientconf .= "}\n";
4868 4868

  
4869
	$dhclientconf = DHCP_Config_File_Substitutions($wancfg, $wanif, $dhclientconf);
4869
	$dhclientconf = DHCP_Config_File_Substitutions($ifcfg, $realif, $dhclientconf);
4870 4870

  
4871 4871
	return $dhclientconf;
4872 4872
}
......
4876 4876
	return $matches ? $matches[0] : [];
4877 4877
}
4878 4878

  
4879
function DHCP_Config_File_Override($wancfg, $wanif) {
4879
function DHCP_Config_File_Override($ifcfg, $realif) {
4880 4880

  
4881
	$dhclientconf = @file_get_contents($wancfg['adv_dhcp_config_file_override_path']);
4881
	$dhclientconf = @file_get_contents($ifcfg['adv_dhcp_config_file_override_path']);
4882 4882

  
4883 4883
	if ($dhclientconf === false) {
4884
		log_error(sprintf(gettext("Error: cannot open %s in DHCP_Config_File_Override() for reading."), $wancfg['adv_dhcp_config_file_override_path']));
4884
		log_error(sprintf(gettext("Error: cannot open %s in DHCP_Config_File_Override() for reading."), $ifcfg['adv_dhcp_config_file_override_path']));
4885 4885
		return '';
4886 4886
	} else {
4887
		return DHCP_Config_File_Substitutions($wancfg, $wanif, $dhclientconf);
4887
		return DHCP_Config_File_Substitutions($ifcfg, $realif, $dhclientconf);
4888 4888
	}
4889 4889
}
4890 4890

  
4891 4891

  
4892
function DHCP_Config_File_Substitutions($wancfg, $wanif, $dhclientconf) {
4892
function DHCP_Config_File_Substitutions($ifcfg, $realif, $dhclientconf) {
4893 4893

  
4894 4894
	/* Apply Interface Substitutions */
4895
	$dhclientconf = str_replace("{interface}", "{$wanif}", $dhclientconf);
4895
	$dhclientconf = str_replace("{interface}", "{$realif}", $dhclientconf);
4896 4896

  
4897 4897
	/* Apply Hostname Substitutions */
4898
	$dhclientconf = str_replace("{hostname}", $wancfg['dhcphostname'], $dhclientconf);
4898
	$dhclientconf = str_replace("{hostname}", $ifcfg['dhcphostname'], $dhclientconf);
4899 4899

  
4900 4900
	/* Arrays of MAC Address Types, Cases, Delimiters */
4901 4901
	/* ASCII or HEX, Upper or Lower Case, Various Delimiters (none, space, colon, hyphen, period) */
......
4913 4913

  
4914 4914
					/* Get MAC Address as ASCII String With Colon (:) delimiters */
4915 4915
					if ("$various_mac_case" == "U") {
4916
						$dhcpclientconf_mac = strtoupper(get_interface_mac($wanif));
4916
						$dhcpclientconf_mac = strtoupper(get_interface_mac($realif));
4917 4917
					}
4918 4918
					if ("$various_mac_case" == "L") {
4919
						$dhcpclientconf_mac = strtolower(get_interface_mac($wanif));
4919
						$dhcpclientconf_mac = strtolower(get_interface_mac($realif));
4920 4920
					}
4921 4921

  
4922 4922
					if ("$various_mac_type" == "mac_addr_hex") {

Also available in: Unified diff