# SPDX-License-Identifier: GPL-2.0-only
# This file is part of Scapy RPC
# See https://scapy.net/ for more information
# Copyright (C) Gabriel Potter

# [ms-csvp] v34.0 (Fri, 21 Nov 2025)

"""
RPC definitions for the following interfaces:
- IClusterStorage2 (v0.0): None
- IUnknown (v0.0): 00000000-0000-0000-C000-000000000046
- 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
- IClusterLogEx2 (v0.0): 2510EA7D-C355-40C9-852C-E3B1B1338D67
- IClusterLogEx3 (v0.0): E6D3C166-560F-4B58-B31A-FDEA05FB606F
- 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,
    NDRConfFieldListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullEmbPointerField,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedByteField,
    NDRSignedIntField,
    NDRUnionField,
    register_com_interface,
)

IUNKNOWN_OPNUMS = {  # 0: Opnum0NotUsedOnWire,
    # 1: Opnum1NotUsedOnWire,
    # 2: Opnum2NotUsedOnWire
}
register_com_interface(
    name="IUnknown",
    uuid=uuid.UUID("00000000-0000-0000-C000-000000000046"),
    opnums=IUNKNOWN_OPNUMS,
)


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("DiskId", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdSignature
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdSignature),
                    ),
                ),
                (
                    NDRPacketField("DiskId", GUID(), GUID),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdGuid
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdGuid),
                    ),
                ),
                (
                    NDRIntField("DiskId", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdNumber
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdNumber),
                    ),
                ),
                (
                    NDRIntField("DiskId", 0),
                    (
                        (
                            lambda pkt: getattr(pkt, "DiskIdType", None)
                            == CPREP_DISKID_ENUM.CprepIdUnknown
                        ),
                        (lambda _, val: val.tag == CPREP_DISKID_ENUM.CprepIdUnknown),
                    ),
                ),
            ],
            StrFixedLenField("DiskId", "", 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 = [
        NDRConfFieldListField(
            "ppbDeviceIdHeader",
            [],
            NDRFullPointerField(NDRSignedByteField("", 0)),
            size_is=lambda pkt: pkt.pcbDihSize,
        ),
        NDRIntField("pcbDihSize", None, size_of="ppbDeviceIdHeader"),
        NDRConfFieldListField(
            "ppDeviceDescriptor",
            [],
            NDRFullPointerField(NDRSignedByteField("", 0)),
            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 = [
        NDRConfFieldListField(
            "ppwszSharePaths",
            [],
            NDRFullPointerField(
                NDRFullPointerField(NDRConfVarStrNullFieldUtf16("", ""))
            ),
            size_is=lambda pkt: pkt.pdwNumberOfPaths,
        ),
        NDRIntField("pdwNumberOfPaths", None, size_of="ppwszSharePaths"),
        NDRIntField("status", 0),
    ]


class CprepConnectToNewSmbShares3_Request(NDRPacket):
    fields_desc = [
        NDRConfFieldListField(
            "ppwszSharePaths",
            [],
            NDRFullPointerField(NDRConfVarStrNullFieldUtf16("", "")),
            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),
        NDRFullEmbPointerField(NDRConfVarStrNullFieldUtf16("pwszFriendlyName", "")),
        NDRIntField("NumPaths", 0),
        NDRIntField("Flags", 0),
        NDRIntField("ExtendedFlags", 0),
        NDRFullEmbPointerField(NDRConfVarStrNullFieldUtf16("pwszPoolName", "")),
        NDRFullEmbPointerField(NDRConfVarStrNullFieldUtf16("pwszPage83Id", "")),
        NDRFullEmbPointerField(NDRConfVarStrNullFieldUtf16("pwszSerialNumber", "")),
        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: Opnum0NotUsedOnWire,
    # 1: Opnum1NotUsedOnWire,
    # 2: Opnum2NotUsedOnWire,
    3: DceRpcOp(CprepDiskGetUniqueIds3_Request, CprepDiskGetUniqueIds3_Response),
    4: DceRpcOp(CprepCheckNetFtBindings3_Request, CprepCheckNetFtBindings3_Response),
    5: DceRpcOp(CprepCsvTestSetup3_Request, CprepCsvTestSetup3_Response),
    6: DceRpcOp(CprepIsNodeClustered3_Request, CprepIsNodeClustered3_Response),
    7: DceRpcOp(CprepCreateNewSmbShares3_Request, CprepCreateNewSmbShares3_Response),
    8: DceRpcOp(
        CprepConnectToNewSmbShares3_Request, CprepConnectToNewSmbShares3_Response
    ),
    9: DceRpcOp(CprepDiskGetProps3_Request, CprepDiskGetProps3_Response),
    10: DceRpcOp(CprepDiskIsReadOnly3_Request, CprepDiskIsReadOnly3_Response),
    11: DceRpcOp(CprepDiskPRRegister3_Request, CprepDiskPRRegister3_Response),
    12: DceRpcOp(CprepDiskFindKey3_Request, CprepDiskFindKey3_Response),
    13: DceRpcOp(CprepDiskPRPreempt3_Request, CprepDiskPRPreempt3_Response),
    14: DceRpcOp(CprepDiskPRReserve3_Request, CprepDiskPRReserve3_Response),
    15: DceRpcOp(CprepDiskIsPRPresent3_Request, CprepDiskIsPRPresent3_Response),
    16: DceRpcOp(CprepDiskPRRelease3_Request, CprepDiskPRRelease3_Response),
    17: 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, 4)
    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(
            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(
            NDRFullPointerField(
                NDRPacketField("LogFilePath", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
            )
        ),
        NDRIntField("status", 0),
    ]


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


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


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


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


class ExportClusterPerformanceHistory_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("Pattern", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRFullPointerField(
            NDRPacketField("StreamName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRInt3264EnumField("flags", 0, ClusterLogExFlag),
    ]


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


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


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


ICLUSTERLOGEX_OPNUMS = {  # 0: Opnum0NotUsedOnWire,
    # 1: Opnum1NotUsedOnWire,
    # 2: Opnum2NotUsedOnWire,
    3: DceRpcOp(GenerateClusterLog_Request, GenerateClusterLog_Response),
    4: DceRpcOp(GenerateClusterHealthLog_Request, GenerateClusterHealthLog_Response),
    5: DceRpcOp(GenerateClusterSetLog_Request, GenerateClusterSetLog_Response),
    6: DceRpcOp(
        GenerateClusterNetworkhLog_Request, GenerateClusterNetworkhLog_Response
    ),
    7: DceRpcOp(
        ExportClusterPerformanceHistory_Request,
        ExportClusterPerformanceHistory_Response,
    ),
    8: DceRpcOp(GenerateNetftLog_Request, GenerateNetftLog_Response),
}
register_com_interface(
    name="IClusterLogEx",
    uuid=uuid.UUID("BD7C23C2-C805-457C-8F86-D17FE6B9D19F"),
    opnums=ICLUSTERLOGEX_OPNUMS,
)


class ClusterLogType(IntEnum):
    ClusterLogTypeCluster = 0
    ClusterLogTypeHealth = 1
    ClusterLogTypeClusterSet = 2
    ClusterLogTypeNetwork = 3
    ClusterLogTypeNetft = 4


class GenerateLogEx_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("Type", 0, ClusterLogType),
        NDRIntField("SpanMinutes", 0),
        NDRInt3264EnumField("flags", 0, ClusterLogExFlag),
        NDRSignedIntField("NoCollate", 0),
    ]


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


class GetCountLogs_Request(NDRPacket):
    fields_desc = []


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


class GetLogFilePath_Request(NDRPacket):
    fields_desc = [NDRIntField("Index", 0)]


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


ICLUSTERLOGEX2_OPNUMS = {  # 0: Opnum0NotUsedOnWire,
    # 1: Opnum1NotUsedOnWire,
    # 2: Opnum2NotUsedOnWire,
    3: DceRpcOp(GenerateClusterLog_Request, GenerateClusterLog_Response),
    4: DceRpcOp(GenerateClusterHealthLog_Request, GenerateClusterHealthLog_Response),
    5: DceRpcOp(GenerateClusterSetLog_Request, GenerateClusterSetLog_Response),
    6: DceRpcOp(
        GenerateClusterNetworkhLog_Request, GenerateClusterNetworkhLog_Response
    ),
    7: DceRpcOp(
        ExportClusterPerformanceHistory_Request,
        ExportClusterPerformanceHistory_Response,
    ),
    8: DceRpcOp(GenerateNetftLog_Request, GenerateNetftLog_Response),
    9: DceRpcOp(GenerateLogEx_Request, GenerateLogEx_Response),
    10: DceRpcOp(GetCountLogs_Request, GetCountLogs_Response),
    11: DceRpcOp(GetLogFilePath_Request, GetLogFilePath_Response),
}
register_com_interface(
    name="IClusterLogEx2",
    uuid=uuid.UUID("2510EA7D-C355-40C9-852C-E3B1B1338D67"),
    opnums=ICLUSTERLOGEX2_OPNUMS,
)


class GenerateLogEx2_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("Type", 0, ClusterLogType),
        NDRIntField("SpanMinutes", 0),
        NDRInt3264EnumField("flags", 0, ClusterLogExFlag),
        NDRSignedIntField("NoCollate", 0),
    ]


class GenerateLogEx2_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("LongFilePath", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
            )
        ),
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField(
                    "SemicolonSeperatedLogFilesPath",
                    FLAGGED_WORD_BLOB(),
                    FLAGGED_WORD_BLOB,
                )
            )
        ),
        NDRIntField("status", 0),
    ]


ICLUSTERLOGEX3_OPNUMS = {  # 0: Opnum0NotUsedOnWire,
    # 1: Opnum1NotUsedOnWire,
    # 2: Opnum2NotUsedOnWire,
    3: DceRpcOp(GenerateClusterLog_Request, GenerateClusterLog_Response),
    4: DceRpcOp(GenerateClusterHealthLog_Request, GenerateClusterHealthLog_Response),
    5: DceRpcOp(GenerateClusterSetLog_Request, GenerateClusterSetLog_Response),
    6: DceRpcOp(
        GenerateClusterNetworkhLog_Request, GenerateClusterNetworkhLog_Response
    ),
    7: DceRpcOp(
        ExportClusterPerformanceHistory_Request,
        ExportClusterPerformanceHistory_Response,
    ),
    8: DceRpcOp(GenerateNetftLog_Request, GenerateNetftLog_Response),
    9: DceRpcOp(GenerateLogEx_Request, GenerateLogEx_Response),
    10: DceRpcOp(GetCountLogs_Request, GetCountLogs_Response),
    11: DceRpcOp(GetLogFilePath_Request, GetLogFilePath_Response),
    12: DceRpcOp(GenerateLogEx2_Request, GenerateLogEx2_Response),
}
register_com_interface(
    name="IClusterLogEx3",
    uuid=uuid.UUID("E6D3C166-560F-4B58-B31A-FDEA05FB606F"),
    opnums=ICLUSTERLOGEX3_OPNUMS,
)
