httpd: slight reduction of #ifdef forest
few other applets: #ifdef CONFIG_ -> #if ENABLE_
traceroute: fix exposed bugs
defconfig: update
diff --git a/networking/httpd.c b/networking/httpd.c
index 08b40e0..3b948b9 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1756,22 +1756,19 @@
/* set the KEEPALIVE option to cull dead connections */
on = 1;
setsockopt(s, SOL_SOCKET, SO_KEEPALIVE, (void *)&on, sizeof(on));
-#if !DEBUG
- if (fork() == 0)
-#endif
- {
- /* This is the spawned thread */
+
+ if (DEBUG || fork() == 0) {
+ /* child */
#if ENABLE_FEATURE_HTTPD_RELOAD_CONFIG_SIGHUP
/* protect reload config, may be confuse checking */
signal(SIGHUP, SIG_IGN);
#endif
handleIncoming();
-#if !DEBUG
- exit(0);
-#endif
+ if (!DEBUG)
+ exit(0);
}
close(s);
- } // while (1)
+ } /* while (1) */
return 0;
}
diff --git a/networking/tftp.c b/networking/tftp.c
index 6213d66..64d376f 100644
--- a/networking/tftp.c
+++ b/networking/tftp.c
@@ -60,7 +60,7 @@
#endif
-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
+#if ENABLE_FEATURE_TFTP_BLOCKSIZE
static int tftp_blocksize_check(int blocksize, int bufsize)
{
@@ -204,7 +204,7 @@
memcpy(cp, MODE_OCTET, MODE_OCTET_LEN);
cp += MODE_OCTET_LEN;
-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
+#if ENABLE_FEATURE_TFTP_BLOCKSIZE
len = tftp_bufsize - 4; /* data block size */
@@ -261,7 +261,7 @@
len = cp - buf;
-#ifdef CONFIG_DEBUG_TFTP
+#if ENABLE_DEBUG_TFTP
fprintf(stderr, "sending %u bytes\n", len);
for (cp = buf; cp < &buf[len]; cp++)
fprintf(stderr, "%02x ", (unsigned char) *cp);
@@ -337,7 +337,7 @@
opcode = ntohs(*((unsigned short *) buf));
tmp = ntohs(*((unsigned short *) &buf[2]));
-#ifdef CONFIG_DEBUG_TFTP
+#if ENABLE_DEBUG_TFTP
fprintf(stderr, "received %d bytes: %04x %04x\n", len, opcode, tmp);
#endif
@@ -359,7 +359,7 @@
break;
}
-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
+#if ENABLE_FEATURE_TFTP_BLOCKSIZE
if (want_option_ack) {
want_option_ack = 0;
@@ -382,7 +382,7 @@
} else {
opcode = TFTP_ACK;
}
-#ifdef CONFIG_DEBUG_TFTP
+#if ENABLE_DEBUG_TFTP
fprintf(stderr, "using %s %u\n", OPTION_BLOCKSIZE,
blksize);
#endif
@@ -448,7 +448,7 @@
}
}
-#ifdef CONFIG_FEATURE_CLEAN_UP
+#if ENABLE_FEATURE_CLEAN_UP
close(socketfd);
free(buf);
#endif
@@ -470,7 +470,7 @@
/* figure out what to pass to getopt */
-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
+#if ENABLE_FEATURE_TFTP_BLOCKSIZE
char *sblocksize = NULL;
#define BS "b:"
@@ -480,7 +480,7 @@
#define BS_ARG
#endif
-#ifdef CONFIG_FEATURE_TFTP_GET
+#if ENABLE_FEATURE_TFTP_GET
#define GET "g"
#define GET_COMPL ":g"
#else
@@ -488,7 +488,7 @@
#define GET_COMPL
#endif
-#ifdef CONFIG_FEATURE_TFTP_PUT
+#if ENABLE_FEATURE_TFTP_PUT
#define PUT "p"
#define PUT_COMPL ":p"
#else
@@ -505,16 +505,16 @@
cmd = getopt32(argc, argv, GET PUT "l:r:" BS, &localfile, &remotefile BS_ARG);
cmd &= (tftp_cmd_get | tftp_cmd_put);
-#ifdef CONFIG_FEATURE_TFTP_GET
+#if ENABLE_FEATURE_TFTP_GET
if (cmd == tftp_cmd_get)
flags = O_WRONLY | O_CREAT | O_TRUNC;
#endif
-#ifdef CONFIG_FEATURE_TFTP_PUT
+#if ENABLE_FEATURE_TFTP_PUT
if (cmd == tftp_cmd_put)
flags = O_RDONLY;
#endif
-#ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE
+#if ENABLE_FEATURE_TFTP_BLOCKSIZE
if (sblocksize) {
blocksize = xatoi_u(sblocksize);
if (!tftp_blocksize_check(blocksize, 0)) {
@@ -542,7 +542,7 @@
host = xgethostbyname(argv[optind]);
port = bb_lookup_port(argv[optind + 1], "udp", 69);
-#ifdef CONFIG_DEBUG_TFTP
+#if ENABLE_DEBUG_TFTP
fprintf(stderr, "using server \"%s\", remotefile \"%s\", "
"localfile \"%s\".\n",
inet_ntoa(*((struct in_addr *) host->h_addr)),
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 3b59063..c4f050a 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -196,12 +196,15 @@
* Tue Dec 20 03:50:13 PST 1988
*/
-#undef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#define TRACEROUTE_SO_DEBUG 0
+
+/* TODO: undefs were uncommented - ??! we have config system for that! */
+/* probably ok to remove altogether */
+//#undef CONFIG_FEATURE_TRACEROUTE_VERBOSE
//#define CONFIG_FEATURE_TRACEROUTE_VERBOSE
-#undef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG /* not in documentation man */
-#undef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+//#undef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
//#define CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
-#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+//#undef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
//#define CONFIG_FEATURE_TRACEROUTE_USE_ICMP
#include "inet_common.h"
@@ -284,17 +287,17 @@
static const char route[] = "/proc/net/route";
/* last inbound (icmp) packet */
-static unsigned char packet[512] ATTRIBUTE_ALIGNED(32);
+static unsigned char packet[512] ATTRIBUTE_ALIGNED(32);
static struct ip *outip; /* last output (udp) packet */
static struct udphdr *outudp; /* last output (udp) packet */
static struct outdata *outdata; /* last output (udp) packet */
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
static struct icmp *outicmp; /* last output (icmp) packet */
#endif
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
/* Maximum number of gateways (include room for one noop) */
#define NGATEWAYS ((int)((MAX_IPOPTLEN - IPOPT_MINOFF - 1) / sizeof(u_int32_t)))
/* loose source route gateway list (including room for final destination) */
@@ -320,16 +323,16 @@
static int nflag; /* print addresses numerically */
static int doipcksum = 1; /* calculate ip checksums by default */
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
static int optlen; /* length of ip options */
#else
#define optlen 0
#endif
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
static int useicmp; /* use icmp echo instead of udp packets */
#endif
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
static int verbose;
#endif
@@ -596,14 +599,14 @@
outdata->ttl = ttl;
memcpy(&outdata->tv, tp, sizeof(outdata->tv));
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
if (useicmp)
outicmp->icmp_seq = htons(seq);
else
#endif
outudp->dest = htons(port + seq);
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
if (useicmp) {
/* Always calculate checksum for icmp packets */
outicmp->icmp_cksum = 0;
@@ -631,7 +634,7 @@
*outip = tip;
}
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
/* XXX undocumented debugging hack */
if (verbose > 1) {
const u_short *sp;
@@ -684,7 +687,7 @@
return dt;
}
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
/*
* Convert an ICMP "type" field to a printable string.
*/
@@ -717,7 +720,7 @@
ip = (struct ip *) buf;
hlen = ip->ip_hl << 2;
if (cc < hlen + ICMP_MINLEN) {
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
if (verbose)
printf("packet too short (%d bytes) from %s\n", cc,
inet_ntoa(from->sin_addr));
@@ -741,7 +744,7 @@
hip = &icp->icmp_ip;
hlen = hip->ip_hl << 2;
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
if (useicmp) {
struct icmp *hicmp;
@@ -770,7 +773,7 @@
return (type == ICMP_TIMXCEED ? -1 : code + 1);
}
}
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
if (verbose) {
int i;
u_int32_t *lp = (u_int32_t *)&icp->icmp_ip;
@@ -821,7 +824,7 @@
cc -= hlen;
inetname(from);
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
if (verbose)
printf(" %d bytes to %s", cc, inet_ntoa (ip->ip_dst));
#endif
@@ -869,7 +872,7 @@
free((char *)hi);
}
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
static void
getaddr(u_int32_t *ap, const char *host)
{
@@ -899,7 +902,7 @@
char *source = NULL;
unsigned long op;
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
int lsrr = 0;
#endif
u_short off = 0;
@@ -915,12 +918,12 @@
char *pausemsecs_str = NULL;
int first_ttl = 1;
char *first_ttl_str = NULL;
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
llist_t *sourse_route_list = NULL;
#endif
opterr = 0;
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
opt_complementary = "x-x:g::";
#else
opt_complementary = "x-x";
@@ -936,23 +939,23 @@
#define USAGE_OP_VERBOSE (1<<6) /* v */
#define USAGE_OP_IP_CHKSUM (1<<7) /* x */
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
"g:"
#endif
, &tos_str, &device, &max_ttl_str, &port_str, &nprobes_str,
&source, &waittime_str, &pausemsecs_str, &first_ttl_str
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
, &sourse_route_list
#endif
);
if (op & USAGE_OP_DONT_FRAGMNT)
off = IP_DF;
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
useicmp = op & USAGE_OP_USE_ICMP;
#endif
nflag = op & USAGE_OP_ADDR_NUM;
-#ifdef CONFIG_FEATURE_TRACEROUTE_VERBOSE
+#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
verbose = op & USAGE_OP_VERBOSE;
#endif
if (op & USAGE_OP_IP_CHKSUM) {
@@ -981,7 +984,7 @@
if (first_ttl_str)
first_ttl = xatoul_range(first_ttl_str, 1, 255);
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
if (sourse_route_list) {
llist_t *l_sr;
@@ -1006,7 +1009,7 @@
minpacket = sizeof(*outip) + sizeof(*outdata) + optlen;
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
if (useicmp)
minpacket += 8; /* XXX magic number */
else
@@ -1044,7 +1047,7 @@
s = xsocket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
-#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
+#if TRACEROUTE_SO_DEBUG
if (op & USAGE_OP_DEBUG)
(void)setsockopt(s, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on));
@@ -1055,7 +1058,7 @@
sndsock = xsocket(AF_INET, SOCK_RAW, IPPROTO_RAW);
-#ifdef CONFIG_FEATURE_TRACEROUTE_SOURCE_ROUTE
+#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
#if defined(IP_OPTIONS)
if (lsrr > 0) {
unsigned char optlist[MAX_IPOPTLEN];
@@ -1101,7 +1104,7 @@
}
#endif
#endif
-#ifdef CONFIG_FEATURE_TRACEROUTE_SO_DEBUG
+#if TRACEROUTE_SO_DEBUG
if (op & USAGE_OP_DEBUG)
(void)setsockopt(sndsock, SOL_SOCKET, SO_DEBUG, (char *)&on,
sizeof(on));
@@ -1126,7 +1129,7 @@
outip->ip_hl = (outp - (unsigned char *)outip) >> 2;
ident = (getpid() & 0xffff) | 0x8000;
-#ifdef CONFIG_FEATURE_TRACEROUTE_USE_ICMP
+#if ENABLE_FEATURE_TRACEROUTE_USE_ICMP
if (useicmp) {
outip->ip_p = IPPROTO_ICMP;
diff --git a/networking/udhcp/static_leases.c b/networking/udhcp/static_leases.c
index b53eac5..aabfb81 100644
--- a/networking/udhcp/static_leases.c
+++ b/networking/udhcp/static_leases.c
@@ -79,7 +79,7 @@
return return_val;
}
-#ifdef CONFIG_FEATURE_UDHCP_DEBUG
+#if ENABLE_FEATURE_UDHCP_DEBUG
/* Print out static leases just to check what's going on */
/* Takes the address of the pointer to the static_leases linked list */
void printStaticLeases(struct static_lease **arg)
diff --git a/networking/zcip.c b/networking/zcip.c
index 6bd7f25..27e281c 100644
--- a/networking/zcip.c
+++ b/networking/zcip.c
@@ -24,14 +24,9 @@
// - link status monitoring (restart on link-up; stop on link-down)
#include "busybox.h"
-#include <errno.h>
-#include <string.h>
#include <syslog.h>
#include <poll.h>
-#include <time.h>
-
#include <sys/wait.h>
-
#include <netinet/ether.h>
#include <net/ethernet.h>
#include <net/if.h>