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
2532537b
Commit
2532537b
authored
9 years ago
by
Pierre LALET
Browse files
Options
Downloads
Patches
Plain Diff
PEP8 compliance
parent
bd083293
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
+29
-6
29 additions, 6 deletions
scapy/layers/lltd.py
with
29 additions
and
6 deletions
scapy/layers/lltd.py
+
29
−
6
View file @
2532537b
#
# This file is part of Scapy
# This file is part of Scapy
#
# See http://www.secdev.org/projects/scapy for more informations
# See http://www.secdev.org/projects/scapy for more informations
#
# Copyright (C) Philippe Biondi <phil@secdev.org>
# Copyright (C) Philippe Biondi <phil@secdev.org>
#
# This program is published under a GPLv2 license
# This program is published under a GPLv2 license
"""
LLTD Protocol
"""
LLTD Protocol
...
@@ -22,6 +22,7 @@ from scapy.layers.inet6 import IP6Field
...
@@ -22,6 +22,7 @@ from scapy.layers.inet6 import IP6Field
from
scapy.config
import
conf
from
scapy.config
import
conf
from
scapy.data
import
ETHER_ANY
from
scapy.data
import
ETHER_ANY
class
LLTD
(
Packet
):
class
LLTD
(
Packet
):
name
=
"
LLTD
"
name
=
"
LLTD
"
fields_desc
=
[
fields_desc
=
[
...
@@ -74,6 +75,7 @@ class LLTD(Packet):
...
@@ -74,6 +75,7 @@ class LLTD(Packet):
ConditionalField
(
ShortField
(
"
seq
"
,
0
),
ConditionalField
(
ShortField
(
"
seq
"
,
0
),
lambda
pkt
:
pkt
.
function
not
in
[
0
,
8
]),
lambda
pkt
:
pkt
.
function
not
in
[
0
,
8
]),
]
]
def
post_build
(
self
,
pkt
,
pay
):
def
post_build
(
self
,
pkt
,
pay
):
if
(
self
.
real_dst
is
None
or
self
.
real_src
is
None
)
and
\
if
(
self
.
real_dst
is
None
or
self
.
real_src
is
None
)
and
\
isinstance
(
self
.
underlayer
,
Ether
):
isinstance
(
self
.
underlayer
,
Ether
):
...
@@ -85,9 +87,11 @@ class LLTD(Packet):
...
@@ -85,9 +87,11 @@ class LLTD(Packet):
pkt
=
(
pkt
[:
10
]
+
eth
.
fields_desc
[
1
].
i2m
(
eth
,
eth
.
src
)
+
pkt
=
(
pkt
[:
10
]
+
eth
.
fields_desc
[
1
].
i2m
(
eth
,
eth
.
src
)
+
pkt
[
16
:])
pkt
[
16
:])
return
pkt
+
pay
return
pkt
+
pay
def
mysummary
(
self
):
def
mysummary
(
self
):
return
self
.
sprintf
(
'
LLTD %tos% - %function%
'
)
return
self
.
sprintf
(
'
LLTD %tos% - %function%
'
)
class
LLTDHello
(
Packet
):
class
LLTDHello
(
Packet
):
name
=
"
LLTD - Hello
"
name
=
"
LLTD - Hello
"
fields_desc
=
[
fields_desc
=
[
...
@@ -96,6 +100,7 @@ class LLTDHello(Packet):
...
@@ -96,6 +100,7 @@ class LLTDHello(Packet):
MACField
(
"
apparent_mapper_address
"
,
ETHER_ANY
),
MACField
(
"
apparent_mapper_address
"
,
ETHER_ANY
),
]
]
class
LLTDDiscover
(
Packet
):
class
LLTDDiscover
(
Packet
):
name
=
"
LLTD - Discover
"
name
=
"
LLTD - Discover
"
fields_desc
=
[
fields_desc
=
[
...
@@ -105,6 +110,7 @@ class LLTDDiscover(Packet):
...
@@ -105,6 +110,7 @@ class LLTDDiscover(Packet):
FieldListField
(
"
stations_list
"
,
[],
MACField
(
""
,
ETHER_ANY
),
FieldListField
(
"
stations_list
"
,
[],
MACField
(
""
,
ETHER_ANY
),
count_from
=
lambda
pkt
:
pkt
.
stations_count
)
count_from
=
lambda
pkt
:
pkt
.
stations_count
)
]
]
def
mysummary
(
self
):
def
mysummary
(
self
):
return
self
.
sprintf
(
"
%stations_list%
"
),
[
LLTD
]
return
self
.
sprintf
(
"
%stations_list%
"
),
[
LLTD
]
...
@@ -132,6 +138,7 @@ class LLTDAttribute(Packet):
...
@@ -132,6 +138,7 @@ class LLTDAttribute(Packet):
FieldLenField
(
"
len
"
,
None
,
length_of
=
"
value
"
,
fmt
=
"
B
"
),
FieldLenField
(
"
len
"
,
None
,
length_of
=
"
value
"
,
fmt
=
"
B
"
),
StrLenField
(
"
value
"
,
""
,
length_from
=
lambda
pkt
:
pkt
.
len
),
StrLenField
(
"
value
"
,
""
,
length_from
=
lambda
pkt
:
pkt
.
len
),
]
]
@classmethod
@classmethod
def
dispatch_hook
(
cls
,
_pkt
=
None
,
*
_
,
**
kargs
):
def
dispatch_hook
(
cls
,
_pkt
=
None
,
*
_
,
**
kargs
):
if
_pkt
:
if
_pkt
:
...
@@ -144,6 +151,7 @@ class LLTDAttribute(Packet):
...
@@ -144,6 +151,7 @@ class LLTDAttribute(Packet):
SPECIFIC_CLASSES
=
{}
SPECIFIC_CLASSES
=
{}
def
register_lltd_specific_class
(
*
attr_types
):
def
register_lltd_specific_class
(
*
attr_types
):
def
_register
(
cls
):
def
_register
(
cls
):
for
attr_type
in
attr_types
:
for
attr_type
in
attr_types
:
...
@@ -154,11 +162,13 @@ def register_lltd_specific_class(*attr_types):
...
@@ -154,11 +162,13 @@ def register_lltd_specific_class(*attr_types):
return
cls
return
cls
return
_register
return
_register
@register_lltd_specific_class
(
0
)
@register_lltd_specific_class
(
0
)
class
LLTDAttributeEOP
(
LLTDAttribute
):
class
LLTDAttributeEOP
(
LLTDAttribute
):
name
=
"
LLTD Attribute - End Of Property
"
name
=
"
LLTD Attribute - End Of Property
"
fields_desc
=
[]
fields_desc
=
[]
@register_lltd_specific_class
(
1
)
@register_lltd_specific_class
(
1
)
class
LLTDAttributeHostID
(
LLTDAttribute
):
class
LLTDAttributeHostID
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Host ID
"
name
=
"
LLTD Attribute - Host ID
"
...
@@ -167,12 +177,13 @@ class LLTDAttributeHostID(LLTDAttribute):
...
@@ -167,12 +177,13 @@ class LLTDAttributeHostID(LLTDAttribute):
MACField
(
"
mac
"
,
ETHER_ANY
),
MACField
(
"
mac
"
,
ETHER_ANY
),
]
]
@register_lltd_specific_class
(
2
)
@register_lltd_specific_class
(
2
)
class
LLTDAttributeCharacteristics
(
LLTDAttribute
):
class
LLTDAttributeCharacteristics
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Characteristics
"
name
=
"
LLTD Attribute - Characteristics
"
fields_desc
=
[
fields_desc
=
[
#
#
According to MS doc, "this field MUST be set to 0x02". But
# According to MS doc, "this field MUST be set to 0x02". But
#
#
according to MS implementation, that's wrong.
# according to MS implementation, that's wrong.
# ByteField("len", 2),
# ByteField("len", 2),
FieldLenField
(
"
len
"
,
None
,
length_of
=
"
reserved2
"
,
fmt
=
"
B
"
,
FieldLenField
(
"
len
"
,
None
,
length_of
=
"
reserved2
"
,
fmt
=
"
B
"
,
adjust
=
lambda
_
,
x
:
x
+
2
),
adjust
=
lambda
_
,
x
:
x
+
2
),
...
@@ -181,6 +192,7 @@ class LLTDAttributeCharacteristics(LLTDAttribute):
...
@@ -181,6 +192,7 @@ class LLTDAttributeCharacteristics(LLTDAttribute):
StrLenField
(
"
reserved2
"
,
""
,
length_from
=
lambda
x
:
x
.
len
-
2
)
StrLenField
(
"
reserved2
"
,
""
,
length_from
=
lambda
x
:
x
.
len
-
2
)
]
]
@register_lltd_specific_class
(
3
)
@register_lltd_specific_class
(
3
)
class
LLTDAttributePhysicalMedium
(
LLTDAttribute
):
class
LLTDAttributePhysicalMedium
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Physical Medium
"
name
=
"
LLTD Attribute - Physical Medium
"
...
@@ -466,6 +478,7 @@ class LLTDAttributePhysicalMedium(LLTDAttribute):
...
@@ -466,6 +478,7 @@ class LLTDAttributePhysicalMedium(LLTDAttribute):
}),
}),
]
]
@register_lltd_specific_class
(
7
)
@register_lltd_specific_class
(
7
)
class
LLTDAttributeIPv4Address
(
LLTDAttribute
):
class
LLTDAttributeIPv4Address
(
LLTDAttribute
):
name
=
"
LLTD Attribute - IPv4 Address
"
name
=
"
LLTD Attribute - IPv4 Address
"
...
@@ -474,6 +487,7 @@ class LLTDAttributeIPv4Address(LLTDAttribute):
...
@@ -474,6 +487,7 @@ class LLTDAttributeIPv4Address(LLTDAttribute):
IPField
(
"
ipv4
"
,
"
0.0.0.0
"
),
IPField
(
"
ipv4
"
,
"
0.0.0.0
"
),
]
]
@register_lltd_specific_class
(
8
)
@register_lltd_specific_class
(
8
)
class
LLTDAttributeIPv6Address
(
LLTDAttribute
):
class
LLTDAttributeIPv6Address
(
LLTDAttribute
):
name
=
"
LLTD Attribute - IPv6 Address
"
name
=
"
LLTD Attribute - IPv6 Address
"
...
@@ -482,6 +496,7 @@ class LLTDAttributeIPv6Address(LLTDAttribute):
...
@@ -482,6 +496,7 @@ class LLTDAttributeIPv6Address(LLTDAttribute):
IP6Field
(
"
ipv6
"
,
"
::
"
),
IP6Field
(
"
ipv6
"
,
"
::
"
),
]
]
@register_lltd_specific_class
(
9
)
@register_lltd_specific_class
(
9
)
class
LLTDAttribute80211MaxRate
(
LLTDAttribute
):
class
LLTDAttribute80211MaxRate
(
LLTDAttribute
):
name
=
"
LLTD Attribute - 802.11 Max Rate
"
name
=
"
LLTD Attribute - 802.11 Max Rate
"
...
@@ -490,6 +505,7 @@ class LLTDAttribute80211MaxRate(LLTDAttribute):
...
@@ -490,6 +505,7 @@ class LLTDAttribute80211MaxRate(LLTDAttribute):
ShortField
(
"
rate
"
,
0
),
ShortField
(
"
rate
"
,
0
),
]
]
@register_lltd_specific_class
(
10
)
@register_lltd_specific_class
(
10
)
class
LLTDAttributePerformanceCounterFrequency
(
LLTDAttribute
):
class
LLTDAttributePerformanceCounterFrequency
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Performance Counter Frequency
"
name
=
"
LLTD Attribute - Performance Counter Frequency
"
...
@@ -498,6 +514,7 @@ class LLTDAttributePerformanceCounterFrequency(LLTDAttribute):
...
@@ -498,6 +514,7 @@ class LLTDAttributePerformanceCounterFrequency(LLTDAttribute):
LongField
(
"
freq
"
,
0
),
LongField
(
"
freq
"
,
0
),
]
]
@register_lltd_specific_class
(
12
)
@register_lltd_specific_class
(
12
)
class
LLTDAttributeLinkSpeed
(
LLTDAttribute
):
class
LLTDAttributeLinkSpeed
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Link Speed
"
name
=
"
LLTD Attribute - Link Speed
"
...
@@ -506,6 +523,7 @@ class LLTDAttributeLinkSpeed(LLTDAttribute):
...
@@ -506,6 +523,7 @@ class LLTDAttributeLinkSpeed(LLTDAttribute):
IntField
(
"
speed
"
,
0
),
IntField
(
"
speed
"
,
0
),
]
]
@register_lltd_specific_class
(
14
,
24
,
26
)
@register_lltd_specific_class
(
14
,
24
,
26
)
class
LLTDAttributeLargeTLV
(
LLTDAttribute
):
class
LLTDAttributeLargeTLV
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Large TLV
"
name
=
"
LLTD Attribute - Large TLV
"
...
@@ -513,6 +531,7 @@ class LLTDAttributeLargeTLV(LLTDAttribute):
...
@@ -513,6 +531,7 @@ class LLTDAttributeLargeTLV(LLTDAttribute):
ByteField
(
"
len
"
,
0
),
ByteField
(
"
len
"
,
0
),
]
]
@register_lltd_specific_class
(
15
)
@register_lltd_specific_class
(
15
)
class
LLTDAttributeMachineName
(
LLTDAttribute
):
class
LLTDAttributeMachineName
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Machine Name
"
name
=
"
LLTD Attribute - Machine Name
"
...
@@ -521,6 +540,7 @@ class LLTDAttributeMachineName(LLTDAttribute):
...
@@ -521,6 +540,7 @@ class LLTDAttributeMachineName(LLTDAttribute):
StrLenFieldUtf16
(
"
hostname
"
,
""
,
length_from
=
lambda
pkt
:
pkt
.
len
),
StrLenFieldUtf16
(
"
hostname
"
,
""
,
length_from
=
lambda
pkt
:
pkt
.
len
),
]
]
@register_lltd_specific_class
(
18
)
@register_lltd_specific_class
(
18
)
class
LLTDAttributeDeviceUUID
(
LLTDAttribute
):
class
LLTDAttributeDeviceUUID
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Device UUID
"
name
=
"
LLTD Attribute - Device UUID
"
...
@@ -529,6 +549,7 @@ class LLTDAttributeDeviceUUID(LLTDAttribute):
...
@@ -529,6 +549,7 @@ class LLTDAttributeDeviceUUID(LLTDAttribute):
StrLenField
(
"
uuid
"
,
"
\x00
"
*
16
,
length_from
=
lambda
pkt
:
pkt
.
len
),
StrLenField
(
"
uuid
"
,
"
\x00
"
*
16
,
length_from
=
lambda
pkt
:
pkt
.
len
),
]
]
@register_lltd_specific_class
(
20
)
@register_lltd_specific_class
(
20
)
class
LLTDAttributeQOSCharacteristics
(
LLTDAttribute
):
class
LLTDAttributeQOSCharacteristics
(
LLTDAttribute
):
name
=
"
LLTD Attribute - QoS Characteristics
"
name
=
"
LLTD Attribute - QoS Characteristics
"
...
@@ -539,6 +560,7 @@ class LLTDAttributeQOSCharacteristics(LLTDAttribute):
...
@@ -539,6 +560,7 @@ class LLTDAttributeQOSCharacteristics(LLTDAttribute):
ShortField
(
"
reserved2
"
,
0
),
ShortField
(
"
reserved2
"
,
0
),
]
]
@register_lltd_specific_class
(
21
)
@register_lltd_specific_class
(
21
)
class
LLTDAttribute80211PhysicalMedium
(
LLTDAttribute
):
class
LLTDAttribute80211PhysicalMedium
(
LLTDAttribute
):
name
=
"
LLTD Attribute - 802.11 Physical Medium
"
name
=
"
LLTD Attribute - 802.11 Physical Medium
"
...
@@ -555,6 +577,7 @@ class LLTDAttribute80211PhysicalMedium(LLTDAttribute):
...
@@ -555,6 +577,7 @@ class LLTDAttribute80211PhysicalMedium(LLTDAttribute):
}),
}),
]
]
@register_lltd_specific_class
(
25
)
@register_lltd_specific_class
(
25
)
class
LLTDAttributeSeesList
(
LLTDAttribute
):
class
LLTDAttributeSeesList
(
LLTDAttribute
):
name
=
"
LLTD Attribute - Sees List Working Set
"
name
=
"
LLTD Attribute - Sees List Working 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