### ms-rai.idl
"""
RPC definitions for the following interfaces:
- IPCHCollection (v0.0): 833E4100-AFF7-4AC3-AAC2-9F24C1457BCE
- IPCHService (v0.0): None
- ISAFSession (v0.0): 833E41AA-AFF7-4AC3-AAC2-9F24C1457BCE
- IRASrv (v0.0): None
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,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRIntField,
    NDRPacketField,
    NDRRecursiveField,
    NDRRefEmbPointerField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    register_com_interface,
)


class MInterfacePointer(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["abData"]
    fields_desc = [
        NDRIntField("ulCntData", None, size_of="abData"),
        NDRConfStrLenField(
            "abData", "", size_is=lambda pkt: pkt.ulCntData, conformant_in_struct=True
        ),
    ]


class get__NewEnum_Request(NDRPacket):
    fields_desc = []


class get__NewEnum_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pVal", MInterfacePointer(), MInterfacePointer)
        ),
        NDRIntField("status", 0),
    ]


class VARENUM(IntEnum):
    VT_EMPTY = 0
    VT_NULL = 1
    VT_I2 = 2
    VT_I4 = 3
    VT_R4 = 4
    VT_R8 = 5
    VT_CY = 6
    VT_DATE = 7
    VT_BSTR = 8
    VT_DISPATCH = 9
    VT_ERROR = 10
    VT_BOOL = 11
    VT_VARIANT = 12
    VT_UNKNOWN = 13
    VT_DECIMAL = 14
    VT_I1 = 16
    VT_UI1 = 17
    VT_UI2 = 18
    VT_UI4 = 19
    VT_I8 = 20
    VT_UI8 = 21
    VT_INT = 22
    VT_UINT = 23
    VT_VOID = 24
    VT_HRESULT = 25
    VT_PTR = 26
    VT_SAFEARRAY = 27
    VT_CARRAY = 28
    VT_USERDEFINED = 29
    VT_LPSTR = 30
    VT_LPWSTR = 31
    VT_RECORD = 36
    VT_INT_PTR = 37
    VT_UINT_PTR = 38
    VT_ARRAY = 8192
    VT_BYREF = 16384


class CURRENCY(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRSignedLongField("int64", 0)]


class FLAGGED_WORD_BLOB(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["asData"]
    fields_desc = [
        NDRIntField("cBytes", 0),
        NDRIntField("clSize", None, size_of="asData"),
        NDRConfStrLenFieldUtf16(
            "asData", "", size_is=lambda pkt: pkt.clSize, conformant_in_struct=True
        ),
    ]


class VARENUM(IntEnum):
    VT_EMPTY = 0
    VT_NULL = 1
    VT_I2 = 2
    VT_I4 = 3
    VT_R4 = 4
    VT_R8 = 5
    VT_CY = 6
    VT_DATE = 7
    VT_BSTR = 8
    VT_DISPATCH = 9
    VT_ERROR = 10
    VT_BOOL = 11
    VT_VARIANT = 12
    VT_UNKNOWN = 13
    VT_DECIMAL = 14
    VT_I1 = 16
    VT_UI1 = 17
    VT_UI2 = 18
    VT_UI4 = 19
    VT_I8 = 20
    VT_UI8 = 21
    VT_INT = 22
    VT_UINT = 23
    VT_VOID = 24
    VT_HRESULT = 25
    VT_PTR = 26
    VT_SAFEARRAY = 27
    VT_CARRAY = 28
    VT_USERDEFINED = 29
    VT_LPSTR = 30
    VT_LPWSTR = 31
    VT_RECORD = 36
    VT_INT_PTR = 37
    VT_UINT_PTR = 38
    VT_ARRAY = 8192
    VT_BYREF = 16384


class SF_TYPE(IntEnum):
    SF_ERROR = VARENUM.VT_ERROR
    SF_I1 = VARENUM.VT_I1
    SF_I2 = VARENUM.VT_I2
    SF_I4 = VARENUM.VT_I4
    SF_I8 = VARENUM.VT_I8
    SF_BSTR = VARENUM.VT_BSTR
    SF_UNKNOWN = VARENUM.VT_UNKNOWN
    SF_DISPATCH = VARENUM.VT_DISPATCH
    SF_VARIANT = VARENUM.VT_VARIANT
    SF_RECORD = VARENUM.VT_RECORD
    SF_HAVEIID = VARENUM.VT_UNKNOWN | 32768


class SAFEARR_BSTR(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="aBstr"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "aBstr", [], FLAGGED_WORD_BLOB, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class SAFEARR_UNKNOWN(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="apUnknown"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "apUnknown", [], MInterfacePointer, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class SAFEARR_DISPATCH(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Size", None, size_of="apDispatch"),
        NDRRefEmbPointerField(
            NDRConfPacketListField(
                "apDispatch", [], MInterfacePointer, size_is=lambda pkt: pkt.Size
            ),
            deferred=True,
        ),
    ]


class wireVARIANTStr(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("clSize", 0),
        NDRIntField("rpcReserved", 0),
        NDRShortField("vt", 0),
        NDRShortField("wReserved1", 0),
        NDRShortField("wReserved2", 0),
        NDRShortField("wReserved3", 0),
        NDRRecursiveField("_varUnion"),
    ]


class get_Item_Request(NDRPacket):
    fields_desc = [NDRSignedIntField("vIndex", 0)]


class get_Item_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("ppEntry", wireVARIANTStr(), wireVARIANTStr)
        ),
        NDRIntField("status", 0),
    ]


class get_Count_Request(NDRPacket):
    fields_desc = []


class get_Count_Response(NDRPacket):
    fields_desc = [NDRSignedIntField("pVal", 0), NDRIntField("status", 0)]


IPCHCOLLECTION_OPNUMS = {
    0: DceRpcOp(get__NewEnum_Request, get__NewEnum_Response),
    1: DceRpcOp(get_Item_Request, get_Item_Response),
    2: DceRpcOp(get_Count_Request, get_Count_Response),
}
register_com_interface(
    name="IPCHCollection",
    uuid=uuid.UUID("833E4100-AFF7-4AC3-AAC2-9F24C1457BCE"),
    opnums=IPCHCOLLECTION_OPNUMS,
)


class get_SessionID_Request(NDRPacket):
    fields_desc = []


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


class put_SessionID_Request(NDRPacket):
    fields_desc = [NDRIntField("pVal", 0)]


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


class SessionStateEnum(IntEnum):
    pchActive = 0
    pchConnected = 1
    pchConnectQuery = 2
    pchShadow = 3
    pchDisconnected = 4
    pchIdle = 5
    pchListen = 6
    pchReset = 7
    pchDown = 8
    pchInit = 9
    pchStateInvalid = 10


class get_SessionState_Request(NDRPacket):
    fields_desc = []


class get_SessionState_Response(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("pVal", 0, SessionStateEnum),
        NDRIntField("status", 0),
    ]


class put_SessionState_Request(NDRPacket):
    fields_desc = [NDRInt3264EnumField("pVal", 0, SessionStateEnum)]


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


class get_DomainName_Request(NDRPacket):
    fields_desc = []


class get_DomainName_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pVal", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class put_DomainName_Request(NDRPacket):
    fields_desc = [NDRPacketField("pVal", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)]


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


class get_UserName_Request(NDRPacket):
    fields_desc = []


class get_UserName_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pVal", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class put_UserName_Request(NDRPacket):
    fields_desc = [NDRPacketField("pVal", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)]


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


ISAFSESSION_OPNUMS = {
    0: DceRpcOp(get_SessionID_Request, get_SessionID_Response),
    1: DceRpcOp(put_SessionID_Request, put_SessionID_Response),
    2: DceRpcOp(get_SessionState_Request, get_SessionState_Response),
    3: DceRpcOp(put_SessionState_Request, put_SessionState_Response),
    4: DceRpcOp(get_DomainName_Request, get_DomainName_Response),
    5: DceRpcOp(put_DomainName_Request, put_DomainName_Response),
    6: DceRpcOp(get_UserName_Request, get_UserName_Response),
    7: DceRpcOp(put_UserName_Request, put_UserName_Response),
}
register_com_interface(
    name="ISAFSession",
    uuid=uuid.UUID("833E41AA-AFF7-4AC3-AAC2-9F24C1457BCE"),
    opnums=ISAFSESSION_OPNUMS,
)
