[tools] pkg-config: install pkg.m4 to aclocal/
[openwrt.git] / package / busybox / patches / 300-netmsg.patch
1 --- a/include/applets.src.h
2 +++ b/include/applets.src.h
3 @@ -278,6 +278,7 @@ IF_MT(APPLET(mt, _BB_DIR_BIN, _BB_SUID_D
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_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_DROP))
11 --- a/networking/Config.src
12 +++ b/networking/Config.src
13 @@ -623,6 +623,12 @@ config FEATURE_NAMEIF_EXTENDED
14 new_interface_name mac=00:80:C8:38:91:B5
15 new_interface_name 00:80:C8:38:91:B5
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,63 @@
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 +
54 +#ifndef CONFIG_NETMSG
55 +int main(int argc, char **argv)
56 +#else
57 +int netmsg_main(int argc, char **argv)
58 +#endif
59 +{
60 + int s;
61 + struct sockaddr_in addr;
62 + int optval = 1;
63 + unsigned char buf[1001];
64 +
65 + if (argc != 3) {
66 + fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
67 + exit(1);
68 + }
69 +
70 + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
71 + perror("Opening socket");
72 + exit(1);
73 + }
74 +
75 + memset(&addr, 0, sizeof(addr));
76 + addr.sin_family = AF_INET;
77 + addr.sin_addr.s_addr = inet_addr(argv[1]);
78 + addr.sin_port = htons(0x1337);
79 +
80 + memset(buf, 0, 1001);
81 + buf[0] = 0xde;
82 + buf[1] = 0xad;
83 +
84 + strncpy(buf + 2, argv[2], 998);
85 +
86 + if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
87 + perror("setsockopt()");
88 + goto fail;
89 + }
90 +
91 + if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
92 + perror("sendto()");
93 + goto fail;
94 + }
95 +
96 + return 0;
97 +
98 +fail:
99 + close(s);
100 + exit(1);
101 +}
102 --- a/include/usage.src.h
103 +++ b/include/usage.src.h
104 @@ -1,3 +1,4 @@
105 +
106 /* vi: set sw=8 ts=8: */
107 /*
108 * This file suffers from chronically incorrect tabification
109 @@ -2961,6 +2962,9 @@ INSERT
110 " or\n" \
111 "$ nameif -c /etc/my_mactab_file\n" \
112
113 +#define netmsg_trivial_usage NOUSAGE_STR
114 +#define netmsg_full_usage ""
115 +
116 #define netstat_trivial_usage \
117 "[-laentuwxr"IF_FEATURE_NETSTAT_WIDE("W")IF_FEATURE_NETSTAT_PRG("p")"]"
118 #define netstat_full_usage "\n\n" \
This page took 0.04887 seconds and 5 git commands to generate.