diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-08-22 18:22:10 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-08-22 18:22:10 +0000 |
commit | 2111d73e03bd959df38f9d292aede3ccc814d53e (patch) | |
tree | 79f3dc09fb7bb5cfc43fc5698731bfa2906bf46f /networking | |
parent | dd08b8f178729f0385cbc21ccb2863e85144f077 (diff) | |
download | busybox-w32-2111d73e03bd959df38f9d292aede3ccc814d53e.tar.gz busybox-w32-2111d73e03bd959df38f9d292aede3ccc814d53e.tar.bz2 busybox-w32-2111d73e03bd959df38f9d292aede3ccc814d53e.zip |
Run through indent, fix comments
git-svn-id: svn://busybox.net/trunk/busybox@5340 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r-- | networking/ifconfig.c | 177 |
1 files changed, 91 insertions, 86 deletions
diff --git a/networking/ifconfig.c b/networking/ifconfig.c index 3ada4f178..513f176d1 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c | |||
@@ -15,7 +15,7 @@ | |||
15 | * Foundation; either version 2 of the License, or (at | 15 | * Foundation; either version 2 of the License, or (at |
16 | * your option) any later version. | 16 | * your option) any later version. |
17 | * | 17 | * |
18 | * $Id: ifconfig.c,v 1.18 2002/07/11 11:11:52 andersen Exp $ | 18 | * $Id: ifconfig.c,v 1.19 2002/08/22 18:22:10 bug1 Exp $ |
19 | * | 19 | * |
20 | */ | 20 | */ |
21 | 21 | ||
@@ -34,9 +34,9 @@ | |||
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | #include <string.h> // strcmp and friends | 37 | #include <string.h> /* strcmp and friends */ |
38 | #include <ctype.h> // isdigit and friends | 38 | #include <ctype.h> /* isdigit and friends */ |
39 | #include <stddef.h> /* offsetof */ | 39 | #include <stddef.h> /* offsetof */ |
40 | #include <sys/ioctl.h> | 40 | #include <sys/ioctl.h> |
41 | #include <net/if_arp.h> | 41 | #include <net/if_arp.h> |
42 | #include <netinet/in.h> | 42 | #include <netinet/in.h> |
@@ -65,14 +65,14 @@ | |||
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifndef IFF_DYNAMIC | 67 | #ifndef IFF_DYNAMIC |
68 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */ | 68 | #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses */ |
69 | #endif | 69 | #endif |
70 | 70 | ||
71 | #if CONFIG_FEATURE_IPV6 | 71 | #if CONFIG_FEATURE_IPV6 |
72 | struct in6_ifreq { | 72 | struct in6_ifreq { |
73 | struct in6_addr ifr6_addr; | 73 | struct in6_addr ifr6_addr; |
74 | uint32_t ifr6_prefixlen; | 74 | uint32_t ifr6_prefixlen; |
75 | int ifr6_ifindex; | 75 | int ifr6_ifindex; |
76 | }; | 76 | }; |
77 | #endif | 77 | #endif |
78 | 78 | ||
@@ -177,70 +177,70 @@ struct options { | |||
177 | #define ifreq_offsetof(x) offsetof(struct ifreq, x) | 177 | #define ifreq_offsetof(x) offsetof(struct ifreq, x) |
178 | 178 | ||
179 | static const struct arg1opt Arg1Opt[] = { | 179 | static const struct arg1opt Arg1Opt[] = { |
180 | {"SIOCSIFMETRIC", SIOCSIFMETRIC, ifreq_offsetof(ifr_metric)}, | 180 | {"SIOCSIFMETRIC", SIOCSIFMETRIC, ifreq_offsetof(ifr_metric)}, |
181 | {"SIOCSIFMTU", SIOCSIFMTU, ifreq_offsetof(ifr_mtu)}, | 181 | {"SIOCSIFMTU", SIOCSIFMTU, ifreq_offsetof(ifr_mtu)}, |
182 | {"SIOCSIFTXQLEN", SIOCSIFTXQLEN, ifreq_offsetof(ifr_qlen)}, | 182 | {"SIOCSIFTXQLEN", SIOCSIFTXQLEN, ifreq_offsetof(ifr_qlen)}, |
183 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, | 183 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, |
184 | {"SIOCSIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask)}, | 184 | {"SIOCSIFNETMASK", SIOCSIFNETMASK, ifreq_offsetof(ifr_netmask)}, |
185 | {"SIOCSIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr)}, | 185 | {"SIOCSIFBRDADDR", SIOCSIFBRDADDR, ifreq_offsetof(ifr_broadaddr)}, |
186 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 186 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
187 | {"SIOCSIFHWADDR", SIOCSIFHWADDR, ifreq_offsetof(ifr_hwaddr)}, | 187 | {"SIOCSIFHWADDR", SIOCSIFHWADDR, ifreq_offsetof(ifr_hwaddr)}, |
188 | #endif | 188 | #endif |
189 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, | 189 | {"SIOCSIFDSTADDR", SIOCSIFDSTADDR, ifreq_offsetof(ifr_dstaddr)}, |
190 | #ifdef SIOCSKEEPALIVE | 190 | #ifdef SIOCSKEEPALIVE |
191 | {"SIOCSKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data)}, | 191 | {"SIOCSKEEPALIVE", SIOCSKEEPALIVE, ifreq_offsetof(ifr_data)}, |
192 | #endif | 192 | #endif |
193 | #ifdef SIOCSOUTFILL | 193 | #ifdef SIOCSOUTFILL |
194 | {"SIOCSOUTFILL", SIOCSOUTFILL, ifreq_offsetof(ifr_data)}, | 194 | {"SIOCSOUTFILL", SIOCSOUTFILL, ifreq_offsetof(ifr_data)}, |
195 | #endif | 195 | #endif |
196 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ | 196 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
197 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.mem_start)}, | 197 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.mem_start)}, |
198 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.base_addr)}, | 198 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.base_addr)}, |
199 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.irq)}, | 199 | {"SIOCSIFMAP", SIOCSIFMAP, ifreq_offsetof(ifr_map.irq)}, |
200 | #endif | 200 | #endif |
201 | /* Last entry if for unmatched (possibly hostname) arg. */ | 201 | /* Last entry if for unmatched (possibly hostname) arg. */ |
202 | #if CONFIG_FEATURE_IPV6 | 202 | #if CONFIG_FEATURE_IPV6 |
203 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ | 203 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ |
204 | {"SIOCDIFADDR", SIOCDIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ | 204 | {"SIOCDIFADDR", SIOCDIFADDR, ifreq_offsetof(ifr_addr)}, /* IPv6 version ignores the offset */ |
205 | #endif | 205 | #endif |
206 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, | 206 | {"SIOCSIFADDR", SIOCSIFADDR, ifreq_offsetof(ifr_addr)}, |
207 | }; | 207 | }; |
208 | 208 | ||
209 | static const struct options OptArray[] = { | 209 | static const struct options OptArray[] = { |
210 | {"metric", N_ARG, ARG_METRIC, 0}, | 210 | {"metric", N_ARG, ARG_METRIC, 0}, |
211 | {"mtu", N_ARG, ARG_MTU, 0}, | 211 | {"mtu", N_ARG, ARG_MTU, 0}, |
212 | {"txqueuelen", N_ARG, ARG_TXQUEUELEN, 0}, | 212 | {"txqueuelen", N_ARG, ARG_TXQUEUELEN, 0}, |
213 | {"dstaddr", N_ARG, ARG_DSTADDR, 0}, | 213 | {"dstaddr", N_ARG, ARG_DSTADDR, 0}, |
214 | {"netmask", N_ARG, ARG_NETMASK, 0}, | 214 | {"netmask", N_ARG, ARG_NETMASK, 0}, |
215 | {"broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST}, | 215 | {"broadcast", N_ARG | M_CLR, ARG_BROADCAST, IFF_BROADCAST}, |
216 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 216 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
217 | {"hw", N_ARG, ARG_HW, 0}, | 217 | {"hw", N_ARG, ARG_HW, 0}, |
218 | #endif | 218 | #endif |
219 | {"pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT}, | 219 | {"pointopoint", N_ARG | M_CLR, ARG_POINTOPOINT, IFF_POINTOPOINT}, |
220 | #ifdef SIOCSKEEPALIVE | 220 | #ifdef SIOCSKEEPALIVE |
221 | {"keepalive", N_ARG, ARG_KEEPALIVE, 0}, | 221 | {"keepalive", N_ARG, ARG_KEEPALIVE, 0}, |
222 | #endif | 222 | #endif |
223 | #ifdef SIOCSOUTFILL | 223 | #ifdef SIOCSOUTFILL |
224 | {"outfill", N_ARG, ARG_OUTFILL, 0}, | 224 | {"outfill", N_ARG, ARG_OUTFILL, 0}, |
225 | #endif | 225 | #endif |
226 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ | 226 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
227 | {"mem_start", N_ARG, ARG_MEM_START, 0}, | 227 | {"mem_start", N_ARG, ARG_MEM_START, 0}, |
228 | {"io_addr", N_ARG, ARG_IO_ADDR, 0}, | 228 | {"io_addr", N_ARG, ARG_IO_ADDR, 0}, |
229 | {"irq", N_ARG, ARG_IRQ, 0}, | 229 | {"irq", N_ARG, ARG_IRQ, 0}, |
230 | #endif | 230 | #endif |
231 | #if CONFIG_FEATURE_IPV6 | 231 | #if CONFIG_FEATURE_IPV6 |
232 | {"add", N_ARG, ARG_ADD_DEL, 0}, | 232 | {"add", N_ARG, ARG_ADD_DEL, 0}, |
233 | {"del", N_ARG, ARG_ADD_DEL, 0}, | 233 | {"del", N_ARG, ARG_ADD_DEL, 0}, |
234 | #endif | 234 | #endif |
235 | {"arp", N_CLR | M_SET, 0, IFF_NOARP}, | 235 | {"arp", N_CLR | M_SET, 0, IFF_NOARP}, |
236 | {"trailers", N_CLR | M_SET, 0, IFF_NOTRAILERS}, | 236 | {"trailers", N_CLR | M_SET, 0, IFF_NOTRAILERS}, |
237 | {"promisc", N_SET | M_CLR, 0, IFF_PROMISC}, | 237 | {"promisc", N_SET | M_CLR, 0, IFF_PROMISC}, |
238 | {"multicast", N_SET | M_CLR, 0, IFF_MULTICAST}, | 238 | {"multicast", N_SET | M_CLR, 0, IFF_MULTICAST}, |
239 | {"allmulti", N_SET | M_CLR, 0, IFF_ALLMULTI}, | 239 | {"allmulti", N_SET | M_CLR, 0, IFF_ALLMULTI}, |
240 | {"dynamic", N_SET | M_CLR, 0, IFF_DYNAMIC}, | 240 | {"dynamic", N_SET | M_CLR, 0, IFF_DYNAMIC}, |
241 | {"up", N_SET , 0, (IFF_UP | IFF_RUNNING)}, | 241 | {"up", N_SET, 0, (IFF_UP | IFF_RUNNING)}, |
242 | {"down", N_CLR , 0, IFF_UP}, | 242 | {"down", N_CLR, 0, IFF_UP}, |
243 | { NULL, 0, ARG_HOSTNAME, (IFF_UP | IFF_RUNNING)} | 243 | {NULL, 0, ARG_HOSTNAME, (IFF_UP | IFF_RUNNING)} |
244 | }; | 244 | }; |
245 | 245 | ||
246 | /* | 246 | /* |
@@ -264,6 +264,7 @@ int ifconfig_main(int argc, char **argv) | |||
264 | { | 264 | { |
265 | struct ifreq ifr; | 265 | struct ifreq ifr; |
266 | struct sockaddr_in sai; | 266 | struct sockaddr_in sai; |
267 | |||
267 | #if CONFIG_FEATURE_IPV6 | 268 | #if CONFIG_FEATURE_IPV6 |
268 | struct sockaddr_in6 sai6; | 269 | struct sockaddr_in6 sai6; |
269 | #endif | 270 | #endif |
@@ -272,7 +273,7 @@ int ifconfig_main(int argc, char **argv) | |||
272 | #endif | 273 | #endif |
273 | const struct arg1opt *a1op; | 274 | const struct arg1opt *a1op; |
274 | const struct options *op; | 275 | const struct options *op; |
275 | int sockfd; /* socket fd we use to manipulate stuff with */ | 276 | int sockfd; /* socket fd we use to manipulate stuff with */ |
276 | int goterr; | 277 | int goterr; |
277 | int selector; | 278 | int selector; |
278 | char *p; | 279 | char *p; |
@@ -288,18 +289,19 @@ int ifconfig_main(int argc, char **argv) | |||
288 | --argc; | 289 | --argc; |
289 | 290 | ||
290 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS | 291 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
291 | if ((argc > 0) && (strcmp(*argv,"-a") == 0)) { | 292 | if ((argc > 0) && (strcmp(*argv, "-a") == 0)) { |
292 | interface_opt_a = 1; | 293 | interface_opt_a = 1; |
293 | --argc; | 294 | --argc; |
294 | ++argv; | 295 | ++argv; |
295 | } | 296 | } |
296 | #endif | 297 | #endif |
297 | 298 | ||
298 | if(argc <= 1) { | 299 | if (argc <= 1) { |
299 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS | 300 | #ifdef CONFIG_FEATURE_IFCONFIG_STATUS |
300 | return display_interfaces(argc ? *argv : NULL); | 301 | return display_interfaces(argc ? *argv : NULL); |
301 | #else | 302 | #else |
302 | error_msg_and_die( "ifconfig was not compiled with interface status display support."); | 303 | error_msg_and_die |
304 | ("ifconfig was not compiled with interface status display support."); | ||
303 | #endif | 305 | #endif |
304 | } | 306 | } |
305 | 307 | ||
@@ -315,14 +317,14 @@ int ifconfig_main(int argc, char **argv) | |||
315 | while (*++argv != (char *) NULL) { | 317 | while (*++argv != (char *) NULL) { |
316 | p = *argv; | 318 | p = *argv; |
317 | mask = N_MASK; | 319 | mask = N_MASK; |
318 | if (*p == '-') { /* If the arg starts with '-'... */ | 320 | if (*p == '-') { /* If the arg starts with '-'... */ |
319 | ++p; /* advance past it and */ | 321 | ++p; /* advance past it and */ |
320 | mask = M_MASK; /* set the appropriate mask. */ | 322 | mask = M_MASK; /* set the appropriate mask. */ |
321 | } | 323 | } |
322 | for (op = OptArray ; op->name ; op++) { /* Find table entry. */ | 324 | for (op = OptArray; op->name; op++) { /* Find table entry. */ |
323 | if (strcmp(p,op->name) == 0) { /* If name matches... */ | 325 | if (strcmp(p, op->name) == 0) { /* If name matches... */ |
324 | if ((mask &= op->flags)) { /* set the mask and go. */ | 326 | if ((mask &= op->flags)) { /* set the mask and go. */ |
325 | goto FOUND_ARG;; | 327 | goto FOUND_ARG;; |
326 | } | 328 | } |
327 | /* If we get here, there was a valid arg with an */ | 329 | /* If we get here, there was a valid arg with an */ |
328 | /* invalid '-' prefix. */ | 330 | /* invalid '-' prefix. */ |
@@ -330,13 +332,13 @@ int ifconfig_main(int argc, char **argv) | |||
330 | goto LOOP; | 332 | goto LOOP; |
331 | } | 333 | } |
332 | } | 334 | } |
333 | 335 | ||
334 | /* We fell through, so treat as possible hostname. */ | 336 | /* We fell through, so treat as possible hostname. */ |
335 | a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; | 337 | a1op = Arg1Opt + (sizeof(Arg1Opt) / sizeof(Arg1Opt[0])) - 1; |
336 | mask = op->arg_flags; | 338 | mask = op->arg_flags; |
337 | goto HOSTNAME; | 339 | goto HOSTNAME; |
338 | 340 | ||
339 | FOUND_ARG: | 341 | FOUND_ARG: |
340 | if (mask & ARG_MASK) { | 342 | if (mask & ARG_MASK) { |
341 | mask = op->arg_flags; | 343 | mask = op->arg_flags; |
342 | a1op = Arg1Opt + (op - OptArray); | 344 | a1op = Arg1Opt + (op - OptArray); |
@@ -348,10 +350,10 @@ int ifconfig_main(int argc, char **argv) | |||
348 | show_usage(); | 350 | show_usage(); |
349 | } else { | 351 | } else { |
350 | --argv; | 352 | --argv; |
351 | mask &= A_SET_AFTER; /* just for broadcast */ | 353 | mask &= A_SET_AFTER; /* just for broadcast */ |
352 | } | 354 | } |
353 | } else { /* got an arg so process it */ | 355 | } else { /* got an arg so process it */ |
354 | HOSTNAME: | 356 | HOSTNAME: |
355 | did_flags |= (mask & A_NETMASK); | 357 | did_flags |= (mask & A_NETMASK); |
356 | if (mask & A_CAST_HOST_COPY) { | 358 | if (mask & A_CAST_HOST_COPY) { |
357 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 359 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
@@ -359,7 +361,7 @@ int ifconfig_main(int argc, char **argv) | |||
359 | #endif | 361 | #endif |
360 | #if CONFIG_FEATURE_IPV6 | 362 | #if CONFIG_FEATURE_IPV6 |
361 | char *prefix; | 363 | char *prefix; |
362 | int prefix_len=0; | 364 | int prefix_len = 0; |
363 | #endif | 365 | #endif |
364 | 366 | ||
365 | safe_strncpy(host, *argv, (sizeof host)); | 367 | safe_strncpy(host, *argv, (sizeof host)); |
@@ -381,21 +383,24 @@ int ifconfig_main(int argc, char **argv) | |||
381 | sai.sin_addr.s_addr = INADDR_ANY; | 383 | sai.sin_addr.s_addr = INADDR_ANY; |
382 | #if CONFIG_FEATURE_IPV6 | 384 | #if CONFIG_FEATURE_IPV6 |
383 | } else | 385 | } else |
384 | if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > 0) { | 386 | if (inet_pton(AF_INET6, host, &sai6.sin6_addr) > |
387 | 0) { | ||
385 | int sockfd6; | 388 | int sockfd6; |
386 | struct in6_ifreq ifr6; | 389 | struct in6_ifreq ifr6; |
387 | 390 | ||
388 | memcpy((char *) &ifr6.ifr6_addr, (char *) &sai6.sin6_addr, | 391 | memcpy((char *) &ifr6.ifr6_addr, |
389 | sizeof(struct in6_addr)); | 392 | (char *) &sai6.sin6_addr, |
393 | sizeof(struct in6_addr)); | ||
390 | 394 | ||
391 | /* Create a channel to the NET kernel. */ | 395 | /* Create a channel to the NET kernel. */ |
392 | if ((sockfd6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | 396 | if ((sockfd6 = |
397 | socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { | ||
393 | perror_msg_and_die("socket6"); | 398 | perror_msg_and_die("socket6"); |
394 | } | 399 | } |
395 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { | 400 | if (ioctl(sockfd6, SIOGIFINDEX, &ifr) < 0) { |
396 | perror("SIOGIFINDEX"); | 401 | perror("SIOGIFINDEX"); |
397 | ++goterr; | 402 | ++goterr; |
398 | continue; | 403 | continue; |
399 | } | 404 | } |
400 | ifr6.ifr6_ifindex = ifr.ifr_ifindex; | 405 | ifr6.ifr6_ifindex = ifr.ifr_ifindex; |
401 | ifr6.ifr6_prefixlen = prefix_len; | 406 | ifr6.ifr6_prefixlen = prefix_len; |
@@ -412,7 +417,7 @@ int ifconfig_main(int argc, char **argv) | |||
412 | } | 417 | } |
413 | p = (char *) &sai; | 418 | p = (char *) &sai; |
414 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 419 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
415 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ | 420 | } else { /* A_CAST_HOST_COPY_IN_ETHER */ |
416 | /* This is the "hw" arg case. */ | 421 | /* This is the "hw" arg case. */ |
417 | if (strcmp("ether", *argv) || (*++argv == NULL)) { | 422 | if (strcmp("ether", *argv) || (*++argv == NULL)) { |
418 | show_usage(); | 423 | show_usage(); |
@@ -426,11 +431,12 @@ int ifconfig_main(int argc, char **argv) | |||
426 | p = (char *) &sa; | 431 | p = (char *) &sa; |
427 | } | 432 | } |
428 | #endif | 433 | #endif |
429 | memcpy((((char *)(&ifr)) + a1op->ifr_offset), | 434 | memcpy((((char *) (&ifr)) + a1op->ifr_offset), |
430 | p, sizeof(struct sockaddr)); | 435 | p, sizeof(struct sockaddr)); |
431 | } else { | 436 | } else { |
432 | unsigned int i = strtoul(*argv,NULL,0); | 437 | unsigned int i = strtoul(*argv, NULL, 0); |
433 | p = ((char *)(&ifr)) + a1op->ifr_offset; | 438 | |
439 | p = ((char *) (&ifr)) + a1op->ifr_offset; | ||
434 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ | 440 | #ifdef CONFIG_FEATURE_IFCONFIG_MEMSTART_IOADDR_IRQ |
435 | if (mask & A_MAP_TYPE) { | 441 | if (mask & A_MAP_TYPE) { |
436 | if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0) { | 442 | if (ioctl(sockfd, SIOCGIFMAP, &ifr) < 0) { |
@@ -448,17 +454,16 @@ int ifconfig_main(int argc, char **argv) | |||
448 | #endif | 454 | #endif |
449 | if (mask & A_CAST_CHAR_PTR) { | 455 | if (mask & A_CAST_CHAR_PTR) { |
450 | *((caddr_t *) p) = (caddr_t) i; | 456 | *((caddr_t *) p) = (caddr_t) i; |
451 | } else { /* A_CAST_INT */ | 457 | } else { /* A_CAST_INT */ |
452 | *((int *) p) = i; | 458 | *((int *) p) = i; |
453 | } | 459 | } |
454 | } | 460 | } |
455 | 461 | ||
456 | if (ioctl(sockfd, a1op->selector, &ifr) < 0) { | 462 | if (ioctl(sockfd, a1op->selector, &ifr) < 0) { |
457 | perror(a1op->name); | 463 | perror(a1op->name); |
458 | ++goterr; | 464 | ++goterr; |
459 | continue; | 465 | continue; |
460 | } | 466 | } |
461 | |||
462 | #ifdef QUESTIONABLE_ALIAS_CASE | 467 | #ifdef QUESTIONABLE_ALIAS_CASE |
463 | if (mask & A_COLON_CHK) { | 468 | if (mask & A_COLON_CHK) { |
464 | /* | 469 | /* |
@@ -470,12 +475,13 @@ int ifconfig_main(int argc, char **argv) | |||
470 | */ | 475 | */ |
471 | char *ptr; | 476 | char *ptr; |
472 | short int found_colon = 0; | 477 | short int found_colon = 0; |
473 | for (ptr = ifr.ifr_name; *ptr; ptr++ ) { | 478 | |
479 | for (ptr = ifr.ifr_name; *ptr; ptr++) { | ||
474 | if (*ptr == ':') { | 480 | if (*ptr == ':') { |
475 | found_colon++; | 481 | found_colon++; |
476 | } | 482 | } |
477 | } | 483 | } |
478 | 484 | ||
479 | if (found_colon && *(ptr - 1) == '-') { | 485 | if (found_colon && *(ptr - 1) == '-') { |
480 | continue; | 486 | continue; |
481 | } | 487 | } |
@@ -489,7 +495,7 @@ int ifconfig_main(int argc, char **argv) | |||
489 | } | 495 | } |
490 | 496 | ||
491 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { | 497 | if (ioctl(sockfd, SIOCGIFFLAGS, &ifr) < 0) { |
492 | perror("SIOCGIFFLAGS"); | 498 | perror("SIOCGIFFLAGS"); |
493 | ++goterr; | 499 | ++goterr; |
494 | } else { | 500 | } else { |
495 | selector = op->selector; | 501 | selector = op->selector; |
@@ -499,31 +505,30 @@ int ifconfig_main(int argc, char **argv) | |||
499 | ifr.ifr_flags &= ~selector; | 505 | ifr.ifr_flags &= ~selector; |
500 | } | 506 | } |
501 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { | 507 | if (ioctl(sockfd, SIOCSIFFLAGS, &ifr) < 0) { |
502 | perror("SIOCSIFFLAGS"); | 508 | perror("SIOCSIFFLAGS"); |
503 | ++goterr; | 509 | ++goterr; |
504 | } | 510 | } |
505 | } | 511 | } |
506 | LOOP: | 512 | LOOP: |
507 | continue; | 513 | continue; |
508 | } /* end of while-loop */ | 514 | } /* end of while-loop */ |
509 | 515 | ||
510 | return goterr; | 516 | return goterr; |
511 | } | 517 | } |
512 | 518 | ||
513 | #ifdef CONFIG_FEATURE_IFCONFIG_HW | 519 | #ifdef CONFIG_FEATURE_IFCONFIG_HW |
514 | /* Input an Ethernet address and convert to binary. */ | 520 | /* Input an Ethernet address and convert to binary. */ |
515 | static int | 521 | static int in_ether(char *bufp, struct sockaddr *sap) |
516 | in_ether(char *bufp, struct sockaddr *sap) | ||
517 | { | 522 | { |
518 | unsigned char *ptr; | 523 | unsigned char *ptr; |
519 | int i, j; | 524 | int i, j; |
520 | unsigned char val; | 525 | unsigned char val; |
521 | unsigned char c; | 526 | unsigned char c; |
522 | 527 | ||
523 | sap->sa_family = ARPHRD_ETHER; | 528 | sap->sa_family = ARPHRD_ETHER; |
524 | ptr = sap->sa_data; | 529 | ptr = sap->sa_data; |
525 | 530 | ||
526 | for (i = 0 ; i < ETH_ALEN ; i++) { | 531 | for (i = 0; i < ETH_ALEN; i++) { |
527 | val = 0; | 532 | val = 0; |
528 | 533 | ||
529 | /* We might get a semicolon here - not required. */ | 534 | /* We might get a semicolon here - not required. */ |
@@ -531,7 +536,7 @@ in_ether(char *bufp, struct sockaddr *sap) | |||
531 | bufp++; | 536 | bufp++; |
532 | } | 537 | } |
533 | 538 | ||
534 | for (j=0 ; j<2 ; j++) { | 539 | for (j = 0; j < 2; j++) { |
535 | c = *bufp; | 540 | c = *bufp; |
536 | if (c >= '0' && c <= '9') { | 541 | if (c >= '0' && c <= '9') { |
537 | c -= '0'; | 542 | c -= '0'; |
@@ -551,6 +556,6 @@ in_ether(char *bufp, struct sockaddr *sap) | |||
551 | *ptr++ = val; | 556 | *ptr++ = val; |
552 | } | 557 | } |
553 | 558 | ||
554 | return (int) (*bufp); /* Error if we don't end at end of string. */ | 559 | return (int) (*bufp); /* Error if we don't end at end of string. */ |
555 | } | 560 | } |
556 | #endif | 561 | #endif |