diff --git a/scapy/layers/lltd.py b/scapy/layers/lltd.py index c89c80a1d7b49ef5453c4de0279ad3943b8a269b..e7cdf685593bd251722f6520016e8508f1538a30 100644 --- a/scapy/layers/lltd.py +++ b/scapy/layers/lltd.py @@ -12,9 +12,9 @@ https://msdn.microsoft.com/en-us/library/cc233983.aspx import struct from scapy.fields import BitField, FlagsField, ByteField, ByteEnumField, \ - ShortField, ShortEnumField, IntField, IntEnumField, LongField, \ - MultiEnumField, FieldLenField, FieldListField, PacketListField, \ - StrLenField, StrLenFieldUtf16, ConditionalField, MACField + ShortField, ShortEnumField, ThreeBytesField, IntField, IntEnumField, \ + LongField, MultiEnumField, FieldLenField, FieldListField, \ + PacketListField, StrLenField, StrLenFieldUtf16, ConditionalField, MACField from scapy.packet import Packet, Padding, bind_layers from scapy.layers.l2 import Ether from scapy.layers.inet import IPField @@ -181,6 +181,48 @@ class LLTDQueryResp(Packet): ), [LLTD] +class LLTDQueryLargeTlv(Packet): + name = "LLTD - Query Large Tlv" + fields_desc = [ + ByteEnumField("type", 14, { + 14: "Icon image", + 17: "Friendly Name", + 19: "Hardware ID", + 22: "AP Association Table", + 24: "Detailed Icon Image", + 26: "Component Table", + 28: "Repeater AP Table", + }), + ThreeBytesField("offset", 0), + ] + + def mysummary(self): + return self.sprintf("%type% (offset %offset%)"), [LLTD] + + +class LLTDQueryLargeTlvResp(Packet): + name = "LLTD - Query Large Tlv Response" + fields_desc = [ + FlagsField("flags", 0, 2, "RM"), + BitField("len", None, 14), + StrLenField("value", "", length_from=lambda pkt: pkt.len) + ] + + def post_build(self, pkt, pay): + if self.len is None: + # len should be a FieldLenField but has an unsupported + # format (14 bits) + flags = ord(pkt[0]) & 0xc0 + length = len(self.value) + pkt = chr(flags + (length >> 8)) + chr(length % 256) + pkt[2:] + return pkt + pay + + def mysummary(self): + return self.sprintf("%%len%% bytes%s" % ( + " (last)" if not self.flags & 2 else "" + )), [LLTD] + + class LLTDAttribute(Packet): name = "LLTD Attribute" show_indent = False @@ -668,6 +710,8 @@ bind_layers(LLTD, LLTDHello, tos=0, function=1) bind_layers(LLTD, LLTDHello, tos=1, function=1) bind_layers(LLTD, LLTDEmit, tos=0, function=2) bind_layers(LLTD, LLTDQueryResp, tos=0, function=7) +bind_layers(LLTD, LLTDQueryLargeTlv, tos=0, function=11) +bind_layers(LLTD, LLTDQueryLargeTlvResp, tos=0, function=12) bind_layers(LLTDHello, LLTDAttribute) bind_layers(LLTDAttribute, LLTDAttribute) bind_layers(LLTDAttribute, Padding, type=0)