| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: brconfig.c,v 1.11 2006/03/20 01:06:07 christos Exp $ */ | | 1 | /* $NetBSD: brconfig.c,v 1.12 2009/03/16 12:56:19 lukem Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2001 Wasabi Systems, Inc. | | 4 | * Copyright 2001 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. | | 7 | * Written by Jason R. Thorpe for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -33,27 +33,27 @@ | | | @@ -33,27 +33,27 @@ |
33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 33 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 34 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
35 | * POSSIBILITY OF SUCH DAMAGE. | | 35 | * POSSIBILITY OF SUCH DAMAGE. |
36 | */ | | 36 | */ |
37 | | | 37 | |
38 | /* | | 38 | /* |
39 | * brconfig(8) -- | | 39 | * brconfig(8) -- |
40 | * | | 40 | * |
41 | * Configuration utility for the bridge(4) driver. | | 41 | * Configuration utility for the bridge(4) driver. |
42 | */ | | 42 | */ |
43 | #include <sys/cdefs.h> | | 43 | #include <sys/cdefs.h> |
44 | | | 44 | |
45 | #ifndef lint | | 45 | #ifndef lint |
46 | __RCSID("$NetBSD: brconfig.c,v 1.11 2006/03/20 01:06:07 christos Exp $"); | | 46 | __RCSID("$NetBSD: brconfig.c,v 1.12 2009/03/16 12:56:19 lukem Exp $"); |
47 | #endif | | 47 | #endif |
48 | | | 48 | |
49 | | | 49 | |
50 | #include <sys/param.h> | | 50 | #include <sys/param.h> |
51 | #include <sys/socket.h> | | 51 | #include <sys/socket.h> |
52 | #include <sys/ioctl.h> | | 52 | #include <sys/ioctl.h> |
53 | | | 53 | |
54 | #include <net/if.h> | | 54 | #include <net/if.h> |
55 | #include <net/if_ether.h> | | 55 | #include <net/if_ether.h> |
56 | #include <net/if_bridgevar.h> | | 56 | #include <net/if_bridgevar.h> |
57 | | | 57 | |
58 | #include <ctype.h> | | 58 | #include <ctype.h> |
59 | #include <err.h> | | 59 | #include <err.h> |
| @@ -411,27 +411,27 @@ show_config(int sock, const char *bridge | | | @@ -411,27 +411,27 @@ show_config(int sock, const char *bridge |
411 | void | | 411 | void |
412 | show_interfaces(int sock, const char *bridge, const char *prefix) | | 412 | show_interfaces(int sock, const char *bridge, const char *prefix) |
413 | { | | 413 | { |
414 | static const char *stpstates[] = { | | 414 | static const char *stpstates[] = { |
415 | "disabled", | | 415 | "disabled", |
416 | "listening", | | 416 | "listening", |
417 | "learning", | | 417 | "learning", |
418 | "forwarding", | | 418 | "forwarding", |
419 | "blocking", | | 419 | "blocking", |
420 | }; | | 420 | }; |
421 | struct ifbifconf bifc; | | 421 | struct ifbifconf bifc; |
422 | struct ifbreq *req; | | 422 | struct ifbreq *req; |
423 | char *inbuf = NULL, *ninbuf; | | 423 | char *inbuf = NULL, *ninbuf; |
424 | int i, len = 8192; | | 424 | uint32_t i, len = 8192; |
425 | | | 425 | |
426 | for (;;) { | | 426 | for (;;) { |
427 | ninbuf = realloc(inbuf, len); | | 427 | ninbuf = realloc(inbuf, len); |
428 | if (ninbuf == NULL) | | 428 | if (ninbuf == NULL) |
429 | err(1, "unable to allocate interface buffer"); | | 429 | err(1, "unable to allocate interface buffer"); |
430 | bifc.ifbic_len = len; | | 430 | bifc.ifbic_len = len; |
431 | bifc.ifbic_buf = inbuf = ninbuf; | | 431 | bifc.ifbic_buf = inbuf = ninbuf; |
432 | if (do_cmd(sock, bridge, BRDGGIFS, &bifc, sizeof(bifc), 0) < 0) | | 432 | if (do_cmd(sock, bridge, BRDGGIFS, &bifc, sizeof(bifc), 0) < 0) |
433 | err(1, "unable to get interface list"); | | 433 | err(1, "unable to get interface list"); |
434 | if ((bifc.ifbic_len + sizeof(*req)) < len) | | 434 | if ((bifc.ifbic_len + sizeof(*req)) < len) |
435 | break; | | 435 | break; |
436 | len *= 2; | | 436 | len *= 2; |
437 | } | | 437 | } |
| @@ -455,27 +455,27 @@ show_interfaces(int sock, const char *br | | | @@ -455,27 +455,27 @@ show_interfaces(int sock, const char *br |
455 | } | | 455 | } |
456 | printf("\n"); | | 456 | printf("\n"); |
457 | } | | 457 | } |
458 | | | 458 | |
459 | free(inbuf); | | 459 | free(inbuf); |
460 | } | | 460 | } |
461 | | | 461 | |
462 | void | | 462 | void |
463 | show_addresses(int sock, const char *bridge, const char *prefix) | | 463 | show_addresses(int sock, const char *bridge, const char *prefix) |
464 | { | | 464 | { |
465 | struct ifbaconf ifbac; | | 465 | struct ifbaconf ifbac; |
466 | struct ifbareq *ifba; | | 466 | struct ifbareq *ifba; |
467 | char *inbuf = NULL, *ninbuf; | | 467 | char *inbuf = NULL, *ninbuf; |
468 | int i, len = 8192; | | 468 | uint32_t i, len = 8192; |
469 | struct ether_addr ea; | | 469 | struct ether_addr ea; |
470 | | | 470 | |
471 | for (;;) { | | 471 | for (;;) { |
472 | ninbuf = realloc(inbuf, len); | | 472 | ninbuf = realloc(inbuf, len); |
473 | if (ninbuf == NULL) | | 473 | if (ninbuf == NULL) |
474 | err(1, "unable to allocate address buffer"); | | 474 | err(1, "unable to allocate address buffer"); |
475 | ifbac.ifbac_len = len; | | 475 | ifbac.ifbac_len = len; |
476 | ifbac.ifbac_buf = inbuf = ninbuf; | | 476 | ifbac.ifbac_buf = inbuf = ninbuf; |
477 | if (do_cmd(sock, bridge, BRDGRTS, &ifbac, sizeof(ifbac), 0) < 0) | | 477 | if (do_cmd(sock, bridge, BRDGRTS, &ifbac, sizeof(ifbac), 0) < 0) |
478 | err(1, "unable to get address cache"); | | 478 | err(1, "unable to get address cache"); |
479 | if ((ifbac.ifbac_len + sizeof(*ifba)) < len) | | 479 | if ((ifbac.ifbac_len + sizeof(*ifba)) < len) |
480 | break; | | 480 | break; |
481 | len *= 2; | | 481 | len *= 2; |