aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
Diffstat (limited to 'networking')
-rw-r--r--networking/nameif.c48
1 files changed, 9 insertions, 39 deletions
diff --git a/networking/nameif.c b/networking/nameif.c
index 769b777f0..5fee465cc 100644
--- a/networking/nameif.c
+++ b/networking/nameif.c
@@ -5,31 +5,16 @@
* Busybox port 2002 by Nick Fedchik <nick@fedchik.org.ua>
* Glenn McGrath <bug1@iinet.net.au>
*
- * 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
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
- * 02111-1307 USA
- *
+ * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
*/
-
#include <sys/syslog.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <errno.h>
-#include <getopt.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include <net/if.h>
#include <netinet/ether.h>
@@ -61,7 +46,7 @@ typedef struct mactable_s {
struct ether_addr *mac;
} mactable_t;
-static unsigned char use_syslog;
+static unsigned long flags;
static void serror(const char *s, ...) __attribute__ ((noreturn));
@@ -71,14 +56,12 @@ static void serror(const char *s, ...)
va_start(ap, s);
- if (use_syslog) {
+ if (flags & 1) {
openlog(bb_applet_name, 0, LOG_LOCAL0);
vsyslog(LOG_ERR, s, ap);
closelog();
- } else {
- bb_verror_msg(s, ap);
- putc('\n', stderr);
- }
+ } else
+ bb_error_msg(s, ap);
va_end(ap);
@@ -106,25 +89,12 @@ int nameif_main(int argc, char **argv)
const char *fname = "/etc/mactab";
char *line;
int ctl_sk;
- int opt;
int if_index = 1;
mactable_t *ch;
+ flags = bb_getopt_ulflags(argc, argv, "sc:", &fname);
- while ((opt = getopt(argc, argv, "c:s")) != -1) {
- switch (opt) {
- case 'c':
- fname = optarg;
- break;
- case 's':
- use_syslog = 1;
- break;
- default:
- bb_show_usage();
- }
- }
-
- if ((argc - optind) & 1)
+ if (argc - optind == 1)
bb_show_usage();
if (optind < argc) {
@@ -177,7 +147,7 @@ int nameif_main(int argc, char **argv)
while (clist) {
struct ifreq ifr;
- bzero(&ifr, sizeof(struct ifreq));
+ memset(&ifr, 0, sizeof(struct ifreq));
if_index++;
ifr.ifr_ifindex = if_index;