From 169af6fc8ac61f60f3b4faebaf21090ac73a7e66 Mon Sep 17 00:00:00 2001 From: Phil <phil@secdev.org> Date: Sun, 10 Aug 2008 02:36:39 +0200 Subject: [PATCH] Ability to choose which layers to load --- scapy/config.py | 3 +++ scapy/layers/all.py | 42 +++++++++++++++--------------------------- 2 files changed, 18 insertions(+), 27 deletions(-) diff --git a/scapy/config.py b/scapy/config.py index a1c44eb3..fc39b826 100644 --- a/scapy/config.py +++ b/scapy/config.py @@ -238,6 +238,9 @@ extensions_paths: path or list of paths where extensions are to be looked for stats_classic_protocols = [] stats_dot11_protocols = [] netcache = NetCache() + load_layers = ["l2", "inet", "dhcp", "dns", "dot11", "gprs", "hsrp", "ip6", "ir", "isakmp", "l2tp", + "mgcp", "mobileip", "netbios", "netflow", "ntp", "ppp", "radius", "rip", "rtp", + "sebek", "skinny", "smb", "snmp", "tftp", "x509", "bluetooth" ] conf=Conf() diff --git a/scapy/layers/all.py b/scapy/layers/all.py index 0887be49..f6518cd3 100644 --- a/scapy/layers/all.py +++ b/scapy/layers/all.py @@ -3,30 +3,18 @@ ## Copyright (C) Philippe Biondi <phil@secdev.org> ## This program is published under a GPLv2 license -from l2 import * -from inet import * -from dhcp import * -from dns import * -from dot11 import * -from gprs import * -from hsrp import * -from ip6 import * -from ir import * -from isakmp import * -from l2tp import * -from mgcp import * -from mobileip import * -from netbios import * -from netflow import * -from ntp import * -from ppp import * -from radius import * -from rip import * -from rtp import * -from sebek import * -from skinny import * -from smb import * -from snmp import * -from tftp import * -from x509 import * -from bluetooth import * +from scapy.config import conf +from scapy.error import log_loading + +def _import_star(m): + mod = __import__(m, globals(), locals()) + for k,v in mod.__dict__.iteritems(): + globals()[k] = v + +for l in conf.load_layers: + log_loading.debug("Loading layer %s" % l) + _import_star(l) + + + + -- GitLab