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
a1c5a258
Commit
a1c5a258
authored
15 years ago
by
Arnaud Ebalard
Browse files
Options
Downloads
Patches
Plain Diff
Have construct_source_candidate_set() return a sorted list with global addresses first
parent
bdcac1c3
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scapy/utils6.py
+15
-0
15 additions, 0 deletions
scapy/utils6.py
with
15 additions
and
0 deletions
scapy/utils6.py
+
15
−
0
View file @
a1c5a258
...
@@ -24,6 +24,20 @@ def construct_source_candidate_set(addr, plen, laddr, loname):
...
@@ -24,6 +24,20 @@ def construct_source_candidate_set(addr, plen, laddr, loname):
will then be performed to select the best source address associated
will then be performed to select the best source address associated
with some specific destination that uses this prefix.
with some specific destination that uses this prefix.
"""
"""
def
cset_sort
(
x
,
y
):
x_global
=
0
if
in6_isgladdr
(
x
):
x_global
=
1
y_global
=
0
if
in6_isgladdr
(
y
):
y_global
=
1
res
=
y_global
-
x_global
if
res
!=
0
or
y_global
!=
1
:
return
res
# two global addresses: if one is native, it wins.
if
not
in6_isaddr6to4
(
x
):
return
-
1
;
return
-
res
cset
=
[]
cset
=
[]
if
in6_isgladdr
(
addr
)
or
in6_isuladdr
(
addr
):
if
in6_isgladdr
(
addr
)
or
in6_isuladdr
(
addr
):
...
@@ -44,6 +58,7 @@ def construct_source_candidate_set(addr, plen, laddr, loname):
...
@@ -44,6 +58,7 @@ def construct_source_candidate_set(addr, plen, laddr, loname):
elif
addr
==
'
::
'
and
plen
==
0
:
elif
addr
==
'
::
'
and
plen
==
0
:
cset
=
filter
(
lambda
x
:
x
[
1
]
==
IPV6_ADDR_GLOBAL
,
laddr
)
cset
=
filter
(
lambda
x
:
x
[
1
]
==
IPV6_ADDR_GLOBAL
,
laddr
)
cset
=
map
(
lambda
x
:
x
[
0
],
cset
)
cset
=
map
(
lambda
x
:
x
[
0
],
cset
)
cset
.
sort
(
cmp
=
cset_sort
)
# Sort with global addresses first
return
cset
return
cset
def
get_source_addr_from_candidate_set
(
dst
,
candidate_set
):
def
get_source_addr_from_candidate_set
(
dst
,
candidate_set
):
...
...
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