summaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko2016-04-21 16:26:30 +0200
committerDenys Vlasenko2016-04-21 17:39:11 +0200
commite6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a (patch)
tree0962142ac9830312cd3df52994db41e8ac47c73c /networking
parent5598bdf0d3d46a865a4d23785e2d09e6db9be420 (diff)
downloadbusybox-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.zip
busybox-e6a2f4cc5a47d3022bdf5ca2cacbaa5a8c5baf7a.tar.gz
libbb: make bb_common_bufsiz1 1 kbyte, add capability to use bss tail for it
The config item is FEATURE_USE_BSS_TAIL. When it is off (default): function old new delta read_config 210 228 +18 doCommands 2279 2294 +15 ipneigh_list_or_flush 763 772 +9 ipaddr_list_or_flush 1256 1261 +5 display_process_list 1301 1306 +5 conspy_main 1378 1383 +5 do_lzo_compress 352 355 +3 do_lzo_decompress 565 567 +2 push 46 44 -2 inetd_main 2136 2134 -2 uevent_main 421 418 -3 addLines 97 92 -5 bb_common_bufsiz1 8193 1024 -7169 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 8/5 up/down: 62/-7181) Total: -7119 bytes text data bss dec hex filename 829850 4086 9080 843016 cdd08 busybox_old 829901 4086 1904 835891 cc133 busybox_unstripped FEATURE_USE_BSS_TAIL=y: read_config 210 228 +18 doCommands 2279 2294 +15 ipneigh_list_or_flush 763 772 +9 ipaddr_list_or_flush 1256 1261 +5 display_process_list 1301 1306 +5 conspy_main 1378 1383 +5 do_lzo_compress 352 355 +3 do_lzo_decompress 565 567 +2 inetd_main 2136 2134 -2 bb_common_bufsiz1 8193 - -8193 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 8/1 up/down: 62/-8195) Total: -8133 bytes text data bss dec hex filename 829850 4086 9080 843016 cdd08 busybox_old 829911 4086 880 834877 cbd3d busybox_unstripped FIXME: setup_common_bufsiz() calls are missing. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/arp.c3
-rw-r--r--networking/arping.c3
-rw-r--r--networking/ftpd.c3
-rw-r--r--networking/ftpgetput.c3
-rw-r--r--networking/httpd.c10
-rw-r--r--networking/ifupdown.c3
-rw-r--r--networking/inetd.c3
-rw-r--r--networking/isrv_identd.c6
-rw-r--r--networking/libiproute/ipaddress.c3
-rw-r--r--networking/libiproute/ipneigh.c3
-rw-r--r--networking/libiproute/iproute.c3
-rw-r--r--networking/nc.c3
-rw-r--r--networking/ping.c5
-rw-r--r--networking/slattach.c3
-rw-r--r--networking/tc.c3
-rw-r--r--networking/tcpudp.c3
-rw-r--r--networking/telnet.c3
-rw-r--r--networking/telnetd.c3
-rw-r--r--networking/tftp.c6
-rw-r--r--networking/udhcp/common.h1
-rw-r--r--networking/udhcp/dhcpd.h2
-rw-r--r--networking/udhcp/dhcprelay.c2
-rw-r--r--networking/udhcp/files.c46
-rw-r--r--networking/zcip.c3
24 files changed, 76 insertions, 50 deletions
diff --git a/networking/arp.c b/networking/arp.c
index 0099aa5..5f78186 100644
--- a/networking/arp.c
+++ b/networking/arp.c
@@ -32,6 +32,7 @@
//usage: "\n -H HWTYPE Hardware address type"
#include "libbb.h"
+#include "common_bufsiz.h"
#include "inet_common.h"
#include <arpa/inet.h>
@@ -69,7 +70,7 @@ struct globals {
const char *device; /* current device */
smallint hw_set; /* flag if hw-type was set (-H) */
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define ap (G.ap )
#define hw (G.hw )
#define device (G.device )
diff --git a/networking/arping.c b/networking/arping.c
index ef205e5..52f5ba5 100644
--- a/networking/arping.c
+++ b/networking/arping.c
@@ -28,6 +28,7 @@
#include <netpacket/packet.h>
#include "libbb.h"
+#include "common_bufsiz.h"
/* We don't expect to see 1000+ seconds delay, unsigned is enough */
#define MONOTONIC_US() ((unsigned)monotonic_us())
@@ -60,7 +61,7 @@ struct globals {
unsigned brd_recv;
unsigned req_recv;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define src (G.src )
#define dst (G.dst )
#define me (G.me )
diff --git a/networking/ftpd.c b/networking/ftpd.c
index 8345ae6..8553a28 100644
--- a/networking/ftpd.c
+++ b/networking/ftpd.c
@@ -29,6 +29,7 @@
//usage: "\n DIR Change root to this directory"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <syslog.h>
#include <netinet/tcp.h>
@@ -123,7 +124,7 @@ struct globals {
char msg_ok [(sizeof("NNN " MSG_OK ) + 3) & 0xfffc];
char msg_err[(sizeof("NNN " MSG_ERR) + 3) & 0xfffc];
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
/* Moved to main */ \
/*strcpy(G.msg_ok + 4, MSG_OK );*/ \
diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c
index b398bc8..61bc45c 100644
--- a/networking/ftpgetput.c
+++ b/networking/ftpgetput.c
@@ -50,6 +50,7 @@
//usage: )
#include "libbb.h"
+#include "common_bufsiz.h"
struct globals {
const char *user;
@@ -60,7 +61,7 @@ struct globals {
int do_continue;
char buf[4]; /* actually [BUFSZ] */
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
enum { BUFSZ = COMMON_BUFSIZE - offsetof(struct globals, buf) };
#define user (G.user )
#define password (G.password )
diff --git a/networking/httpd.c b/networking/httpd.c
index ed15fd8..ef90770 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -125,6 +125,7 @@
//usage: "\n -d STRING URL decode STRING"
#include "libbb.h"
+#include "common_bufsiz.h"
#if ENABLE_PAM
/* PAM may include <locale.h>. We may need to undefine bbox's stub define: */
# undef setlocale
@@ -307,7 +308,8 @@ struct globals {
Htaccess *script_i; /* config script interpreters */
#endif
char *iobuf; /* [IOBUF_SIZE] */
-#define hdr_buf bb_common_bufsiz1
+#define hdr_buf bb_common_bufsiz1
+#define sizeof_hdr_buf COMMON_BUFSIZE
char *hdr_ptr;
int hdr_cnt;
#if ENABLE_FEATURE_HTTPD_ERROR_PAGES
@@ -1066,7 +1068,7 @@ static int get_line(void)
alarm(HEADER_READ_TIMEOUT);
while (1) {
if (hdr_cnt <= 0) {
- hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
+ hdr_cnt = safe_read(STDIN_FILENO, hdr_buf, sizeof_hdr_buf);
if (hdr_cnt <= 0)
break;
hdr_ptr = hdr_buf;
@@ -1191,9 +1193,9 @@ static NOINLINE void cgi_io_loop_and_exit(int fromCgi_rd, int toCgi_wr, int post
/* We expect data, prev data portion is eaten by CGI
* and there *is* data to read from the peer
* (POSTDATA) */
- //count = post_len > (int)sizeof(hdr_buf) ? (int)sizeof(hdr_buf) : post_len;
+ //count = post_len > (int)sizeof_hdr_buf ? (int)sizeof_hdr_buf : post_len;
//count = safe_read(STDIN_FILENO, hdr_buf, count);
- count = safe_read(STDIN_FILENO, hdr_buf, sizeof(hdr_buf));
+ count = safe_read(STDIN_FILENO, hdr_buf, sizeof_hdr_buf);
if (count > 0) {
hdr_cnt = count;
hdr_ptr = hdr_buf;
diff --git a/networking/ifupdown.c b/networking/ifupdown.c
index 2c6db92..399ff6b 100644
--- a/networking/ifupdown.c
+++ b/networking/ifupdown.c
@@ -44,6 +44,7 @@
//usage: "\n -f Force de/configuration"
#include "libbb.h"
+#include "common_bufsiz.h"
/* After libbb.h, since it needs sys/types.h on some systems */
#include <sys/utsname.h>
#include <fnmatch.h>
@@ -129,7 +130,7 @@ struct globals {
const char *startup_PATH;
char *shell;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0)
diff --git a/networking/inetd.c b/networking/inetd.c
index 4f6673b..aa35ffa 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -170,6 +170,7 @@
#include <sys/un.h>
#include "libbb.h"
+#include "common_bufsiz.h"
#if ENABLE_FEATURE_INETD_RPC
# if defined(__UCLIBC__) && ! defined(__UCLIBC_HAS_RPC__)
@@ -327,7 +328,7 @@ struct globals {
/* Used in next_line(), and as scratch read buffer */
char line[256]; /* _at least_ 256, see LINE_SIZE */
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
enum { LINE_SIZE = COMMON_BUFSIZE - offsetof(struct globals, line) };
#define rlim_ofile_cur (G.rlim_ofile_cur )
#define rlim_ofile (G.rlim_ofile )
diff --git a/networking/isrv_identd.c b/networking/isrv_identd.c
index 252c8ab..f63ed8e 100644
--- a/networking/isrv_identd.c
+++ b/networking/isrv_identd.c
@@ -18,6 +18,7 @@
//usage: "\n STRING Ident answer string (default: nobody)"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <syslog.h>
#include "isrv.h"
@@ -28,7 +29,8 @@ typedef struct identd_buf_t {
char buf[64 - sizeof(int)];
} identd_buf_t;
-#define bogouser bb_common_bufsiz1
+#define bogouser bb_common_bufsiz1
+#define sizeof_bogouser COMMON_BUFSIZE
static int new_peer(isrv_state_t *state, int fd)
{
@@ -118,7 +120,7 @@ int fakeidentd_main(int argc UNUSED_PARAM, char **argv)
opt = getopt32(argv, "fiwb:", &bind_address);
strcpy(bogouser, "nobody");
if (argv[optind])
- strncpy(bogouser, argv[optind], sizeof(bogouser) - 1);
+ strncpy(bogouser, argv[optind], sizeof_bogouser - 1);
/* Daemonize if no -f and no -i and no -w */
if (!(opt & OPT_fiw))
diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c
index 5c975d8..2c0f514 100644
--- a/networking/libiproute/ipaddress.c
+++ b/networking/libiproute/ipaddress.c
@@ -13,6 +13,7 @@
#include <net/if_arp.h>
#include "ip_common.h" /* #include "libbb.h" is inside */
+#include "common_bufsiz.h"
#include "rt_names.h"
#include "utils.h"
@@ -39,7 +40,7 @@ struct filter_t {
} FIX_ALIASING;
typedef struct filter_t filter_t;
-#define G_filter (*(filter_t*)&bb_common_bufsiz1)
+#define G_filter (*(filter_t*)bb_common_bufsiz1)
static void print_link_flags(unsigned flags, unsigned mdown)
diff --git a/networking/libiproute/ipneigh.c b/networking/libiproute/ipneigh.c
index 179505c..151d3d1 100644
--- a/networking/libiproute/ipneigh.c
+++ b/networking/libiproute/ipneigh.c
@@ -8,6 +8,7 @@
*/
#include "ip_common.h" /* #include "libbb.h" is inside */
+#include "common_bufsiz.h"
#include "rt_names.h"
#include "utils.h"
#include <linux/neighbour.h>
@@ -40,7 +41,7 @@ struct filter_t {
} FIX_ALIASING;
typedef struct filter_t filter_t;
-#define G_filter (*(filter_t*)&bb_common_bufsiz1)
+#define G_filter (*(filter_t*)bb_common_bufsiz1)
static int flush_update(void)
{
diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c
index 8282748..34d4f47 100644
--- a/networking/libiproute/iproute.c
+++ b/networking/libiproute/iproute.c
@@ -11,6 +11,7 @@
*/
#include "ip_common.h" /* #include "libbb.h" is inside */
+#include "common_bufsiz.h"
#include "rt_names.h"
#include "utils.h"
@@ -43,7 +44,7 @@ struct filter_t {
} FIX_ALIASING;
typedef struct filter_t filter_t;
-#define G_filter (*(filter_t*)&bb_common_bufsiz1)
+#define G_filter (*(filter_t*)bb_common_bufsiz1)
static int flush_update(void)
{
diff --git a/networking/nc.c b/networking/nc.c
index 2f9e174..50edee4 100644
--- a/networking/nc.c
+++ b/networking/nc.c
@@ -8,6 +8,7 @@
*/
#include "libbb.h"
+#include "common_bufsiz.h"
//config:config NC
//config: bool "nc"
@@ -252,7 +253,7 @@ int nc_main(int argc, char **argv)
fd = STDIN_FILENO;
while (1) {
if (FD_ISSET(fd, &testfds)) {
- nread = safe_read(fd, iobuf, sizeof(iobuf));
+ nread = safe_read(fd, iobuf, COMMON_BUFSIZE);
if (fd == cfd) {
if (nread < 1)
exit(EXIT_SUCCESS);
diff --git a/networking/ping.c b/networking/ping.c
index 0eb1ae7..7616609 100644
--- a/networking/ping.c
+++ b/networking/ping.c
@@ -28,6 +28,7 @@
#include <net/if.h>
#include <netinet/ip_icmp.h>
#include "libbb.h"
+#include "common_bufsiz.h"
#ifdef __BIONIC__
/* should be in netinet/ip_icmp.h */
@@ -186,7 +187,7 @@ struct globals {
char *hostname;
char packet[DEFDATALEN + MAXIPLEN + MAXICMPLEN];
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0)
static void noresp(int ign UNUSED_PARAM)
@@ -378,7 +379,7 @@ struct globals {
} pingaddr;
unsigned char rcvd_tbl[MAX_DUP_CHK / 8];
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define if_index (G.if_index )
#define source_lsa (G.source_lsa )
#define str_I (G.str_I )
diff --git a/networking/slattach.c b/networking/slattach.c
index 14e0c19..d9d8fe7 100644
--- a/networking/slattach.c
+++ b/networking/slattach.c
@@ -27,6 +27,7 @@
//usage: "\n -F Disable RTS/CTS flow control"
#include "libbb.h"
+#include "common_bufsiz.h"
#include "libiproute/utils.h" /* invarg_1_to_2() */
struct globals {
@@ -34,7 +35,7 @@ struct globals {
int saved_disc;
struct termios saved_state;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define handle (G.handle )
#define saved_disc (G.saved_disc )
#define saved_state (G.saved_state )
diff --git a/networking/tc.c b/networking/tc.c
index c84c18a..1372ca0 100644
--- a/networking/tc.c
+++ b/networking/tc.c
@@ -29,6 +29,7 @@
//usage: "filter show [ dev STRING ] [ root | parent CLASSID ]"
#include "libbb.h"
+#include "common_bufsiz.h"
#include "libiproute/utils.h"
#include "libiproute/ip_common.h"
@@ -63,7 +64,7 @@ struct globals {
uint32_t filter_prio;
uint32_t filter_proto;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define filter_ifindex (G.filter_ifindex)
#define filter_qdisc (G.filter_qdisc)
#define filter_parent (G.filter_parent)
diff --git a/networking/tcpudp.c b/networking/tcpudp.c
index 3df6a98..6249730 100644
--- a/networking/tcpudp.c
+++ b/networking/tcpudp.c
@@ -67,6 +67,7 @@
//usage: "\n -v Verbose"
#include "libbb.h"
+#include "common_bufsiz.h"
/* Wants <limits.h> etc, thus included after libbb.h: */
#ifdef __linux__
@@ -91,7 +92,7 @@ struct globals {
char **env_cur;
char *env_var[1]; /* actually bigger */
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define verbose (G.verbose )
#define max_per_host (G.max_per_host)
#define cur_per_host (G.cur_per_host)
diff --git a/networking/telnet.c b/networking/telnet.c
index 944cf1b..2946bc8 100644
--- a/networking/telnet.c
+++ b/networking/telnet.c
@@ -39,6 +39,7 @@
#include <arpa/telnet.h>
#include <netinet/in.h>
#include "libbb.h"
+#include "common_bufsiz.h"
#ifdef __BIONIC__
/* should be in arpa/telnet.h */
@@ -108,7 +109,7 @@ struct globals {
struct termios termios_def;
struct termios termios_raw;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0)
diff --git a/networking/telnetd.c b/networking/telnetd.c
index 25d05fe..13d5a8f 100644
--- a/networking/telnetd.c
+++ b/networking/telnetd.c
@@ -44,6 +44,7 @@
#define DEBUG 0
#include "libbb.h"
+#include "common_bufsiz.h"
#include <syslog.h>
#if DEBUG
@@ -82,7 +83,7 @@ struct globals {
const char *issuefile;
int maxfd;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
G.loginpath = "/bin/login"; \
G.issuefile = "/etc/issue.net"; \
diff --git a/networking/tftp.c b/networking/tftp.c
index ad9308e..8aeb79a 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -51,6 +51,7 @@
//usage: "\n -l Log to syslog (inetd mode requires this)"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <syslog.h>
#if ENABLE_FEATURE_TFTP_GET || ENABLE_FEATURE_TFTP_PUT
@@ -128,7 +129,7 @@ struct globals {
bb_progress_t pmt;
#endif
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { \
BUILD_BUG_ON(sizeof(G) > COMMON_BUFSIZE); \
} while (0)
@@ -757,7 +758,8 @@ int tftpd_main(int argc UNUSED_PARAM, char **argv)
{
len_and_sockaddr *our_lsa;
len_and_sockaddr *peer_lsa;
- char *local_file, *mode, *user_opt;
+ char *mode, *user_opt;
+ char *local_file = local_file;
const char *error_msg;
int opt, result, opcode;
IF_FEATURE_TFTP_BLOCKSIZE(int blksize = TFTP_BLKSIZE_DEFAULT;)
diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h
index 496ab11..a526494 100644
--- a/networking/udhcp/common.h
+++ b/networking/udhcp/common.h
@@ -9,6 +9,7 @@
#define UDHCP_COMMON_H 1
#include "libbb.h"
+#include "common_bufsiz.h"
#include <netinet/udp.h>
#include <netinet/ip.h>
diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h
index 183e7e2..9dd5bef 100644
--- a/networking/udhcp/dhcpd.h
+++ b/networking/udhcp/dhcpd.h
@@ -57,7 +57,7 @@ struct server_config_t {
struct static_lease *static_leases; /* List of ip/mac pairs to assign static leases */
} FIX_ALIASING;
-#define server_config (*(struct server_config_t*)&bb_common_bufsiz1)
+#define server_config (*(struct server_config_t*)bb_common_bufsiz1)
/* client_config sits in 2nd half of bb_common_bufsiz1 */
#if ENABLE_FEATURE_UDHCP_PORT
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c
index f82ac05..1722a85 100644
--- a/networking/udhcp/dhcprelay.c
+++ b/networking/udhcp/dhcprelay.c
@@ -33,7 +33,7 @@ struct xid_item {
struct xid_item *next;
} FIX_ALIASING;
-#define dhcprelay_xid_list (*(struct xid_item*)&bb_common_bufsiz1)
+#define dhcprelay_xid_list (*(struct xid_item*)bb_common_bufsiz1)
static struct xid_item *xid_add(uint32_t xid, struct sockaddr_in *ip, int client)
{
diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c
index 7b57c62..b224253 100644
--- a/networking/udhcp/files.c
+++ b/networking/udhcp/files.c
@@ -57,33 +57,35 @@ static int FAST_FUNC read_staticlease(const char *const_line, void *arg)
struct config_keyword {
const char *keyword;
int (*handler)(const char *line, void *var) FAST_FUNC;
- void *var;
+ unsigned ofs;
const char *def;
};
+#define OFS(field) offsetof(struct server_config_t, field)
+
static const struct config_keyword keywords[] = {
/* keyword handler variable address default */
- {"start" , udhcp_str2nip , &server_config.start_ip , "192.168.0.20"},
- {"end" , udhcp_str2nip , &server_config.end_ip , "192.168.0.254"},
- {"interface" , read_str , &server_config.interface , "eth0"},
+ {"start" , udhcp_str2nip , OFS(start_ip ), "192.168.0.20"},
+ {"end" , udhcp_str2nip , OFS(end_ip ), "192.168.0.254"},
+ {"interface" , read_str , OFS(interface ), "eth0"},
/* Avoid "max_leases value not sane" warning by setting default
* to default_end_ip - default_start_ip + 1: */
- {"max_leases" , read_u32 , &server_config.max_leases , "235"},
- {"auto_time" , read_u32 , &server_config.auto_time , "7200"},
- {"decline_time" , read_u32 , &server_config.decline_time , "3600"},
- {"conflict_time", read_u32 , &server_config.conflict_time, "3600"},
- {"offer_time" , read_u32 , &server_config.offer_time , "60"},
- {"min_lease" , read_u32 , &server_config.min_lease_sec, "60"},
- {"lease_file" , read_str , &server_config.lease_file , LEASES_FILE},
- {"pidfile" , read_str , &server_config.pidfile , "/var/run/udhcpd.pid"},
- {"siaddr" , udhcp_str2nip , &server_config.siaddr_nip , "0.0.0.0"},
+ {"max_leases" , read_u32 , OFS(max_leases ), "235"},
+ {"auto_time" , read_u32 , OFS(auto_time ), "7200"},
+ {"decline_time" , read_u32 , OFS(decline_time ), "3600"},
+ {"conflict_time", read_u32 , OFS(conflict_time), "3600"},
+ {"offer_time" , read_u32 , OFS(offer_time ), "60"},
+ {"min_lease" , read_u32 , OFS(min_lease_sec), "60"},
+ {"lease_file" , read_str , OFS(lease_file ), LEASES_FILE},
+ {"pidfile" , read_str , OFS(pidfile ), "/var/run/udhcpd.pid"},
+ {"siaddr" , udhcp_str2nip , OFS(siaddr_nip ), "0.0.0.0"},
/* keywords with no defaults must be last! */
- {"option" , udhcp_str2optset, &server_config.options , ""},
- {"opt" , udhcp_str2optset, &server_config.options , ""},
- {"notify_file" , read_str , &server_config.notify_file , NULL},
- {"sname" , read_str , &server_config.sname , NULL},
- {"boot_file" , read_str , &server_config.boot_file , NULL},
- {"static_lease" , read_staticlease, &server_config.static_leases, ""},
+ {"option" , udhcp_str2optset, OFS(options ), ""},
+ {"opt" , udhcp_str2optset, OFS(options ), ""},
+ {"notify_file" , read_str , OFS(notify_file ), NULL},
+ {"sname" , read_str , OFS(sname ), NULL},
+ {"boot_file" , read_str , OFS(boot_file ), NULL},
+ {"static_lease" , read_staticlease, OFS(static_leases), ""},
};
enum { KWS_WITH_DEFAULTS = ARRAY_SIZE(keywords) - 6 };
@@ -95,17 +97,17 @@ void FAST_FUNC read_config(const char *file)
char *token[2];
for (i = 0; i < KWS_WITH_DEFAULTS; i++)
- keywords[i].handler(keywords[i].def, keywords[i].var);
+ keywords[i].handler(keywords[i].def, (char*)&server_config + keywords[i].ofs);
parser = config_open(file);
while (config_read(parser, token, 2, 2, "# \t", PARSE_NORMAL)) {
for (k = keywords, i = 0; i < ARRAY_SIZE(keywords); k++, i++) {
if (strcasecmp(token[0], k->keyword) == 0) {
- if (!k->handler(token[1], k->var)) {
+ if (!k->handler(token[1], (char*)&server_config + k->ofs)) {
bb_error_msg("can't parse line %u in %s",
parser->lineno, file);
/* reset back to the default value */
- k->handler(k->def, k->var);
+ k->handler(k->def, (char*)&server_config + k->ofs);
}
break;
}
diff --git a/networking/zcip.c b/networking/zcip.c
index c930826..7964345 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -40,6 +40,7 @@
//usage: "\nexits only on I/O errors (link down etc)"
#include "libbb.h"
+#include "common_bufsiz.h"
#include <netinet/ether.h>
#include <net/if.h>
#include <net/if_arp.h>
@@ -90,7 +91,7 @@ struct globals {
struct ether_addr our_ethaddr;
uint32_t localnet_ip;
} FIX_ALIASING;
-#define G (*(struct globals*)&bb_common_bufsiz1)
+#define G (*(struct globals*)bb_common_bufsiz1)
#define INIT_G() do { } while (0)