diff options
author | thompsa <thompsa@FreeBSD.org> | 2005-12-14 02:52:13 +0000 |
---|---|---|
committer | thompsa <thompsa@FreeBSD.org> | 2005-12-14 02:52:13 +0000 |
commit | dbd94fcd442b994abe665d34aeab2f591f98f217 (patch) | |
tree | 9d77641fd4a325856117cac0087488e049e353bd /sbin/ifconfig | |
parent | 952c53a74a9de27a465719536a17a0cbd0ef1a4e (diff) | |
download | FreeBSD-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')
-rw-r--r-- | sbin/ifconfig/ifbridge.c | 24 | ||||
-rw-r--r-- | sbin/ifconfig/ifconfig.8 | 11 |
2 files changed, 35 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), diff --git a/sbin/ifconfig/ifconfig.8 b/sbin/ifconfig/ifconfig.8 index 5f0853b..0aa6e67 100644 --- a/sbin/ifconfig/ifconfig.8 +++ b/sbin/ifconfig/ifconfig.8 @@ -1106,6 +1106,17 @@ This is the default for all interfaces added to a bridge. Clear the .Dq learning attribute on a member interface. +.It Cm span Ar interface +Add the interface named by +.Ar interface +as a span port on the bridge. +Span ports transmit a copy of every frame received by the bridge. +This is most useful for snooping a bridged network passively on +another host connected to one of the span ports of the bridge. +.It Cm -span Ar interface +Delete the interface named by +.Ar interface +from the list of span ports of the bridge. .It Cm stp Ar interface Enable Spanning Tree protocol on .Ar interface . |