diff --git a/extra/wake-on-lan/authors.txt b/extra/wake-on-lan/authors.txt new file mode 100644 index 0000000000..e091bb8164 --- /dev/null +++ b/extra/wake-on-lan/authors.txt @@ -0,0 +1 @@ +John Benediktsson diff --git a/extra/wake-on-lan/summary.txt b/extra/wake-on-lan/summary.txt new file mode 100644 index 0000000000..6ecaafb3fc --- /dev/null +++ b/extra/wake-on-lan/summary.txt @@ -0,0 +1 @@ +Wake-on-LAN support diff --git a/extra/wake-on-lan/wake-on-lan.factor b/extra/wake-on-lan/wake-on-lan.factor new file mode 100644 index 0000000000..43082904d0 --- /dev/null +++ b/extra/wake-on-lan/wake-on-lan.factor @@ -0,0 +1,22 @@ +! Copyright (C) 2012 John Benediktsson +! See http://factorcode.org/license.txt for BSD license + +USING: arrays destructors io.sockets kernel math.parser +sequences splitting ; + +IN: wake-on-lan + + ] B{ } map-as ; + +: wake-on-lan-packet ( mac-address -- bytearray ) + [ 16 ] [ mac-address-bytes ] bi* concat + B{ 0xff 0xff 0xff 0xff 0xff 0xff } prepend ; + +PRIVATE> + +: wake-on-lan ( mac-address broadcast-ip -- ) + [ wake-on-lan-packet ] [ 9 ] bi* + f 0 [ send ] with-disposal ;