### ms-csvp.idl
"""
RPC definitions for the following interfaces:
- IClusterStorage2 (v0.0): None
- IClusterStorage3 (v0.0): 11942D87-A1DE-4E7F-83FB-A840D9C5928D
- IClusterNetwork2 (v0.0): None
- IClusterCleanup (v0.0): None
- IClusterSetup (v0.0): None
- IClusterLog (v0.0): None
- IClusterLogEx (v0.0): BD7C23C2-C805-457C-8F86-D17FE6B9D19F
- IClusterFirewall (v0.0): None
- IClusterUpdate (v0.0): None
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid

from scapy.fields import StrFixedLenField, StrFixedLenFieldUtf16
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarStrLenField,
    NDRConfVarStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedByteField,
    NDRSignedIntField,
    NDRUnionField,
    register_com_interface,
)


class CPREP_DISKID_ENUM(IntEnum):
    CprepIdSignature = 0
    CprepIdGuid = 1
    CprepIdNumber = 4000
    CprepIdUnknown = 5000


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


class CPREP_DISKID(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRInt3264EnumField("DiskIdType", 0, CPREP_DISKID_ENUM),
        NDRUnionField(
            [
                (
                    NDRIntField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdSignature
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdSignature),
                    ),
                ),
                (
                    NDRPacketField("value", GUID(), GUID),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdGuid
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdGuid),
                    ),
                ),
                (
                    NDRIntField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdNumber
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdNumber),
                    ),
                ),
                (
                    NDRIntField("value", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdUnknown
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdUnknown),
                    ),
                ),
            ],
            StrFixedLenField("value", "", length=0),
            align=(2, 4),
            switch_fmt=("H", "I"),
        ),
    ]


class CprepDiskGetUniqueIds3_Request(NDRPacket):
    fields_desc = [NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID)]


class CprepDiskGetUniqueIds3_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("ppbDeviceIdHeader", "", size_is=lambda pkt: pkt.pcbDihSize),
        NDRIntField("pcbDihSize", None, size_of="ppbDeviceIdHeader"),
        NDRConfStrLenField("ppDeviceDescriptor", "", size_is=lambda pkt: pkt.pcbDdSize),
        NDRIntField("pcbDdSize", None, size_of="ppDeviceDescriptor"),
        NDRIntField("status", 0),
    ]


class CprepCheckNetFtBindings3_Request(NDRPacket):
    fields_desc = []


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


class CprepCsvTestSetup3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("TestShareGuid", GUID(), GUID),
        NDRConfVarStrNullFieldUtf16("Reserved", ""),
    ]


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


class CprepIsNodeClustered3_Request(NDRPacket):
    fields_desc = []


class CprepIsNodeClustered3_Response(NDRPacket):
    fields_desc = [NDRSignedByteField("pbIsClusterNode", 0), NDRIntField("status", 0)]


class CprepCreateNewSmbShares3_Request(NDRPacket):
    fields_desc = []


class CprepCreateNewSmbShares3_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenFieldUtf16(
            "ppwszSharePaths", "", size_is=lambda pkt: pkt.pdwNumberOfPaths
        ),
        NDRIntField("pdwNumberOfPaths", None, size_of="ppwszSharePaths"),
        NDRIntField("status", 0),
    ]


class CprepConnectToNewSmbShares3_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenFieldUtf16(
            "ppwszSharePaths", "", size_is=lambda pkt: pkt.dwNumberOfPaths
        ),
        NDRIntField("dwNumberOfPaths", None, size_of="ppwszSharePaths"),
    ]


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


class DiskStackType(IntEnum):
    DiskStackScsiPort = 0
    DiskStackStorPort = 1
    DiskStackFullPort = 2


class CPREP_SCSI_ADDRESS(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("Length", 0),
        NDRByteField("PortNumber", 0),
        NDRByteField("PathId", 0),
        NDRByteField("TargetId", 0),
        NDRByteField("Lun", 0),
    ]


class DISK_PROPS_EX(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("DiskNumber", 0),
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRIntField("DiskBusType", 0),
        NDRInt3264EnumField("StackType", 0, DiskStackType),
        NDRPacketField("ScsiAddress", CPREP_SCSI_ADDRESS(), CPREP_SCSI_ADDRESS),
        NDRSignedIntField("DiskIsClusterable", 0),
        StrFixedLenFieldUtf16("AdapterDesc", "", length=260 * 2),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pwszFriendlyName", ""), deferred=True
        ),
        NDRIntField("NumPaths", 0),
        NDRIntField("Flags", 0),
        NDRIntField("ExtendedFlags", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pwszPoolName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pwszPage83Id", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("pwszSerialNumber", ""), deferred=True
        ),
        NDRPacketField("guidPoolId", GUID(), GUID),
    ]


class CprepDiskGetProps3_Request(NDRPacket):
    fields_desc = [NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID)]


class CprepDiskGetProps3_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pDiskProps", DISK_PROPS_EX(), DISK_PROPS_EX),
        NDRIntField("status", 0),
    ]


class CprepDiskIsReadOnly3_Request(NDRPacket):
    fields_desc = [NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID)]


class CprepDiskIsReadOnly3_Response(NDRPacket):
    fields_desc = [NDRSignedByteField("pbReadOnly", 0), NDRIntField("status", 0)]


class CprepDiskPRRegister3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("OldPrKey", 0),
        NDRLongField("NewPrKey", 0),
    ]


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


class CprepDiskFindKey3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("Key", 0),
    ]


class CprepDiskFindKey3_Response(NDRPacket):
    fields_desc = [NDRSignedByteField("pbFound", 0), NDRIntField("status", 0)]


class CprepDiskPRPreempt3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("OwnerKey", 0),
        NDRLongField("NewKey", 0),
    ]


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


class CprepDiskPRReserve3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("Key", 0),
    ]


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


class CprepDiskIsPRPresent3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("Key", 0),
    ]


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


class CprepDiskPRRelease3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("Key", 0),
    ]


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


class CprepDiskPRClear3_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("DiskId", CPREP_DISKID(), CPREP_DISKID),
        NDRLongField("Key", 0),
    ]


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


ICLUSTERSTORAGE3_OPNUMS = {
    0: DceRpcOp(CprepDiskGetUniqueIds3_Request, CprepDiskGetUniqueIds3_Response),
    1: DceRpcOp(CprepCheckNetFtBindings3_Request, CprepCheckNetFtBindings3_Response),
    2: DceRpcOp(CprepCsvTestSetup3_Request, CprepCsvTestSetup3_Response),
    3: DceRpcOp(CprepIsNodeClustered3_Request, CprepIsNodeClustered3_Response),
    4: DceRpcOp(CprepCreateNewSmbShares3_Request, CprepCreateNewSmbShares3_Response),
    5: DceRpcOp(
        CprepConnectToNewSmbShares3_Request, CprepConnectToNewSmbShares3_Response
    ),
    6: DceRpcOp(CprepDiskGetProps3_Request, CprepDiskGetProps3_Response),
    7: DceRpcOp(CprepDiskIsReadOnly3_Request, CprepDiskIsReadOnly3_Response),
    8: DceRpcOp(CprepDiskPRRegister3_Request, CprepDiskPRRegister3_Response),
    9: DceRpcOp(CprepDiskFindKey3_Request, CprepDiskFindKey3_Response),
    10: DceRpcOp(CprepDiskPRPreempt3_Request, CprepDiskPRPreempt3_Response),
    11: DceRpcOp(CprepDiskPRReserve3_Request, CprepDiskPRReserve3_Response),
    12: DceRpcOp(CprepDiskIsPRPresent3_Request, CprepDiskIsPRPresent3_Response),
    13: DceRpcOp(CprepDiskPRRelease3_Request, CprepDiskPRRelease3_Response),
    14: DceRpcOp(CprepDiskPRClear3_Request, CprepDiskPRClear3_Response),
}
register_com_interface(
    name="IClusterStorage3",
    uuid=uuid.UUID("11942D87-A1DE-4E7F-83FB-A840D9C5928D"),
    opnums=ICLUSTERSTORAGE3_OPNUMS,
)


class ClusterLogExFlag(IntEnum):
    ClusterLogFlagNone = 0
    ClusterLogFlagLocalTime = 1
    ClusterLogFlagSkipClusterState = 2


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 GenerateClusterLog_Request(NDRPacket):
    fields_desc = [
        NDRIntField("SpanMinutes", 0),
        NDRInt3264EnumField("flags", 0, ClusterLogExFlag),
    ]


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


class GenerateClusterHealthLog_Request(NDRPacket):
    fields_desc = [
        NDRIntField("SpanMinutes", 0),
        NDRInt3264EnumField("flags", 0, ClusterLogExFlag),
    ]


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


ICLUSTERLOGEX_OPNUMS = {
    0: DceRpcOp(GenerateClusterLog_Request, GenerateClusterLog_Response),
    1: DceRpcOp(GenerateClusterHealthLog_Request, GenerateClusterHealthLog_Response),
}
register_com_interface(
    name="IClusterLogEx",
    uuid=uuid.UUID("BD7C23C2-C805-457C-8F86-D17FE6B9D19F"),
    opnums=ICLUSTERLOGEX_OPNUMS,
)
