Skip to content

Commit 64aba81

Browse files
authored
[MS-NRTP] do not use 'type' attribute (#4909)
1 parent f303033 commit 64aba81

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

scapy/layers/ms_nrtp.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def _members_cb(pkt, lst, cur, remain):
602602
].Value
603603
return functools.partial(
604604
NRBFMemberPrimitiveUnTyped,
605-
type=PrimitiveTypeEnum(primitiveType),
605+
primtype=PrimitiveTypeEnum(primitiveType),
606606
)
607607
return NRBFRecord
608608

@@ -639,14 +639,14 @@ class NRBFClassInfo(Packet):
639639

640640

641641
class NRBFAdditionalInfo(Packet):
642-
__slots__ = ["type"]
642+
__slots__ = ["bintype"]
643643

644644
fields_desc = [
645645
MultipleTypeField(
646646
[
647647
(
648648
ByteEnumField("Value", 0, PrimitiveTypeEnum),
649-
lambda pkt: pkt.type
649+
lambda pkt: pkt.bintype
650650
in [
651651
BinaryTypeEnum.Primitive,
652652
BinaryTypeEnum.PrimitiveArray,
@@ -656,30 +656,30 @@ class NRBFAdditionalInfo(Packet):
656656
PacketField(
657657
"Value", NRBFLengthPrefixedString(), NRBFLengthPrefixedString
658658
),
659-
lambda pkt: pkt.type == BinaryTypeEnum.SystemClass,
659+
lambda pkt: pkt.bintype == BinaryTypeEnum.SystemClass,
660660
),
661661
(
662662
PacketField("Value", NRBFClassTypeInfo(), NRBFClassTypeInfo),
663-
lambda pkt: pkt.type == BinaryTypeEnum.Class,
663+
lambda pkt: pkt.bintype == BinaryTypeEnum.Class,
664664
),
665665
],
666666
StrFixedLenField("Value", b"", length=0),
667667
),
668668
]
669669

670670
def __init__(self, _pkt=None, **kwargs):
671-
self.type = kwargs.pop("type", BinaryTypeEnum.Primitive)
672-
assert isinstance(self.type, BinaryTypeEnum)
671+
self.bintype = kwargs.pop("bintype", BinaryTypeEnum.Primitive)
672+
assert isinstance(self.bintype, BinaryTypeEnum)
673673
super(NRBFAdditionalInfo, self).__init__(_pkt, **kwargs)
674674

675675
def clone_with(self, *args, **kwargs):
676676
pkt = super(NRBFAdditionalInfo, self).clone_with(*args, **kwargs)
677-
pkt.type = self.type
677+
pkt.bintype = self.bintype
678678
return pkt
679679

680680
def copy(self):
681681
pkt = super(NRBFAdditionalInfo, self).copy()
682-
pkt.type = self.type
682+
pkt.bintype = self.bintype
683683
return pkt
684684

685685
def default_payload_class(self, payload):
@@ -715,7 +715,7 @@ def _member_type_infos_cb(pkt, lst, cur, remain):
715715
# Return BinaryTypeEnum tainted with a pre-selected type.
716716
return functools.partial(
717717
NRBFAdditionalInfo,
718-
type=typeEnum,
718+
bintype=typeEnum,
719719
)
720720

721721

@@ -752,30 +752,30 @@ class NRBFClassWithId(NRBFRecord):
752752

753753

754754
class NRBFMemberPrimitiveUnTyped(Packet):
755-
__slots__ = ["type"]
755+
__slots__ = ["primtype"]
756756

757757
fields_desc = [
758758
NRBFValueWithCode.fields_desc[1],
759759
]
760760

761761
def __init__(self, _pkt=None, **kwargs):
762-
self.type = kwargs.pop("type", PrimitiveTypeEnum.Byte)
763-
assert isinstance(self.type, PrimitiveTypeEnum)
762+
self.primtype = kwargs.pop("primtype", PrimitiveTypeEnum.Byte)
763+
assert isinstance(self.primtype, PrimitiveTypeEnum)
764764
super(NRBFMemberPrimitiveUnTyped, self).__init__(_pkt, **kwargs)
765765

766766
def clone_with(self, *args, **kwargs):
767767
pkt = super(NRBFMemberPrimitiveUnTyped, self).clone_with(*args, **kwargs)
768-
pkt.type = self.type
768+
pkt.primtype = self.primtype
769769
return pkt
770770

771771
def copy(self):
772772
pkt = super(NRBFMemberPrimitiveUnTyped, self).copy()
773-
pkt.type = self.type
773+
pkt.primtype = self.primtype
774774
return pkt
775775

776776
@property
777777
def PrimitiveType(self):
778-
return self.type
778+
return self.primtype
779779

780780
def default_payload_class(self, payload):
781781
return conf.padding_layer
@@ -848,7 +848,7 @@ def _values_singleprim_cb(pkt, lst, cur, remain):
848848
return None
849849
return functools.partial(
850850
NRBFMemberPrimitiveUnTyped,
851-
type=PrimitiveTypeEnum(pkt.PrimitiveTypeEnum),
851+
primtype=PrimitiveTypeEnum(pkt.PrimitiveTypeEnum),
852852
)
853853

854854

test/scapy/layers/msnrtp.uts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pkt = NRBF(
8080
],
8181
AdditionalInfos=[
8282
NRBFAdditionalInfo(
83-
type=BinaryTypeEnum.SystemClass,
83+
bintype=BinaryTypeEnum.SystemClass,
8484
Value=NRBFClassTypeInfo(
8585
TypeName=NRBFLengthPrefixedString(
8686
String=b"System.Data.SerializationFormat"
@@ -89,23 +89,23 @@ pkt = NRBF(
8989
)
9090
),
9191
NRBFAdditionalInfo(
92-
type=BinaryTypeEnum.Primitive,
92+
bintype=BinaryTypeEnum.Primitive,
9393
Value=PrimitiveTypeEnum.Boolean,
9494
),
9595
NRBFAdditionalInfo(
96-
type=BinaryTypeEnum.Primitive,
96+
bintype=BinaryTypeEnum.Primitive,
9797
Value=PrimitiveTypeEnum.Int32,
9898
),
9999
NRBFAdditionalInfo(
100-
type=BinaryTypeEnum.Primitive,
100+
bintype=BinaryTypeEnum.Primitive,
101101
Value=PrimitiveTypeEnum.Boolean,
102102
),
103103
NRBFAdditionalInfo(
104-
type=BinaryTypeEnum.Primitive,
104+
bintype=BinaryTypeEnum.Primitive,
105105
Value=PrimitiveTypeEnum.Int32,
106106
),
107107
NRBFAdditionalInfo(
108-
type=BinaryTypeEnum.PrimitiveArray,
108+
bintype=BinaryTypeEnum.PrimitiveArray,
109109
Value=PrimitiveTypeEnum.Byte,
110110
),
111111
],
@@ -121,12 +121,12 @@ pkt = NRBF(
121121
],
122122
BinaryTypeEnums=[BinaryTypeEnum.Primitive],
123123
AdditionalInfos=[
124-
NRBFAdditionalInfo(type=BinaryTypeEnum.Primitive,
124+
NRBFAdditionalInfo(bintype=BinaryTypeEnum.Primitive,
125125
Value=PrimitiveTypeEnum.Int32),
126126
],
127127
LibraryId=2,
128128
Members=[
129-
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Int32, Value=1)
129+
NRBFMemberPrimitiveUnTyped(primtype=PrimitiveTypeEnum.Int32, Value=1)
130130
],
131131
),
132132
NRBFBinaryObjectString(
@@ -135,11 +135,11 @@ pkt = NRBF(
135135
),
136136
NRBFMemberReference(IdRef=4),
137137
NRBFMemberReference(IdRef=4),
138-
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Boolean, Value=0),
139-
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Int32, Value=1033),
140-
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Boolean, Value=0),
138+
NRBFMemberPrimitiveUnTyped(primtype=PrimitiveTypeEnum.Boolean, Value=0),
139+
NRBFMemberPrimitiveUnTyped(primtype=PrimitiveTypeEnum.Int32, Value=1033),
140+
NRBFMemberPrimitiveUnTyped(primtype=PrimitiveTypeEnum.Boolean, Value=0),
141141
NRBFObjectNull(),
142-
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Int32, Value=1),
142+
NRBFMemberPrimitiveUnTyped(primtype=PrimitiveTypeEnum.Int32, Value=1),
143143
NRBFMemberReference(IdRef=5),
144144
],
145145
),

0 commit comments

Comments
 (0)