1 ! Copyright (C) 2012 John Benediktsson
2 ! See http://factorcode.org/license.txt for BSD license
4 USING: arrays destructors io.sockets kernel math.parser
11 : mac-address-bytes ( mac-address -- byte-array )
12 ":-" split [ hex> ] B{ } map-as ;
14 : wake-on-lan-packet ( mac-address -- byte-array )
15 [ 16 ] [ mac-address-bytes ] bi* <array> concat
16 B{ 0xff 0xff 0xff 0xff 0xff 0xff } prepend ;
20 : wake-on-lan ( mac-address broadcast-ip -- )
21 [ wake-on-lan-packet ] [ 9 <inet4> ] bi*