aboutsummaryrefslogtreecommitdiffstats
path: root/brctl
diff options
context:
space:
mode:
authorshemminger <shemminger>2004-04-07 23:18:04 +0000
committershemminger <shemminger>2004-04-07 23:18:04 +0000
commit99274cbbd7c2fc8ed0791119fbba2765da29c0c5 (patch)
tree297c5e3a737d6c86340166e6aaa6c73118562fa1 /brctl
parent61335e2eb53a2792e8e24bc29c758c31ebc87fe5 (diff)
downloadandroid_external_brctl-99274cbbd7c2fc8ed0791119fbba2765da29c0c5.tar.gz
android_external_brctl-99274cbbd7c2fc8ed0791119fbba2765da29c0c5.tar.bz2
android_external_brctl-99274cbbd7c2fc8ed0791119fbba2765da29c0c5.zip
Changes for 0.9.8
- cleanup dependicies - allow 4k ports - don't fetch info till needed.
Diffstat (limited to 'brctl')
-rw-r--r--brctl/Makefile.in6
-rw-r--r--brctl/brctl.h3
-rw-r--r--brctl/brctl_cmd.c25
-rw-r--r--brctl/brctl_disp.c40
4 files changed, 43 insertions, 31 deletions
diff --git a/brctl/Makefile.in b/brctl/Makefile.in
index 23515ef..f56bd9c 100644
--- a/brctl/Makefile.in
+++ b/brctl/Makefile.in
@@ -4,7 +4,7 @@ KERNEL_HEADERS=-I@KERNEL_HEADERS@
CC=@CC@
CFLAGS= -Wall -g @CFLAGS@
INCLUDE=-I../libbridge $(KERNEL_HEADERS)
-LIBS= -L ../libbridge -lbridge
+LIBS= -L ../libbridge -lbridge -lsysfs
prefix=@prefix@
exec_prefix=@exec_prefix@
@@ -25,7 +25,6 @@ brctld_OBJECTS= $(brctld_SOURCES:.c=.o)
OBJECTS= $(common_OBJECTS) $(brctl_OBJECTS) $(brctld_OBJECTS)
-# brctld is for debug only, not production use
PROGRAMS= brctl
@@ -35,9 +34,10 @@ install: $(PROGRAMS)
mkdir -p $(DESTDIR)$(sbindir)
$(INSTALL) -m 755 $(PROGRAMS) $(DESTDIR)$(sbindir)
-brctl: $(brctl_OBJECTS)
+brctl: $(brctl_OBJECTS) ../libbridge/libbridge.a
$(CC) $(brctl_OBJECTS) $(LIBS) -o brctl
+# brctld is for debug only, not production use
brctld: $(brctld_OBJECTS)
$(CC) $(brctld_OBJECTS) $(LIBS) -o brctld
diff --git a/brctl/brctl.h b/brctl/brctl.h
index c8a6c0c..901b6ce 100644
--- a/brctl/brctl.h
+++ b/brctl/brctl.h
@@ -32,6 +32,7 @@ void br_dump_bridge_id(const unsigned char *x);
void br_show_timer(const struct timeval *tv);
void br_dump_interface_list(const struct bridge *br);
void br_dump_port_info(const struct port *p);
-void br_dump_info(const struct bridge *br);
+void br_dump_info(const struct bridge *br,
+ const struct bridge_info *bri);
#endif
diff --git a/brctl/brctl_cmd.c b/brctl/brctl_cmd.c
index 5a5e87d..5e630e8 100644
--- a/brctl/brctl_cmd.c
+++ b/brctl/brctl_cmd.c
@@ -282,20 +282,33 @@ void br_cmd_stp(struct bridge *br, char *arg0, char *arg1)
void br_cmd_showstp(struct bridge *br, char *arg0, char *arg1)
{
- br_dump_info(br);
+ struct bridge_info info;
+
+ if (br_get_bridge_info(br, &info)) {
+ fprintf(stderr, "%s: can't get info %s\n", br->ifname,
+ strerror(errno));
+ return;
+ }
+ br_dump_info(br, &info);
}
void br_cmd_show(struct bridge *br, char *arg0, char *arg1)
{
+ struct bridge_info info;
+
printf("bridge name\tbridge id\t\tSTP enabled\tinterfaces\n");
- br = bridge_list;
- while (br != NULL) {
+ for (br = bridge_list; br; br = br->next) {
printf("%s\t\t", br->ifname);
- br_dump_bridge_id((unsigned char *)&br->info.bridge_id);
- printf("\t%s\t\t", br->info.stp_enabled?"yes":"no");
+ if (br_get_bridge_info(br, &info)) {
+ fprintf(stderr, "can't get info %s\n",
+ strerror(errno));
+ continue;
+ }
+
+ br_dump_bridge_id((unsigned char *)&info.bridge_id);
+ printf("\t%s\t\t", info.stp_enabled?"yes":"no");
br_dump_interface_list(br);
- br = br->next;
}
}
diff --git a/brctl/brctl_disp.c b/brctl/brctl_disp.c
index b0f983d..9849f18 100644
--- a/brctl/brctl_disp.c
+++ b/brctl/brctl_disp.c
@@ -54,43 +54,43 @@ void br_dump_interface_list(const struct bridge *br)
void br_dump_port_info(const struct port *p)
{
char ifname[IFNAMSIZ];
- const struct port_info *pi;
-
- pi = &p->info;
+ struct port_info pinfo;
printf("%s (%i)\n", if_indextoname(p->ifindex, ifname), p->index);
- printf(" port id\t\t%.4x\t\t\t", pi->port_id);
- printf("state\t\t\t%s\n", br_get_state_name(pi->state));
+ if (br_get_port_info(p, &pinfo)) {
+ printf(" can't get port info\n");
+ return;
+ }
+
+ printf(" port id\t\t%.4x\t\t\t", pinfo.port_id);
+ printf("state\t\t\t%s\n", br_get_state_name(pinfo.state));
printf(" designated root\t");
- br_dump_bridge_id((unsigned char *)&pi->designated_root);
- printf("\tpath cost\t\t%4i\n", pi->path_cost);
+ br_dump_bridge_id((unsigned char *)&pinfo.designated_root);
+ printf("\tpath cost\t\t%4i\n", pinfo.path_cost);
printf(" designated bridge\t");
- br_dump_bridge_id((unsigned char *)&pi->designated_bridge);
+ br_dump_bridge_id((unsigned char *)&pinfo.designated_bridge);
printf("\tmessage age timer\t");
- br_show_timer(&pi->message_age_timer_value);
- printf("\n designated port\t%.4x", pi->designated_port);
+ br_show_timer(&pinfo.message_age_timer_value);
+ printf("\n designated port\t%.4x", pinfo.designated_port);
printf("\t\t\tforward delay timer\t");
- br_show_timer(&pi->forward_delay_timer_value);
- printf("\n designated cost\t%4i", pi->designated_cost);
+ br_show_timer(&pinfo.forward_delay_timer_value);
+ printf("\n designated cost\t%4i", pinfo.designated_cost);
printf("\t\t\thold timer\t\t");
- br_show_timer(&pi->hold_timer_value);
+ br_show_timer(&pinfo.hold_timer_value);
printf("\n flags\t\t\t");
- if (pi->config_pending)
+ if (pinfo.config_pending)
printf("CONFIG_PENDING ");
- if (pi->top_change_ack)
+ if (pinfo.top_change_ack)
printf("TOPOLOGY_CHANGE_ACK ");
printf("\n");
printf("\n");
}
-void br_dump_info(const struct bridge *br)
+void br_dump_info(const struct bridge *br, const struct bridge_info *bri)
{
- const struct bridge_info *bri;
const struct port *p;
- bri = &br->info;
-
printf("%s\n", br->ifname);
if (!bri->stp_enabled) {
printf(" STP is disabled for this interface\n");
@@ -117,8 +117,6 @@ void br_dump_info(const struct bridge *br)
br_show_timer(&bri->bridge_forward_delay);
printf("\n ageing time\t\t");
br_show_timer(&bri->ageing_time);
- printf("\t\t\tgc interval\t\t");
- br_show_timer(&bri->gc_interval);
printf("\n hello timer\t\t");
br_show_timer(&bri->hello_timer_value);
printf("\t\t\ttcn timer\t\t");