fix(?) extended + long-extended decoding
This commit is contained in:
@@ -118,11 +118,9 @@ def pre_decode_attributes( # pylint: disable=too-many-branches
|
|||||||
tmp_attributes = decode_vsa(rad_dict, key, value, offset)
|
tmp_attributes = decode_vsa(rad_dict, key, value, offset)
|
||||||
else:
|
else:
|
||||||
if attr_def.datatype == Datatype.extended:
|
if attr_def.datatype == Datatype.extended:
|
||||||
key, value, modifier = decode_extended(key, value, offset)
|
key, value, modifier = decode_extended(key, value)
|
||||||
elif attr_def.datatype == Datatype.longextended:
|
elif attr_def.datatype == Datatype.longextended:
|
||||||
key, value, modifier = decode_longextended(
|
key, value, modifier = decode_longextended(key, value)
|
||||||
key, value, offset
|
|
||||||
)
|
|
||||||
elif attr_def.datatype == Datatype.evs:
|
elif attr_def.datatype == Datatype.evs:
|
||||||
# Shouldn't this be part of extended/longextended?
|
# Shouldn't this be part of extended/longextended?
|
||||||
key, value, modifier = decode_evs(key, value, offset)
|
key, value, modifier = decode_evs(key, value, offset)
|
||||||
@@ -130,7 +128,7 @@ def pre_decode_attributes( # pylint: disable=too-many-branches
|
|||||||
key, value, modifier = decode_concat(key, value, offset)
|
key, value, modifier = decode_concat(key, value, offset)
|
||||||
else:
|
else:
|
||||||
modifier = 2
|
modifier = 2
|
||||||
# Redundand in the "normal" case
|
# Redundant in the "normal" case
|
||||||
tmp_attributes = [(key, value, offset + modifier)]
|
tmp_attributes = [(key, value, offset + modifier)]
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
# We do not know the TLV, but the packet seems to be well-formed so far
|
# We do not know the TLV, but the packet seems to be well-formed so far
|
||||||
@@ -227,21 +225,17 @@ def decode_vsa(
|
|||||||
return vendor_attributes
|
return vendor_attributes
|
||||||
|
|
||||||
|
|
||||||
def decode_extended(
|
def decode_extended(key: int, value: bytes) -> SpecialTlvDescription:
|
||||||
key: int, value: bytes, offset: int
|
|
||||||
) -> SpecialTlvDescription:
|
|
||||||
"""Decode an Attribute of type extended"""
|
"""Decode an Attribute of type extended"""
|
||||||
key = (key, value[0])
|
key = (key, value[0])
|
||||||
value = value[1 : length - 2]
|
value = value[1:-2]
|
||||||
return (key, value, 3)
|
return (key, value, 3)
|
||||||
|
|
||||||
|
|
||||||
def decode_longextended(
|
def decode_longextended(key: int, value: bytes) -> SpecialTlvDescription:
|
||||||
key: int, value: bytes, offset: int
|
|
||||||
) -> SpecialTlvDescription:
|
|
||||||
"""Decode an Attribute of type long-extended"""
|
"""Decode an Attribute of type long-extended"""
|
||||||
key = (key, value[0])
|
key = (key, value[0])
|
||||||
value = value[2 : length - 3]
|
value = value[2:-3]
|
||||||
return (key, value, 4)
|
return (key, value, 4)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user