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
986eaf14
Commit
986eaf14
authored
7 years ago
by
gpotter2
Browse files
Options
Downloads
Patches
Plain Diff
Static access to LOOPBACK_INTERFACE
parent
6a783f4a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/route.py
+10
-7
10 additions, 7 deletions
scapy/route.py
with
10 additions
and
7 deletions
scapy/route.py
+
10
−
7
View file @
986eaf14
...
...
@@ -11,8 +11,8 @@ Routing and handling of network interfaces.
from
__future__
import
absolute_import
import
scapy.consts
from
scapy.config
import
conf
from
scapy.consts
import
WINDOWS
,
LOOPBACK_INTERFACE
from
scapy.error
import
Scapy_Exception
,
warning
from
scapy.modules
import
six
from
scapy.utils
import
atol
,
ltoa
,
itom
,
pretty_list
...
...
@@ -97,7 +97,7 @@ class Route:
for
i
,
route
in
enumerate
(
self
.
routes
):
net
,
msk
,
gw
,
iface
,
addr
,
metric
=
route
if
WINDOWS
:
if
scapy
.
consts
.
WINDOWS
:
if
iff
.
guid
!=
iface
.
guid
:
continue
elif
iff
!=
iface
:
...
...
@@ -114,7 +114,7 @@ class Route:
self
.
invalidate_cache
()
new_routes
=
[]
for
rt
in
self
.
routes
:
if
WINDOWS
:
if
scapy
.
consts
.
WINDOWS
:
if
iff
.
guid
==
rt
[
3
].
guid
:
continue
elif
iff
==
rt
[
3
]:
...
...
@@ -157,14 +157,14 @@ class Route:
aa
=
atol
(
a
)
if
aa
==
dst
:
pathes
.
append
(
(
0xffffffff
,
1
,
(
LOOPBACK_INTERFACE
,
a
,
"
0.0.0.0
"
))
(
0xffffffff
,
1
,
(
scapy
.
consts
.
LOOPBACK_INTERFACE
,
a
,
"
0.0.0.0
"
))
)
if
(
dst
&
m
)
==
(
d
&
m
):
pathes
.
append
((
m
,
me
,
(
i
,
a
,
gw
)))
if
not
pathes
:
if
verbose
:
warning
(
"
No route found (no default route?)
"
)
return
LOOPBACK_INTERFACE
,
"
0.0.0.0
"
,
"
0.0.0.0
"
return
scapy
.
consts
.
LOOPBACK_INTERFACE
,
"
0.0.0.0
"
,
"
0.0.0.0
"
# Choose the more specific route
# Sort by greatest netmask
pathes
.
sort
(
key
=
lambda
x
:
x
[
0
],
reverse
=
True
)
...
...
@@ -181,7 +181,7 @@ class Route:
for
net
,
msk
,
gw
,
iface
,
addr
,
metric
in
self
.
routes
:
if
net
==
0
:
continue
if
WINDOWS
:
if
scapy
.
consts
.
WINDOWS
:
if
iff
.
guid
!=
iface
.
guid
:
continue
elif
iff
!=
iface
:
...
...
@@ -194,7 +194,10 @@ conf.route=Route()
iface
=
conf
.
route
.
route
(
"
0.0.0.0
"
,
verbose
=
0
)[
0
]
if
(
iface
.
name
if
hasattr
(
iface
,
"
name
"
)
else
iface
)
==
LOOPBACK_INTERFACE
:
# Warning: scapy.consts.LOOPBACK_INTERFACE must always be used statically, because it
# may be changed by scapy/arch/windows during execution
if
(
iface
.
name
if
hasattr
(
iface
,
"
name
"
)
else
iface
)
==
scapy
.
consts
.
LOOPBACK_INTERFACE
:
from
scapy.arch
import
get_working_if
conf
.
iface
=
get_working_if
()
else
:
...
...
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