### ms-cmpo.idl
"""
RPC definitions for the following interfaces:
- IXnRemote (v1.0): 906B0CE0-C70B-1067-B317-00DD010662DA
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfStrLenField,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRContextHandle,
    NDRInt3264EnumField,
    NDRIntField,
    NDRPacketField,
    register_dcerpc_interface,
)


class SESSION_RANK(IntEnum):
    SRANK_PRIMARY = 1
    SRANK_SECONDARY = 2


class Poke_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("sRank", 0, SESSION_RANK),
        NDRConfVarStrLenField("pszCalleeUuid", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRConfVarStrLenField(
            "pszHostName", "", size_is=lambda pkt: (pkt.MAX_COMPUTERNAME_LENGTH + 1)
        ),
        NDRConfVarStrLenField("pszUuidString", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRIntField("dwcbSizeOfBlob", None, size_of="rguchBlob"),
        NDRConfStrLenField("rguchBlob", "", size_is=lambda pkt: pkt.dwcbSizeOfBlob),
    ]


class Poke_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class BIND_VERSION_SET(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("dwMinLevelOne", 0),
        NDRIntField("dwMaxLevelOne", 0),
        NDRIntField("dwMinLevelTwo", 0),
        NDRIntField("dwMaxLevelTwo", 0),
        NDRIntField("dwMinLevelThree", 0),
        NDRIntField("dwMaxLevelThree", 0),
    ]


class BOUND_VERSION_SET(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("dwLevelOneAccepted", 0),
        NDRIntField("dwLevelTwoAccepted", 0),
        NDRIntField("dwLevelThreeAccepted", 0),
    ]


class BuildContext_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("sRank", 0, SESSION_RANK),
        NDRPacketField("BindVersionSet", BIND_VERSION_SET(), BIND_VERSION_SET),
        NDRConfVarStrLenField("pszCalleeUuid", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRConfVarStrLenField(
            "pszHostName", "", size_is=lambda pkt: (pkt.MAX_COMPUTERNAME_LENGTH + 1)
        ),
        NDRConfVarStrLenField("pszUuidString", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRConfVarStrLenField("pszGuidIn", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRConfVarStrLenField("pszGuidOut", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRPacketField("pBoundVersionSet", BOUND_VERSION_SET(), BOUND_VERSION_SET),
        NDRIntField("dwcbSizeOfBlob", None, size_of="rguchBlob"),
        NDRConfStrLenField("rguchBlob", "", size_is=lambda pkt: pkt.dwcbSizeOfBlob),
    ]


class BuildContext_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenField("pszGuidOut", "", size_is=lambda pkt: pkt.GUID_LENGTH),
        NDRPacketField("pBoundVersionSet", BOUND_VERSION_SET(), BOUND_VERSION_SET),
        NDRPacketField("ppHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class RESOURCE_TYPE(IntEnum):
    RT_CONNECTIONS = 0


class NegotiateResources_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("phContext", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("resourceType", 0, RESOURCE_TYPE),
        NDRIntField("dwcRequested", 0),
        NDRIntField("pdwcAccepted", 0),
    ]


class NegotiateResources_Response(NDRPacket):
    fields_desc = [NDRIntField("pdwcAccepted", 0), NDRIntField("status", 0)]


class SendReceive_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("phContext", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwcMessages", 0),
        NDRIntField("dwcbSizeOfBoxCar", None, size_of="rguchBoxCar"),
        NDRConfStrLenField("rguchBoxCar", "", size_is=lambda pkt: pkt.dwcbSizeOfBoxCar),
    ]


class SendReceive_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class TEARDOWN_TYPE(IntEnum):
    TT_FORCE = 0
    TT_PROBLEM = 2


class TearDownContext_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("contextHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("sRank", 0, SESSION_RANK),
        NDRInt3264EnumField("tearDownType", 0, TEARDOWN_TYPE),
    ]


class TearDownContext_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("contextHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class BeginTearDown_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("contextHandle", NDRContextHandle(), NDRContextHandle),
        NDRInt3264EnumField("tearDownType", 0, TEARDOWN_TYPE),
    ]


class BeginTearDown_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class PokeW_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("sRank", 0, SESSION_RANK),
        NDRConfVarStrLenFieldUtf16(
            "pwszCalleeUuid", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRConfVarStrLenFieldUtf16(
            "pwszHostName", "", size_is=lambda pkt: (pkt.MAX_COMPUTERNAME_LENGTH + 1)
        ),
        NDRConfVarStrLenFieldUtf16(
            "pwszUuidString", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRIntField("dwcbSizeOfBlob", None, size_of="rguchBlob"),
        NDRConfStrLenField("rguchBlob", "", size_is=lambda pkt: pkt.dwcbSizeOfBlob),
    ]


class PokeW_Response(NDRPacket):
    fields_desc = [NDRIntField("status", 0)]


class BuildContextW_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("sRank", 0, SESSION_RANK),
        NDRPacketField("BindVersionSet", BIND_VERSION_SET(), BIND_VERSION_SET),
        NDRConfVarStrLenFieldUtf16(
            "pwszCalleeUuid", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRConfVarStrLenFieldUtf16(
            "pwszHostName", "", size_is=lambda pkt: (pkt.MAX_COMPUTERNAME_LENGTH + 1)
        ),
        NDRConfVarStrLenFieldUtf16(
            "pwszUuidString", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRConfVarStrLenFieldUtf16(
            "pwszGuidIn", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRConfVarStrLenFieldUtf16(
            "pwszGuidOut", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRPacketField("pBoundVersionSet", BOUND_VERSION_SET(), BOUND_VERSION_SET),
        NDRIntField("dwcbSizeOfBlob", None, size_of="rguchBlob"),
        NDRConfStrLenField("rguchBlob", "", size_is=lambda pkt: pkt.dwcbSizeOfBlob),
    ]


class BuildContextW_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenFieldUtf16(
            "pwszGuidOut", "", size_is=lambda pkt: pkt.GUID_LENGTH
        ),
        NDRPacketField("pBoundVersionSet", BOUND_VERSION_SET(), BOUND_VERSION_SET),
        NDRPacketField("ppHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


IXNREMOTE_OPNUMS = {
    0: DceRpcOp(Poke_Request, Poke_Response),
    1: DceRpcOp(BuildContext_Request, BuildContext_Response),
    2: DceRpcOp(NegotiateResources_Request, NegotiateResources_Response),
    3: DceRpcOp(SendReceive_Request, SendReceive_Response),
    4: DceRpcOp(TearDownContext_Request, TearDownContext_Response),
    5: DceRpcOp(BeginTearDown_Request, BeginTearDown_Response),
    6: DceRpcOp(PokeW_Request, PokeW_Response),
    7: DceRpcOp(BuildContextW_Request, BuildContextW_Response),
}
register_dcerpc_interface(
    name="IXnRemote",
    uuid=uuid.UUID("906B0CE0-C70B-1067-B317-00DD010662DA"),
    version="1.0",
    opnums=IXNREMOTE_OPNUMS,
)
