Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
scapy
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CodeLinaro
public-release-test-restored
platform
external
scapy
Commits
c7b722ee
Commit
c7b722ee
authored
7 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
Fix layers import
parent
40978686
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
scapy/layers/all.py
+3
-27
3 additions, 27 deletions
scapy/layers/all.py
scapy/main.py
+20
-8
20 additions, 8 deletions
scapy/main.py
scapy/route.py
+0
-1
0 additions, 1 deletion
scapy/route.py
with
23 additions
and
36 deletions
scapy/layers/all.py
+
3
−
27
View file @
c7b722ee
...
@@ -10,6 +10,7 @@ All layers. Configurable with conf.load_layers.
...
@@ -10,6 +10,7 @@ All layers. Configurable with conf.load_layers.
from
__future__
import
absolute_import
from
__future__
import
absolute_import
from
scapy.config
import
conf
from
scapy.config
import
conf
from
scapy.error
import
log_loading
from
scapy.error
import
log_loading
from
scapy.main
import
load_layer
import
logging
,
importlib
import
logging
,
importlib
import
scapy.modules.six
as
six
import
scapy.modules.six
as
six
ignored
=
list
(
six
.
moves
.
builtins
.
__dict__
.
keys
())
+
[
"
sys
"
]
ignored
=
list
(
six
.
moves
.
builtins
.
__dict__
.
keys
())
+
[
"
sys
"
]
...
@@ -17,36 +18,11 @@ log = logging.getLogger("scapy.loading")
...
@@ -17,36 +18,11 @@ log = logging.getLogger("scapy.loading")
__all__
=
[]
__all__
=
[]
def
_validate_local
(
x
):
"""
Returns whether or not a variable should be imported.
Will return False for any default modules (sys), or if
they are detected as private vars (starting with a _)
"""
global
ignored
return
x
[
0
]
!=
"
_
"
and
not
x
in
ignored
def
_import_star
(
m
):
mod
=
importlib
.
import_module
(
"
.
"
+
m
,
"
scapy.layers
"
)
if
'
__all__
'
in
mod
.
__dict__
:
# only import the exported symbols in __all__
for
name
in
mod
.
__dict__
[
'
__all__
'
]:
__all__
.
append
(
name
)
globals
()[
name
]
=
mod
.
__dict__
[
name
]
else
:
# import all the non-private symbols
for
name
,
sym
in
six
.
iteritems
(
mod
.
__dict__
):
if
_validate_local
(
name
):
__all__
.
append
(
name
)
globals
()[
name
]
=
sym
LAYER_ALIASES
=
{
"
tls
"
:
"
tls.all
"
,
}
for
_l
in
conf
.
load_layers
:
for
_l
in
conf
.
load_layers
:
log_loading
.
debug
(
"
Loading layer %s
"
%
_l
)
log_loading
.
debug
(
"
Loading layer %s
"
%
_l
)
try
:
try
:
_import_star
(
LAYER_ALIASES
.
get
(
_l
,
_l
)
)
load_layer
(
_l
,
globals_dict
=
globals
(),
symb_list
=
__all__
)
except
Exception
as
e
:
except
Exception
as
e
:
log
.
warning
(
"
can
'
t import layer %s: %s
"
%
(
_l
,
e
))
log
.
warning
(
"
can
'
t import layer %s: %s
"
%
(
_l
,
e
))
del
_l
This diff is collapsed.
Click to expand it.
scapy/main.py
+
20
−
8
View file @
c7b722ee
...
@@ -18,7 +18,12 @@ import importlib
...
@@ -18,7 +18,12 @@ import importlib
ignored
=
list
(
six
.
moves
.
builtins
.
__dict__
.
keys
())
ignored
=
list
(
six
.
moves
.
builtins
.
__dict__
.
keys
())
from
scapy.error
import
*
from
scapy.error
import
*
from
scapy.layers.all
import
LAYER_ALIASES
__all__
=
[]
LAYER_ALIASES
=
{
"
tls
"
:
"
tls.all
"
}
def
_probe_config_file
(
cf
):
def
_probe_config_file
(
cf
):
cf_path
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"
~
"
),
cf
)
cf_path
=
os
.
path
.
join
(
os
.
path
.
expanduser
(
"
~
"
),
cf
)
...
@@ -65,26 +70,33 @@ from scapy.themes import DefaultTheme
...
@@ -65,26 +70,33 @@ from scapy.themes import DefaultTheme
######################
######################
def
_load
(
module
):
def
_load
(
module
,
globals_dict
=
None
,
symb_list
=
None
):
if
globals_dict
is
None
:
globals_dict
=
six
.
moves
.
builtins
.
__dict__
try
:
try
:
mod
=
importlib
.
import_module
(
module
)
mod
=
importlib
.
import_module
(
module
)
if
'
__all__
'
in
mod
.
__dict__
:
if
'
__all__
'
in
mod
.
__dict__
:
# import listed symbols
# import listed symbols
for
name
in
mod
.
__dict__
[
'
__all__
'
]:
for
name
in
mod
.
__dict__
[
'
__all__
'
]:
six
.
moves
.
builtins
.
__dict__
[
name
]
=
mod
.
__dict__
[
name
]
if
symb_list
is
not
None
:
symb_list
.
append
(
name
)
globals_dict
[
name
]
=
mod
.
__dict__
[
name
]
else
:
else
:
# only import non-private symbols
# only import non-private symbols
for
name
,
sym
in
six
.
iteritems
(
mod
.
__dict__
):
for
name
,
sym
in
six
.
iteritems
(
mod
.
__dict__
):
if
_validate_local
(
name
):
if
_validate_local
(
name
):
six
.
moves
.
builtins
.
__dict__
[
name
]
=
sym
if
symb_list
is
not
None
:
except
Exception
as
e
:
symb_list
.
append
(
name
)
log_interactive
.
error
(
e
)
globals_dict
[
name
]
=
sym
except
Exception
:
log_interactive
.
error
(
"
Loading module %s
"
,
module
,
exc_info
=
True
)
def
load_module
(
name
):
def
load_module
(
name
):
_load
(
"
scapy.modules.
"
+
name
)
_load
(
"
scapy.modules.
"
+
name
)
def
load_layer
(
name
):
def
load_layer
(
name
,
globals_dict
=
None
,
symb_list
=
None
):
_load
(
"
scapy.layers.
"
+
LAYER_ALIASES
.
get
(
name
,
name
))
_load
(
"
scapy.layers.
"
+
LAYER_ALIASES
.
get
(
name
,
name
),
globals_dict
=
globals_dict
,
symb_list
=
symb_list
)
def
load_contrib
(
name
):
def
load_contrib
(
name
):
try
:
try
:
...
...
This diff is collapsed.
Click to expand it.
scapy/route.py
+
0
−
1
View file @
c7b722ee
...
@@ -8,7 +8,6 @@ Routing and handling of network interfaces.
...
@@ -8,7 +8,6 @@ Routing and handling of network interfaces.
"""
"""
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
socket
from
scapy.consts
import
LOOPBACK_NAME
,
LOOPBACK_INTERFACE
from
scapy.consts
import
LOOPBACK_NAME
,
LOOPBACK_INTERFACE
from
scapy.utils
import
atol
,
ltoa
,
itom
,
pretty_routes
from
scapy.utils
import
atol
,
ltoa
,
itom
,
pretty_routes
from
scapy.config
import
conf
from
scapy.config
import
conf
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment