diff options
author | Eric Andersen | 2004-03-15 08:29:22 +0000 |
---|---|---|
committer | Eric Andersen | 2004-03-15 08:29:22 +0000 |
commit | c7bda1ce659294d6e22c06e087f6f265983c7578 (patch) | |
tree | 4c6d2217f4d8306c59cf1096f8664e1cfd167213 /networking | |
parent | 8854004b41065b3d081af7f3df13a100b0c8bfbe (diff) | |
download | busybox-c7bda1ce659294d6e22c06e087f6f265983c7578.zip busybox-c7bda1ce659294d6e22c06e087f6f265983c7578.tar.gz |
Remove trailing whitespace. Update copyright to include 2004.
Diffstat (limited to 'networking')
55 files changed, 420 insertions, 421 deletions
diff --git a/networking/Config.in b/networking/Config.in index d2916e7..a7cef41 100644 --- a/networking/Config.in +++ b/networking/Config.in @@ -63,7 +63,7 @@ config CONFIG_FEATURE_HTTPD_AUTH_MD5 default n depends on CONFIG_FEATURE_HTTPD_BASIC_AUTH help - Enables basic per url authentication from /etc/httpd.conf + Enables basic per url authentication from /etc/httpd.conf using md5 passwords. @@ -187,7 +187,7 @@ config CONFIG_IFUPDOWN config CONFIG_FEATURE_IFUPDOWN_IP bool " Use ip applet" default n - depends on CONFIG_IFUPDOWN + depends on CONFIG_IFUPDOWN help Use the iproute "ip" command to implement "ifup" and "ifdown", rather than the default of using the older 'ifconfig' and 'route' utilities. @@ -213,11 +213,11 @@ config CONFIG_FEATURE_IFUPDOWN_IP_BUILTIN select CONFIG_IFCONFIG select CONFIG_ROUTE help - Use the busybox iproute "ifconfig" and "route" applets to + Use the busybox iproute "ifconfig" and "route" applets to implement the "ifup" and "ifdown" utilities. If leave this disabled, you must install the full-blown ifconfig - and route utilities, or the "ifup" and "ifdown" applets will not + and route utilities, or the "ifup" and "ifdown" applets will not work. config CONFIG_FEATURE_IFUPDOWN_IPV4 @@ -339,7 +339,7 @@ if !(CONFIG_IP && CONFIG_IPROUTE) default y depends on CONFIG_IP help - Add support for routing table management to "ip". + Add support for routing table management to "ip". endif if CONFIG_IP && CONFIG_IPTUNNEL diff --git a/networking/Makefile b/networking/Makefile index 022f29e..456c433 100644 --- a/networking/Makefile +++ b/networking/Makefile @@ -1,6 +1,6 @@ # Makefile for busybox # -# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/networking/Makefile.in b/networking/Makefile.in index 7748d06..31de77f 100644 --- a/networking/Makefile.in +++ b/networking/Makefile.in @@ -1,6 +1,6 @@ # Makefile for busybox # -# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/networking/ftpgetput.c b/networking/ftpgetput.c index 17ee8a5..814253b 100644 --- a/networking/ftpgetput.c +++ b/networking/ftpgetput.c @@ -1,7 +1,7 @@ /* vi: set sw=4 ts=4: */ /* - * ftpget - * + * ftpget + * * Mini implementation of FTP to retrieve a remote file. * * Copyright (C) 2002 Jeff Angielski, The PTR Group <jeff@theptrgroup.com> @@ -131,7 +131,7 @@ static FILE *ftp_login(ftp_host_info_t *server) } #ifdef CONFIG_FTPGET -static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream, +static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream, const char *local_path, char *server_path) { char buf[512]; @@ -203,13 +203,13 @@ static int ftp_recieve(ftp_host_info_t *server, FILE *control_stream, bb_error_msg_and_die("ftp error: %s", buf + 4); } ftpcmd("QUIT", NULL, control_stream, buf); - + return(EXIT_SUCCESS); } #endif #ifdef CONFIG_FTPPUT -static int ftp_send(ftp_host_info_t *server, FILE *control_stream, +static int ftp_send(ftp_host_info_t *server, FILE *control_stream, const char *server_path, char *local_path) { struct stat sbuf; @@ -329,8 +329,8 @@ int ftpgetput_main(int argc, char **argv) server->password = "busybox@"; verbose_flag = 0; - /* - * Decipher the command line + /* + * Decipher the command line */ bb_applet_long_options = ftpgetput_long_options; opt = bb_getopt_ulflags(argc, argv, "cvu:p:P:", &server->user, &server->password, &port); diff --git a/networking/httpd.c b/networking/httpd.c index f2fd2b3..aad30a1 100644 --- a/networking/httpd.c +++ b/networking/httpd.c @@ -44,7 +44,7 @@ * for page display. * * httpd.conf has the following format: - * + * * A:172.20. # Allow address from 172.20.0.0/16 * A:10.0.0.0/25 # Allow any address from 10.0.0.0-10.0.0.127 * A:10.0.0.0/255.255.255.128 # Allow any address that previous set @@ -54,13 +54,13 @@ * /adm:admin:setup # Require user admin, pwd setup on urls starting with /adm/ * /adm:toor:PaSsWd # or user toor, pwd PaSsWd on urls starting with /adm/ * .au:audio/basic # additional mime type for audio.au files - * + * * A/D may be as a/d or allow/deny - first char case unsensitive * Deny IP rules take precedence over allow rules. - * - * + * + * * The Deny/Allow IP logic: - * + * * - Default is to allow all. No addresses are denied unless * denied with a D: rule. * - Order of Deny/Allow rules is significant @@ -68,19 +68,19 @@ * - If a deny all rule (D:*) is used it acts as a catch-all for unmatched * addresses. * - Specification of Allow all (A:*) is a no-op - * + * * Example: * 1. Allow only specified addresses * A:172.20 # Allow any address that begins with 172.20. * A:10.10. # Allow any address that begins with 10.10. * A:127.0.0.1 # Allow local loopback connections * D:* # Deny from other IP connections - * + * * 2. Only deny specified addresses * D:1.2.3. # deny from 1.2.3.0 - 1.2.3.255 * D:2.3.4. # deny from 2.3.4.0 - 2.3.4.255 * A:* # (optional line added for clarity) - * + * * If a sub directory contains a config file it is parsed and merged with * any existing settings as if it was appended to the original configuration. * @@ -91,11 +91,11 @@ * subdir http request, any merge is discarded when the process exits. As a * result, the subdir settings only have a lifetime of a single request. * - * - * If -c is not set, an attempt will be made to open the default + * + * If -c is not set, an attempt will be made to open the default * root configuration file. If -c is set and the file is not found, the * server exits with an error. - * + * */ @@ -447,7 +447,7 @@ static void free_config_lines(Htaccess **pprev) > $Function: parse_conf() * * $Description: parse configuration file into in-memory linked list. - * + * * The first non-white character is examined to determine if the config line * is one of the following: * .ext:mime/type # new mime type not compiled into httpd @@ -464,7 +464,7 @@ static void free_config_lines(Htaccess **pprev) * checks. * (int) flag . . . . . . the source of the parse request. * - * $Return: (None) + * $Return: (None) * ****************************************************************************/ static void parse_conf(const char *path, int flag) @@ -1726,7 +1726,7 @@ FORBIDDEN: /* protect listing /cgi-bin */ /* Properly wait for remote to closed */ FD_ZERO (&s_fd) ; FD_SET (a_c_w, &s_fd) ; - + do { tv.tv_sec = 2 ; tv.tv_usec = 0 ; diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 341998d..b884ef7 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -6,7 +6,7 @@ * Bjorn Wesen, Axis Communications AB * * - * Authors of the original ifconfig was: + * Authors of the original ifconfig was: * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * * This program is free software; you can redistribute it @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.28 2004/03/06 22:11:44 andersen Exp $ + * $Id: ifconfig.c,v 1.29 2004/03/15 08:28:48 andersen Exp $ * */ @@ -510,7 +510,7 @@ int ifconfig_main(int argc, char **argv) * a - at the end, since it's deleted already! - Roman * * Should really use regex.h here, not sure though how well - * it'll go with the cross-platform support etc. + * it'll go with the cross-platform support etc. */ char *ptr; short int found_colon = 0; diff --git a/networking/ifupdown.c b/networking/ifupdown.c index bd0021a..c34e2b9 100644 --- a/networking/ifupdown.c +++ b/networking/ifupdown.c @@ -2,7 +2,7 @@ /* * ifupdown for busybox * Copyright (c) 2002 Glenn McGrath <bug1@optushome.com.au> - * Copyright (c) 2003 Erik Andersen <andersen@codepoet.org> + * Copyright (c) 2003-2004 Erik Andersen <andersen@codepoet.org> * * Based on ifupdown v 0.6.4 by Anthony Towns * Copyright (c) 1999 Anthony Towns <aj@azure.humbug.org.au> @@ -56,7 +56,7 @@ #if 0 #define debug_noise(fmt, args...) printf(fmt, ## args) #else -#define debug_noise(fmt, args...) +#define debug_noise(fmt, args...) #endif /* Forward declaration */ @@ -72,7 +72,7 @@ extern llist_t *llist_add_to_end(llist_t *list_head, char *data) new_item = xmalloc(sizeof(llist_t)); new_item->data = data; new_item->link = NULL; - + prev = NULL; tmp = list_head; while(tmp) { @@ -80,7 +80,7 @@ extern llist_t *llist_add_to_end(llist_t *list_head, char *data) tmp = tmp->link; } if (prev) { - prev->link = new_item; + prev->link = new_item; } else { list_head = new_item; } @@ -123,7 +123,7 @@ struct variable_t char *value; }; -struct interface_defn_t +struct interface_defn_t { struct interface_defn_t *prev; struct interface_defn_t *next; @@ -598,7 +598,7 @@ static int wvdial_down(struct interface_defn_t *ifd, execfn *exec) "-p /var/run/wvdial.%iface% -s 2", ifd, exec)); } -static struct method_t methods[] = +static struct method_t methods[] = { { "wvdial", wvdial_up, wvdial_down, }, { "ppp", ppp_up, ppp_down, }, @@ -608,7 +608,7 @@ static struct method_t methods[] = { "loopback", loopback_up, loopback_down, }, }; -struct address_family_t addr_inet = +struct address_family_t addr_inet = { "inet", sizeof(methods) / sizeof(struct method_t), @@ -885,7 +885,7 @@ static struct interfaces_file_t *read_interfaces(char *filename) perror(filename); return NULL; } - debug_noise("\t%s=%s\n", currif->option[currif->n_options].name, + debug_noise("\t%s=%s\n", currif->option[currif->n_options].name, currif->option[currif->n_options].value); currif->n_options++; break; @@ -1031,7 +1031,7 @@ static int execute_all(struct interface_defn_t *ifd, execfn *exec, const char *o } } } - + bb_xasprintf(&buf, "run-parts /etc/network/if-%s.d", opt); (*exec)(buf); @@ -1211,7 +1211,7 @@ extern int ifupdown_main(int argc, char **argv) #ifdef CONFIG_FEATURE_IFUPDOWN_MAPPING while ((i = getopt(argc, argv, "i:hvnamf")) != -1) #else - while ((i = getopt(argc, argv, "i:hvnaf")) != -1) + while ((i = getopt(argc, argv, "i:hvnaf")) != -1) #endif { switch (i) { @@ -1249,7 +1249,7 @@ extern int ifupdown_main(int argc, char **argv) if (!do_all) { bb_show_usage(); } - } + } debug_noise("reading %s file:\n", interfaces); defn = read_interfaces(interfaces); @@ -1297,8 +1297,8 @@ extern int ifupdown_main(int argc, char **argv) list = list->link; } target_list = defn->autointerfaces; -#endif - } +#endif + } } else { target_list = llist_add_to_end(target_list, argv[optind]); } @@ -1413,7 +1413,7 @@ extern int ifupdown_main(int argc, char **argv) } else { iface_state->data = NULL; iface_state->link = NULL; - } + } } } } diff --git a/networking/libiproute/Makefile b/networking/libiproute/Makefile index c1f18be..0dc7191 100644 --- a/networking/libiproute/Makefile +++ b/networking/libiproute/Makefile @@ -1,6 +1,6 @@ # Makefile for busybox # -# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/networking/libiproute/Makefile.in b/networking/libiproute/Makefile.in index f39eeb3..d6f9504 100644 --- a/networking/libiproute/Makefile.in +++ b/networking/libiproute/Makefile.in @@ -1,6 +1,6 @@ # Makefile for busybox # -# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/networking/libiproute/ip_parse_common_args.c b/networking/libiproute/ip_parse_common_args.c index 1f3d739..a76df48 100644 --- a/networking/libiproute/ip_parse_common_args.c +++ b/networking/libiproute/ip_parse_common_args.c @@ -47,7 +47,7 @@ void ip_parse_common_args(int *argcp, char ***argvp) if (matches(opt, "-family") == 0) { argc--; argv++; - if (! argv[1]) + if (! argv[1]) bb_show_usage(); if (strcmp(argv[1], "inet") == 0) preferred_family = AF_INET; diff --git a/networking/libiproute/ipaddress.c b/networking/libiproute/ipaddress.c index 44e871e..7e0c757 100644 --- a/networking/libiproute/ipaddress.c +++ b/networking/libiproute/ipaddress.c @@ -91,7 +91,7 @@ static void print_queuelen(char *name) memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, name); - if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) { + if (ioctl(s, SIOCGIFTXQLEN, &ifr) < 0) { perror("SIOCGIFXQLEN"); close(s); return; @@ -166,7 +166,7 @@ static int print_linkinfo(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg #endif if (filter.showqueue) print_queuelen((char*)RTA_DATA(tb[IFLA_IFNAME])); - + if (!filter.family || filter.family == AF_PACKET) { SPRINT_BUF(b1); fprintf(fp, "%s", _SL_); @@ -378,7 +378,7 @@ static int print_selected_addrinfo(int ifindex, struct nlmsg_list *ainfo, FILE * if (n->nlmsg_len < NLMSG_LENGTH(sizeof(ifa))) return -1; - if (ifa->ifa_index != ifindex || + if (ifa->ifa_index != ifindex || (filter.family && filter.family != ifa->ifa_family)) continue; @@ -564,7 +564,7 @@ extern int ipaddr_list_or_flush(int argc, char **argv, int flush) struct nlmsghdr *n = &a->h; struct ifaddrmsg *ifa = NLMSG_DATA(n); - if (ifa->ifa_index != ifi->ifi_index || + if (ifa->ifa_index != ifi->ifi_index || (filter.family && filter.family != ifa->ifa_family)) continue; if ((filter.scope^ifa->ifa_scope)&filter.scopemask) diff --git a/networking/libiproute/iplink.c b/networking/libiproute/iplink.c index daab693..44b546d 100644 --- a/networking/libiproute/iplink.c +++ b/networking/libiproute/iplink.c @@ -128,8 +128,8 @@ static int set_qlen(char *dev, int qlen) return -1; memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, dev); - ifr.ifr_qlen = qlen; + strcpy(ifr.ifr_name, dev); + ifr.ifr_qlen = qlen; if (ioctl(s, SIOCSIFTXQLEN, &ifr) < 0) { perror("SIOCSIFXQLEN"); close(s); @@ -137,7 +137,7 @@ static int set_qlen(char *dev, int qlen) } close(s); - return 0; + return 0; } static int set_mtu(char *dev, int mtu) @@ -150,8 +150,8 @@ static int set_mtu(char *dev, int mtu) return -1; memset(&ifr, 0, sizeof(ifr)); - strcpy(ifr.ifr_name, dev); - ifr.ifr_mtu = mtu; + strcpy(ifr.ifr_name, dev); + ifr.ifr_mtu = mtu; if (ioctl(s, SIOCSIFMTU, &ifr) < 0) { perror("SIOCSIFMTU"); close(s); @@ -159,7 +159,7 @@ static int set_mtu(char *dev, int mtu) } close(s); - return 0; + return 0; } static int get_address(char *dev, int *htype) @@ -170,7 +170,7 @@ static int get_address(char *dev, int *htype) int s; s = socket(PF_PACKET, SOCK_DGRAM, 0); - if (s < 0) { + if (s < 0) { perror("socket(PF_PACKET)"); return -1; } @@ -218,7 +218,7 @@ static int parse_address(char *dev, int hatype, int halen, char *lla, struct ifr bb_error_msg("Wrong address (%s) length: expected %d bytes", lla, halen); return -1; } - return 0; + return 0; } static int set_address(struct ifreq *ifr, int brd) @@ -234,7 +234,7 @@ static int set_address(struct ifreq *ifr, int brd) return -1; } close(s); - return 0; + return 0; } @@ -311,7 +311,7 @@ static int do_set(int argc, char **argv) } if (newbrd) { if (parse_address(dev, htype, halen, newbrd, &ifr1) < 0) - return -1; + return -1; } } @@ -320,18 +320,18 @@ static int do_set(int argc, char **argv) return -1; dev = newname; } - if (qlen != -1) { + if (qlen != -1) { if (set_qlen(dev, qlen) < 0) - return -1; + return -1; } - if (mtu != -1) { + if (mtu != -1) { if (set_mtu(dev, mtu) < 0) - return -1; + return -1; } if (newaddr || newbrd) { if (newbrd) { if (set_address(&ifr1, 1) < 0) - return -1; + return -1; } if (newaddr) { if (set_address(&ifr0, 0) < 0) diff --git a/networking/libiproute/iproute.c b/networking/libiproute/iproute.c index 0fdf798..7adbfcd 100644 --- a/networking/libiproute/iproute.c +++ b/networking/libiproute/iproute.c @@ -76,7 +76,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) inet_prefix src; int host_len = -1; SPRINT_BUF(b1); - + if (n->nlmsg_type != RTM_NEWROUTE && n->nlmsg_type != RTM_DELROUTE) { fprintf(stderr, "Not a route: %08x %08x %08x\n", @@ -228,7 +228,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) fprintf(fp, "from 0/%u ", r->rtm_src_len); } if (tb[RTA_GATEWAY] && filter.rvia.bitlen != host_len) { - fprintf(fp, "via %s ", + fprintf(fp, "via %s ", format_host(r->rtm_family, RTA_PAYLOAD(tb[RTA_GATEWAY]), RTA_DATA(tb[RTA_GATEWAY]), @@ -242,7 +242,7 @@ static int print_route(struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) /* Do not use format_host(). It is our local addr and symbolic name will not be useful. */ - fprintf(fp, " src %s ", + fprintf(fp, " src %s ", rt_addr_n2a(r->rtm_family, RTA_PAYLOAD(tb[RTA_PREFSRC]), RTA_DATA(tb[RTA_PREFSRC]), @@ -665,7 +665,7 @@ static int iproute_get(int argc, char **argv) req.r.rtm_src_len = 0; req.r.rtm_dst_len = 0; req.r.rtm_tos = 0; - + while (argc > 0) { switch (compare_string_array(options, *argv)) { case 0: /* from */ diff --git a/networking/libiproute/iptunnel.c b/networking/libiproute/iptunnel.c index eae5bb0..3f5d05a 100644 --- a/networking/libiproute/iptunnel.c +++ b/networking/libiproute/iptunnel.c @@ -354,7 +354,7 @@ static int do_add(int cmd, int argc, char **argv) return do_add_ioctl(cmd, "gre0", &p); case IPPROTO_IPV6: return do_add_ioctl(cmd, "sit0", &p); - default: + default: bb_error_msg("cannot determine tunnel mode (ipip, gre or sit)"); return -1; } @@ -375,7 +375,7 @@ int do_del(int argc, char **argv) return do_del_ioctl("gre0", &p); case IPPROTO_IPV6: return do_del_ioctl("sit0", &p); - default: + default: return do_del_ioctl(p.name, &p); } return -1; @@ -506,7 +506,7 @@ static int do_show(int argc, char **argv) return -1; switch (p.iph.protocol) { - case IPPROTO_IPIP: + case IPPROTO_IPIP: err = do_get_ioctl(p.name[0] ? p.name : "tunl0", &p); break; case IPPROTO_GRE: diff --git a/networking/libiproute/libnetlink.c b/networking/libiproute/libnetlink.c index 9390e56..861daef 100644 --- a/networking/libiproute/libnetlink.c +++ b/networking/libiproute/libnetlink.c @@ -317,7 +317,7 @@ int rtnl_talk(struct rtnl_handle *rtnl, struct nlmsghdr *n, pid_t peer, } } -int rtnl_listen(struct rtnl_handle *rtnl, +int rtnl_listen(struct rtnl_handle *rtnl, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg) { @@ -389,7 +389,7 @@ int rtnl_listen(struct rtnl_handle *rtnl, } } -int rtnl_from_file(FILE *rtnl, +int rtnl_from_file(FILE *rtnl, int (*handler)(struct sockaddr_nl *,struct nlmsghdr *n, void *), void *jarg) { diff --git a/networking/libiproute/linux/pkt_sched.h b/networking/libiproute/linux/pkt_sched.h index e174588..70cbabc 100644 --- a/networking/libiproute/linux/pkt_sched.h +++ b/networking/libiproute/linux/pkt_sched.h @@ -221,19 +221,19 @@ enum #define TCA_SET_OFF TCA_GRED_PARMS struct tc_gred_qopt { - __u32 limit; /* HARD maximal queue length (bytes) + __u32 limit; /* HARD maximal queue length (bytes) */ - __u32 qth_min; /* Min average length threshold (bytes) + __u32 qth_min; /* Min average length threshold (bytes) */ - __u32 qth_max; /* Max average length threshold (bytes) + __u32 qth_max; /* Max average length threshold (bytes) */ __u32 DP; /* upto 2^32 DPs */ - __u32 backlog; - __u32 qave; - __u32 forced; - __u32 early; - __u32 other; - __u32 pdrop; + __u32 backlog; + __u32 qave; + __u32 forced; + __u32 early; + __u32 other; + __u32 pdrop; unsigned char Wlog; /* log(W) */ unsigned char Plog; /* log(P_max/(qth_max-qth_min)) */ @@ -294,7 +294,7 @@ struct tc_htb_xstats __u32 lends; __u32 borrows; __u32 giants; /* too big packets (rate will not be accurate) */ - __u32 injects; /* how many times leaf used injected bw */ + __u32 injects; /* how many times leaf used injected bw */ __u32 tokens; __u32 ctokens; }; diff --git a/networking/libiproute/ll_proto.c b/networking/libiproute/ll_proto.c index 45afdb8..9b5260b 100644 --- a/networking/libiproute/ll_proto.c +++ b/networking/libiproute/ll_proto.c @@ -26,62 +26,62 @@ static struct { char *name; } llproto_names[] = { __PF(LOOP,loop) -__PF(PUP,pup) +__PF(PUP,pup) #ifdef ETH_P_PUPAT -__PF(PUPAT,pupat) +__PF(PUPAT,pupat) #endif __PF(IP,ip) __PF(X25,x25) __PF(ARP,arp) __PF(BPQ,bpq) #ifdef ETH_P_IEEEPUP -__PF(IEEEPUP,ieeepup) +__PF(IEEEPUP,ieeepup) #endif #ifdef ETH_P_IEEEPUPAT -__PF(IEEEPUPAT,ieeepupat) +__PF(IEEEPUPAT,ieeepupat) #endif -__PF(DEC,dec) -__PF(DNA_DL,dna_dl) -__PF(DNA_RC,dna_rc) -__PF(DNA_RT,dna_rt) -__PF(LAT,lat) -__PF(DIAG,diag) -__PF(CUST,cust) -__PF(SCA,sca) -__PF(RARP,rarp) -__PF(ATALK,atalk) -__PF(AARP,aarp) -__PF(IPX,ipx) -__PF(IPV6,ipv6) +__PF(DEC,dec) +__PF(DNA_DL,dna_dl) +__PF(DNA_RC,dna_rc) +__PF(DNA_RT,dna_rt) +__PF(LAT,lat) +__PF(DIAG,diag) +__PF(CUST,cust) +__PF(SCA,sca) +__PF(RARP,rarp) +__PF(ATALK,atalk) +__PF(AARP,aarp) +__PF(IPX,ipx) +__PF(IPV6,ipv6) #ifdef ETH_P_PPP_DISC -__PF(PPP_DISC,ppp_disc) +__PF(PPP_DISC,ppp_disc) #endif #ifdef ETH_P_PPP_SES -__PF(PPP_SES,ppp_ses) +__PF(PPP_SES,ppp_ses) #endif #ifdef ETH_P_ATMMPOA -__PF(ATMMPOA,atmmpoa) +__PF(ATMMPOA,atmmpoa) #endif #ifdef ETH_P_ATMFATE -__PF(ATMFATE,atmfate) +__PF(ATMFATE,atmfate) #endif -__PF(802_3,802_3) -__PF(AX25,ax25) -__PF(ALL,all) -__PF(802_2,802_2) -__PF(SNAP,snap) -__PF(DDCMP,ddcmp) -__PF(WAN_PPP,wan_ppp) -__PF(PPP_MP,ppp_mp) -__PF(LOCALTALK,localtalk) -__PF(PPPTALK,ppptalk) -__PF(TR_802_2,tr_802_2) -__PF(MOBITEX,mobitex) -__PF(CONTROL,control) -__PF(IRDA,irda) +__PF(802_3,802_3) +__PF(AX25,ax25) +__PF(ALL,all) +__PF(802_2,802_2) +__PF(SNAP,snap) +__PF(DDCMP,ddcmp) +__PF(WAN_PPP,wan_ppp) +__PF(PPP_MP,ppp_mp) +__PF(LOCALTALK,localtalk) +__PF(PPPTALK,ppptalk) +__PF(TR_802_2,tr_802_2) +__PF(MOBITEX,mobitex) +__PF(CONTROL,control) +__PF(IRDA,irda) #ifdef ETH_P_ECONET -__PF(ECONET,econet) +__PF(ECONET,econet) #endif { 0x8100, "802.1Q" }, diff --git a/networking/libiproute/utils.h b/networking/libiproute/utils.h index b51e07b..e79e177 100644 --- a/networking/libiproute/utils.h +++ b/networking/libiproute/utils.h @@ -43,7 +43,7 @@ typedef struct #define AF_DECnet 12 #endif -struct dn_naddr +struct dn_naddr { unsigned short a_len; unsigned char a_addr[DN_MAXADDL]; diff --git a/networking/nc.c b/networking/nc.c index ecb4a00..9a353c9 100644 --- a/networking/nc.c +++ b/networking/nc.c @@ -4,7 +4,7 @@ 0.0.1 6K It works. 0.0.2 5K Smaller and you can also check the exit condition if you wish. - 0.0.3 Uses select() + 0.0.3 Uses select() 19980918 Busy Boxed! Dave Cinege 19990512 Uses Select. Charles P. Wright @@ -47,7 +47,7 @@ int nc_main(int argc, char **argv) int do_listen = 0, lport = 0, delay = 0, tmpfd, opt, sfd, x; char buf[BUFSIZ]; #ifdef GAPING_SECURITY_HOLE - char * pr00gie = NULL; + char * pr00gie = NULL; #endif struct sockaddr_in address; @@ -79,7 +79,7 @@ int nc_main(int argc, char **argv) #ifdef GAPING_SECURITY_HOLE if (pr00gie) { /* won't need stdin */ - close (fileno(stdin)); + close (fileno(stdin)); } #endif /* GAPING_SECURITY_HOLE */ diff --git a/networking/netstat.c b/networking/netstat.c index 17a5887..bc1ed05 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -210,7 +210,7 @@ static void tcp_do_one(int lnr, const char *line) snprint_ip_port(local_addr, sizeof(local_addr), (struct sockaddr *) &localaddr, local_port, "tcp", flags&NETSTAT_NUMERIC); - + snprint_ip_port(rem_addr, sizeof(rem_addr), (struct sockaddr *) &remaddr, rem_port, "tcp", flags&NETSTAT_NUMERIC); @@ -305,7 +305,7 @@ static void udp_do_one(int lnr, const char *line) snprint_ip_port(local_addr, sizeof(local_addr), (struct sockaddr *) &localaddr, local_port, "udp", flags&NETSTAT_NUMERIC); - + snprint_ip_port(rem_addr, sizeof(rem_addr), (struct sockaddr *) &remaddr, rem_port, "udp", flags&NETSTAT_NUMERIC); @@ -387,7 +387,7 @@ static void raw_do_one(int lnr, const char *line) snprint_ip_port(local_addr, sizeof(local_addr), (struct sockaddr *) &localaddr, local_port, "raw", flags&NETSTAT_NUMERIC); - + snprint_ip_port(rem_addr, sizeof(rem_addr), (struct sockaddr *) &remaddr, rem_port, "raw", flags&NETSTAT_NUMERIC); @@ -558,7 +558,7 @@ int netstat_main(int argc, char **argv) { int opt; int new_flags=0; - int showroute = 0, extended = 0; + int showroute = 0, extended = 0; #ifdef CONFIG_FEATURE_IPV6 int inet=1; int inet6=1; @@ -600,14 +600,14 @@ int netstat_main(int argc, char **argv) bb_show_usage(); } if ( showroute ) { -#ifdef CONFIG_ROUTE +#ifdef CONFIG_ROUTE displayroutes ( flags & NETSTAT_NUMERIC, !extended ); - return 0; + return 0; #else bb_error_msg_and_die( "-r (display routing table) is not compiled in." ); #endif - } - + } + if (new_flags) { flags &= ~(NETSTAT_TCP|NETSTAT_UDP|NETSTAT_RAW|NETSTAT_UNIX); flags |= new_flags; diff --git a/networking/nslookup.c b/networking/nslookup.c index 3295106..bb691d6 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -187,7 +187,7 @@ int nslookup_main(int argc, char **argv) if (argc < 2 || *argv[1]=='-' || argc > 3) bb_show_usage(); - else if(argc == 3) + else if(argc == 3) set_default_dns(argv[2]); server_print(); @@ -200,4 +200,4 @@ int nslookup_main(int argc, char **argv) return EXIT_SUCCESS; } -/* $Id: nslookup.c,v 1.31 2004/01/30 22:40:05 andersen Exp $ */ +/* $Id: nslookup.c,v 1.32 2004/03/15 08:28:48 andersen Exp $ */ diff --git a/networking/ping.c b/networking/ping.c index a38f356..50f3930 100644 --- a/networking/ping.c +++ b/networking/ping.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping.c,v 1.55 2003/07/22 08:56:51 andersen Exp $ + * $Id: ping.c,v 1.56 2004/03/15 08:28:48 andersen Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> @@ -27,7 +27,7 @@ * * This code is derived from software contributed to Berkeley by * Mike Muuss. - * + * * Original copyright notice is retained at the end of this file. */ @@ -329,7 +329,7 @@ static void unpack(char *buf, int sz, struct sockaddr_in *from) if (dupflag) printf(" (DUP!)"); printf("\n"); - } else + } else if (icmppkt->icmp_type != ICMP_ECHO) bb_error_msg("Warning: Got ICMP %d (%s)", icmppkt->icmp_type, icmp_type_name (icmppkt->icmp_type)); @@ -451,8 +451,8 @@ extern int ping_main(int argc, char **argv) * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change - * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> + * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change + * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> * * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software diff --git a/networking/ping6.c b/networking/ping6.c index d9d0dd3..72867f3 100644 --- a/networking/ping6.c +++ b/networking/ping6.c @@ -1,6 +1,6 @@ /* vi: set sw=4 ts=4: */ /* - * $Id: ping6.c,v 1.5 2003/05/22 07:10:22 andersen Exp $ + * $Id: ping6.c,v 1.6 2004/03/15 08:28:48 andersen Exp $ * Mini ping implementation for busybox * * Copyright (C) 1999 by Randolph Chung <tausq@debian.org> @@ -27,7 +27,7 @@ * * This code is derived from software contributed to Berkeley by * Mike Muuss. - * + * * Original copyright notice is retained at the end of this file. * * This version is an adaptation of ping.c from busybox. @@ -162,7 +162,7 @@ static unsigned long tmin = ULONG_MAX, tmax, tsum; static char rcvd_tbl[MAX_DUP_CHK / 8]; # ifdef CONFIG_FEATURE_FANCY_PING -extern +extern # endif struct hostent *hostent; @@ -302,12 +302,12 @@ static void unpack(char *packet, int sz, struct sockaddr_in6 *from, int hoplimit inet_ntop(AF_INET6, (struct in_addr6 *) &pingaddr.sin6_addr, buf, sizeof(buf)), icmppkt->icmp6_seq); - printf(" ttl=%d time=%lu.%lu ms", hoplimit, + printf(" ttl=%d time=%lu.%lu ms", hoplimit, triptime / 10, triptime % 10); if (dupflag) printf(" (DUP!)"); printf("\n"); - } else + } else if (icmppkt->icmp6_type != ICMP6_ECHO_REQUEST) bb_error_msg("Warning: Got ICMP %d (%s)", icmppkt->icmp6_type, icmp6_type_name (icmppkt->icmp6_type)); @@ -494,8 +494,8 @@ extern int ping6_main(int argc, char **argv) * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change - * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> + * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change + * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> * * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software diff --git a/networking/route.c b/networking/route.c index 111900d..9e7a010 100644 --- a/networking/route.c +++ b/networking/route.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: route.c,v 1.24 2004/03/10 07:42:38 mjn3 Exp $ + * $Id: route.c,v 1.25 2004/03/15 08:28:49 andersen Exp $ * * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> @@ -107,7 +107,7 @@ static const char tbl_hash_net_host[] = #define KW_IPVx_DYN 042 #define KW_IPVx_REINSTATE 043 -static const char tbl_ipvx[] = +static const char tbl_ipvx[] = /* 020 is the "takes an arg" bit */ #if HAVE_NEW_ADDRT "\011\020metric\0" @@ -206,7 +206,7 @@ static void INET_setroute(int action, char **args) while (*args) { int k = kw_lookup(tbl_ipvx, &args); const char *args_m1 = args[-1]; - + if (k & KW_IPVx_FLAG_ONLY) { rt.rt_flags |= flags_ipvx[k & 3]; continue; @@ -666,7 +666,7 @@ int route_main(int argc, char **argv) p[0][0] = '#'; } } - } + } opt = bb_getopt_ulflags(argc, argv, "A:ne", &family); diff --git a/networking/telnet.c b/networking/telnet.c index 574fe8d..6c5f3d1 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -54,7 +54,7 @@ static const int DOTRACE = 1; #include <arpa/inet.h> /* for inet_ntoa()... */ #define TRACE(x, y) do { if (x) printf y; } while (0) #else -#define TRACE(x, y) +#define TRACE(x, y) #endif #if 0 @@ -99,8 +99,8 @@ static struct Globalvars { /* buffer to handle telnet negotiations */ char iacbuf[IACBUFSIZE]; short iaclen; /* could even use byte */ - struct termios termios_def; - struct termios termios_raw; + struct termios termios_def; + struct termios termios_raw; } G; #define xUSE_GLOBALVAR_PTR /* xUSE... -> don't use :D (makes smaller code) */ @@ -143,7 +143,7 @@ static void doexit(int ev) { cookmode(); exit(ev); -} +} static void conescape(void) { @@ -190,10 +190,10 @@ static void conescape(void) if (G.gotsig) cookmode(); - + rrturn: G.gotsig = 0; - + } static void handlenetoutput(int len) { @@ -442,7 +442,7 @@ static void will_charmode(void) G.charmode = CHM_TRY; G.telflags |= (UF_ECHO | UF_SGA); setConMode(); - + putiac2(DO, TELOPT_ECHO); putiac2(DO, TELOPT_SGA); iacflush(); @@ -472,7 +472,7 @@ static inline void to_echo(void) /* if server requests ECHO, don't agree */ if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; } else if (G.telwish == DONT) return; - + if (G.telflags & UF_ECHO) { if (G.telwish == WILL) @@ -506,7 +506,7 @@ static inline void to_sga(void) else if (G.telwish == WONT) return; - + if ((G.telflags ^= UF_SGA) & UF_SGA) /* toggle */ putiac2(DO, TELOPT_SGA); else @@ -545,11 +545,11 @@ static inline void to_new_environ(void) #ifdef CONFIG_FEATURE_AUTOWIDTH static inline void to_naws(void) -{ +{ /* Tell server we will do NAWS */ putiac2(WILL, TELOPT_NAWS); return; -} +} #endif static void telopt(byte c) @@ -617,7 +617,7 @@ static void fgotsig(int sig) static void rawmode(void) { tcsetattr(0, TCSADRAIN, &G.termios_raw); -} +} static void cookmode(void) { @@ -630,10 +630,10 @@ extern int telnet_main(int argc, char** argv) struct sockaddr_in s_in; #ifdef USE_POLL struct pollfd ufds[2]; -#else +#else fd_set readfds; int maxfd; -#endif +#endif #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN int opt; @@ -651,13 +651,13 @@ extern int telnet_main(int argc, char** argv) if (tcgetattr(0, &G.termios_def) < 0) exit(1); - + G.termios_raw = G.termios_def; cfmakeraw(&G.termios_raw); - + if (argc < 2) bb_show_usage(); - + #ifdef CONFIG_FEATURE_TELNET_AUTOLOGIN autologin = NULL; while ((opt = getopt(argc, argv, "al:")) != EOF) { @@ -685,7 +685,7 @@ extern int telnet_main(int argc, char** argv) bb_lookup_host(&s_in, argv[1]); s_in.sin_port = bb_lookup_port((argc == 3) ? argv[2] : "telnet", "tcp", 23); #endif - + G.netfd = xconnect(&s_in); setsockopt(G.netfd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof one); @@ -695,22 +695,22 @@ extern int telnet_main(int argc, char** argv) #ifdef USE_POLL ufds[0].fd = 0; ufds[1].fd = G.netfd; ufds[0].events = ufds[1].events = POLLIN; -#else +#else FD_ZERO(&readfds); FD_SET(0, &readfds); FD_SET(G.netfd, &readfds); maxfd = G.netfd + 1; #endif - + while (1) { #ifndef USE_POLL fd_set rfds = readfds; - + switch (select(maxfd, &rfds, NULL, NULL, NULL)) #else switch (poll(ufds, 2, -1)) -#endif +#endif { case 0: /* timeout */ @@ -725,9 +725,9 @@ extern int telnet_main(int argc, char** argv) #ifdef USE_POLL if (ufds[0].revents) /* well, should check POLLIN, but ... */ -#else +#else if (FD_ISSET(0, &rfds)) -#endif +#endif { len = read(0, G.buf, DATABUFSIZE); @@ -735,15 +735,15 @@ extern int telnet_main(int argc, char** argv) doexit(0); TRACE(0, ("Read con: %d\n", len)); - + handlenetoutput(len); } #ifdef USE_POLL if (ufds[1].revents) /* well, should check POLLIN, but ... */ -#else +#else if (FD_ISSET(G.netfd, &rfds)) -#endif +#endif { len = read(G.netfd, G.buf, DATABUFSIZE); diff --git a/networking/telnetd.c b/networking/telnetd.c index 3051cfa..efb2988 100644 --- a/networking/telnetd.c +++ b/networking/telnetd.c @@ -1,4 +1,4 @@ -/* $Id: telnetd.c,v 1.10 2004/02/22 09:45:57 bug1 Exp $ +/* $Id: telnetd.c,v 1.11 2004/03/15 08:28:53 andersen Exp $ * * Simple telnet server * Bjorn Wesen, Axis Communications AB (bjornw@axis.com) @@ -49,7 +49,7 @@ #define BUFSIZE 4000 -static const char *loginpath +static const char *loginpath #ifdef CONFIG_LOGIN = "/bin/login"; #else @@ -540,7 +540,7 @@ telnetd_main(int argc, char **argv) #ifndef CONFIG_FEATURE_TELNETD_INETD struct tsession *next = ts->next; /* in case we free ts. */ #endif /* CONFIG_FEATURE_TELNETD_INETD */ - + if (ts->size1 && FD_ISSET(ts->ptyfd, &wrfdset)) { int num_totty; char *ptr; diff --git a/networking/tftp.c b/networking/tftp.c index 10aa63b..bd973d7 100644 --- a/networking/tftp.c +++ b/networking/tftp.c @@ -76,15 +76,15 @@ const int tftp_cmd_put = 2; #ifdef CONFIG_FEATURE_TFTP_BLOCKSIZE -static int tftp_blocksize_check(int blocksize, int bufsize) +static int tftp_blocksize_check(int blocksize, int bufsize) { - /* Check if the blocksize is valid: + /* Check if the blocksize is valid: * RFC2348 says between 8 and 65464, * but our implementation makes it impossible * to use blocksizes smaller than 22 octets. */ - if ((bufsize && (blocksize > bufsize)) || + if ((bufsize && (blocksize > bufsize)) || (blocksize < 8) || (blocksize > 65464)) { bb_error_msg("bad blocksize"); return 0; @@ -93,12 +93,12 @@ static int tftp_blocksize_check(int blocksize, int bufsize) return blocksize; } -static char *tftp_option_get(char *buf, int len, char *option) +static char *tftp_option_get(char *buf, int len, char *option) { int opt_val = 0; int opt_found = 0; int k; - + while (len > 0) { /* Make sure the options are terminated correctly */ @@ -117,21 +117,21 @@ static char *tftp_option_get(char *buf, int len, char *option) if (strcasecmp(buf, option) == 0) { opt_found = 1; } - } + } else { if (opt_found) { return buf; } } - + k++; - + buf += k; len -= k; - + opt_val ^= 1; } - + return NULL; } @@ -207,7 +207,7 @@ static inline int tftp(const int cmd, const struct hostent *host, if ((cmd_get && (opcode == TFTP_RRQ)) || (cmd_put && (opcode == TFTP_WRQ))) { - int too_long = 0; + int too_long = 0; /* see if the filename fits into buf */ /* and fill in packet */ @@ -380,7 +380,7 @@ static inline int tftp(const int cmd, const struct hostent *host, if (buf[4] != '\0') { msg = &buf[4]; buf[tftp_bufsize - 1] = '\0'; - } else if (tmp < (sizeof(tftp_bb_error_msg) + } else if (tmp < (sizeof(tftp_bb_error_msg) / sizeof(char *))) { msg = (char *) tftp_bb_error_msg[tmp]; @@ -404,12 +404,12 @@ static inline int tftp(const int cmd, const struct hostent *host, char *res; - res = tftp_option_get(&buf[2], len-2, + res = tftp_option_get(&buf[2], len-2, "blksize"); if (res) { int blksize = atoi(res); - + if (tftp_blocksize_check(blksize, tftp_bufsize - 4)) { @@ -443,7 +443,7 @@ static inline int tftp(const int cmd, const struct hostent *host, if (cmd_get && (opcode == TFTP_DATA)) { if (tmp == block_nr) { - + len = write(localfd, &buf[4], len - 4); if (len < 0) { @@ -506,13 +506,13 @@ int tftp_main(int argc, char **argv) #ifdef CONFIG_FEATURE_TFTP_GET #define GET "g" #else -#define GET +#define GET #endif #ifdef CONFIG_FEATURE_TFTP_PUT #define PUT "p" #else -#define PUT +#define PUT #endif while ((opt = getopt(argc, argv, BS GET PUT "l:r:")) != -1) { @@ -537,7 +537,7 @@ int tftp_main(int argc, char **argv) flags = O_RDONLY; break; #endif - case 'l': + case 'l': localfile = bb_xstrdup(optarg); break; case 'r': diff --git a/networking/traceroute.c b/networking/traceroute.c index 5f8989f..44ffdf0 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -75,7 +75,7 @@ #include <netinet/ip.h> #include <netinet/ip_icmp.h> - + #define MAXPACKET 65535 /* max ip packet size */ #ifndef MAXHOSTNAMELEN #define MAXHOSTNAMELEN 64 diff --git a/networking/udhcp/AUTHORS b/networking/udhcp/AUTHORS index bb58de1..f3f4336 100644 --- a/networking/udhcp/AUTHORS +++ b/networking/udhcp/AUTHORS @@ -8,7 +8,6 @@ Chris Trew <christ@moreton.com.au> Other Credits: -------------- Moreton Bay (http://www.moretonbay.com/) -Lineo (http://opensource.lineo.com) Vladimir Oleynik <dzo@simtrea.ru> Size optimizations diff --git a/networking/udhcp/ChangeLog b/networking/udhcp/ChangeLog index f1aac06..2feffc7 100644 --- a/networking/udhcp/ChangeLog +++ b/networking/udhcp/ChangeLog @@ -39,7 +39,7 @@ (Ted Lemon <Ted.Lemon@nominum.com>) + Improved (hopefully) NAKing behavior (me) + Added -b option (Jouni Malinen) -+ Compute checksums correctly on big endian hosts ++ Compute checksums correctly on big endian hosts (Jouni Malinen <jkmaline@cc.hut.fi>) 0.9.7 (020526) diff --git a/networking/udhcp/Makefile b/networking/udhcp/Makefile index ee34d48..2b79d22 100644 --- a/networking/udhcp/Makefile +++ b/networking/udhcp/Makefile @@ -1,6 +1,6 @@ # Makefile for busybox # -# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/networking/udhcp/Makefile.in b/networking/udhcp/Makefile.in index 4d3f270..b480794 100644 --- a/networking/udhcp/Makefile.in +++ b/networking/udhcp/Makefile.in @@ -1,6 +1,6 @@ # Makefile for busybox # -# Copyright (C) 1999-2003 by Erik Andersen <andersen@codepoet.org> +# Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/networking/udhcp/README b/networking/udhcp/README index eddb24b..dd99294 100644 --- a/networking/udhcp/README +++ b/networking/udhcp/README @@ -10,30 +10,30 @@ compile time options ------------------- The Makefile contains three of the compile time options: - + UDHCP_DEBUG: If UDHCP_DEBUG is defined, udhcpd will output extra debugging output, compile with -g, and not fork to the background when run. UDHCP_SYSLOG: If UDHCP_SYSLOG is defined, udhcpd will log all its messages syslog, otherwise, it will attempt to log them to stdout. - + COMBINED_BINARY: If COMBINED_BINARY is define, one binary, udhcpd, is created. If called as udhcpd, the dhcp server will be started. If called as udhcpc, the dhcp client will be started. - + dhcpd.h contains the other three compile time options: - + LEASE_TIME: The default lease time if not specified in the config file. LEASES_FILE: The default file for storing leases. - + DHCPD_CONFIG_FILE: The defualt config file to use. - + options.c contains a set of dhcp options for the client: name[10]: The name of the option as it will appear in scripts - + flags: The type of option, as well as if it will be requested by the client (OPTION_REQ) @@ -45,7 +45,7 @@ busybox drop-in udhcp is now a drop-in component for busybox (http://busybox.net). To update busybox to the latest revision, simply do a: -cp *.[ch] README AUTHORS COPYING ChangeLog TODO \ +cp *.[ch] README AUTHORS COPYING ChangeLog TODO \ <busybox_source>/networking/udhcp The only two files udhcp does not provide are config.in and diff --git a/networking/udhcp/README.udhcpc b/networking/udhcp/README.udhcpc index 8aee981..d720a37 100644 --- a/networking/udhcp/README.udhcpc +++ b/networking/udhcp/README.udhcpc @@ -36,20 +36,20 @@ udhcp client scripts When an event occurs, udhcpc calls the action script. udhcpc never does any configuration of the network interface itself, but instead relies on -a set of scripts. The script by default is +a set of scripts. The script by default is /usr/share/udhcpc/default.script but this can be changed via the command line arguments. The three possible arguments to the script are: deconfig: This argument is used when udhcpc starts, and when a leases is lost. The script must put the interface in an up, but deconfigured state, ie: ifconfig $interface 0.0.0.0. - + bound: This argument is used when udhcpc moves from an unbound, to a bound state. All of the paramaters are set in enviromental variables, The script should configure the interface, - and set any other relavent parameters (default gateway, dns server, + and set any other relavent parameters (default gateway, dns server, etc). - + renew: This argument is used when a DHCP lease is renewed. All of the paramaters are set in enviromental variables. This argument is used when the interface is already configured, so the IP address, @@ -133,7 +133,7 @@ compile time options options.c contains a set of dhcp options for the client: name[10]: The name of the option as it will appear in scripts - + flags: The type of option, as well as if it will be requested by the client (OPTION_REQ) diff --git a/networking/udhcp/README.udhcpd b/networking/udhcp/README.udhcpd index bc6137d..169de78 100644 --- a/networking/udhcp/README.udhcpd +++ b/networking/udhcp/README.udhcpd @@ -14,7 +14,7 @@ udhcpd.leases The udhcpd.leases behavior is designed for an embedded system. The file is written either every auto_time seconds, or when a SIGUSR1 -is received (the auto_time timer restarts if a SIGUSR1 is received). +is received (the auto_time timer restarts if a SIGUSR1 is received). If you send a SIGTERM to udhcpd directly after a SIGUSR1, udhcpd will finish writing the leases file and wait for the aftermentioned script to be executed and finish before quiting, so you do not need to sleep @@ -50,10 +50,10 @@ available options and comments describing them in samples/udhcpd.conf compile time options ------------------- - + dhcpd.h contains the other two compile time options: - + LEASE_TIME: The default lease time if not specified in the config file. - + DHCPD_CONFIG_FILE: The defualt config file to use. diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c index 23c7d46..ab4c6d2 100644 --- a/networking/udhcp/arpping.c +++ b/networking/udhcp/arpping.c @@ -25,8 +25,8 @@ * interface - interface to use * retn: 1 addr free * 0 addr used - * -1 error - */ + * -1 error + */ /* FIXME: match response against chaddr */ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) @@ -51,7 +51,7 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) #endif return -1; } - + if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, &optval, sizeof(optval)) == -1) { LOG(LOG_ERR, "Could not setsocketopt on raw socket"); close(s); @@ -71,12 +71,12 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) memcpy(arp.sInaddr, &ip, sizeof(ip)); /* source IP address */ memcpy(arp.sHaddr, mac, 6); /* source hardware address */ memcpy(arp.tInaddr, &yiaddr, sizeof(yiaddr)); /* target IP address */ - + memset(&addr, 0, sizeof(addr)); strcpy(addr.sa_data, interface); if (sendto(s, &arp, sizeof(arp), 0, &addr, sizeof(addr)) < 0) rv = 0; - + /* wait arp reply, and check it */ tm.tv_usec = 0; time(&prevTime); @@ -89,8 +89,8 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) if (errno != EINTR) rv = 0; } else if (FD_ISSET(s, &fdset)) { if (recv(s, &arp, sizeof(arp), 0) < 0 ) rv = 0; - if (arp.operation == htons(ARPOP_REPLY) && - bcmp(arp.tHaddr, mac, 6) == 0 && + if (arp.operation == htons(ARPOP_REPLY) && + bcmp(arp.tHaddr, mac, 6) == 0 && *((uint32_t *) arp.sInaddr) == yiaddr) { DEBUG(LOG_INFO, "Valid arp reply receved for this address"); rv = 0; @@ -101,6 +101,6 @@ int arpping(uint32_t yiaddr, uint32_t ip, uint8_t *mac, char *interface) time(&prevTime); } close(s); - DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); + DEBUG(LOG_INFO, "%salid arp replies for this address", rv ? "No v" : "V"); return rv; } diff --git a/networking/udhcp/arpping.h b/networking/udhcp/arpping.h index 6cbd297..6f27d9f 100644 --- a/networking/udhcp/arpping.h +++ b/networking/udhcp/arpping.h @@ -15,7 +15,7 @@ struct arpMsg { u_char h_dest[6]; /* destination ether addr */ u_char h_source[6]; /* source ether addr */ u_short h_proto; /* packet type ID field */ - + /* ARP packet */ uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */ uint16_t ptype; /* protocol type (must be ETH_P_IP) */ diff --git a/networking/udhcp/clientpacket.c b/networking/udhcp/clientpacket.c index 6838c07..5b27004 100644 --- a/networking/udhcp/clientpacket.c +++ b/networking/udhcp/clientpacket.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include <string.h> #include <sys/socket.h> #include <features.h> @@ -73,7 +73,7 @@ static void init_packet(struct dhcpMessage *packet, char type) char vendor, length; char str[sizeof("udhcp "VERSION)]; } vendor_id = { DHCP_VENDOR, sizeof("udhcp "VERSION) - 1, "udhcp "VERSION}; - + init_header(packet, type); memcpy(packet->chaddr, client_config.arp, 6); add_option_string(packet->options, client_config.clientid); @@ -112,7 +112,7 @@ int send_discover(unsigned long xid, unsigned long requested) add_requests(&packet); LOG(LOG_DEBUG, "Sending discover..."); - return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, + return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); } @@ -128,11 +128,11 @@ int send_selecting(unsigned long xid, unsigned long server, unsigned long reques add_simple_option(packet.options, DHCP_REQUESTED_IP, requested); add_simple_option(packet.options, DHCP_SERVER_ID, server); - + add_requests(&packet); addr.s_addr = requested; LOG(LOG_DEBUG, "Sending select for %s...", inet_ntoa(addr)); - return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, + return raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); } @@ -149,12 +149,12 @@ int send_renew(unsigned long xid, unsigned long server, unsigned long ciaddr) add_requests(&packet); LOG(LOG_DEBUG, "Sending renew..."); - if (server) + if (server) ret = kernel_packet(&packet, ciaddr, CLIENT_PORT, server, SERVER_PORT); else ret = raw_packet(&packet, INADDR_ANY, CLIENT_PORT, INADDR_BROADCAST, SERVER_PORT, MAC_BCAST_ADDR, client_config.ifindex); return ret; -} +} /* Unicasts a DHCP release message */ @@ -165,7 +165,7 @@ int send_release(unsigned long server, unsigned long ciaddr) init_packet(&packet, DHCPRELEASE); packet.xid = random_xid(); packet.ciaddr = ciaddr; - + add_simple_option(packet.options, DHCP_REQUESTED_IP, ciaddr); add_simple_option(packet.options, DHCP_SERVER_ID, server); @@ -189,20 +189,20 @@ int get_raw_packet(struct dhcpMessage *payload, int fd) usleep(500000); /* possible down interface, looping condition */ return -1; } - + if (bytes < (int) (sizeof(struct iphdr) + sizeof(struct udphdr))) { DEBUG(LOG_INFO, "message too short, ignoring"); return -2; } - + if (bytes < ntohs(packet.ip.tot_len)) { DEBUG(LOG_INFO, "Truncated packet"); return -2; } - + /* ignore any extra garbage bytes */ bytes = ntohs(packet.ip.tot_len); - + /* Make sure its the right packet for us, and that it passes sanity checks */ if (packet.ip.protocol != IPPROTO_UDP || packet.ip.version != IPVERSION || packet.ip.ihl != sizeof(packet.ip) >> 2 || packet.udp.dest != htons(CLIENT_PORT) || @@ -219,7 +219,7 @@ int get_raw_packet(struct dhcpMessage *payload, int fd) DEBUG(LOG_INFO, "bad IP header checksum, ignoring"); return -1; } - + /* verify the UDP checksum by replacing the header with a psuedo header */ source = packet.ip.saddr; dest = packet.ip.daddr; @@ -235,14 +235,14 @@ int get_raw_packet(struct dhcpMessage *payload, int fd) DEBUG(LOG_ERR, "packet with bad UDP checksum received, ignoring"); return -2; } - + memcpy(payload, &(packet.data), bytes - (sizeof(packet.ip) + sizeof(packet.udp))); - + if (ntohl(payload->cookie) != DHCP_MAGIC) { LOG(LOG_ERR, "received bogus message (bad magic) -- ignoring"); return -2; } DEBUG(LOG_INFO, "oooooh!!! got some!"); return bytes - (sizeof(packet.ip) + sizeof(packet.udp)); - + } diff --git a/networking/udhcp/common.c b/networking/udhcp/common.c index 8542c66..5dad7d5 100644 --- a/networking/udhcp/common.c +++ b/networking/udhcp/common.c @@ -55,7 +55,7 @@ static inline void sanitize_fds(void) void background(const char *pidfile) { #ifdef __uClinux__ - LOG(LOG_ERR, "Cannot background in uclinux (yet)"); + LOG(LOG_ERR, "Cannot background in uclinux (yet)"); #else /* __uClinux__ */ int pid_fd; diff --git a/networking/udhcp/common.h b/networking/udhcp/common.h index 78eb1c1..677bbfd 100644 --- a/networking/udhcp/common.h +++ b/networking/udhcp/common.h @@ -43,7 +43,7 @@ void background(const char *pidfile); void start_log_and_pid(const char *client_server, const char *pidfile); void background(const char *pidfile); void udhcp_logging(int level, const char *fmt, ...); - + #define LOG(level, str, args...) udhcp_logging(level, str, ## args) #ifdef UDHCP_DEBUG diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 2ba42d2..dda6789 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c @@ -18,7 +18,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - + #include <sys/time.h> #include <sys/file.h> #include <unistd.h> @@ -152,7 +152,7 @@ static void perform_release(void) temp_addr.s_addr = server_addr; sprintf(buffer, "%s", inet_ntoa(temp_addr)); temp_addr.s_addr = requested_ip; - LOG(LOG_INFO, "Unicasting a release of %s to %s", + LOG(LOG_INFO, "Unicasting a release of %s to %s", inet_ntoa(temp_addr), buffer); send_release(server_addr, requested_ip); /* unicast */ run_script(NULL, "deconfig"); @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) int option_index = 0; c = getopt_long(argc, argv, "c:fbH:h:i:np:qr:s:v", arg_options, &option_index); if (c == -1) break; - + switch (c) { case 'c': len = strlen(optarg) > 255 ? 255 : strlen(optarg); @@ -269,10 +269,10 @@ int main(int argc, char *argv[]) /* Start the log, sanitize fd's, and write a pid file */ start_log_and_pid("udhcpc", client_config.pidfile); - if (read_interface(client_config.interface, &client_config.ifindex, + if (read_interface(client_config.interface, &client_config.ifindex, NULL, client_config.arp) < 0) return 1; - + if (!client_config.clientid) { client_config.clientid = xmalloc(6 + 3); client_config.clientid[OPT_CODE] = DHCP_CLIENT_ID; @@ -282,8 +282,8 @@ int main(int argc, char *argv[]) } /* setup the signal pipe */ - udhcp_sp_setup(); - + udhcp_sp_setup(); + state = INIT_SELECTING; run_script(NULL, "deconfig"); change_mode(LISTEN_RAW); @@ -321,7 +321,7 @@ int main(int argc, char *argv[]) /* send discover packet */ send_discover(xid, requested_ip); /* broadcast */ - + timeout = now + ((packet_num == 2) ? 4 : 2); packet_num++; } else { @@ -345,7 +345,7 @@ int main(int argc, char *argv[]) if (state == RENEW_REQUESTED) send_renew(xid, server_addr, requested_ip); /* unicast */ else send_selecting(xid, server_addr, requested_ip); /* broadcast */ - + timeout = now + ((packet_num == 2) ? 10 : 2); packet_num++; } else { @@ -373,7 +373,7 @@ int main(int argc, char *argv[]) } else { /* send a request packet */ send_renew(xid, server_addr, requested_ip); /* unicast */ - + t1 = (t2 - t1) / 2 + t1; timeout = t1 + start; } @@ -403,28 +403,28 @@ int main(int argc, char *argv[]) } } else if (retval > 0 && listen_mode != LISTEN_NONE && FD_ISSET(fd, &rfds)) { /* a packet is ready, read it */ - + if (listen_mode == LISTEN_KERNEL) len = get_packet(&packet, fd); else len = get_raw_packet(&packet, fd); - + if (len == -1 && errno != EINTR) { DEBUG(LOG_INFO, "error on read, %m, reopening socket"); change_mode(listen_mode); /* just close and reopen */ } if (len < 0) continue; - + if (packet.xid != xid) { DEBUG(LOG_INFO, "Ignoring XID %lx (our xid is %lx)", (unsigned long) packet.xid, xid); continue; } - + if ((message = get_option(&packet, DHCP_MESSAGE_TYPE)) == NULL) { DEBUG(LOG_ERR, "couldnt get option from packet -- ignoring"); continue; } - + switch (state) { case INIT_SELECTING: /* Must be a DHCPOFFER to one of our xid's */ @@ -433,7 +433,7 @@ int main(int argc, char *argv[]) memcpy(&server_addr, temp, 4); xid = packet.xid; requested_ip = packet.yiaddr; - + /* enter requesting state */ state = REQUESTING; timeout = now; @@ -455,14 +455,14 @@ int main(int argc, char *argv[]) memcpy(&lease, temp, 4); lease = ntohl(lease); } - + /* enter bound state */ t1 = lease / 2; - + /* little fixed point for n * .875 */ t2 = (lease * 0x7) >> 3; temp_addr.s_addr = packet.yiaddr; - LOG(LOG_INFO, "Lease of %s obtained, lease time %ld", + LOG(LOG_INFO, "Lease of %s obtained, lease time %ld", inet_ntoa(temp_addr), lease); start = now; timeout = t1 + start; @@ -472,7 +472,7 @@ int main(int argc, char *argv[]) state = BOUND; change_mode(LISTEN_NONE); - if (client_config.quit_after_lease) + if (client_config.quit_after_lease) return 0; if (!client_config.foreground) client_background(); @@ -492,10 +492,10 @@ int main(int argc, char *argv[]) } break; /* case BOUND, RELEASED: - ignore all packets */ - } + } } else if (retval > 0 && (sig = udhcp_sp_read(&rfds))) { switch (sig) { - case SIGUSR1: + case SIGUSR1: perform_renew(); break; case SIGUSR2: @@ -506,12 +506,12 @@ int main(int argc, char *argv[]) return 0; } } else if (retval == -1 && errno == EINTR) { - /* a signal was caught */ + /* a signal was caught */ } else { /* An error occured */ DEBUG(LOG_ERR, "Error on select"); } - + } return 0; } diff --git a/networking/udhcp/dhcpd.c b/networking/udhcp/dhcpd.c index 8c944f2..6f38f07 100644 --- a/networking/udhcp/dhcpd.c +++ b/networking/udhcp/dhcpd.c @@ -51,12 +51,12 @@ struct dhcpOfferedAddr *leases; struct server_config_t server_config; -#ifdef COMBINED_BINARY +#ifdef COMBINED_BINARY int udhcpd_main(int argc, char *argv[]) #else int main(int argc, char *argv[]) #endif -{ +{ fd_set rfds; struct timeval tv; int server_socket = -1; @@ -70,7 +70,7 @@ int main(int argc, char *argv[]) struct dhcpOfferedAddr *lease; int max_sock; unsigned long num_ips; - + memset(&server_config, 0, sizeof(struct server_config_t)); read_config(argc < 2 ? DHCPD_CONF_FILE : argv[1]); @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) server_config.lease = ntohl(server_config.lease); } else server_config.lease = LEASE_TIME; - + /* Sanity check */ num_ips = ntohl(server_config.end) - ntohl(server_config.start); if (server_config.max_leases > num_ips) { @@ -113,7 +113,7 @@ int main(int argc, char *argv[]) if ((server_socket = listen_socket(INADDR_ANY, SERVER_PORT, server_config.interface)) < 0) { LOG(LOG_ERR, "FATAL: couldn't create server socket, %m"); return 2; - } + } max_sock = udhcp_sp_fd_set(&rfds, server_socket); if (server_config.auto_time) { @@ -121,7 +121,7 @@ int main(int argc, char *argv[]) tv.tv_usec = 0; } if (!server_config.auto_time || tv.tv_sec > 0) { - retval = select(max_sock + 1, &rfds, NULL, NULL, + retval = select(max_sock + 1, &rfds, NULL, NULL, server_config.auto_time ? &tv : NULL); } else retval = 0; /* If we already timed out, fall through */ @@ -133,7 +133,7 @@ int main(int argc, char *argv[]) DEBUG(LOG_INFO, "error on select"); continue; } - + switch (udhcp_sp_read(&rfds)) { case SIGUSR1: LOG(LOG_INFO, "Received a SIGUSR1"); @@ -161,17 +161,17 @@ int main(int argc, char *argv[]) DEBUG(LOG_ERR, "couldn't get option from packet, ignoring"); continue; } - + /* ADDME: look for a static lease */ lease = find_lease_by_chaddr(packet.chaddr); switch (state[0]) { case DHCPDISCOVER: DEBUG(LOG_INFO,"received DISCOVER"); - + if (sendOffer(&packet) < 0) { LOG(LOG_ERR, "send OFFER failed"); } - break; + break; case DHCPREQUEST: DEBUG(LOG_INFO, "received REQUEST"); @@ -180,12 +180,12 @@ int main(int argc, char *argv[]) if (requested) memcpy(&requested_align, requested, 4); if (server_id) memcpy(&server_id_align, server_id, 4); - + if (lease) { /*ADDME: or static lease */ if (server_id) { /* SELECTING State */ DEBUG(LOG_INFO, "server_id = %08x", ntohl(server_id_align)); - if (server_id_align == server_config.server && requested && + if (server_id_align == server_config.server && requested && requested_align == lease->yiaddr) { sendACK(&packet, lease->yiaddr); } @@ -203,9 +203,9 @@ int main(int argc, char *argv[]) /* don't know what to do!!!! */ sendNAK(&packet); } - } + } } - + /* what to do if we have no record of the client */ } else if (server_id) { /* SELECTING State */ @@ -218,7 +218,7 @@ int main(int argc, char *argv[]) memset(lease->chaddr, 0, 16); /* make some contention for this address */ } else sendNAK(&packet); - } else if (requested_align < server_config.start || + } else if (requested_align < server_config.start || requested_align > server_config.end) { sendNAK(&packet); } /* else remain silent */ @@ -232,7 +232,7 @@ int main(int argc, char *argv[]) if (lease) { memset(lease->chaddr, 0, 16); lease->expires = time(0) + server_config.decline_time; - } + } break; case DHCPRELEASE: DEBUG(LOG_INFO,"received RELEASE"); @@ -241,7 +241,7 @@ int main(int argc, char *argv[]) case DHCPINFORM: DEBUG(LOG_INFO,"received INFORM"); send_inform(&packet); - break; + break; default: LOG(LOG_WARNING, "unsupported DHCP message (%02x) -- ignoring", state[0]); } diff --git a/networking/udhcp/dhcpd.h b/networking/udhcp/dhcpd.h index 9256344..39658a8 100644 --- a/networking/udhcp/dhcpd.h +++ b/networking/udhcp/dhcpd.h @@ -124,10 +124,10 @@ struct server_config_t { uint32_t siaddr; /* next server bootp option */ char *sname; /* bootp server name */ char *boot_file; /* bootp boot file option */ -}; +}; extern struct server_config_t server_config; extern struct dhcpOfferedAddr *leases; - + #endif diff --git a/networking/udhcp/dumpleases.c b/networking/udhcp/dumpleases.c index e2b1931..a9036df 100644 --- a/networking/udhcp/dumpleases.c +++ b/networking/udhcp/dumpleases.c @@ -47,7 +47,7 @@ int main(int argc, char *argv[]) const char *file = LEASES_FILE; struct dhcpOfferedAddr lease; struct in_addr addr; - + static const struct option options[] = { {"absolute", 0, 0, 'a'}, {"remaining", 0, 0, 'r'}, @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) int option_index = 0; c = getopt_long(argc, argv, "arf:", options, &option_index); if (c == -1) break; - + switch (c) { case 'a': mode = ABSOLUTE; break; case 'r': mode = REMAINING; break; @@ -70,10 +70,10 @@ int main(int argc, char *argv[]) show_usage(); } } - + fp = xfopen(file, "r"); - printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at"); + printf("Mac Address IP-Address Expires %s\n", mode == REMAINING ? "in" : "at"); /* "00:00:00:00:00:00 255.255.255.255 Wed Jun 30 21:49:08 1993" */ while (fread(&lease, sizeof(lease), 1, fp)) { @@ -105,6 +105,6 @@ int main(int argc, char *argv[]) } else printf("%s", ctime(&expires)); } fclose(fp); - + return 0; } diff --git a/networking/udhcp/files.c b/networking/udhcp/files.c index 0802bb3..89287ca 100644 --- a/networking/udhcp/files.c +++ b/networking/udhcp/files.c @@ -1,8 +1,8 @@ -/* +/* * files.c -- DHCP server file manipulation * * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001 */ - + #include <sys/socket.h> #include <arpa/inet.h> #include <string.h> @@ -16,7 +16,7 @@ #include "options.h" #include "common.h" -/* +/* * Domain names may have 254 chars, and string options can be 254 * chars long. However, 80 bytes will be enough for most, and won't * hog up memory. If you have a special application, change it @@ -31,7 +31,7 @@ static int read_ip(const char *line, void *arg) int retval = 1; if (!inet_aton(line, addr)) { - if ((host = gethostbyname(line))) + if ((host = gethostbyname(line))) addr->s_addr = *((unsigned long *) host->h_addr_list[0]); else retval = 0; } @@ -42,10 +42,10 @@ static int read_ip(const char *line, void *arg) static int read_str(const char *line, void *arg) { char **dest = arg; - + if (*dest) free(*dest); *dest = strdup(line); - + return 1; } @@ -69,7 +69,7 @@ static int read_yn(const char *line, void *arg) else if (!strcasecmp("no", line)) *dest = 0; else retval = 0; - + return retval; } @@ -89,11 +89,11 @@ static int read_opt(const char *const_line, void *arg) /* Cheat, the only const line we'll actually get is "" */ line = (char *) const_line; if (!(opt = strtok(line, " \t="))) return 0; - + for (option = dhcp_options; option->code; option++) if (!strcasecmp(option->name, opt)) break; - + if (!option->code) return 0; do { @@ -134,17 +134,17 @@ static int read_opt(const char *const_line, void *arg) retval = (endptr[0] == '\0'); break; case OPTION_U32: - *result_u32 = htonl(strtoul(val, &endptr, 0)); + *result_u32 = htonl(strtoul(val, &endptr, 0)); retval = (endptr[0] == '\0'); break; case OPTION_S32: - *result_u32 = htonl(strtol(val, &endptr, 0)); + *result_u32 = htonl(strtol(val, &endptr, 0)); retval = (endptr[0] == '\0'); break; default: break; } - if (retval) + if (retval) attach_option(opt_list, option, opt, length); } while (retval && option->flags & OPTION_LIST); return retval; @@ -193,7 +193,7 @@ int read_config(const char *file) LOG(LOG_ERR, "unable to open config file: %s", file); return 0; } - + while (fgets(buffer, READ_CONFIG_BUF_SIZE, in)) { lm++; if (strchr(buffer, '\n')) *(strchr(buffer, '\n')) = '\0'; @@ -203,14 +203,14 @@ int read_config(const char *file) if (strchr(buffer, '#')) *(strchr(buffer, '#')) = '\0'; if (!(token = strtok(buffer, " \t"))) continue; - if (!(line = strtok(NULL, ""))) continue; - + if (!(line = strtok(NULL, ""))) continue; + /* eat leading whitespace */ line = line + strspn(line, " \t="); /* eat trailing whitespace */ for (i = strlen(line); i > 0 && isspace(line[i - 1]); i--); line[i] = '\0'; - + for (i = 0; keywords[i].keyword[0]; i++) if (!strcasecmp(token, keywords[i].keyword)) if (!keywords[i].handler(line, keywords[i].var)) { @@ -232,12 +232,12 @@ void write_leases(void) char buf[255]; time_t curr = time(0); unsigned long tmp_time; - + if (!(fp = fopen(server_config.lease_file, "w"))) { LOG(LOG_ERR, "Unable to open %s for writing", server_config.lease_file); return; } - + for (i = 0; i < server_config.max_leases; i++) { if (leases[i].yiaddr != 0) { @@ -257,7 +257,7 @@ void write_leases(void) } } fclose(fp); - + if (server_config.notify_file) { sprintf(buf, "%s %s", server_config.notify_file, server_config.lease_file); system(buf); @@ -270,12 +270,12 @@ void read_leases(const char *file) FILE *fp; unsigned int i = 0; struct dhcpOfferedAddr lease; - + if (!(fp = fopen(file, "r"))) { LOG(LOG_ERR, "Unable to open %s for reading", file); return; } - + while (i < server_config.max_leases && (fread(&lease, sizeof lease, 1, fp) == 1)) { /* ADDME: is it a static lease */ if (lease.yiaddr >= server_config.start && lease.yiaddr <= server_config.end) { @@ -284,7 +284,7 @@ void read_leases(const char *file) if (!(add_lease(lease.chaddr, lease.yiaddr, lease.expires))) { LOG(LOG_WARNING, "Too many leases while loading %s\n", file); break; - } + } i++; } } diff --git a/networking/udhcp/frontend.c b/networking/udhcp/frontend.c index de57795..fa77ab9 100644 --- a/networking/udhcp/frontend.c +++ b/networking/udhcp/frontend.c @@ -7,10 +7,10 @@ int main(int argc, char *argv[]) { int ret = 0; char *base = strrchr(argv[0], '/'); - + if (strstr(base ? (base + 1) : argv[0], "dhcpd")) ret = udhcpd_main(argc, argv); else ret = udhcpc_main(argc, argv); - + return ret; } diff --git a/networking/udhcp/leases.c b/networking/udhcp/leases.c index dce0566..d478880 100644 --- a/networking/udhcp/leases.c +++ b/networking/udhcp/leases.c @@ -1,5 +1,5 @@ -/* - * leases.c -- tools to manage DHCP leases +/* + * leases.c -- tools to manage DHCP leases * Russ Dill <Russ.Dill@asu.edu> July 2001 */ @@ -23,9 +23,9 @@ uint8_t blank_chaddr[] = {[0 ... 15] = 0}; void clear_lease(uint8_t *chaddr, uint32_t yiaddr) { unsigned int i, j; - + for (j = 0; j < 16 && !chaddr[j]; j++); - + for (i = 0; i < server_config.max_leases; i++) if ((j != 16 && !memcmp(leases[i].chaddr, chaddr, 16)) || (yiaddr && leases[i].yiaddr == yiaddr)) { @@ -38,18 +38,18 @@ void clear_lease(uint8_t *chaddr, uint32_t yiaddr) struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned long lease) { struct dhcpOfferedAddr *oldest; - + /* clean out any old ones */ clear_lease(chaddr, yiaddr); - + oldest = oldest_expired_lease(); - + if (oldest) { memcpy(oldest->chaddr, chaddr, 16); oldest->yiaddr = yiaddr; oldest->expires = time(0) + lease; } - + return oldest; } @@ -58,7 +58,7 @@ struct dhcpOfferedAddr *add_lease(uint8_t *chaddr, uint32_t yiaddr, unsigned lon int lease_expired(struct dhcpOfferedAddr *lease) { return (lease->expires < (unsigned long) time(0)); -} +} /* Find the oldest expired lease, NULL if there are no expired leases */ @@ -68,14 +68,14 @@ struct dhcpOfferedAddr *oldest_expired_lease(void) unsigned long oldest_lease = time(0); unsigned int i; - + for (i = 0; i < server_config.max_leases; i++) if (oldest_lease > leases[i].expires) { oldest_lease = leases[i].expires; oldest = &(leases[i]); } return oldest; - + } @@ -86,7 +86,7 @@ struct dhcpOfferedAddr *find_lease_by_chaddr(uint8_t *chaddr) for (i = 0; i < server_config.max_leases; i++) if (!memcmp(leases[i].chaddr, chaddr, 16)) return &(leases[i]); - + return NULL; } @@ -98,7 +98,7 @@ struct dhcpOfferedAddr *find_lease_by_yiaddr(uint32_t yiaddr) for (i = 0; i < server_config.max_leases; i++) if (leases[i].yiaddr == yiaddr) return &(leases[i]); - + return NULL; } @@ -120,10 +120,10 @@ static int check_ip(uint32_t addr) /* find an assignable address, it check_expired is true, we check all the expired leases as well. * Maybe this should try expired leases by age... */ -uint32_t find_address(int check_expired) +uint32_t find_address(int check_expired) { uint32_t addr, ret; - struct dhcpOfferedAddr *lease = NULL; + struct dhcpOfferedAddr *lease = NULL; addr = ntohl(server_config.start); /* addr is in host order here */ for (;addr <= ntohl(server_config.end); addr++) { diff --git a/networking/udhcp/options.c b/networking/udhcp/options.c index 1bdf257..d75bc5a 100644 --- a/networking/udhcp/options.c +++ b/networking/udhcp/options.c @@ -1,8 +1,8 @@ -/* - * options.c -- DHCP server option packet tools +/* + * options.c -- DHCP server option packet tools * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001 */ - + #include <stdlib.h> #include <string.h> @@ -64,7 +64,7 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) int i, length; uint8_t *optionptr; int over = 0, done = 0, curr = OPTION_FIELD; - + optionptr = packet->options; i = 0; length = 308; @@ -79,7 +79,7 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) return NULL; } return optionptr + i + 2; - } + } switch (optionptr[i + OPT_CODE]) { case DHCP_PADDING: i++; @@ -114,10 +114,10 @@ uint8_t *get_option(struct dhcpMessage *packet, int code) /* return the position of the 'end' option (no bounds checking) */ -int end_option(uint8_t *optionptr) +int end_option(uint8_t *optionptr) { int i = 0; - + while (optionptr[i] != DHCP_END) { if (optionptr[i] == DHCP_PADDING) i++; else i += optionptr[i + OPT_LEN] + 2; @@ -131,7 +131,7 @@ int end_option(uint8_t *optionptr) int add_option_string(uint8_t *optionptr, uint8_t *string) { int end = end_option(optionptr); - + /* end position + string length + option code/length + end option */ if (end + string[OPT_LEN] + 2 + 1 >= 308) { LOG(LOG_ERR, "Option 0x%02x did not fit into the packet!", string[OPT_CODE]); @@ -162,12 +162,12 @@ int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data) if (dhcp_options[i].code == code) { length = option_lengths[dhcp_options[i].flags & TYPE_MASK]; } - + if (!length) { DEBUG(LOG_ERR, "Could not add option 0x%02x", code); return 0; } - + option[OPT_CODE] = code; option[OPT_LEN] = length; @@ -202,7 +202,7 @@ void attach_option(struct option_set **opt_list, struct dhcp_option *option, cha DEBUG(LOG_INFO, "Attaching option %s to existing member of list", option->name); if (option->flags & OPTION_LIST) { if (existing->data[OPT_LEN] + length <= 255) { - existing->data = realloc(existing->data, + existing->data = realloc(existing->data, existing->data[OPT_LEN] + length + 2); memcpy(existing->data + existing->data[OPT_LEN] + 2, buffer, length); existing->data[OPT_LEN] += length; @@ -210,19 +210,19 @@ void attach_option(struct option_set **opt_list, struct dhcp_option *option, cha } /* else, ignore the new data */ } else { DEBUG(LOG_INFO, "Attaching option %s to list", option->name); - + /* make a new option */ new = xmalloc(sizeof(struct option_set)); new->data = xmalloc(length + 2); new->data[OPT_CODE] = option->code; new->data[OPT_LEN] = length; memcpy(new->data + 2, buffer, length); - + curr = opt_list; while (*curr && (*curr)->data[OPT_CODE] < option->code) curr = &(*curr)->next; - + new->next = *curr; - *curr = new; + *curr = new; } } diff --git a/networking/udhcp/packet.c b/networking/udhcp/packet.c index a3c7ae1..7cbd83a 100644 --- a/networking/udhcp/packet.c +++ b/networking/udhcp/packet.c @@ -66,7 +66,7 @@ int get_packet(struct dhcpMessage *packet, int fd) return -2; } DEBUG(LOG_INFO, "Received a packet"); - + if (packet->op == BOOTREQUEST && (vendor = get_option(packet, DHCP_VENDOR))) { for (i = 0; broken_vendors[i][0]; i++) { if (vendor[OPT_LEN - 2] == (uint8_t) strlen(broken_vendors[i]) && @@ -77,7 +77,7 @@ int get_packet(struct dhcpMessage *packet, int fd) } } } - + return bytes; } @@ -126,10 +126,10 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, DEBUG(LOG_ERR, "socket call failed: %m"); return -1; } - + memset(&dest, 0, sizeof(dest)); memset(&packet, 0, sizeof(packet)); - + dest.sll_family = AF_PACKET; dest.sll_protocol = htons(ETH_P_IP); dest.sll_ifindex = ifindex; @@ -150,7 +150,7 @@ int raw_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_port, packet.ip.tot_len = packet.udp.len; memcpy(&(packet.data), payload, sizeof(struct dhcpMessage)); packet.udp.check = checksum(&packet, sizeof(struct udp_dhcp_packet)); - + packet.ip.tot_len = htons(sizeof(struct udp_dhcp_packet)); packet.ip.ihl = sizeof(packet.ip) >> 2; packet.ip.version = IPVERSION; @@ -173,10 +173,10 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po int n = 1; int fd, result; struct sockaddr_in client; - + if ((fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) return -1; - + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *) &n, sizeof(n)) == -1) return -1; @@ -191,7 +191,7 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po memset(&client, 0, sizeof(client)); client.sin_family = AF_INET; client.sin_port = htons(dest_port); - client.sin_addr.s_addr = dest_ip; + client.sin_addr.s_addr = dest_ip; if (connect(fd, (struct sockaddr *)&client, sizeof(struct sockaddr)) == -1) return -1; @@ -199,4 +199,4 @@ int kernel_packet(struct dhcpMessage *payload, uint32_t source_ip, int source_po result = write(fd, payload, sizeof(struct dhcpMessage)); close(fd); return result; -} +} diff --git a/networking/udhcp/packet.h b/networking/udhcp/packet.h index 22c4d09..f5859e8 100644 --- a/networking/udhcp/packet.h +++ b/networking/udhcp/packet.h @@ -20,7 +20,7 @@ struct dhcpMessage { uint8_t sname[64]; uint8_t file[128]; uint32_t cookie; - uint8_t options[308]; /* 312 - cookie */ + uint8_t options[308]; /* 312 - cookie */ }; struct udp_dhcp_packet { diff --git a/networking/udhcp/script.c b/networking/udhcp/script.c index b7d7862..cae4db7 100644 --- a/networking/udhcp/script.c +++ b/networking/udhcp/script.c @@ -1,6 +1,6 @@ /* script.c * - * Functions to call the DHCP client notification scripts + * Functions to call the DHCP client notification scripts * * Russ Dill <Russ.Dill@asu.edu> July 2001 * @@ -157,7 +157,7 @@ static char **fill_envp(struct dhcpMessage *packet) if (!(over & FILE_FIELD) && packet->file[0]) num_options++; if (!(over & SNAME_FIELD) && packet->sname[0]) num_options++; } - + envp = xcalloc(sizeof(char *), num_options + 5); j = 0; asprintf(&envp[j++], "interface=%s", client_config.interface); @@ -220,13 +220,13 @@ void run_script(struct dhcpMessage *packet, const char *name) return; } else if (pid == 0) { envp = fill_envp(packet); - + /* close fd's? */ - + /* exec script */ execle(client_config.script, client_config.script, name, NULL, envp); LOG(LOG_ERR, "script %s failed: %m", client_config.script); exit(1); - } + } } diff --git a/networking/udhcp/serverpacket.c b/networking/udhcp/serverpacket.c index d39e6ba..937436a 100644 --- a/networking/udhcp/serverpacket.c +++ b/networking/udhcp/serverpacket.c @@ -45,7 +45,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas { uint8_t *chaddr; uint32_t ciaddr; - + if (force_broadcast) { DEBUG(LOG_INFO, "broadcasting packet to client (NAK)"); ciaddr = INADDR_BROADCAST; @@ -63,7 +63,7 @@ static int send_packet_to_client(struct dhcpMessage *payload, int force_broadcas ciaddr = payload->yiaddr; chaddr = payload->chaddr; } - return raw_packet(payload, server_config.server, SERVER_PORT, + return raw_packet(payload, server_config.server, SERVER_PORT, ciaddr, CLIENT_PORT, chaddr, server_config.ifindex); } @@ -101,7 +101,7 @@ static void add_bootp_options(struct dhcpMessage *packet) if (server_config.boot_file) strncpy(packet->file, server_config.boot_file, sizeof(packet->file) - 1); } - + /* send a DHCP OFFER to a DHCP DISCOVER */ int sendOffer(struct dhcpMessage *oldpacket) @@ -114,14 +114,14 @@ int sendOffer(struct dhcpMessage *oldpacket) struct in_addr addr; init_packet(&packet, oldpacket, DHCPOFFER); - + /* ADDME: if static, short circuit */ /* the client is in our lease/offered table */ if ((lease = find_lease_by_chaddr(oldpacket->chaddr))) { - if (!lease_expired(lease)) + if (!lease_expired(lease)) lease_time_align = lease->expires - time(0); packet.yiaddr = lease->yiaddr; - + /* Or the client has a requested ip */ } else if ((req = get_option(oldpacket, DHCP_REQUESTED_IP)) && @@ -131,10 +131,10 @@ int sendOffer(struct dhcpMessage *oldpacket) /* and the ip is in the lease range */ ntohl(req_align) >= ntohl(server_config.start) && ntohl(req_align) <= ntohl(server_config.end) && - + /* and its not already taken/offered */ /* ADDME: check that its not a static lease */ ((!(lease = find_lease_by_yiaddr(req_align)) || - + /* or its taken, but expired */ /* ADDME: or maybe in here */ lease_expired(lease)))) { packet.yiaddr = req_align; /* FIXME: oh my, is there a host using this IP? */ @@ -142,32 +142,32 @@ int sendOffer(struct dhcpMessage *oldpacket) /* otherwise, find a free IP */ /*ADDME: is it a static lease? */ } else { packet.yiaddr = find_address(0); - + /* try for an expired lease */ if (!packet.yiaddr) packet.yiaddr = find_address(1); } - + if(!packet.yiaddr) { LOG(LOG_WARNING, "no IP addresses to give -- OFFER abandoned"); return -1; } - + if (!add_lease(packet.chaddr, packet.yiaddr, server_config.offer_time)) { LOG(LOG_WARNING, "lease pool is full -- OFFER abandoned"); return -1; - } + } if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { memcpy(&lease_time_align, lease_time, 4); lease_time_align = ntohl(lease_time_align); - if (lease_time_align > server_config.lease) + if (lease_time_align > server_config.lease) lease_time_align = server_config.lease; } /* Make sure we aren't just using the lease time from the previous offer */ - if (lease_time_align < server_config.min_lease) + if (lease_time_align < server_config.min_lease) lease_time_align = server_config.lease; - /* ADDME: end of short circuit */ + /* ADDME: end of short circuit */ add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); curr = server_config.options; @@ -178,7 +178,7 @@ int sendOffer(struct dhcpMessage *oldpacket) } add_bootp_options(&packet); - + addr.s_addr = packet.yiaddr; LOG(LOG_INFO, "sending OFFER of %s", inet_ntoa(addr)); return send_packet(&packet, 0); @@ -190,7 +190,7 @@ int sendNAK(struct dhcpMessage *oldpacket) struct dhcpMessage packet; init_packet(&packet, oldpacket, DHCPNAK); - + DEBUG(LOG_INFO, "sending NAK"); return send_packet(&packet, 1); } @@ -206,18 +206,18 @@ int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) init_packet(&packet, oldpacket, DHCPACK); packet.yiaddr = yiaddr; - + if ((lease_time = get_option(oldpacket, DHCP_LEASE_TIME))) { memcpy(&lease_time_align, lease_time, 4); lease_time_align = ntohl(lease_time_align); - if (lease_time_align > server_config.lease) + if (lease_time_align > server_config.lease) lease_time_align = server_config.lease; - else if (lease_time_align < server_config.min_lease) + else if (lease_time_align < server_config.min_lease) lease_time_align = server_config.lease; } - + add_simple_option(packet.options, DHCP_LEASE_TIME, htonl(lease_time_align)); - + curr = server_config.options; while (curr) { if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) @@ -230,7 +230,7 @@ int sendACK(struct dhcpMessage *oldpacket, uint32_t yiaddr) addr.s_addr = packet.yiaddr; LOG(LOG_INFO, "sending ACK to %s", inet_ntoa(addr)); - if (send_packet(&packet, 0) < 0) + if (send_packet(&packet, 0) < 0) return -1; add_lease(packet.chaddr, packet.yiaddr, lease_time_align); @@ -245,7 +245,7 @@ int send_inform(struct dhcpMessage *oldpacket) struct option_set *curr; init_packet(&packet, oldpacket, DHCPACK); - + curr = server_config.options; while (curr) { if (curr->data[OPT_CODE] != DHCP_LEASE_TIME) diff --git a/networking/udhcp/socket.c b/networking/udhcp/socket.c index 582f0fc..7b05752 100644 --- a/networking/udhcp/socket.c +++ b/networking/udhcp/socket.c @@ -55,7 +55,7 @@ int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) ifr.ifr_addr.sa_family = AF_INET; strcpy(ifr.ifr_name, interface); - if (addr) { + if (addr) { if (ioctl(fd, SIOCGIFADDR, &ifr) == 0) { our_ip = (struct sockaddr_in *) &ifr.ifr_addr; *addr = our_ip->sin_addr.s_addr; @@ -65,7 +65,7 @@ int read_interface(char *interface, int *ifindex, uint32_t *addr, uint8_t *arp) return -1; } } - + if (ioctl(fd, SIOCGIFINDEX, &ifr) == 0) { DEBUG(LOG_INFO, "adapter index %d", ifr.ifr_ifindex); *ifindex = ifr.ifr_ifindex; @@ -102,7 +102,7 @@ int listen_socket(uint32_t ip, int port, char *inf) DEBUG(LOG_ERR, "socket call failed: %m"); return -1; } - + memset(&addr, 0, sizeof(addr)); addr.sin_family = AF_INET; addr.sin_port = htons(port); @@ -127,6 +127,6 @@ int listen_socket(uint32_t ip, int port, char *inf) close(fd); return -1; } - + return fd; } diff --git a/networking/vconfig.c b/networking/vconfig.c index 0bb3308..bbd2987 100644 --- a/networking/vconfig.c +++ b/networking/vconfig.c @@ -63,7 +63,7 @@ struct vlan_ioctl_args { unsigned int flag; /* Matches vlan_dev_info flags */ } u; - short vlan_qos; + short vlan_qos; }; #define VLAN_GROUP_ARRAY_LEN 4096 @@ -110,7 +110,7 @@ static const char name_types[] = { '_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D', 0, VLAN_NAME_TYPE_PLUS_VID_NO_PAD, 22, - 'V', 'L', 'A', 'N', + 'V', 'L', 'A', 'N', '_', 'P', 'L', 'U', 'S', '_', 'V', 'I', 'D', '_', 'N', 'O', '_', 'P', 'A', 'D', 0, VLAN_NAME_TYPE_RAW_PLUS_VID, 15, diff --git a/networking/wget.c b/networking/wget.c index cb0790e..619c138 100644 --- a/networking/wget.c +++ b/networking/wget.c @@ -55,7 +55,7 @@ static volatile unsigned long statbytes = 0; /* Number of bytes transferred so f /* For progressmeter() -- number of seconds before xfer considered "stalled" */ static const int STALLTIME = 5; #endif - + static void close_and_delete_outfile(FILE* output, char *fname_out, int do_continue) { if (output != stdout && do_continue==0) { @@ -236,18 +236,18 @@ int wget_main(int argc, char **argv) use_proxy = 0; } } - + /* Guess an output filename */ if (!fname_out) { - fname_out = + fname_out = #ifdef CONFIG_FEATURE_WGET_STATUSBAR - curfile = + curfile = #endif bb_get_last_path_component(target.path); if (fname_out==NULL || strlen(fname_out)<1) { - fname_out = + fname_out = #ifdef CONFIG_FEATURE_WGET_STATUSBAR - curfile = + curfile = #endif "index.html"; } @@ -309,7 +309,7 @@ int wget_main(int argc, char **argv) */ if (sfp) fclose(sfp); sfp = open_socket(&s_in); - + /* * Send HTTP request. */ @@ -351,7 +351,7 @@ int wget_main(int argc, char **argv) read_response: if (fgets(buf, sizeof(buf), sfp) == NULL) close_delete_and_die("no response from server"); - + for (s = buf ; *s != '\0' && !isspace(*s) ; ++s) ; for ( ; isspace(*s) ; ++s) @@ -379,7 +379,7 @@ read_response: chomp(buf); close_delete_and_die("server returned error %d: %s", atoi(s), buf); } - + /* * Retrieve HTTP headers. */ @@ -416,7 +416,7 @@ read_response: } } } while(status >= 300); - + dfp = sfp; } else @@ -431,7 +431,7 @@ read_response: if (ftpcmd(NULL, NULL, sfp, buf) != 220) close_delete_and_die("%s", buf+4); - /* + /* * Splitting username:password pair, * trying to log in */ @@ -448,10 +448,10 @@ read_response: default: close_delete_and_die("ftp login: %s", buf+4); } - + ftpcmd("CDUP", NULL, sfp, buf); ftpcmd("TYPE I", NULL, sfp, buf); - + /* * Querying file size */ @@ -463,7 +463,7 @@ read_response: filesize = value; got_clen = 1; } - + /* * Entering passive mode */ @@ -486,7 +486,7 @@ read_response: } else filesize -= beg_range; } - + if (ftpcmd("RETR /", target.path, sfp, buf) > 150) close_delete_and_die("RETR: %s", buf+4); @@ -661,27 +661,27 @@ char *gethdr(char *buf, size_t bufsiz, FILE *fp, int *istrunc) static int ftpcmd(char *s1, char *s2, FILE *fp, char *buf) { char *p; - + if (s1) { if (!s2) s2=""; fprintf(fp, "%s%s\r\n", s1, s2); fflush(fp); } - + do { p = fgets(buf, 510, fp); if (!p) bb_perror_msg_and_die("fgets()"); } while (! isdigit(buf[0]) || buf[3] != ' '); - + return atoi(buf); } #ifdef CONFIG_FEATURE_WGET_STATUSBAR -/* Stuff below is from BSD rcp util.c, as added to openshh. +/* Stuff below is from BSD rcp util.c, as added to openshh. * Original copyright notice is retained at the end of this file. - * - */ + * + */ static int @@ -813,7 +813,7 @@ progressmeter(int flag) /* Original copyright notice which applies to the CONFIG_FEATURE_WGET_STATUSBAR stuff, * much of which was blatently stolen from openssh. */ - + /*- * Copyright (c) 1992, 1993 * The Regents of the University of California. All rights reserved. @@ -827,8 +827,8 @@ progressmeter(int flag) * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * - * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change - * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> + * 3. <BSD Advertising Clause omitted per the July 22, 1999 licensing change + * ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change> * * 4. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software @@ -846,7 +846,7 @@ progressmeter(int flag) * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: wget.c,v 1.70 2004/03/06 22:11:44 andersen Exp $ + * $Id: wget.c,v 1.71 2004/03/15 08:28:53 andersen Exp $ */ |