2 +++ b/networking/netmsg.c
5 + * Copyright (C) 2006 Felix Fietkau <nbd@nbd.name>
7 + * This is free software, licensed under the GNU General Public License v2.
10 +//config:config NETMSG
11 +//config: bool "netmsg"
14 +//config: simple program for sending udp broadcast messages
16 +//applet:IF_NETMSG(APPLET(netmsg, BB_DIR_BIN, BB_SUID_REQUIRE))
18 +//kbuild:lib-$(CONFIG_NETMSG) += netmsg.o
20 +//usage:#define netmsg_trivial_usage NOUSAGE_STR
21 +//usage:#define netmsg_full_usage ""
23 +#include <sys/types.h>
24 +#include <sys/socket.h>
25 +#include <netinet/in.h>
32 +#ifndef CONFIG_NETMSG
33 +int main(int argc, char **argv)
35 +int netmsg_main(int argc, char **argv)
39 + struct sockaddr_in addr;
41 + unsigned char buf[1001];
44 + fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
48 + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
49 + perror("Opening socket");
53 + memset(&addr, 0, sizeof(addr));
54 + addr.sin_family = AF_INET;
55 + addr.sin_addr.s_addr = inet_addr(argv[1]);
56 + addr.sin_port = htons(0x1337);
58 + memset(buf, 0, 1001);
62 + strncpy(buf + 2, argv[2], 998);
64 + if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
65 + perror("setsockopt()");
69 + if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {