add support for -t 0 (infinite retry) in busybox udhcpc and use it in the network...
[openwrt.git] / package / busybox / patches / 320-httpd_address_binding.patch
1 # Copyright (C) 2006 OpenWrt.org
2 #
3 # This is free software, licensed under the GNU General Public License v2.
4 # See /LICENSE for more information.
5 #
6 diff -ruN busybox-1.2.0-old/networking/httpd.c busybox-1.2.0-new/networking/httpd.c
7 --- busybox-1.2.0-old/networking/httpd.c 2006-07-01 00:42:02.000000000 +0200
8 +++ busybox-1.2.0-new/networking/httpd.c 2006-08-01 10:06:58.000000000 +0200
9 @@ -99,6 +99,7 @@
10 #include <sys/types.h>
11 #include <sys/socket.h> /* for connect and socket*/
12 #include <netinet/in.h> /* for sockaddr_in */
13 +#include <arpa/inet.h>
14 #include <sys/stat.h>
15 #include <sys/wait.h>
16 #include <fcntl.h> /* for open modes */
17 @@ -165,6 +166,7 @@
18 #endif
19 unsigned port; /* server initial port and for
20 set env REMOTE_PORT */
21 + char *address;
22 union HTTPD_FOUND {
23 const char *found_mime_type;
24 const char *found_moved_temporarily;
25 @@ -868,7 +870,10 @@
26 /* inet_addr() returns a value that is already in network order */
27 memset(&lsocket, 0, sizeof(lsocket));
28 lsocket.sin_family = AF_INET;
29 - lsocket.sin_addr.s_addr = INADDR_ANY;
30 + if (inet_aton(config->address, &(lsocket.sin_addr)) == 1) {
31 + if (config->address != NULL) lsocket.sin_addr.s_addr = ((struct in_addr *) ((gethostbyname(config->address))->h_addr))->s_addr;
32 + else lsocket.sin_addr.s_addr = htons(INADDR_ANY);
33 + }
34 lsocket.sin_port = htons(config->port);
35 fd = bb_xsocket(AF_INET, SOCK_STREAM, 0);
36 /* tell the OS it's OK to reuse a previous address even though */
37 @@ -1899,6 +1904,7 @@
38 USE_FEATURE_HTTPD_AUTH_MD5(m_opt_md5,)
39 USE_FEATURE_HTTPD_SETUID(u_opt_setuid,)
40 USE_FEATURE_HTTPD_WITHOUT_INETD(p_opt_port,)
41 + USE_FEATURE_HTTPD_WITHOUT_INETD(l_opt_addr,)
42 };
43
44 static const char httpd_opts[]="c:d:h:"
45 @@ -1906,7 +1912,7 @@
46 USE_FEATURE_HTTPD_BASIC_AUTH("r:")
47 USE_FEATURE_HTTPD_AUTH_MD5("m:")
48 USE_FEATURE_HTTPD_SETUID("u:")
49 - USE_FEATURE_HTTPD_WITHOUT_INETD("p:");
50 + USE_FEATURE_HTTPD_WITHOUT_INETD("p:l:");
51
52 #define OPT_CONFIG_FILE (1<<c_opt_config_file)
53 #define OPT_DECODE_URL (1<<d_opt_decode_url)
54 @@ -1927,6 +1933,8 @@
55 #define OPT_PORT USE_FEATURE_HTTPD_WITHOUT_INETD((1<<p_opt_port)) \
56 SKIP_FEATURE_HTTPD_WITHOUT_INETD(0)
57
58 +#define OPT_ADDRESS USE_FEATURE_HTTPD_WITHOUT_INETD((1<<l_opt_addr)) \
59 + SKIP_FEATURE_HTTPD_WITHOUT_INETD(0)
60
61 int httpd_main(int argc, char *argv[])
62 {
63 @@ -1935,6 +1943,7 @@
64 char *url_for_decode;
65 USE_FEATURE_HTTPD_ENCODE_URL_STR(const char *url_for_encode;)
66 USE_FEATURE_HTTPD_WITHOUT_INETD(const char *s_port;)
67 + USE_FEATURE_HTTPD_WITHOUT_INETD(const char *s_addr;)
68 USE_FEATURE_HTTPD_WITHOUT_INETD(int server;)
69
70 USE_FEATURE_HTTPD_SETUID(const char *s_uid;)
71 @@ -1949,6 +1958,7 @@
72
73 #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
74 config->port = 80;
75 + config->address = "";
76 #endif
77
78 config->ContentLength = -1;
79 @@ -1960,6 +1970,7 @@
80 USE_FEATURE_HTTPD_AUTH_MD5(, &pass)
81 USE_FEATURE_HTTPD_SETUID(, &s_uid)
82 USE_FEATURE_HTTPD_WITHOUT_INETD(, &s_port)
83 + USE_FEATURE_HTTPD_WITHOUT_INETD(, &s_addr)
84 );
85
86 if(opt & OPT_DECODE_URL) {
87 @@ -1981,6 +1992,8 @@
88 #ifdef CONFIG_FEATURE_HTTPD_WITHOUT_INETD
89 if(opt & OPT_PORT)
90 config->port = bb_xgetlarg(s_port, 10, 1, 0xffff);
91 + if (opt & OPT_ADDRESS)
92 + if (s_addr) config->address = (char *) s_addr;
93 #ifdef CONFIG_FEATURE_HTTPD_SETUID
94 if(opt & OPT_SETUID) {
95 char *e;
This page took 0.048147 seconds and 5 git commands to generate.