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
8dabca8e
Commit
8dabca8e
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
LLTD: implement .answers() (for some cases)
parent
455feebb
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/layers/lltd.py
+38
-0
38 additions, 0 deletions
scapy/layers/lltd.py
with
38 additions
and
0 deletions
scapy/layers/lltd.py
+
38
−
0
View file @
8dabca8e
...
@@ -25,6 +25,12 @@ from scapy.data import ETHER_ANY
...
@@ -25,6 +25,12 @@ from scapy.data import ETHER_ANY
class
LLTD
(
Packet
):
class
LLTD
(
Packet
):
name
=
"
LLTD
"
name
=
"
LLTD
"
answer_hashret
=
{
# (tos, function) tuple mapping (answer -> query), used by
# .hashret()
(
1
,
1
):
(
0
,
0
),
(
0
,
12
):
(
0
,
11
),
}
fields_desc
=
[
fields_desc
=
[
ByteField
(
"
version
"
,
1
),
ByteField
(
"
version
"
,
1
),
ByteEnumField
(
"
tos
"
,
0
,
{
ByteEnumField
(
"
tos
"
,
0
,
{
...
@@ -96,6 +102,38 @@ class LLTD(Packet):
...
@@ -96,6 +102,38 @@ class LLTD(Packet):
else
:
else
:
return
self
.
sprintf
(
'
LLTD %tos% - %function%
'
)
return
self
.
sprintf
(
'
LLTD %tos% - %function%
'
)
def
hashret
(
self
):
tos
,
function
=
self
.
tos
,
self
.
function
return
"
%c%c
"
%
self
.
answer_hashret
.
get
((
tos
,
function
),
(
tos
,
function
))
def
answers
(
self
,
other
):
if
not
isinstance
(
other
,
LLTD
):
return
False
if
self
.
tos
==
0
:
if
self
.
function
==
0
and
isinstance
(
self
.
payload
,
LLTDDiscover
)
\
and
len
(
self
[
LLTDDiscover
].
stations_list
)
==
1
:
# "Topology discovery - Discover" with one MAC address
# discovered answers a "Quick discovery - Hello"
return
other
.
tos
==
1
and
\
other
.
function
==
1
and
\
LLTDAttributeHostID
in
other
and
\
other
[
LLTDAttributeHostID
].
mac
==
\
self
[
LLTDDiscover
].
stations_list
[
0
]
elif
self
.
function
==
12
:
# "Topology discovery - QueryLargeTlvResp" answers
# "Topology discovery - QueryLargeTlv" with same .seq
# value
return
other
.
tos
==
0
and
other
.
function
==
11
\
and
other
.
seq
==
self
.
seq
elif
self
.
tos
==
1
:
if
self
.
function
==
1
and
isinstance
(
self
.
payload
,
LLTDHello
):
# "Quick discovery - Hello" answers a "Topology
# discovery - Discover"
return
other
.
tos
==
0
and
other
.
function
==
0
and
\
other
.
real_src
==
self
.
current_mapper_address
return
False
class
LLTDHello
(
Packet
):
class
LLTDHello
(
Packet
):
name
=
"
LLTD - Hello
"
name
=
"
LLTD - Hello
"
...
...
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