Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
b"\x22" \
b"\x10\x00\x00\x00" \
b"\x1c\x00" \
b"\x00\x00" \
b"\x01\x00\x00\x00" \
b"\x20\x00\x00\x00" \
b"\x00\x00" \
b"\x00" \
b"\x00" \
b"\x02\x00\x00\x1c"
data = actual.unpack(data)
assert len(actual) == 28
assert data == b""
assert actual['rpc_vers'].get_value() == 5
assert actual['rpc_vers_minor'].get_value() == 0
assert actual['ptype'].get_value() == PType.FAULT
assert actual['pfx_flags'].get_value() == 34
assert actual['packed_drep'].pack() == b"\x10\x00\x00\x00"
assert actual['frag_length'].get_value() == 28
assert actual['auth_length'].get_value() == 0
assert actual['call_id'].get_value() == 1
assert actual['alloc_hint'].get_value() == 32
assert actual['p_cont_id'].get_value() == 0
assert actual['cancel_count'].get_value() == 0
assert actual['reserved'].get_value() == 0
assert actual['status'].get_value() == \
FaultStatus.NCA_S_FAULT_ADDR_ERROR
b"\x10\x00\x00\x00" \
b"\x2c\x00" \
b"\x00\x00" \
b"\x04\x00\x00\x00" \
b"\x00\x00\x00\x00" \
b"\x01\x00" \
b"\x0a\x00" \
b"\xff\xff\xff\xff\xff\xff\xff\xff" \
b"\xff\xff\xff\xff\xff\xff\xff\xff" \
b"\x01\x02\x03\x04"
data = actual.unpack(data)
assert len(actual) == 44
assert data == b""
assert actual['rpc_vers'].get_value() == 5
assert actual['rpc_vers_minor'].get_value() == 0
assert actual['ptype'].get_value() == PType.REQUEST
assert actual['pfx_flags'].get_value() == 128
assert actual['packed_drep'].pack() == b"\x10\x00\x00\x00"
assert actual['frag_length'].get_value() == 44
assert actual['auth_length'].get_value() == 0
assert actual['call_id'].get_value() == 4
assert actual['alloc_hint'].get_value() == 0
assert actual['cont_id'].get_value() == 1
assert actual['opnum'].get_value() == 10
assert actual['object'].get_value() == b"\xff" * 16
assert actual['stub_data'].get_value() == b"\x01\x02\x03\x04"
assert actual['auth_verifier'].get_value() == b""
b"\x00\x00" \
b"\x01" \
b"\x00" \
b"\x01" \
b"\x00" \
b"\xff\xff\xff\xff\xff\xff\xff\xff" \
b"\xff\xff\xff\xff\xff\xff\xff\xff" \
b"\x00\x00\x00\x00" \
b"\xff\xff\xff\xff\xff\xff\xff\xff" \
b"\xff\xff\xff\xff\xff\xff\xff\xff" \
b"\x00\x00\x00\x00"
actual.unpack(data)
assert len(actual) == 72
assert actual['rpc_vers'].get_value() == 5
assert actual['rpc_vers_minor'].get_value() == 0
assert actual['ptype'].get_value() == PType.BIND
assert actual['pfx_flags'].get_value() == PFlags.PFC_MAYBE
assert actual['packed_drep']['integer_character'].get_value() == \
IntegerCharacterRepresentation.ASCII_LITTLE_ENDIAN
assert actual['packed_drep']['floating_point'].get_value() == \
FloatingPointRepresentation.IEEE
assert actual['packed_drep']['reserved1'].get_value() == 0
assert actual['packed_drep']['reserved2'].get_value() == 0
assert actual['frag_length'].get_value() == 72
assert actual['auth_length'].get_value() == 0
assert actual['call_id'].get_value() == 4
assert actual['max_xmit_frag'].get_value() == 4280
assert actual['max_recv_frag'].get_value() == 4280
assert actual['assoc_group_id'].get_value() == 2
assert actual['n_context_elem'].get_value() == 1
assert actual['reserved'].get_value() == 0
assert actual['reserved2'].get_value() == 0
data = b"\x05" \
b"\x00" \
b"\x0d" \
b"\x00" \
b"\x10\x00\x00\x00" \
b"\x15\x00" \
b"\x00\x00" \
b"\x04\x00\x00\x00" \
b"\x02\x00" \
b"\x01" \
b"\x05\x00"
data = actual.unpack(data)
assert len(actual) == 21
assert actual['rpc_vers'].get_value() == 5
assert actual['rpc_vers_minor'].get_value() == 0
assert actual['ptype'].get_value() == PType.BIND_NAK
assert actual['pfx_flags'].get_value() == 0
assert actual['packed_drep'].pack() == b"\x10\x00\x00\x00"
assert actual['frag_length'].get_value() == 21
assert actual['auth_length'].get_value() == 0
assert actual['call_id'].get_value() == 4
assert actual['provider_reject_reason'].get_value() == \
BindNakReason.LOCAL_LIMIT_EXCEEDED
assert actual['n_protocols'].get_value() == 1
assert len(actual['p_protocols'].get_value()) == 1
assert actual['p_protocols'][0] == 5
b"\x00" \
b"\x10\x00\x00\x00" \
b"\x1c\x00" \
b"\x00\x00" \
b"\x04\x00\x00\x00" \
b"\x08\x00\x00\x00" \
b"\x0c\x00" \
b"\x01" \
b"\x00" \
b"\x01\x02\x03\x04"
data = actual.unpack(data)
assert len(actual) == 28
assert data == b""
assert actual['rpc_vers'].get_value() == 5
assert actual['rpc_vers_minor'].get_value() == 0
assert actual['ptype'].get_value() == PType.RESPONSE
assert actual['pfx_flags'].get_value() == 0
assert actual['packed_drep'].pack() == b"\x10\x00\x00\x00"
assert actual['frag_length'].get_value() == 28
assert actual['auth_length'].get_value() == 0
assert actual['call_id'].get_value() == 4
assert actual['alloc_hint'].get_value() == 8
assert actual['cont_id'].get_value() == 12
assert actual['cancel_count'].get_value() == 1
assert actual['reserved'].get_value() == 0
assert actual['stub_data'].get_value() == b"\x01\x02\x03\x04"
assert actual['auth_verifier'].get_value() == b""
def __init__(self):
self.fields = OrderedDict([
('rpc_vers', IntField(
size=1,
default=5
)),
('rpc_vers_minor', IntField(size=1)),
('ptype', EnumField(
size=1,
enum_type=PType,
default=PType.FAULT
)),
('pfx_flags', FlagField(
size=1,
flag_type=PFlags
)),
('packed_drep', StructureField(
size=4,
structure_type=DataRepresentationFormat
)),
('frag_length', IntField(
size=2,
default=lambda s: len(s)
)),
('auth_length', IntField(size=2)),
('call_id', IntField(size=4)),
('alloc_hint', IntField(size=4)),
def parse_pdu(data):
"""
Converts the raw byte string of PDU data into a *PDU() structure. If the
type is invalid or unknown to pypsexec it will throw a PDUException.
:param data: The byte string returned in the buffer of the IOCTL response
:return: *PDU() structure that is dependent on the type being parsed
"""
type = struct.unpack("
def __init__(self):
self.fields = OrderedDict([
('rpc_vers', IntField(
size=1,
default=5
)),
('rpc_vers_minor', IntField(size=1)),
('ptype', EnumField(
size=1,
enum_type=PType,
default=PType.REQUEST
)),
('pfx_flags', FlagField(
size=1,
flag_type=PFlags
)),
('packed_drep', StructureField(
size=4,
structure_type=DataRepresentationFormat
)),
('frag_length', IntField(
size=2,
default=lambda s: len(s)
)),
('auth_length', IntField(
size=2,
default=lambda s: len(s['auth_verifier'])
def __init__(self):
self.fields = OrderedDict([
('rpc_vers', IntField(
size=1,
default=5
)),
('rpc_vers_minor', IntField(
size=1,
default=0
)),
('ptype', EnumField(
size=1,
enum_type=PType,
default=PType.BIND
)),
('pfx_flags', FlagField(
size=1,
flag_type=PFlags
)),
('packed_drep', StructureField(
size=4,
structure_type=DataRepresentationFormat
)),
('frag_length', IntField(
size=2,
default=lambda s: len(s)
)),
('auth_length', IntField(
size=2,
default=lambda s: len(s['auth_verifier'])