[package] iwinfo: implement proper hardware detection for ar23xx SoC devices like...
[openwrt.git] / package / busybox / patches / 300-netmsg.patch
1 --- a/include/applets.src.h
2 +++ b/include/applets.src.h
3 @@ -266,6 +266,7 @@ IF_MT(APPLET(mt, BB_DIR_BIN, BB_SUID_DRO
4 IF_MV(APPLET(mv, BB_DIR_BIN, BB_SUID_DROP))
5 IF_NAMEIF(APPLET(nameif, BB_DIR_SBIN, BB_SUID_DROP))
6 IF_NC(APPLET(nc, BB_DIR_USR_BIN, BB_SUID_DROP))
7 +IF_NETMSG(APPLET(netmsg, BB_DIR_BIN, BB_SUID_REQUIRE))
8 IF_NETSTAT(APPLET(netstat, BB_DIR_BIN, BB_SUID_DROP))
9 IF_NICE(APPLET(nice, BB_DIR_BIN, BB_SUID_DROP))
10 IF_NOHUP(APPLET(nohup, BB_DIR_USR_BIN, BB_SUID_DROP))
11 --- a/networking/Config.src
12 +++ b/networking/Config.src
13 @@ -612,6 +612,12 @@ config FEATURE_IPCALC_LONG_OPTIONS
14 help
15 Support long options for the ipcalc applet.
16
17 +config NETMSG
18 + bool "netmsg"
19 + default n
20 + help
21 + simple program for sending udp broadcast messages
22 +
23 config NETSTAT
24 bool "netstat"
25 default y
26 --- a/networking/Kbuild.src
27 +++ b/networking/Kbuild.src
28 @@ -27,6 +27,7 @@ lib-$(CONFIG_IP) += ip.o
29 lib-$(CONFIG_IPCALC) += ipcalc.o
30 lib-$(CONFIG_NAMEIF) += nameif.o
31 lib-$(CONFIG_NC) += nc.o
32 +lib-$(CONFIG_NETMSG) += netmsg.o
33 lib-$(CONFIG_NETSTAT) += netstat.o
34 lib-$(CONFIG_NSLOOKUP) += nslookup.o
35 lib-$(CONFIG_NTPD) += ntpd.o
36 --- /dev/null
37 +++ b/networking/netmsg.c
38 @@ -0,0 +1,65 @@
39 +/*
40 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
41 + *
42 + * This is free software, licensed under the GNU General Public License v2.
43 + */
44 +#include <sys/types.h>
45 +#include <sys/socket.h>
46 +#include <netinet/in.h>
47 +#include <netdb.h>
48 +#include <stdio.h>
49 +#include <stdlib.h>
50 +#include <string.h>
51 +#include "busybox.h"
52 +
53 +//usage:#define netmsg_trivial_usage NOUSAGE_STR
54 +//usage:#define netmsg_full_usage ""
55 +
56 +#ifndef CONFIG_NETMSG
57 +int main(int argc, char **argv)
58 +#else
59 +int netmsg_main(int argc, char **argv)
60 +#endif
61 +{
62 + int s;
63 + struct sockaddr_in addr;
64 + int optval = 1;
65 + unsigned char buf[1001];
66 +
67 + if (argc != 3) {
68 + fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
69 + exit(1);
70 + }
71 +
72 + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
73 + perror("Opening socket");
74 + exit(1);
75 + }
76 +
77 + memset(&addr, 0, sizeof(addr));
78 + addr.sin_family = AF_INET;
79 + addr.sin_addr.s_addr = inet_addr(argv[1]);
80 + addr.sin_port = htons(0x1337);
81 +
82 + memset(buf, 0, 1001);
83 + buf[0] = 0xde;
84 + buf[1] = 0xad;
85 +
86 + strncpy(buf + 2, argv[2], 998);
87 +
88 + if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
89 + perror("setsockopt()");
90 + goto fail;
91 + }
92 +
93 + if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
94 + perror("sendto()");
95 + goto fail;
96 + }
97 +
98 + return 0;
99 +
100 +fail:
101 + close(s);
102 + exit(1);
103 +}
This page took 0.049083 seconds and 5 git commands to generate.