Commit 4dd529d3 authored by Leigh Stoller's avatar Leigh Stoller

Add dobridges command for yet to completed layer two bridge support.

parent 692df899
......@@ -224,6 +224,7 @@ COMMAND_PROTOTYPE(donodeid);
COMMAND_PROTOTYPE(dostatus);
COMMAND_PROTOTYPE(doifconfig);
COMMAND_PROTOTYPE(doaccounts);
COMMAND_PROTOTYPE(dobridges);
COMMAND_PROTOTYPE(dodelay);
COMMAND_PROTOTYPE(dolinkdelay);
COMMAND_PROTOTYPE(dohosts);
......@@ -327,6 +328,7 @@ struct command {
{ "ifconfig", FULLCONFIG_ALL, F_ALLOCATED, doifconfig },
{ "accounts", FULLCONFIG_ALL, F_REMREQSSL, doaccounts },
{ "delay", FULLCONFIG_ALL, F_ALLOCATED, dodelay },
{ "bridges", FULLCONFIG_ALL, F_ALLOCATED, dobridges },
{ "linkdelay", FULLCONFIG_ALL, F_ALLOCATED, dolinkdelay },
{ "hostnames", FULLCONFIG_NONE, F_ALLOCATED, dohosts },
{ "rpms", FULLCONFIG_ALL, F_ALLOCATED, dorpms },
......@@ -2782,6 +2784,63 @@ COMMAND_PROTOTYPE(dolinkdelay)
return 0;
}
/*
* Return bridge config stuff.
*/
COMMAND_PROTOTYPE(dobridges)
{
MYSQL_RES *res;
MYSQL_ROW row;
char buf[2*MYBUFSIZE], *ebufp = &buf[sizeof(buf)];
int nrows;
/*
* Get bridge parameters for the machine.
*/
res = mydb_query("select b.bridx,i.MAC,b.vnode,b.vname "
" from bridges as b"
"left join interfaces as i on "
" i.node_id=b.node_id and i.iface=b.iface "
" where b.node_id='%s' order by bridx",
4, reqp->nodeid);
if (!res) {
error("BRIDGES: %s: DB Error getting bridges!\n", reqp->nodeid);
return 1;
}
if ((nrows = (int)mysql_num_rows(res)) == 0) {
mysql_free_result(res);
return 0;
}
while (nrows) {
char *bufp = buf;
row = mysql_fetch_row(res);
/*
* Sanity check.
*/
if (!row[0] || !row[1] || !row[2] || !row[3]) {
error("BRIDGES: %s: DB values are bogus!\n",
reqp->nodeid);
mysql_free_result(res);
return 1;
}
bufp += OUTPUT(bufp, ebufp - bufp,
"BRIDGE IDX=%s IFACE=%s VNODE=%s LINKNAME=%s\n",
row[0], row[1], row[2], row[3]);
client_writeback(sock, buf, strlen(buf), tcp);
nrows--;
if (verbose)
info("BRIDGES: %s", buf);
}
mysql_free_result(res);
return 0;
}
COMMAND_PROTOTYPE(dohosts)
{
MYSQL_RES *res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment