### ms-fsrvp.idl
"""
RPC definitions for the following interfaces:
- FileServerVssAgent (v1.0): A8E0653C-2744-4389-A61D-7373DF8B2292
This file is auto-generated by midl-to-scapy, do not modify.
"""

import uuid

from scapy.fields import StrFixedLenField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    NDRUnionField,
    register_dcerpc_interface,
)


class GetSupportedVersion_Request(NDRPacket):
    fields_desc = []


class GetSupportedVersion_Response(NDRPacket):
    fields_desc = [
        NDRIntField("MinVersion", 0),
        NDRIntField("MaxVersion", 0),
        NDRIntField("status", 0),
    ]


class SetContext_Request(NDRPacket):
    fields_desc = [NDRIntField("Context", 0)]


class SetContext_Response(NDRPacket):
    fields_desc = [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 StartShadowCopySet_Request(NDRPacket):
    fields_desc = [NDRPacketField("ClientShadowCopySetId", GUID(), GUID)]


class StartShadowCopySet_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pShadowCopySetId", GUID(), GUID),
        NDRIntField("status", 0),
    ]


class AddToShadowCopySet_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ClientShadowCopyId", GUID(), GUID),
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRConfVarStrNullFieldUtf16("ShareName", ""),
    ]


class AddToShadowCopySet_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pShadowCopyId", GUID(), GUID),
        NDRIntField("status", 0),
    ]


class CommitShadowCopySet_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRIntField("TimeOutInMilliseconds", 0),
    ]


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


class ExposeShadowCopySet_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRIntField("TimeOutInMilliseconds", 0),
    ]


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


class RecoveryCompleteShadowCopySet_Request(NDRPacket):
    fields_desc = [NDRPacketField("ShadowCopySetId", GUID(), GUID)]


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


class AbortShadowCopySet_Request(NDRPacket):
    fields_desc = [NDRPacketField("ShadowCopySetId", GUID(), GUID)]


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


class IsPathSupported_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("ShareName", "")]


class IsPathSupported_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("SupportedByThisProvider", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("OwnerMachineName", "")),
        NDRIntField("status", 0),
    ]


class IsPathShadowCopied_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("ShareName", "")]


class IsPathShadowCopied_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("ShadowCopyPresent", 0),
        NDRSignedIntField("ShadowCopyCompatibility", 0),
        NDRIntField("status", 0),
    ]


class PFSSAGENT_SHARE_MAPPING_1(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRPacketField("ShadowCopyId", GUID(), GUID),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ShareNameUNC", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ShadowCopyShareName", ""), deferred=True
        ),
        NDRSignedLongField("CreationTimestamp", 0),
    ]


class GetShareMapping_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ShadowCopyId", GUID(), GUID),
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRConfVarStrNullFieldUtf16("ShareName", ""),
        NDRIntField("Level", 0),
    ]


class GetShareMapping_Response(NDRPacket):
    fields_desc = [
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "ShareMapping",
                            PFSSAGENT_SHARE_MAPPING_1(),
                            PFSSAGENT_SHARE_MAPPING_1,
                        )
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                )
            ],
            StrFixedLenField("ShareMapping", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
        NDRIntField("status", 0),
    ]


class DeleteShareMapping_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRPacketField("ShadowCopyId", GUID(), GUID),
        NDRConfVarStrNullFieldUtf16("ShareName", ""),
    ]


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


class PrepareShadowCopySet_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ShadowCopySetId", GUID(), GUID),
        NDRIntField("TimeOutInMilliseconds", 0),
    ]


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


FILESERVERVSSAGENT_OPNUMS = {
    0: DceRpcOp(GetSupportedVersion_Request, GetSupportedVersion_Response),
    1: DceRpcOp(SetContext_Request, SetContext_Response),
    2: DceRpcOp(StartShadowCopySet_Request, StartShadowCopySet_Response),
    3: DceRpcOp(AddToShadowCopySet_Request, AddToShadowCopySet_Response),
    4: DceRpcOp(CommitShadowCopySet_Request, CommitShadowCopySet_Response),
    5: DceRpcOp(ExposeShadowCopySet_Request, ExposeShadowCopySet_Response),
    6: DceRpcOp(
        RecoveryCompleteShadowCopySet_Request, RecoveryCompleteShadowCopySet_Response
    ),
    7: DceRpcOp(AbortShadowCopySet_Request, AbortShadowCopySet_Response),
    8: DceRpcOp(IsPathSupported_Request, IsPathSupported_Response),
    9: DceRpcOp(IsPathShadowCopied_Request, IsPathShadowCopied_Response),
    10: DceRpcOp(GetShareMapping_Request, GetShareMapping_Response),
    11: DceRpcOp(DeleteShareMapping_Request, DeleteShareMapping_Response),
    12: DceRpcOp(PrepareShadowCopySet_Request, PrepareShadowCopySet_Response),
}
register_dcerpc_interface(
    name="FileServerVssAgent",
    uuid=uuid.UUID("A8E0653C-2744-4389-A61D-7373DF8B2292"),
    version="1.0",
    opnums=FILESERVERVSSAGENT_OPNUMS,
)
