openbsd-ports/net/scapy/patches/patch-scapy_layers_loop_py
bluhm 144304141e Scapy did not handle the DLT_LOOP type that is used when sniffing
from OpenBSD loopback device.  Add a new layer for that.
ok sthen@
2012-01-12 03:16:24 +00:00

39 lines
1.3 KiB
Plaintext

$OpenBSD: patch-scapy_layers_loop_py,v 1.1 2012/01/12 03:16:24 bluhm Exp $
Add layer for sniffing on OpenBSD loopback device.
http://trac.secdev.org/scapy/ticket/485
--- scapy/layers/loop.py.orig Wed Jan 11 23:58:04 2012
+++ scapy/layers/loop.py Thu Jan 12 00:12:21 2012
@@ -0,0 +1,31 @@
+## This file is part of Scapy
+## See http://www.secdev.org/projects/scapy for more informations
+## Copyright (C) Alexander Bluhm <alexander.bluhm@gmx.net>
+## Copyright (C) Philippe Biondi <phil@secdev.org>
+## This program is published under a GPLv2 license
+
+import scapy.arch
+from scapy.packet import *
+from scapy.fields import *
+from scapy.layers.inet import IP
+if conf.ipv6_enabled:
+ from scapy.layers.inet6 import IPv6
+from scapy.config import conf
+
+class Loop(Packet):
+ name = "Loop"
+ # from OpenBSD src/sys/net/if_loop.c
+ fields_desc = [ IntEnumField("addrfamily", 2, { socket.AF_INET: "IPv4",
+ socket.AF_INET6: "IPv6" }),
+ ]
+ def mysummary(self):
+ return self.sprintf("%Loop.addrfamily%")
+
+bind_layers(Loop, IP, addrfamily=socket.AF_INET)
+if conf.ipv6_enabled:
+ bind_layers(Loop, IPv6, addrfamily=socket.AF_INET6)
+
+if scapy.arch.OPENBSD:
+ conf.l2types.register(12, Loop)
+else:
+ conf.l2types.register(108, Loop)