From e5c256daa1c9fa94ab8667b5f4e7c89eea8b0c32 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Wed, 13 Jan 2016 11:52:43 +0000 Subject: [PATCH] add Bridge.Interface() --- router/bridge.go | 9 +++++++++ router/fastdp.go | 4 ++++ router/pcap.go | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/router/bridge.go b/router/bridge.go index 00481a0a..434669bd 100644 --- a/router/bridge.go +++ b/router/bridge.go @@ -1,5 +1,9 @@ package router +import ( + "net" +) + // Interface to packet handling on the local virtual bridge type Bridge interface { // Inject a packet to be delivered locally @@ -9,6 +13,7 @@ type Bridge interface { // should not be included. StartConsumingPackets(BridgeConsumer) error + Interface() *net.Interface String() string Stats() map[string]int } @@ -26,6 +31,10 @@ func (NullBridge) StartConsumingPackets(BridgeConsumer) error { return nil } +func (NullBridge) Interface() *net.Interface { + return nil +} + func (NullBridge) String() string { return "" } diff --git a/router/fastdp.go b/router/fastdp.go index d0c5a43f..ad294bfd 100644 --- a/router/fastdp.go +++ b/router/fastdp.go @@ -204,6 +204,10 @@ func (fastdp *FastDatapath) Bridge() Bridge { return fastDatapathBridge{fastdp} } +func (fastdp fastDatapathBridge) Interface() *net.Interface { + return fastdp.iface +} + func (fastdp fastDatapathBridge) String() string { return fmt.Sprint(fastdp.dpname, " (via ODP)") } diff --git a/router/pcap.go b/router/pcap.go index 848870be..781bb816 100644 --- a/router/pcap.go +++ b/router/pcap.go @@ -104,6 +104,10 @@ func newPcapHandle(ifName string, promisc bool, snaplen int, bufSz int) (handle return } +func (p *Pcap) Interface() *net.Interface { + return p.iface +} + func (p *Pcap) String() string { return fmt.Sprint(p.iface.Name, " (via pcap)") }