⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions doc/scapy/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,5 @@
'',
'Miscellaneous'),
]

suppress_warnings = ["app.add_directive"]
34 changes: 17 additions & 17 deletions scapy/layers/ms_nrtp.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ def _members_cb(pkt, lst, cur, remain):
].Value
return functools.partial(
NRBFMemberPrimitiveUnTyped,
type=PrimitiveTypeEnum(primitiveType),
nrbf_type=PrimitiveTypeEnum(primitiveType),
)
return NRBFRecord

Expand Down Expand Up @@ -639,14 +639,14 @@ class NRBFClassInfo(Packet):


class NRBFAdditionalInfo(Packet):
__slots__ = ["type"]
__slots__ = ["nrbf_type"]

fields_desc = [
MultipleTypeField(
[
(
ByteEnumField("Value", 0, PrimitiveTypeEnum),
lambda pkt: pkt.type
lambda pkt: pkt.nrbf_type
in [
BinaryTypeEnum.Primitive,
BinaryTypeEnum.PrimitiveArray,
Expand All @@ -656,30 +656,30 @@ class NRBFAdditionalInfo(Packet):
PacketField(
"Value", NRBFLengthPrefixedString(), NRBFLengthPrefixedString
),
lambda pkt: pkt.type == BinaryTypeEnum.SystemClass,
lambda pkt: pkt.nrbf_type == BinaryTypeEnum.SystemClass,
),
(
PacketField("Value", NRBFClassTypeInfo(), NRBFClassTypeInfo),
lambda pkt: pkt.type == BinaryTypeEnum.Class,
lambda pkt: pkt.nrbf_type == BinaryTypeEnum.Class,
),
],
StrFixedLenField("Value", b"", length=0),
),
]

def __init__(self, _pkt=None, **kwargs):
self.type = kwargs.pop("type", BinaryTypeEnum.Primitive)
assert isinstance(self.type, BinaryTypeEnum)
self.nrbf_type = kwargs.pop("nrbf_type", BinaryTypeEnum.Primitive)
assert isinstance(self.nrbf_type, BinaryTypeEnum)
super(NRBFAdditionalInfo, self).__init__(_pkt, **kwargs)

def clone_with(self, *args, **kwargs):
pkt = super(NRBFAdditionalInfo, self).clone_with(*args, **kwargs)
pkt.type = self.type
pkt.nrbf_type = self.nrbf_type
return pkt

def copy(self):
pkt = super(NRBFAdditionalInfo, self).copy()
pkt.type = self.type
pkt.nrbf_type = self.nrbf_type
return pkt

def default_payload_class(self, payload):
Expand Down Expand Up @@ -715,7 +715,7 @@ def _member_type_infos_cb(pkt, lst, cur, remain):
# Return BinaryTypeEnum tainted with a pre-selected type.
return functools.partial(
NRBFAdditionalInfo,
type=typeEnum,
nrbf_type=typeEnum,
)


Expand Down Expand Up @@ -752,30 +752,30 @@ class NRBFClassWithId(NRBFRecord):


class NRBFMemberPrimitiveUnTyped(Packet):
__slots__ = ["type"]
__slots__ = ["nrbf_type"]

fields_desc = [
NRBFValueWithCode.fields_desc[1],
]

def __init__(self, _pkt=None, **kwargs):
self.type = kwargs.pop("type", PrimitiveTypeEnum.Byte)
assert isinstance(self.type, PrimitiveTypeEnum)
self.nrbf_type = kwargs.pop("nrbf_type", PrimitiveTypeEnum.Byte)
assert isinstance(self.nrbf_type, PrimitiveTypeEnum)
super(NRBFMemberPrimitiveUnTyped, self).__init__(_pkt, **kwargs)

def clone_with(self, *args, **kwargs):
pkt = super(NRBFMemberPrimitiveUnTyped, self).clone_with(*args, **kwargs)
pkt.type = self.type
pkt.nrbf_type = self.nrbf_type
return pkt

def copy(self):
pkt = super(NRBFMemberPrimitiveUnTyped, self).copy()
pkt.type = self.type
pkt.nrbf_type = self.nrbf_type
return pkt

@property
def PrimitiveType(self):
return self.type
return self.nrbf_type

def default_payload_class(self, payload):
return conf.padding_layer
Expand Down Expand Up @@ -848,7 +848,7 @@ def _values_singleprim_cb(pkt, lst, cur, remain):
return None
return functools.partial(
NRBFMemberPrimitiveUnTyped,
type=PrimitiveTypeEnum(pkt.PrimitiveTypeEnum),
nrbf_type=PrimitiveTypeEnum(pkt.PrimitiveTypeEnum),
)


Expand Down
24 changes: 12 additions & 12 deletions test/scapy/layers/msnrtp.uts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pkt = NRBF(
],
AdditionalInfos=[
NRBFAdditionalInfo(
type=BinaryTypeEnum.SystemClass,
nrbf_type=BinaryTypeEnum.SystemClass,
Value=NRBFClassTypeInfo(
TypeName=NRBFLengthPrefixedString(
String=b"System.Data.SerializationFormat"
Expand All @@ -89,23 +89,23 @@ pkt = NRBF(
)
),
NRBFAdditionalInfo(
type=BinaryTypeEnum.Primitive,
nrbf_type=BinaryTypeEnum.Primitive,
Value=PrimitiveTypeEnum.Boolean,
),
NRBFAdditionalInfo(
type=BinaryTypeEnum.Primitive,
nrbf_type=BinaryTypeEnum.Primitive,
Value=PrimitiveTypeEnum.Int32,
),
NRBFAdditionalInfo(
type=BinaryTypeEnum.Primitive,
nrbf_type=BinaryTypeEnum.Primitive,
Value=PrimitiveTypeEnum.Boolean,
),
NRBFAdditionalInfo(
type=BinaryTypeEnum.Primitive,
nrbf_type=BinaryTypeEnum.Primitive,
Value=PrimitiveTypeEnum.Int32,
),
NRBFAdditionalInfo(
type=BinaryTypeEnum.PrimitiveArray,
nrbf_type=BinaryTypeEnum.PrimitiveArray,
Value=PrimitiveTypeEnum.Byte,
),
],
Expand All @@ -121,12 +121,12 @@ pkt = NRBF(
],
BinaryTypeEnums=[BinaryTypeEnum.Primitive],
AdditionalInfos=[
NRBFAdditionalInfo(type=BinaryTypeEnum.Primitive,
NRBFAdditionalInfo(nrbf_type=BinaryTypeEnum.Primitive,
Value=PrimitiveTypeEnum.Int32),
],
LibraryId=2,
Members=[
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Int32, Value=1)
NRBFMemberPrimitiveUnTyped(nrbf_type=PrimitiveTypeEnum.Int32, Value=1)
],
),
NRBFBinaryObjectString(
Expand All @@ -135,11 +135,11 @@ pkt = NRBF(
),
NRBFMemberReference(IdRef=4),
NRBFMemberReference(IdRef=4),
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Boolean, Value=0),
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Int32, Value=1033),
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Boolean, Value=0),
NRBFMemberPrimitiveUnTyped(nrbf_type=PrimitiveTypeEnum.Boolean, Value=0),
NRBFMemberPrimitiveUnTyped(nrbf_type=PrimitiveTypeEnum.Int32, Value=1033),
NRBFMemberPrimitiveUnTyped(nrbf_type=PrimitiveTypeEnum.Boolean, Value=0),
NRBFObjectNull(),
NRBFMemberPrimitiveUnTyped(type=PrimitiveTypeEnum.Int32, Value=1),
NRBFMemberPrimitiveUnTyped(nrbf_type=PrimitiveTypeEnum.Int32, Value=1),
NRBFMemberReference(IdRef=5),
],
),
Expand Down
Loading