summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2005-07-14 04:27:51 +0000
committerScott Ullrich <sullrich@pfsense.org>2005-07-14 04:27:51 +0000
commit94e8082f59e0c55bee9fc9d5f1d44a6c18f2fec3 (patch)
tree4a83a2cc6afa19c5415651a1c6d1ca9662f59cd6 /etc
parent730768f7a5711b753cf93c6b52f22c5cf07cc2e2 (diff)
downloadpfsense-94e8082f59e0c55bee9fc9d5f1d44a6c18f2fec3.zip
pfsense-94e8082f59e0c55bee9fc9d5f1d44a6c18f2fec3.tar.gz
Correctly generate a mac address and add comment
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc32
1 files changed, 29 insertions, 3 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index eece269..4f4d895 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -50,6 +50,21 @@ function log_error($error) {
return;
}
+/****f* pfsense-utils/get_interface_mac_address
+ * NAME
+ * get_interface_mac_address - Return a interfaces mac address
+ * INPUTS
+ * $interface - interface to obtain mac address from
+ * RESULT
+ * $mac - the mac address of the interface
+ ******/
+function get_interface_mac_address($interface) {
+ $mac = `ifconfig fxp0 | grep ether | cut -d" " -f 2`;
+ $mac = str_replace("\n", "", $mac);
+ $mac = str_replace("\r", "", $mac);
+ return $mac;
+}
+
/****f* pfsense-utils/return_dir_as_array
* NAME
* return_dir_as_array - Return a directory's contents as an array.
@@ -959,10 +974,21 @@ function display_topbar($text = "", $bg_color="#990000", $replace_color="#FFFFFF
echo "</script>";
}
+/****f* pfsense-utils/generate_random_mac
+ * NAME
+ * generate_random_mac - generates a random mac address
+ * INPUTS
+ * none
+ * RESULT
+ * $mac - a random mac address
+ ******/
function generate_random_mac() {
- for($i = 0; $i < 6; $i++) {
- $mac .= dechex(rand(16, 255)) . ':';
+ $mac = "00:00";
+ for($x=0; $x<4; $x++) {
+ $mac .= ":";
+ $mac .= dechex(rand(16, 255));
}
return $mac;
}
-?>
+
+?> \ No newline at end of file
OpenPOWER on IntegriCloud