Move curl from packages to trunk, opkg depends on it
[openwrt.git] / package / busybox / patches / 300-netmsg.patch
1 Index: busybox-1.7.2/include/applets.h
2 ===================================================================
3 --- busybox-1.7.2.orig/include/applets.h 2007-10-30 15:34:59.000000000 -0500
4 +++ busybox-1.7.2/include/applets.h 2007-10-30 15:35:03.000000000 -0500
5 @@ -241,6 +241,7 @@
6 USE_MV(APPLET(mv, _BB_DIR_BIN, _BB_SUID_NEVER))
7 USE_NAMEIF(APPLET(nameif, _BB_DIR_SBIN, _BB_SUID_NEVER))
8 USE_NC(APPLET(nc, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
9 +USE_NETMSG(APPLET_NOUSAGE(netmsg, netmsg, _BB_DIR_BIN, _BB_SUID_ALWAYS))
10 USE_NETSTAT(APPLET(netstat, _BB_DIR_BIN, _BB_SUID_NEVER))
11 USE_NICE(APPLET(nice, _BB_DIR_BIN, _BB_SUID_NEVER))
12 USE_NMETER(APPLET(nmeter, _BB_DIR_USR_BIN, _BB_SUID_NEVER))
13 Index: busybox-1.7.2/networking/Config.in
14 ===================================================================
15 --- busybox-1.7.2.orig/networking/Config.in 2007-10-30 15:34:59.000000000 -0500
16 +++ busybox-1.7.2/networking/Config.in 2007-10-30 15:35:03.000000000 -0500
17 @@ -508,6 +508,12 @@
18 help
19 A simple Unix utility which reads and writes data across network
20 connections.
21 +
22 +config NETMSG
23 + bool "netmsg"
24 + default n
25 + help
26 + simple program for sending udp broadcast messages
27
28 config NC_SERVER
29 bool "Netcat server options (-l)"
30 Index: busybox-1.7.2/networking/Kbuild
31 ===================================================================
32 --- busybox-1.7.2.orig/networking/Kbuild 2007-10-30 15:34:59.000000000 -0500
33 +++ busybox-1.7.2/networking/Kbuild 2007-10-30 15:35:03.000000000 -0500
34 @@ -21,6 +21,7 @@
35 lib-$(CONFIG_IPCALC) += ipcalc.o
36 lib-$(CONFIG_NAMEIF) += nameif.o
37 lib-$(CONFIG_NC) += nc.o
38 +lib-$(CONFIG_NETMSG) += netmsg.o
39 lib-$(CONFIG_NETSTAT) += netstat.o
40 lib-$(CONFIG_NSLOOKUP) += nslookup.o
41 lib-$(CONFIG_PING) += ping.o
42 Index: busybox-1.7.2/networking/netmsg.c
43 ===================================================================
44 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
45 +++ busybox-1.7.2/networking/netmsg.c 2007-10-30 15:35:03.000000000 -0500
46 @@ -0,0 +1,63 @@
47 +/*
48 + * Copyright (C) 2006 Felix Fietkau <nbd@openwrt.org>
49 + *
50 + * This is free software, licensed under the GNU General Public License v2.
51 + */
52 +#include <sys/types.h>
53 +#include <sys/socket.h>
54 +#include <netinet/in.h>
55 +#include <netdb.h>
56 +#include <stdio.h>
57 +#include <stdlib.h>
58 +#include <string.h>
59 +#include "busybox.h"
60 +
61 +
62 +#ifndef CONFIG_NETMSG
63 +int main(int argc, char **argv)
64 +#else
65 +int netmsg_main(int argc, char **argv)
66 +#endif
67 +{
68 + int s;
69 + struct sockaddr_in addr;
70 + int optval = 1;
71 + unsigned char buf[1001];
72 +
73 + if (argc != 3) {
74 + fprintf(stderr, "usage: %s <ip> \"<message>\"\n", argv[0]);
75 + exit(1);
76 + }
77 +
78 + if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
79 + perror("Opening socket");
80 + exit(1);
81 + }
82 +
83 + memset(&addr, 0, sizeof(addr));
84 + addr.sin_family = AF_INET;
85 + addr.sin_addr.s_addr = inet_addr(argv[1]);
86 + addr.sin_port = htons(0x1337);
87 +
88 + memset(buf, 0, 1001);
89 + buf[0] = 0xde;
90 + buf[1] = 0xad;
91 +
92 + strncpy(buf + 2, argv[2], 998);
93 +
94 + if (setsockopt (s, SOL_SOCKET, SO_BROADCAST, (caddr_t) &optval, sizeof (optval)) < 0) {
95 + perror("setsockopt()");
96 + goto fail;
97 + }
98 +
99 + if (sendto(s, buf, 1001, 0, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
100 + perror("sendto()");
101 + goto fail;
102 + }
103 +
104 + return 0;
105 +
106 +fail:
107 + close(s);
108 + exit(1);
109 +}
This page took 0.044983 seconds and 5 git commands to generate.