Me again!
After attempting a number of things in house we are no closer to an answer. I just wanted to add some context.
Currently our routers allow our main FOG server to send directed broadcasts to all of our workstation VLAN broadcast IPs (X.X.X.255).
In version 0.32 we followed this wiki in order to forward WOL packets to the seperate VLAN broadcast IPs: [url]http://www.fogproject.org/wiki/index.php/WOL_Forwarding[/url]. It seems that this was a home-built solution and that editing the wol.php file is a thing of the past (or at least it isn’t possible to do it the same way).
Which brings me to the WakeOnLan.class.php file. I have extremely limited php knowledge so I’m not sure how this file works, but I can read comments as well as anyone and it clearly states that this is the file that builds the magic packet. Can anyone give me a brief breakdown on how it works and if editing is necessary to broadcast to VLAN broadcast IPs rather that 255.255.255.255?
[PHP]<?php
/** \class WakeOnLan
Builds the magic packet needed for waking systems from LAN.
*/
class WakeOnLan
{
private $strMac;
/** __construct($mac)
Stores the MAC of which to system to wake.
*/
public function __construct( $mac )
{
$this->strMac = $mac;
}
/** send()
Creates the packet and sends it to wake up the machine.
*/
public function send()
{
if ( $this->strMac != null )
{
$arByte = explode(':', $this->strMac);
$strAddr = null;
for ($i=0; $i<count( $arByte); $i++)
$strAddr .= chr(hexdec($arByte[$i]));
$strRaw = null;
for ($i=0; $i<6; $i++)
$strRaw .= chr(255);
for ($i=0; $i<16; $i++)
$strRaw .= $strAddr;
$soc = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP);
if ( $soc !== FALSE )
{
if(socket_set_option($soc, SOL_SOCKET, SO_BROADCAST, TRUE))
{
if( socket_sendto($soc, $strRaw, strlen($strRaw), 0, "255.255.255.255", 9) )
{
socket_close($soc);
return true;
}
else
return false;
}
else
new Exception( "Failed to set option!");
}
else
{
$errCd = socket_last_error();
$errMsg = socket_strerror($errCd);
throw new Exception( "Socket Error: $errCd :: $errMsg" );
}
}
return false;
}
}[/PHP]
We are currently between web developers here or I would ask him/her to give me a quick tutorial. Any help would be greatly appreciated!
Jacob