To change the wol program to keep looping and use the correct port by default make the following changes to the wol.c file. Code changes are bold to make them stand out.
Change the line:
static unsigned int port = DEFAULT_PORT;
to:
static unsigned int port = 9;
and replace the lines:
if (udp_send (socketfd, host_str, portnum, m->packet, m->size))
{
error (0, errno, _("Cannot send magic packet for '%s' to %s:%d"),
mac_str, host_str, portnum);
errno = 0;
return -1;
}
fprintf (stdout, _("Waking up %s"), mac_str);
if (verbose)
{
fprintf (stdout, _(" with %s:%d"), host_str, portnum);
}
fprintf (stdout, _("...\n"));
with:
/* Loop forever */
while (-1){
if (udp_send (socketfd, host_str, portnum, m->packet, m->size))
{
error (0, errno, _("Cannot send magic packet for '%s' to %s:%d"),
mac_str, host_str, portnum);
errno = 0;
}
fprintf (stdout, _("Waking up %s"), mac_str);
if (verbose)
{
fprintf (stdout, _(" with %s:%d"), host_str, portnum);
}
fprintf (stdout, _("...\n"));
/* Delay for 10s - value is in microseconds */
usleep(10000000);
}
Compile and run the program from the command line passing in the MAC address of the Buffalo drive to wake up. So if your Buffalo NAS MAC address was 11:22:33:44:55:66 you would use the command "wol 11:22:33:44:55:66" without the quotes. If using a *nix you may need to enter "./wol 11:22:33:44:55:66"