English Language flag
// Log In
// CVSweb
Project: FreeWRT
// Summary // Activity // Search // Tracker // Lists // News // SCM // Wiki

SCM Repository

ViewVC logotype

Diff of /branches/common-nfo/package/busybox/patches/300-netmsg.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3426 by tg, Wed Jul 18 12:45:43 2007 UTC revision 3427 by tg, Wed Aug 8 11:08:41 2007 UTC
# Line 1  Line 1 
1  diff -Nur busybox-1.4.1.orig/include/applets.h busybox-1.4.1/include/applets.h  $FreeWRT$
2  --- busybox-1.4.1.orig/include/applets.h        2007-01-24 22:34:48.000000000 +0100  
3  +++ busybox-1.4.1/include/applets.h     2007-02-05 13:11:49.000000000 +0100          submitted as http://bugs.busybox.net/view.php?id=1431
4  @@ -209,6 +209,7 @@  
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))   USE_MV(APPLET(mv, _BB_DIR_BIN, _BB_SUID_NEVER))
9   USE_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_NEVER))   USE_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_NEVER))
10   USE_NC(APPLET(nc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))   USE_NC(APPLET(nc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
# Line 9  diff -Nur busybox-1.4.1.orig/include/app Line 12  diff -Nur busybox-1.4.1.orig/include/app
12   USE_NETSTAT(APPLET(netstat, _BB_DIR_BIN, _BB_SUID_NEVER))   USE_NETSTAT(APPLET(netstat, _BB_DIR_BIN, _BB_SUID_NEVER))
13   USE_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_NEVER))   USE_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_NEVER))
14   USE_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_NEVER))   USE_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
15  diff -Nur busybox-1.4.1.orig/networking/Config.in busybox-1.4.1/networking/Config.in  --- busybox-1.4.2.orig/networking/Kbuild        Sun Mar 18 16:59:01 2007
16  --- busybox-1.4.1.orig/networking/Config.in     2007-01-24 22:34:34.000000000 +0100  +++ busybox-1.4.2/networking/Kbuild     Fri Jul 20 11:39:04 2007
17  +++ busybox-1.4.1/networking/Config.in  2007-02-05 13:12:25.000000000 +0100  @@ -27,6 +27,7 @@ lib-$(CONFIG_IPRULE)       += iprule.o
18  @@ -458,7 +458,7 @@   lib-$(CONFIG_IPTUNNEL)     += iptunnel.o
19          help   lib-$(CONFIG_NAMEIF)       += nameif.o
20            A simple Unix utility which reads and writes data across network   lib-$(CONFIG_NC)           += nc.o
21            connections.  +lib-$(CONFIG_NETMSG)       += netmsg.o
22  -   lib-$(CONFIG_NETSTAT)      += netstat.o
23  +           lib-$(CONFIG_NSLOOKUP)     += nslookup.o
24   config NC_SERVER   lib-$(CONFIG_PING)         += ping.o
25          bool "Netcat server options (-lp)"  --- busybox-1.4.2.orig/networking/Config.in     Sun Mar 18 16:59:01 2007
26          default n  +++ busybox-1.4.2/networking/Config.in  Fri Jul 20 11:39:04 2007
27  @@ -475,6 +475,12 @@  @@ -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            making or receiving a successful connection), -i (delay interval for
30            lines sent), -w (timeout for initial connection).            lines sent), -w (timeout for initial connection).
31    +
32  +config NETMSG  +config NETMSG
33  +       bool "netmsg"  +       bool "netmsg"
34  +       default n  +       default n
35  +       help  +       help
36  +         simple program for sending udp broadcast messages  +         simple program for sending udp broadcast messages
37  +  
38   config NETSTAT   config NETSTAT
39          bool "netstat"          bool "netstat"
40          default n  --- busybox-1.4.2.orig/networking/netmsg.c      Thu Jan  1 00:00:00 1970
41  diff -Nur busybox-1.4.1.orig/networking/Kbuild busybox-1.4.1/networking/Kbuild  +++ busybox-1.4.2/networking/netmsg.c   Fri Jul 20 11:45:58 2007
42  --- busybox-1.4.1.orig/networking/Kbuild        2007-01-24 22:34:34.000000000 +0100  @@ -0,0 +1,67 @@
 +++ busybox-1.4.1/networking/Kbuild     2007-02-05 13:11:49.000000000 +0100  
 @@ -27,6 +27,7 @@  
  lib-$(CONFIG_IPTUNNEL)     += iptunnel.o  
  lib-$(CONFIG_NAMEIF)       += nameif.o  
  lib-$(CONFIG_NC)           += nc.o  
 +lib-$(CONFIG_NETMSG)       += netmsg.o  
  lib-$(CONFIG_NETSTAT)      += netstat.o  
  lib-$(CONFIG_NSLOOKUP)     += nslookup.o  
  lib-$(CONFIG_PING)         += ping.o  
 diff -Nur busybox-1.4.1.orig/networking/netmsg.c busybox-1.4.1/networking/netmsg.c  
 --- busybox-1.4.1.orig/networking/netmsg.c      1970-01-01 01:00:00.000000000 +0100  
 +++ busybox-1.4.1/networking/netmsg.c   2007-02-05 13:11:49.000000000 +0100  
 @@ -0,0 +1,63 @@  
43  +/*  +/*
44  + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>  + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
45    + * Copyright (c) 2007 Thorsten Glaser <tg@mirbsd.org>
46  + *  + *
47  + * This is free software, licensed under the GNU General Public License v2.  + * This is free software, licenced under the GNU General Public License v2.
48  + */  + */
49    +
50  +#include <sys/types.h>  +#include <sys/types.h>
51  +#include <sys/socket.h>  +#include <sys/socket.h>
52  +#include <netinet/in.h>  +#include <netinet/in.h>
# Line 63  diff -Nur busybox-1.4.1.orig/networking/ Line 56  diff -Nur busybox-1.4.1.orig/networking/
56  +#include <string.h>  +#include <string.h>
57  +#include "busybox.h"  +#include "busybox.h"
58  +  +
 +  
59  +#ifndef CONFIG_NETMSG  +#ifndef CONFIG_NETMSG
60  +int main(int argc, char **argv)  +int main(int argc, char **argv)
61  +#else  +#else
62  +int netmsg_main(int argc, char **argv)  +int netmsg_main(int argc, char **argv)
63  +#endif  +#endif
64  +{  +{
65  +       int s;  +       int s, optval = -1, rv = 1;
66  +       struct sockaddr_in addr;  +       struct sockaddr_in addr;
 +       int optval = 1;  
67  +       unsigned char buf[1001];  +       unsigned char buf[1001];
68  +  +
69  +       if (argc != 3) {  +       if (argc != 3) {
70  +               fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);  +               fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
71  +               exit(1);  +               return (1);
72  +       }  +       }
73  +  +
74  +       if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {  +       if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
75  +               perror("Opening socket");  +               perror("Opening socket");
76  +               exit(1);  +               return (1);
77  +       }  +       }
78  +  +
79  +       memset(&addr, 0, sizeof(addr));  +       memset(&addr, 0, sizeof (addr));
80  +       addr.sin_family = AF_INET;  +       addr.sin_family = AF_INET;
81  +       addr.sin_addr.s_addr = inet_addr(argv[1]);  +       addr.sin_addr.s_addr = inet_addr(argv[1]);
82  +       addr.sin_port = htons(0x1337);  +       addr.sin_port = htons(0x1337);
83  +  +
84  +       memset(buf, 0, 1001);  +       while (strlen(argv[2]) > 0) {
85  +       buf[0] = 0xde;  +               memset(buf, 0, sizeof (buf));
 +       buf[1] = 0xad;  
 +  
 +       strncpy(buf + 2, argv[2], 998);  
 +  
 +       if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {  
 +               perror("setsockopt()");  
 +               goto fail;  
 +       }  
86  +  +
87  +       if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {  +               buf[0] = 0xde;
88  +               perror("sendto()");  +               buf[1] = 0xad;
89  +               goto fail;  +               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  +       return 0;  + fail:
 +        
 +fail:  
107  +       close(s);  +       close(s);
108  +       exit(1);  +       return (rv);
109  +}  +}

Legend:
Removed from v.3426  
changed lines
  Added in v.3427

root@freewrt.org:443
ViewVC Help
Powered by ViewVC 1.1.20