From a7d199a93e4b8deeefaf4e85fd553ec0a1c002da Mon Sep 17 00:00:00 2001
From: Daniel Jakots <vigdis@chown.me>
Date: Sat, 23 Jan 2016 16:22:34 +0100
Subject: [PATCH] Fix IPv6 support on OpenBSD

---
 scapy/arch/unix.py | 30 +++++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/scapy/arch/unix.py b/scapy/arch/unix.py
index 87745dc6..88acdb04 100644
--- a/scapy/arch/unix.py
+++ b/scapy/arch/unix.py
@@ -155,14 +155,30 @@ def in6_getifaddr():
     """
 
     # List all network interfaces
-    try:
-	f = os.popen("%s -l" % conf.prog.ifconfig)
-    except OSError,msg:
-	log_interactive.warning("Failed to execute ifconfig.")
-	return []
+    if scapy.arch.OPENBSD:
+        try:
+            f = os.popen("%s" % conf.prog.ifconfig)
+        except OSError,msg:
+	    log_interactive.warning("Failed to execute ifconfig.")
+	    return []
+
+        # Get the list of network interfaces
+        splitted_line = []
+        for l in f:
+            if "flags" in l:
+                iface = l.split()[0].rstrip(':')
+                splitted_line.append(iface)
+
+    else: # FreeBSD, NetBSD or Darwin
+        try:
+	    f = os.popen("%s -l" % conf.prog.ifconfig)
+        except OSError,msg:
+	    log_interactive.warning("Failed to execute ifconfig.")
+	    return []
+
+        # Get the list of network interfaces
+        splitted_line = f.readline().rstrip().split()
 
-    # Get the list of network interfaces
-    splitted_line = f.readline().rstrip().split()
     ret = []
     for i in splitted_line:
 	ret += _in6_getifaddr(i)
-- 
GitLab