summary refs log tree commit diff
path: root/bin/wake.c
blob: cb5e5386526ab22a4dd4f3a1eb0324e3d1ef157e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/* Copyright (c) 2017, Curtis McEnroe <programble@gmail.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <sys/types.h>

#include <err.h>
#include <netinet/in.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <sysexits.h>

#define MAC 0x04, 0x7D, 0x7B, 0xD5, 0x6A, 0x53
static const uint8_t Payload[102] = {
	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 size = sendto(
		sock, Payload, sizeof(Payload), 0,
		(struct sockaddr *)&addr, sizeof(addr)
	);
	if (size < 0) err(EX_IOERR, "sendto");

	return EX_OK;
}
311795bf412012ae42c0a4e4ba0afc55517f2bc8&follow=1'>Return a format->split even at the end of the stringJune McEnroe 2018-09-13Fix weird tab-complete after commaJune McEnroe 2018-09-13Rewrite UI againJune McEnroe 2018-09-12Add note about C-oJune McEnroe 2018-09-12Use formatParse split to position input cursorJune McEnroe 2018-09-12Factor out IRC formatting parsingJune McEnroe 2018-09-11Add /help equivalent to /manJune McEnroe 2018-09-11Don't render every PM as a pingJune McEnroe 2018-09-11Add urlOpenMatchJune McEnroe 2018-09-10Depend on man.sh for chroot.tar targetJune McEnroe 2018-09-10Set LESSSECURE=1 in man.shJune McEnroe 2018-09-10Add /man commandJune McEnroe 2018-09-10Install man page in chrootJune McEnroe 2018-09-10Install man pageJune McEnroe 2018-09-10Split keys into subsections and document colorsJune McEnroe 2018-09-10Add "blank" lines to chatte.1June McEnroe 2018-09-10Document key bindings in chatte.1June McEnroe 2018-09-08Document slash commands in chatte.1June McEnroe