--- brcfg.c.DIST Thu Apr 9 09:27:20 1998
+++ brcfg.c Thu Jul 30 14:02:08 1998
@@ -13,8 +13,8 @@
#include <sys/socket.h>
#include <linux/skbuff.h>
#include <linux/sockios.h>
-/*#include <net/br.h>*/
-#include "/usr/src/linux/include/net/br.h"
+#include <net/br.h>
+/*#include "/usr/src/linux/include/net/br.h"*/
/*#include "br.h"*/
@@ -109,6 +109,7 @@
printf("BLOCKING (0x%x)\n",ports[i].state);
break;
}
+ printf("\tvlan id 0x%08x\n",ports[i].vlan_id);
printf("designated root ");
disp_id(&ports[i].designated_root);
printf("\n");
@@ -198,12 +199,16 @@
printf("\n");
}
-void cmd(int cmd,int arg1,int arg2)
+void cmd(int cmd,int arg1,int arg2,char *ula)
{ struct br_cf bcf;
+ char *pt;
+ pt = &bcf.ula[0];
+
bcf.cmd = cmd;
bcf.arg1 = arg1;
bcf.arg2 = arg2;
+ memcpy(pt, ula, 12);
if (ioctl(fd, SIOCSIFBR, &bcf) < 0) {
perror("ioctl(SIOCSIFBR) failed");
exit(1);
@@ -218,6 +223,8 @@
"brcfg p[ort] x e[nable] Enable a port\n"
"brcfg p[ort] x d[isable] Disable a port\n"
"brcfg p[ort] x p[riority] y Set the priority of a port\n"
+"brcfg p[ort] x v[lan] y Set the vlan_id of a port\n"
+"brcfg m[ac] x v[lan] y Set the vlan_id of a mac address\n"
"brcfg pr[iority] y Set bridge priority\n"
"brcfg pa[thcost] y Set the pathcosts\n"
"brcfg d[ebug] on Switch debugging on\n"
@@ -225,10 +232,10 @@
"brcfg pol[icy] r[eject]/a[ccept] Switch the policy/flush protocol list\n"
"brcfg e[xempt] <protocol> .. Set list of exempt protocols\n"
"brcfg l[ist] List available protocols\n"
-"brcfg stat[s] z[ero] Reset Statistics counters"
-"brcfg stat[s] d[isable] Switch protocol statistics off"
-"brcfg stat[s] e[nable] Switch keeping protocol statistics on"
-"brcfg stat[s] s[how] Show protocol statistics"
+"brcfg stat[s] z[ero] Reset Statistics counters\n"
+"brcfg stat[s] d[isable] Switch protocol statistics off\n"
+"brcfg stat[s] e[nable] Switch keeping protocol statistics on\n"
+"brcfg stat[s] s[how] Show protocol statistics\n"
"brcfg statu[s] Show bridge status\n"
"\n"
"Examples:\n"
@@ -240,11 +247,11 @@
void debug(char *option)
{ if (strcasecmp(option,"on")==0)
- { cmd(BRCMD_ENABLE_DEBUG,0,0);
+ { cmd(BRCMD_ENABLE_DEBUG,0,0,"");
printf("Debug on.\n");
} else
if (strcasecmp(option,"off")==0)
- { cmd(BRCMD_DISABLE_DEBUG,0,0);
+ { cmd(BRCMD_DISABLE_DEBUG,0,0,"");
printf("Debug off.\n");
} else
{ printf("Debug mode can only be on or off!");
@@ -259,7 +266,7 @@
for(p=protocols;p->nr && strcasecmp(protocol,p->name)!=0;p++) ;
if (p->nr)
- { cmd(BRCMD_EXEMPT_PROTOCOL,p->nr,0);
+ { cmd(BRCMD_EXEMPT_PROTOCOL,p->nr,0,"");
printf("Exempt protocol ");disp_protocol(p->nr);printf(".\n");
return;
}
@@ -275,11 +282,11 @@
void policy(char *kind)
{ if (kind[0]=='a')
- { cmd(BRCMD_SET_POLICY,1,0);
+ { cmd(BRCMD_SET_POLICY,1,0,"");
printf("Policy accept all protocols.\n");
} else
if (kind[0]=='r')
- { cmd(BRCMD_SET_POLICY,0,0);
+ { cmd(BRCMD_SET_POLICY,0,0,"");
printf("Policy reject all protocols.\n");
} else
{ printf("Policy must be either accept or deny.\n");
@@ -289,18 +296,18 @@
void pathcost(char *port,char *cost)
{ int p=atoi(port),c=atoi(cost);
- cmd(BRCMD_SET_PATH_COST,p,c);
+ cmd(BRCMD_SET_PATH_COST,p,c,"");
printf("Pathcost for port %d set to %d",p,c);
}
void port(char *no,char *mode)
{ int port=atoi(no);
if (mode[0]=='e')
- { cmd(BRCMD_PORT_ENABLE,port,0);
+ { cmd(BRCMD_PORT_ENABLE,port,0,"");
printf("Enable Port %d\n",port);
} else
if (mode[0]=='d')
- { cmd(BRCMD_PORT_DISABLE,port,0);
+ { cmd(BRCMD_PORT_DISABLE,port,0,"");
printf("Disable Port %d\n",port);
} else
{ printf("Port option can only be enable or disable");
@@ -309,13 +316,40 @@
void portprior(char *port,char *prio)
{ int po=atoi(port),pr=atoi(prio);
- cmd(BRCMD_SET_PORT_PRIORITY,po,pr);
+ cmd(BRCMD_SET_PORT_PRIORITY,po,pr,"");
printf("Port Priority for port %d set to %d\n",po,pr);
}
+void create_vlan(char *port,char *vlan)
+{ int po=atoi(port),id=atoi(vlan);
+ cmd(BRCMD_VLAN_CONFIG,po,id,"");
+ printf("Vlan_id for port %d set to 0x%08x\n",po,id);
+}
+
+void create_mac_vlan(char *mac,char *vlan)
+{ unsigned int i,j;
+ unsigned char ula[6];
+ int id=atoi(vlan);
+
+ for ( i=0; i<6; i++) {
+ j = i;
+ sscanf( &mac[j*2], "%02x", &ula[j]);
+ }
+ printf("Vlan_id for mac %02x:%02x:%02x:%02x:%02x:%02x set to 0x%08x\n",
+ ula[0],
+ ula[1],
+ ula[2],
+ ula[3],
+ ula[4],
+ ula[5],
+ id);
+
+ cmd(BRCMD_MAC_VLAN,id,0,ula);
+}
+
void priority(char *prio)
{ int p=atoi(prio);
- cmd(BRCMD_SET_BRIDGE_PRIORITY,p,0);
+ cmd(BRCMD_SET_BRIDGE_PRIORITY,p,0,"");
printf("Bridge priority set to %d\n",p);
}
@@ -323,15 +357,15 @@
{ int x;
switch (a[0]) {
case 'e' :
- cmd(BRCMD_ENABLE_PROT_STATS,0,0);
+ cmd(BRCMD_ENABLE_PROT_STATS,0,0,"");
printf("Protocol Statistics enabled\n");
break;
case 'd' :
- cmd(BRCMD_DISABLE_PROT_STATS,0,0);
+ cmd(BRCMD_DISABLE_PROT_STATS,0,0,"");
printf("Protocol Statistics disabled\n");
break;
case 'z' :
- cmd(BRCMD_ZERO_PROT_STATS,0,0);
+ cmd(BRCMD_ZERO_PROT_STATS,0,0,"");
printf("Protocol Statistics counters reset.\n");
break;
case 's' :
@@ -379,7 +413,7 @@
argv--;
break;
case 'p' : if (p[2]=='l') { policy(*++argv);break; }
- else if (p[2]=='a') { pathcost(*++argv,*++argv);break; }
+ else if (p[1]=='a') { pathcost(*++argv,*++argv);break; }
else if (p[1]=='r') { priority(*++argv);break; }
else
if (argv[2][0]=='p')
@@ -387,15 +421,26 @@
break;
}
else
+ if (argv[2][0]=='v')
+ { create_vlan(argv[1],argv[3]);argv+=3;
+ break;
+ }
+ else
{ port(*++argv,*++argv);break;
}
+ case 'm' : if (argv[2][0]=='v')
+ {
+ create_mac_vlan(argv[1],argv[3]);argv+=3;
+
+ break;
+ }
case 's' : if (p[3]=='r') {
- cmd(BRCMD_BRIDGE_ENABLE,0,0);
+ cmd(BRCMD_BRIDGE_ENABLE,0,0,"");
printf("Bridge started.\n");
break;
}
else if (p[2]=='o') {
- cmd(BRCMD_BRIDGE_DISABLE,0,0);
+ cmd(BRCMD_BRIDGE_DISABLE,0,0,"");
printf("Bridge stopped.\n");
break;
}