summaryrefslogtreecommitdiffstats
path: root/sbin/ifconfig/ifbridge.c
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2005-12-14 02:52:13 +0000
committerthompsa <thompsa@FreeBSD.org>2005-12-14 02:52:13 +0000
commitdbd94fcd442b994abe665d34aeab2f591f98f217 (patch)
tree9d77641fd4a325856117cac0087488e049e353bd /sbin/ifconfig/ifbridge.c
parent952c53a74a9de27a465719536a17a0cbd0ef1a4e (diff)
downloadFreeBSD-src-dbd94fcd442b994abe665d34aeab2f591f98f217.zip
FreeBSD-src-dbd94fcd442b994abe665d34aeab2f591f98f217.tar.gz
Add support for creating span ports so that one can snoop bridged traffic
from another interface/machine/network. Obtained from: OpenBSD MFC after: 2 weeks
Diffstat (limited to 'sbin/ifconfig/ifbridge.c')
-rw-r--r--sbin/ifconfig/ifbridge.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sbin/ifconfig/ifbridge.c b/sbin/ifconfig/ifbridge.c
index 36e308b..c42213f 100644
--- a/sbin/ifconfig/ifbridge.c
+++ b/sbin/ifconfig/ifbridge.c
@@ -290,6 +290,28 @@ unsetbridge_learn(const char *val, int d, int s, const struct afswtch *afp)
}
static void
+setbridge_span(const char *val, int d, int s, const struct afswtch *afp)
+{
+ struct ifbreq req;
+
+ memset(&req, 0, sizeof(req));
+ strlcpy(req.ifbr_ifsname, val, sizeof(req.ifbr_ifsname));
+ if (do_cmd(s, BRDGADDS, &req, sizeof(req), 1) < 0)
+ err(1, "BRDGADDS %s", val);
+}
+
+static void
+unsetbridge_span(const char *val, int d, int s, const struct afswtch *afp)
+{
+ struct ifbreq req;
+
+ memset(&req, 0, sizeof(req));
+ strlcpy(req.ifbr_ifsname, val, sizeof(req.ifbr_ifsname));
+ if (do_cmd(s, BRDGDELS, &req, sizeof(req), 1) < 0)
+ err(1, "BRDGDELS %s", val);
+}
+
+static void
setbridge_stp(const char *val, int d, int s, const struct afswtch *afp)
{
@@ -506,6 +528,8 @@ static struct cmd bridge_cmds[] = {
DEF_CMD_ARG("-discover", unsetbridge_discover),
DEF_CMD_ARG("learn", setbridge_learn),
DEF_CMD_ARG("-learn", unsetbridge_learn),
+ DEF_CMD_ARG("span", setbridge_span),
+ DEF_CMD_ARG("-span", unsetbridge_span),
DEF_CMD_ARG("stp", setbridge_stp),
DEF_CMD_ARG("-stp", unsetbridge_stp),
DEF_CMD("flush", 0, setbridge_flush),
OpenPOWER on IntegriCloud