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

Windows: remove compatibility submodule

parent d5e3fc20
No related branches found
No related tags found
No related merge requests found
......@@ -68,14 +68,6 @@ elif SOLARIS:
from scapy.arch.solaris import *
elif WINDOWS:
from scapy.arch.windows import *
# import only if parent is not route.py
# because compatibility.py will require route.py to work (through sendrecv.py)
parents = parent_function()
if len(parents) >= 3:
if not parents[2][1].endswith("route.py"):
from scapy.arch.windows.compatibility import *
else:
from scapy.arch.windows.compatibility import *
if scapy.config.conf.iface is None:
scapy.config.conf.iface = LOOPBACK_NAME
......
......
......@@ -423,7 +423,7 @@ class NetworkInterfaceDict(UserDict):
except (KeyError, PcapNameNotFoundError):
pass
if len(self.data) == 0 and conf.use_winpcapy:
if not self.data and conf.use_winpcapy:
_detect = pcap_service_status()
def _ask_user():
if not conf.interactive:
......@@ -692,7 +692,7 @@ def _append_route6(routes, dpref, dp, nh, iface, lifaddr):
else:
devaddrs = (x for x in lifaddr if x[2] == iface)
cset = scapy.utils6.construct_source_candidate_set(dpref, dp, devaddrs)
if len(cset) == 0:
if not cset:
return
# APPEND (DESTINATION, NETMASK, NEXT HOP, IFACE, CANDIDATS)
routes.append((dpref, dp, nh, iface, cset))
......@@ -745,7 +745,7 @@ def _read_routes6_7():
index = 0
for l in stdout.split('\n'):
if not l.strip():
if len(current_object) == 0:
if not current_object:
continue
if len(current_object) == len(regex_list):
......@@ -836,10 +836,10 @@ def route_add_loopback(routes=None, ipv6=False, iflist=None):
warning("This will completly mess up the routes. Testing purpose only !")
# Add only if some adpaters already exist
if ipv6:
if len(conf.route6.routes) == 0:
if not conf.route6.routes:
return
else:
if len(conf.route.routes) == 0:
if not conf.route.routes:
return
data = {}
data['name'] = LOOPBACK_NAME
......@@ -884,3 +884,16 @@ def route_add_loopback(routes=None, ipv6=False, iflist=None):
routes.append(loopback_route6_custom)
else:
routes.append(loopback_route)
if not conf.use_winpcapy:
class NotAvailableSocket(SuperSocket):
desc = "wpcap.dll missing"
def __init__(self, *args, **kargs):
raise RuntimeError("Sniffing and sending packets is not available: "
"winpcap is not installed")
conf.L2socket = NotAvailableSocket
conf.L2listen = NotAvailableSocket
conf.L3socket = NotAvailableSocket
## 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
"""
Instanciate part of the customizations needed to support Microsoft Windows.
"""
from __future__ import absolute_import, print_function
from scapy.config import conf
# If wpcap.dll is not available
if not (conf.use_winpcapy or conf.use_pcap or conf.use_dnet):
from scapy.arch.windows.disable_sendrecv import *
## 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
"""
When wpcap.dll is not available, replace all sendrecv functions that won't work.
"""
from scapy.error import log_runtime
import scapy.sendrecv as sendrecv
import scapy.config as conf
from scapy.supersocket import SuperSocket
def log_warning():
if conf.conf.interactive:
log_runtime.warning("Function not available (winpcap is not installed)")
else:
raise ImportError("Function not available (winpcap is not installed)")
def not_available(*args, **kwargs):
log_warning()
return None
class not_available_socket(SuperSocket):
desc = "wpcap.dll missing"
def __init__(self, type=None, promisc=None, filter=None, iface=None, nofilter=0):
log_warning()
return
def send(self, x):
return
def recv(self,x=None):
return
def nonblock_recv(self):
return
def close(self):
return
sendrecv.send = not_available
sendrecv.sendp = not_available
sendrecv.sendpfast = not_available
sendrecv.sr = not_available
sendrecv.sr1 = not_available
sendrecv.srflood = not_available
sendrecv.srloop = not_available
sendrecv.srp = not_available
sendrecv.srp1 = not_available
sendrecv.srpflood = not_available
sendrecv.srploop = not_available
sendrecv.sniff = not_available
sendrecv.sndrcv = not_available
sendrecv.sndrcvflood = not_available
sendrecv.tshark = not_available
conf.L3socket=not_available_socket
conf.L2socket=not_available_socket
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment