From 6f1f6767bd6eb8997361e3ddce685d1551955852 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Mon, 18 Jun 2012 12:47:21 -0700 Subject: [PATCH] wake-on-lan: adding support for Wake-on-LAN protocol. --- extra/wake-on-lan/authors.txt | 1 + extra/wake-on-lan/summary.txt | 1 + extra/wake-on-lan/wake-on-lan.factor | 22 ++++++++++++++++++++++ 3 files changed, 24 insertions(+) create mode 100644 extra/wake-on-lan/authors.txt create mode 100644 extra/wake-on-lan/summary.txt create mode 100644 extra/wake-on-lan/wake-on-lan.factor 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 ;