diff options
author | marjohn56 <martin@queens-park.com> | 2016-12-22 20:00:39 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-22 20:00:39 +0000 |
commit | 9e08a2bdbe21e94fb392cc67ce39cd43bbb1b383 (patch) | |
tree | a7fcad5ef5b06118a18eecc0e8abcaa0b3e6c843 /src/etc/inc/util.inc | |
parent | c0a3864eb85a2cae67b6c39321c7138fb7a9a6cb (diff) | |
download | pfsense-9e08a2bdbe21e94fb392cc67ce39cd43bbb1b383.zip pfsense-9e08a2bdbe21e94fb392cc67ce39cd43bbb1b383.tar.gz |
Added get_duid_from_file() function
Used in System->Advanced->Networking to display the current DUID in the placeholder for setting the DUID.
Diffstat (limited to 'src/etc/inc/util.inc')
-rw-r--r-- | src/etc/inc/util.inc | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/etc/inc/util.inc b/src/etc/inc/util.inc index f8fceea..63ffb9f 100644 --- a/src/etc/inc/util.inc +++ b/src/etc/inc/util.inc @@ -2578,4 +2578,35 @@ function write_dhcp6_duid($duidstring) { log_error(gettext("Error: attempting to write DUID file - File write error")); return false; } +/* returns duid string from 'vardb_path']}/dhcp6c_duid' */ +function get_duid_from_file() +{ + global $g; + + $count = 0; + + if ($fd = fopen("{$g['vardb_path']}/dhcp6c_duid", "r")) { + + if(filesize("{$g['vardb_path']}/dhcp6c_duid")==16) { + + $string = fread($fd,filesize("{$g['vardb_path']}/dhcp6c_duid")); + + while($count < 16) { + + $a = $string[$count]; + $duid_ASCII .= bin2hex($a); + $count++; + if($count < 16) { + $duid_ASCII .= ":"; + } + } + } + fclose($fd); + } + //if no file or error with read then the string returns blanked DUID string + if($count != 16) { + return "--:--:--:--:--:--:--:--:--:--:--:--:--:--:--:--"; + } + return($duid_ASCII); +} ?> |