| 1 |
$FreeWRT$ |
| 2 |
|
| 3 |
submitted as http://bugs.busybox.net/view.php?id=1431 |
| 4 |
|
| 5 |
--- busybox-1.4.2.orig/include/applets.h Sun Mar 18 16:59:11 2007 |
| 6 |
+++ busybox-1.4.2/include/applets.h Fri Jul 20 11:39:04 2007 |
| 7 |
@@ -209,6 +209,7 @@ USE_MT(APPLET(mt, _BB_DIR_BIN, _BB_SUID_ |
| 8 |
USE_MV(APPLET(mv, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 9 |
USE_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_NEVER)) |
| 10 |
USE_NC(APPLET(nc, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
| 11 |
+USE_NETMSG(APPLET_NOUSAGE(netmsg, netmsg, _BB_DIR_BIN, _BB_SUID_ALWAYS)) |
| 12 |
USE_NETSTAT(APPLET(netstat, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 13 |
USE_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_NEVER)) |
| 14 |
USE_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_NEVER)) |
| 15 |
--- busybox-1.4.2.orig/networking/Kbuild Sun Mar 18 16:59:01 2007 |
| 16 |
+++ busybox-1.4.2/networking/Kbuild Fri Jul 20 11:39:04 2007 |
| 17 |
@@ -27,6 +27,7 @@ lib-$(CONFIG_IPRULE) += iprule.o |
| 18 |
lib-$(CONFIG_IPTUNNEL) += iptunnel.o |
| 19 |
lib-$(CONFIG_NAMEIF) += nameif.o |
| 20 |
lib-$(CONFIG_NC) += nc.o |
| 21 |
+lib-$(CONFIG_NETMSG) += netmsg.o |
| 22 |
lib-$(CONFIG_NETSTAT) += netstat.o |
| 23 |
lib-$(CONFIG_NSLOOKUP) += nslookup.o |
| 24 |
lib-$(CONFIG_PING) += ping.o |
| 25 |
--- busybox-1.4.2.orig/networking/Config.in Sun Mar 18 16:59:01 2007 |
| 26 |
+++ busybox-1.4.2/networking/Config.in Fri Jul 20 11:39:04 2007 |
| 27 |
@@ -474,6 +474,12 @@ config NC_EXTRA |
| 28 |
Add -e (support for executing the rest of the command line after |
| 29 |
making or receiving a successful connection), -i (delay interval for |
| 30 |
lines sent), -w (timeout for initial connection). |
| 31 |
+ |
| 32 |
+config NETMSG |
| 33 |
+ bool "netmsg" |
| 34 |
+ default n |
| 35 |
+ help |
| 36 |
+ simple program for sending udp broadcast messages |
| 37 |
|
| 38 |
config NETSTAT |
| 39 |
bool "netstat" |
| 40 |
--- busybox-1.4.2.orig/networking/netmsg.c Thu Jan 1 00:00:00 1970 |
| 41 |
+++ busybox-1.4.2/networking/netmsg.c Fri Jul 20 11:45:58 2007 |
| 42 |
@@ -0,0 +1,67 @@ |
| 43 |
+/* |
| 44 |
+ * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org> |
| 45 |
+ * Copyright (c) 2007 Thorsten Glaser <tg@mirbsd.org> |
| 46 |
+ * |
| 47 |
+ * This is free software, licenced under the GNU General Public License v2. |
| 48 |
+ */ |
| 49 |
+ |
| 50 |
+#include <sys/types.h> |
| 51 |
+#include <sys/socket.h> |
| 52 |
+#include <netinet/in.h> |
| 53 |
+#include <netdb.h> |
| 54 |
+#include <stdio.h> |
| 55 |
+#include <stdlib.h> |
| 56 |
+#include <string.h> |
| 57 |
+#include "busybox.h" |
| 58 |
+ |
| 59 |
+#ifndef CONFIG_NETMSG |
| 60 |
+int main(int argc, char **argv) |
| 61 |
+#else |
| 62 |
+int netmsg_main(int argc, char **argv) |
| 63 |
+#endif |
| 64 |
+{ |
| 65 |
+ int s, optval = -1, rv = 1; |
| 66 |
+ struct sockaddr_in addr; |
| 67 |
+ unsigned char buf[1001]; |
| 68 |
+ |
| 69 |
+ if (argc != 3) { |
| 70 |
+ fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]); |
| 71 |
+ return (1); |
| 72 |
+ } |
| 73 |
+ |
| 74 |
+ if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { |
| 75 |
+ perror("Opening socket"); |
| 76 |
+ return (1); |
| 77 |
+ } |
| 78 |
+ |
| 79 |
+ memset(&addr, 0, sizeof (addr)); |
| 80 |
+ addr.sin_family = AF_INET; |
| 81 |
+ addr.sin_addr.s_addr = inet_addr(argv[1]); |
| 82 |
+ addr.sin_port = htons(0x1337); |
| 83 |
+ |
| 84 |
+ while (strlen(argv[2]) > 0) { |
| 85 |
+ memset(buf, 0, sizeof (buf)); |
| 86 |
+ |
| 87 |
+ buf[0] = 0xde; |
| 88 |
+ buf[1] = 0xad; |
| 89 |
+ strlcpy(buf + 2, argv[2], sizeof (buf) - 2); |
| 90 |
+ argv[2] += strlen(buf + 2); |
| 91 |
+ |
| 92 |
+ if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, |
| 93 |
+ (caddr_t)&optval, sizeof (optval)) < 0) { |
| 94 |
+ perror("setsockopt()"); |
| 95 |
+ goto fail; |
| 96 |
+ } |
| 97 |
+ |
| 98 |
+ if (sendto(s, buf, 1001, 0, (struct sockaddr *)&addr, |
| 99 |
+ sizeof (addr)) < 0) { |
| 100 |
+ perror("sendto()"); |
| 101 |
+ goto fail; |
| 102 |
+ } |
| 103 |
+ } |
| 104 |
+ rv = 0; |
| 105 |
+ |
| 106 |
+ fail: |
| 107 |
+ close(s); |
| 108 |
+ return (rv); |
| 109 |
+} |