aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2006-01-15 02:20:06 +0000
committerRob Landley <rob@landley.net>2006-01-15 02:20:06 +0000
commit855f1e13202845a3b7f354b5452db4627c37f33c (patch)
tree6391e433cd1094b049a5eab05bfcb53cbc2048a8
parent734a779a42d0b136a7e42af37b21af5127a4fb33 (diff)
downloadbusybox-w32-855f1e13202845a3b7f354b5452db4627c37f33c.tar.gz
busybox-w32-855f1e13202845a3b7f354b5452db4627c37f33c.tar.bz2
busybox-w32-855f1e13202845a3b7f354b5452db4627c37f33c.zip
Cleanup patch from Rob Sullivan.
-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 @@
5 * Busybox port 2002 by Nick Fedchik <nick@fedchik.org.ua> 5 * Busybox port 2002 by Nick Fedchik <nick@fedchik.org.ua>
6 * Glenn McGrath <bug1@iinet.net.au> 6 * Glenn McGrath <bug1@iinet.net.au>
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Licensed under the GPL v2 or later, see the file LICENSE in this tarball.
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
21 * 02111-1307 USA
22 *
23 */ 9 */
24 10
25
26#include <sys/syslog.h> 11#include <sys/syslog.h>
27#include <sys/socket.h> 12#include <sys/socket.h>
28#include <sys/ioctl.h> 13#include <sys/ioctl.h>
29#include <errno.h> 14#include <errno.h>
30#include <getopt.h>
31#include <stdlib.h> 15#include <stdlib.h>
32#include <string.h> 16#include <string.h>
17#include <unistd.h>
33#include <net/if.h> 18#include <net/if.h>
34#include <netinet/ether.h> 19#include <netinet/ether.h>
35 20
@@ -61,7 +46,7 @@ typedef struct mactable_s {
61 struct ether_addr *mac; 46 struct ether_addr *mac;
62} mactable_t; 47} mactable_t;
63 48
64static unsigned char use_syslog; 49static unsigned long flags;
65 50
66static void serror(const char *s, ...) __attribute__ ((noreturn)); 51static void serror(const char *s, ...) __attribute__ ((noreturn));
67 52
@@ -71,14 +56,12 @@ static void serror(const char *s, ...)
71 56
72 va_start(ap, s); 57 va_start(ap, s);
73 58
74 if (use_syslog) { 59 if (flags & 1) {
75 openlog(bb_applet_name, 0, LOG_LOCAL0); 60 openlog(bb_applet_name, 0, LOG_LOCAL0);
76 vsyslog(LOG_ERR, s, ap); 61 vsyslog(LOG_ERR, s, ap);
77 closelog(); 62 closelog();
78 } else { 63 } else
79 bb_verror_msg(s, ap); 64 bb_error_msg(s, ap);
80 putc('\n', stderr);
81 }
82 65
83 va_end(ap); 66 va_end(ap);
84 67
@@ -106,25 +89,12 @@ int nameif_main(int argc, char **argv)
106 const char *fname = "/etc/mactab"; 89 const char *fname = "/etc/mactab";
107 char *line; 90 char *line;
108 int ctl_sk; 91 int ctl_sk;
109 int opt;
110 int if_index = 1; 92 int if_index = 1;
111 mactable_t *ch; 93 mactable_t *ch;
112 94
95 flags = bb_getopt_ulflags(argc, argv, "sc:", &fname);
113 96
114 while ((opt = getopt(argc, argv, "c:s")) != -1) { 97 if (argc - optind == 1)
115 switch (opt) {
116 case 'c':
117 fname = optarg;
118 break;
119 case 's':
120 use_syslog = 1;
121 break;
122 default:
123 bb_show_usage();
124 }
125 }
126
127 if ((argc - optind) & 1)
128 bb_show_usage(); 98 bb_show_usage();
129 99
130 if (optind < argc) { 100 if (optind < argc) {
@@ -177,7 +147,7 @@ int nameif_main(int argc, char **argv)
177 while (clist) { 147 while (clist) {
178 struct ifreq ifr; 148 struct ifreq ifr;
179 149
180 bzero(&ifr, sizeof(struct ifreq)); 150 memset(&ifr, 0, sizeof(struct ifreq));
181 if_index++; 151 if_index++;
182 ifr.ifr_ifindex = if_index; 152 ifr.ifr_ifindex = if_index;
183 153