From 8674a16312ab5e7d143953e9b9f70a3b8928522d Mon Sep 17 00:00:00 2001 From: June McEnroe Date: Sun, 6 Aug 2017 20:03:36 -0400 Subject: Add wake That payload can appear anywhere within an ethernet frame. Wake-on-LAN is funny. --- home/.bin/wake.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 home/.bin/wake.c (limited to 'home/.bin/wake.c') diff --git a/home/.bin/wake.c b/home/.bin/wake.c new file mode 100755 index 00000000..2f314975 --- /dev/null +++ b/home/.bin/wake.c @@ -0,0 +1,41 @@ +#if 0 +exec cc -Wall -Wextra -Wpedantic $@ -o $(dirname $0)/wake $0 +#endif + +#include +#include +#include +#include +#include +#include + +#define MAC 0x04, 0x7D, 0x7B, 0xD5, 0x6A, 0x53 + +const uint8_t payload[] = { + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + MAC, MAC, MAC, MAC, MAC, MAC, MAC, MAC, + MAC, MAC, MAC, MAC, MAC, MAC, MAC, MAC, +}; + +int main() { + int sock = socket(PF_INET, SOCK_DGRAM, 0); + if (sock < 0) err(EX_OSERR, "socket"); + + int on = 1; + int error = setsockopt(sock, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on)); + if (error) err(EX_OSERR, "setsockopt"); + + struct sockaddr_in addr = { + .sin_family = AF_INET, + .sin_port = 9, + .sin_addr.s_addr = INADDR_BROADCAST, + }; + + ssize_t len = sendto( + sock, payload, sizeof(payload), 0, + (struct sockaddr *)&addr, sizeof(addr) + ); + if (len < 0) err(EX_IOERR, "sendto"); + + return EX_OK; +} -- cgit 1.4.1 ='hidden' name='id' value='d6ea384566ec2594f95edb486f2d05a52c8bac45'/>
Commit message (Expand)Author
2019-10-23Track own originJune McEnroe
2019-10-23Track channels and sync ISUPPORTJune McEnroe
2019-10-23Track nick changesJune McEnroe
2019-10-23Rename Command to MessageJune McEnroe
2019-10-23Synchronize state after client registrationJune McEnroe
2019-10-23Send to server if client has no needsJune McEnroe
2019-10-23Implement some amount of client connectionJune McEnroe
2019-10-23Set clients non-blockingJune McEnroe
2019-10-23Clean up state.c and factor out parsingJune McEnroe
2019-10-23Respond to pingsJune McEnroe
2019-10-23Add verbose flagJune McEnroe
2019-10-23Set NOSIGPIPE on server connectionJune McEnroe
2019-10-23Set an initial loop capJune McEnroe
2019-10-23Fix rest parsingJune McEnroe
2019-10-23Add dynamic poll listJune McEnroe
2019-10-23Don't assume commands have targets and handle ERRORJune McEnroe
2019-10-23Clean up state somewhatJune McEnroe
2019-10-23Actually send the buffer...June McEnroe
2019-10-23Add stateJune McEnroe