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