Skip to content
Snippets Groups Projects
Commit 180abb8a authored by Guillaume Valadon's avatar Guillaume Valadon Committed by GitHub
Browse files

Merge pull request #484 from p-l-/fix-64bits

Fix 64 bits architectures detection
parents 73b92e79 c37d00a9
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ Operating system specific functionality.
import socket
from scapy.consts import LINUX, OPENBSD, FREEBSD, NETBSD, DARWIN, \
SOLARIS, WINDOWS, BSD, X86_64, ARM_64, LOOPBACK_NAME, plt, MATPLOTLIB_INLINED, \
SOLARIS, WINDOWS, BSD, IS_64BITS, LOOPBACK_NAME, plt, MATPLOTLIB_INLINED, \
MATPLOTLIB_DEFAULT_PLOT_KARGS, PYX, parent_function
from scapy.error import *
import scapy.config
......
......@@ -11,7 +11,7 @@ import sys,os,struct,socket,time
from select import select
from fcntl import ioctl
from scapy.consts import LOOPBACK_NAME
from scapy.consts import LOOPBACK_NAME, IS_64BITS
import scapy.utils
import scapy.utils6
from scapy.packet import Packet, Padding
......@@ -149,10 +149,7 @@ def attach_filter(s, bpf_filter, iface):
# XXX. Argl! We need to give the kernel a pointer on the BPF,
# python object header seems to be 20 bytes. 36 bytes for x86 64bits arch.
if scapy.arch.X86_64 or scapy.arch.ARM_64:
bpfh = struct.pack("HL", nb, id(bpf)+36)
else:
bpfh = struct.pack("HI", nb, id(bpf)+20)
bpfh = struct.pack("HL", nb, id(bpf) + (36 if IS_64BITS else 20))
s.setsockopt(SOL_SOCKET, SO_ATTACH_FILTER, bpfh)
def set_promisc(s,iff,val=1):
......
......@@ -4,7 +4,7 @@
## This program is published under a GPLv2 license
import os, inspect
from sys import platform
from sys import platform, maxsize
import platform as platform_lib
from scapy.error import *
......@@ -40,10 +40,10 @@ DARWIN = platform.startswith("darwin")
SOLARIS = platform.startswith("sunos")
WINDOWS = platform.startswith("win32")
BSD = DARWIN or FREEBSD or OPENBSD or NETBSD
# See https://docs.python.org/3/library/platform.html#cross-platform
IS_64BITS = maxsize > 2**32
if WINDOWS:
X86_64 = False
ARM_64 = False
try:
if float(platform_lib.release()) >= 8.1:
LOOPBACK_NAME = "Microsoft KM-TEST Loopback Adapter"
......@@ -53,8 +53,6 @@ if WINDOWS:
LOOPBACK_NAME = "Microsoft Loopback Adapter"
else:
uname = os.uname()
X86_64 = uname[4] == 'x86_64'
ARM_64 = uname[4] == 'aarch64'
LOOPBACK_NAME = "lo" if LINUX else "lo0"
def parent_function():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment