From c1004afc1b7f3c6e05c7bee9fd70b1e2e8d706a9 Mon Sep 17 00:00:00 2001 From: Guillaume Valadon Date: Wed, 27 Dec 2017 05:57:29 +0100 Subject: [PATCH] Missing get_working_if() implementation with dnet --- scapy/arch/pcapdnet.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scapy/arch/pcapdnet.py b/scapy/arch/pcapdnet.py index b261d8c8c..e6ec14583 100644 --- a/scapy/arch/pcapdnet.py +++ b/scapy/arch/pcapdnet.py @@ -557,6 +557,19 @@ if conf.use_dnet: return [i.get("name", None) for i in dnet.intf()] + def get_working_if(): + """Returns the first interface than can be used with dnet""" + + if_iter = iter(dnet.intf()) + + try: + intf = next(if_iter) + except StopIteration: + return scapy.consts.LOOPBACK_NAME + + return intf.get("name", scapy.consts.LOOPBACK_NAME) + + if conf.use_pcap and conf.use_dnet: class L3dnetSocket(SuperSocket): desc = "read/write packets at layer 3 using libdnet and libpcap"