### ms-mqqp.idl
"""
RPC definitions for the following interfaces:
- qm2qm (v1.0): 1088a980-eae5-11d0-8d9b-00a02453c337
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid

from scapy.fields import StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfVarStrLenField,
    NDRContextHandle,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    register_dcerpc_interface,
)


class REMOTEREADACK(IntEnum):
    RR_UNKNOWN = 1
    RR_NACK = 2
    RR_ACK = 3


class REMOTEREADDESC(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("hRemoteQueue", 0),
        NDRIntField("hCursor", 0),
        NDRIntField("ulAction", 0),
        NDRIntField("ulTimeout", 0),
        NDRIntField("dwSize", None, size_of="lpBuffer"),
        NDRIntField("dwQueue", 0),
        NDRIntField("dwRequestID", 0),
        NDRIntField("Reserved", 0),
        NDRIntField("dwArriveTime", 0),
        NDRInt3264EnumField("eAckNack", 0, REMOTEREADACK),
        NDRFullPointerField(
            NDRConfVarStrLenField(
                "lpBuffer",
                "",
                size_is=lambda pkt: pkt.dwSize,
                length_is=lambda pkt: pkt.dwSize,
            ),
            deferred=True,
        ),
    ]


class RemoteQMStartReceive_Request(NDRPacket):
    fields_desc = [NDRPacketField("lpRemoteReadDesc", REMOTEREADDESC(), REMOTEREADDESC)]


class RemoteQMStartReceive_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pphContext", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("lpRemoteReadDesc", REMOTEREADDESC(), REMOTEREADDESC),
        NDRIntField("status", 0),
    ]


class RemoteQMEndReceive_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pphContext", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwAck", 0),
    ]


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


class GUID(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("Data1", 0),
        NDRShortField("Data2", 0),
        NDRShortField("Data3", 0),
        StrFixedLenField("Data4", "", length=8),
    ]


class RemoteQMOpenQueue_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pLicGuid", GUID(), GUID),
        NDRIntField("dwMQS", 0),
        NDRIntField("hQueue", 0),
        NDRIntField("pQueue", 0),
        NDRIntField("dwpContext", 0),
    ]


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


class RemoteQMCloseQueue_Request(NDRPacket):
    fields_desc = [NDRPacketField("pphContext", NDRContextHandle(), NDRContextHandle)]


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


class RemoteQMCloseCursor_Request(NDRPacket):
    fields_desc = [NDRIntField("hQueue", 0), NDRIntField("hCursor", 0)]


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


class RemoteQMCancelReceive_Request(NDRPacket):
    fields_desc = [
        NDRIntField("hQueue", 0),
        NDRIntField("pQueue", 0),
        NDRIntField("dwRequestID", 0),
    ]


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


class RemoteQMPurgeQueue_Request(NDRPacket):
    fields_desc = [NDRIntField("hQueue", 0)]


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


class RemoteQMGetQMQMServerPort_Request(NDRPacket):
    fields_desc = [NDRIntField("dwPortType", 0)]


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


class RemoteQmGetVersion_Request(NDRPacket):
    fields_desc = []


class RemoteQmGetVersion_Response(NDRPacket):
    fields_desc = [
        NDRByteField("pMajor", 0),
        NDRByteField("pMinor", 0),
        NDRShortField("pBuildNumber", 0),
        NDRIntField("status", 0),
    ]


class REMOTEREADDESC2(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pRemoteReadDesc", REMOTEREADDESC(), REMOTEREADDESC),
            deferred=True,
        ),
        NDRLongField("SequentialId", 0),
    ]


class RemoteQMStartReceive2_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("lpRemoteReadDesc2", REMOTEREADDESC2(), REMOTEREADDESC2)
    ]


class RemoteQMStartReceive2_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pphContext", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("lpRemoteReadDesc2", REMOTEREADDESC2(), REMOTEREADDESC2),
        NDRIntField("status", 0),
    ]


class RemoteQMStartReceiveByLookupId_Request(NDRPacket):
    fields_desc = [
        NDRLongField("LookupId", 0),
        NDRPacketField("lpRemoteReadDesc2", REMOTEREADDESC2(), REMOTEREADDESC2),
    ]


class RemoteQMStartReceiveByLookupId_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pphContext", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("lpRemoteReadDesc2", REMOTEREADDESC2(), REMOTEREADDESC2),
        NDRIntField("status", 0),
    ]


QM2QM_OPNUMS = {
    0: DceRpcOp(RemoteQMStartReceive_Request, RemoteQMStartReceive_Response),
    1: DceRpcOp(RemoteQMEndReceive_Request, RemoteQMEndReceive_Response),
    2: DceRpcOp(RemoteQMOpenQueue_Request, RemoteQMOpenQueue_Response),
    3: DceRpcOp(RemoteQMCloseQueue_Request, RemoteQMCloseQueue_Response),
    4: DceRpcOp(RemoteQMCloseCursor_Request, RemoteQMCloseCursor_Response),
    5: DceRpcOp(RemoteQMCancelReceive_Request, RemoteQMCancelReceive_Response),
    6: DceRpcOp(RemoteQMPurgeQueue_Request, RemoteQMPurgeQueue_Response),
    7: DceRpcOp(RemoteQMGetQMQMServerPort_Request, RemoteQMGetQMQMServerPort_Response),
    8: DceRpcOp(RemoteQmGetVersion_Request, RemoteQmGetVersion_Response),
    9: DceRpcOp(RemoteQMStartReceive2_Request, RemoteQMStartReceive2_Response),
    10: DceRpcOp(
        RemoteQMStartReceiveByLookupId_Request, RemoteQMStartReceiveByLookupId_Response
    ),
}
register_dcerpc_interface(
    name="qm2qm",
    uuid=uuid.UUID("1088a980-eae5-11d0-8d9b-00a02453c337"),
    version="1.0",
    opnums=QM2QM_OPNUMS,
)
