Skip to content
Snippets Groups Projects
Commit 32b71044 authored by Pierre LALET's avatar Pierre LALET
Browse files

Arch: move constant values to a new submodule

This avoids a circular import problem affecting Windows platforms.
parent 3d027710
Branches
No related tags found
No related merge requests found
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
Operating system specific functionality. Operating system specific functionality.
""" """
import socket
import sys,os,socket from scapy.arch.consts import LINUX, OPENBSD, FREEBSD, NETBSD, DARWIN, \
SOLARIS, WINDOWS, BSD, X86_64, ARM_64
from scapy.error import * from scapy.error import *
import scapy.config import scapy.config
from scapy.pton_ntop import inet_pton from scapy.pton_ntop import inet_pton
...@@ -54,19 +55,6 @@ def get_if_hwaddr(iff): ...@@ -54,19 +55,6 @@ def get_if_hwaddr(iff):
raise Scapy_Exception("Unsupported address family (%i) for interface [%s]" % (addrfamily,iff)) raise Scapy_Exception("Unsupported address family (%i) for interface [%s]" % (addrfamily,iff))
LINUX = sys.platform.startswith("linux")
OPENBSD = sys.platform.startswith("openbsd")
FREEBSD = "freebsd" in sys.platform
NETBSD = sys.platform.startswith("netbsd")
DARWIN = sys.platform.startswith("darwin")
SOLARIS = sys.platform.startswith("sunos")
WINDOWS = sys.platform.startswith("win32")
BSD = DARWIN or FREEBSD or OPENBSD or NETBSD
X86_64 = not WINDOWS and (os.uname()[4] == 'x86_64')
ARM_64 = not WINDOWS and (os.uname()[4] == 'aarch64')
# Next step is to import following architecture specific functions: # Next step is to import following architecture specific functions:
# def get_if_raw_hwaddr(iff) # def get_if_raw_hwaddr(iff)
# def get_if_raw_addr(iff): # def get_if_raw_addr(iff):
......
## This file is part of Scapy
## See http://www.secdev.org/projects/scapy for more informations
## Copyright (C) Philippe Biondi <phil@secdev.org>
## This program is published under a GPLv2 license
import os
from sys import platform
LINUX = platform.startswith("linux")
OPENBSD = platform.startswith("openbsd")
FREEBSD = "freebsd" in platform
NETBSD = platform.startswith("netbsd")
DARWIN = platform.startswith("darwin")
SOLARIS = platform.startswith("sunos")
WINDOWS = platform.startswith("win32")
BSD = DARWIN or FREEBSD or OPENBSD or NETBSD
if WINDOWS:
X86_64 = False
ARM_64 = False
else:
uname = os.uname()
X86_64 = uname[4] == 'x86_64'
ARM_64 = uname[4] == 'aarch64'
...@@ -11,8 +11,8 @@ import errno ...@@ -11,8 +11,8 @@ import errno
import cPickle,os,sys,time,subprocess import cPickle,os,sys,time,subprocess
import itertools import itertools
from select import select from select import select
from scapy.arch.consts import DARWIN, FREEBSD
from scapy.data import * from scapy.data import *
from scapy import arch
from scapy.config import conf from scapy.config import conf
from scapy.packet import Gen from scapy.packet import Gen
from scapy.utils import warning,get_temp_file,PcapReader,wrpcap from scapy.utils import warning,get_temp_file,PcapReader,wrpcap
...@@ -127,7 +127,7 @@ def sndrcv(pks, pkt, timeout = None, inter = 0, verbose=None, chainCC=0, retry=0 ...@@ -127,7 +127,7 @@ def sndrcv(pks, pkt, timeout = None, inter = 0, verbose=None, chainCC=0, retry=0
if remaintime <= 0: if remaintime <= 0:
break break
r = None r = None
if not isinstance(pks, StreamSocket) and (arch.FREEBSD or arch.DARWIN): if not isinstance(pks, StreamSocket) and (FREEBSD or DARWIN):
inp, out, err = select(inmask,[],[], 0.05) inp, out, err = select(inmask,[],[], 0.05)
if len(inp) == 0 or pks in inp: if len(inp) == 0 or pks in inp:
r = pks.nonblock_recv() r = pks.nonblock_recv()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment