### ms-dfsnm.idl
"""
RPC definitions for the following interfaces:
- netdfs (v3.0): 4fc742e0-4a10-11cf-8273-00aa004ae673
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,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRIntEnumField,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRUnionField,
    register_dcerpc_interface,
)


class NetrDfsManagerGetVersion_Request(NDRPacket):
    fields_desc = []


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


class NetrDfsAdd_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", "")),
        NDRIntField("Flags", 0),
    ]


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


class NetrDfsRemove_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
    ]


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


class DFS_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True)
    ]


class DFS_INFO_2(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("NumberOfStorages", 0),
    ]


class DFS_STORAGE_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("State", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ServerName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ShareName", ""), deferred=True
        ),
    ]


class DFS_INFO_3(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("NumberOfStorages", None, size_of="Storage"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Storage",
                [],
                DFS_STORAGE_INFO,
                size_is=lambda pkt: pkt.NumberOfStorages,
            ),
            deferred=True,
        ),
    ]


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


class DFS_INFO_4(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("NumberOfStorages", None, size_of="Storage"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Storage",
                [],
                DFS_STORAGE_INFO,
                size_is=lambda pkt: pkt.NumberOfStorages,
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_5(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("MetadataSize", 0),
        NDRIntField("NumberOfStorages", 0),
    ]


class DFS_TARGET_PRIORITY_CLASS(IntEnum):
    DfsInvalidPriorityClass = -1
    DfsSiteCostNormalPriorityClass = 0
    DfsGlobalHighPriorityClass = 1
    DfsSiteCostHighPriorityClass = 2
    DfsSiteCostLowPriorityClass = 3
    DfsGlobalLowPriorityClass = 4


class DFS_TARGET_PRIORITY(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntEnumField("TargetPriorityClass", 0, DFS_TARGET_PRIORITY_CLASS),
        NDRShortField("TargetPriorityRank", 0),
        NDRShortField("Reserved", 0),
    ]


class DFS_STORAGE_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("State", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ServerName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ShareName", ""), deferred=True
        ),
        NDRPacketField("TargetPriority", DFS_TARGET_PRIORITY(), DFS_TARGET_PRIORITY),
    ]


class DFS_INFO_6(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("MetadataSize", 0),
        NDRIntField("NumberOfStorages", None, size_of="Storage"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Storage",
                [],
                DFS_STORAGE_INFO_1,
                size_is=lambda pkt: pkt.NumberOfStorages,
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_7(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRPacketField("GenerationGuid", GUID(), GUID)]


class DFS_INFO_8(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("MetadataSize", 0),
        NDRIntField("SecurityDescriptorLength", None, size_of="pSecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor",
                "",
                size_is=lambda pkt: pkt.SecurityDescriptorLength,
            ),
            deferred=True,
        ),
        NDRIntField("NumberOfStorages", 0),
    ]


class LPDFS_STORAGE_INFO_1(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("State", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ServerName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ShareName", ""), deferred=True
        ),
        NDRPacketField("TargetPriority", DFS_TARGET_PRIORITY(), DFS_TARGET_PRIORITY),
    ]


class DFS_INFO_9(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("MetadataSize", 0),
        NDRIntField("SecurityDescriptorLength", None, size_of="pSecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor",
                "",
                size_is=lambda pkt: pkt.SecurityDescriptorLength,
            ),
            deferred=True,
        ),
        NDRIntField("NumberOfStorages", None, size_of="Storage"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Storage",
                [LPDFS_STORAGE_INFO_1()],
                LPDFS_STORAGE_INFO_1,
                size_is=lambda pkt: pkt.NumberOfStorages,
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_50(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("NamespaceMajorVersion", 0),
        NDRIntField("NamespaceMinorVersion", 0),
        NDRLongField("NamespaceCapabilities", 0),
    ]


class DFS_INFO_100(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True)
    ]


class DFS_INFO_101(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("State", 0)]


class DFS_INFO_102(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("Timeout", 0)]


class DFS_INFO_103(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("PropertyFlagMask", 0), NDRIntField("PropertyFlags", 0)]


class DFS_INFO_104(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("TargetPriority", DFS_TARGET_PRIORITY(), DFS_TARGET_PRIORITY)
    ]


class DFS_INFO_105(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRIntField("PropertyFlagMask", 0),
        NDRIntField("PropertyFlags", 0),
    ]


class DFS_INFO_106(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("State", 0),
        NDRPacketField("TargetPriority", DFS_TARGET_PRIORITY(), DFS_TARGET_PRIORITY),
    ]


class DFS_INFO_107(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRIntField("PropertyFlagMask", 0),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("SecurityDescriptorLength", None, size_of="pSecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor",
                "",
                size_is=lambda pkt: pkt.SecurityDescriptorLength,
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_150(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("SecurityDescriptorLength", None, size_of="pSecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor",
                "",
                size_is=lambda pkt: pkt.SecurityDescriptorLength,
            ),
            deferred=True,
        ),
    ]


class NetrDfsSetInfo_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_1(), DFS_INFO_1)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_2(), DFS_INFO_2)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_3(), DFS_INFO_3)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_4(), DFS_INFO_4)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_5(), DFS_INFO_5)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 5),
                        (lambda _, val: val.tag == 5),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_6(), DFS_INFO_6)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 6),
                        (lambda _, val: val.tag == 6),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_7(), DFS_INFO_7)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 7),
                        (lambda _, val: val.tag == 7),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_8(), DFS_INFO_8)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 8),
                        (lambda _, val: val.tag == 8),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_9(), DFS_INFO_9)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 9),
                        (lambda _, val: val.tag == 9),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_50(), DFS_INFO_50)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 50),
                        (lambda _, val: val.tag == 50),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_100(), DFS_INFO_100)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 100),
                        (lambda _, val: val.tag == 100),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_101(), DFS_INFO_101)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 101),
                        (lambda _, val: val.tag == 101),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_102(), DFS_INFO_102)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 102),
                        (lambda _, val: val.tag == 102),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_103(), DFS_INFO_103)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 103),
                        (lambda _, val: val.tag == 103),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_104(), DFS_INFO_104)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 104),
                        (lambda _, val: val.tag == 104),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_105(), DFS_INFO_105)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 105),
                        (lambda _, val: val.tag == 105),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_106(), DFS_INFO_106)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 106),
                        (lambda _, val: val.tag == 106),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_107(), DFS_INFO_107)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 107),
                        (lambda _, val: val.tag == 107),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_150(), DFS_INFO_150)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 150),
                        (lambda _, val: val.tag == 150),
                    ),
                ),
            ],
            StrFixedLenField("pDfsInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


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


class NetrDfsGetInfo_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
        NDRIntField("Level", 0),
    ]


class NetrDfsGetInfo_Response(NDRPacket):
    fields_desc = [
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_1(), DFS_INFO_1)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_2(), DFS_INFO_2)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_3(), DFS_INFO_3)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_4(), DFS_INFO_4)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_5(), DFS_INFO_5)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 5),
                        (lambda _, val: val.tag == 5),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_6(), DFS_INFO_6)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 6),
                        (lambda _, val: val.tag == 6),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_7(), DFS_INFO_7)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 7),
                        (lambda _, val: val.tag == 7),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_8(), DFS_INFO_8)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 8),
                        (lambda _, val: val.tag == 8),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_9(), DFS_INFO_9)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 9),
                        (lambda _, val: val.tag == 9),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_50(), DFS_INFO_50)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 50),
                        (lambda _, val: val.tag == 50),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_100(), DFS_INFO_100)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 100),
                        (lambda _, val: val.tag == 100),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_101(), DFS_INFO_101)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 101),
                        (lambda _, val: val.tag == 101),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_102(), DFS_INFO_102)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 102),
                        (lambda _, val: val.tag == 102),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_103(), DFS_INFO_103)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 103),
                        (lambda _, val: val.tag == 103),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_104(), DFS_INFO_104)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 104),
                        (lambda _, val: val.tag == 104),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_105(), DFS_INFO_105)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 105),
                        (lambda _, val: val.tag == 105),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_106(), DFS_INFO_106)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 106),
                        (lambda _, val: val.tag == 106),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_107(), DFS_INFO_107)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 107),
                        (lambda _, val: val.tag == 107),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_150(), DFS_INFO_150)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 150),
                        (lambda _, val: val.tag == 150),
                    ),
                ),
            ],
            StrFixedLenField("pDfsInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
        NDRIntField("status", 0),
    ]


class DFS_INFO_1_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_1, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_2_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_2, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_3_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_3, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_4_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_4, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_5_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_5, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_6_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_6, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class LPDFS_INFO_8(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("MetadataSize", 0),
        NDRIntField("SecurityDescriptorLength", None, size_of="pSecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor",
                "",
                size_is=lambda pkt: pkt.SecurityDescriptorLength,
            ),
            deferred=True,
        ),
        NDRIntField("NumberOfStorages", 0),
    ]


class DFS_INFO_8_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [LPDFS_INFO_8()],
                LPDFS_INFO_8,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class LPDFS_INFO_9(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("EntryPath", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", ""), deferred=True),
        NDRIntField("State", 0),
        NDRIntField("Timeout", 0),
        NDRPacketField("Guid", GUID(), GUID),
        NDRIntField("PropertyFlags", 0),
        NDRIntField("MetadataSize", 0),
        NDRIntField("SecurityDescriptorLength", None, size_of="pSecurityDescriptor"),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor",
                "",
                size_is=lambda pkt: pkt.SecurityDescriptorLength,
            ),
            deferred=True,
        ),
        NDRIntField("NumberOfStorages", None, size_of="Storage"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Storage",
                [LPDFS_STORAGE_INFO_1()],
                LPDFS_STORAGE_INFO_1,
                size_is=lambda pkt: pkt.NumberOfStorages,
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_9_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer",
                [LPDFS_INFO_9()],
                LPDFS_INFO_9,
                size_is=lambda pkt: pkt.EntriesRead,
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_200(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("FtDfsName", ""), deferred=True)
    ]


class DFS_INFO_200_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_200, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_300(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("DfsName", ""), deferred=True),
    ]


class DFS_INFO_300_CONTAINER(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("EntriesRead", None, size_of="Buffer"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "Buffer", [], DFS_INFO_300, size_is=lambda pkt: pkt.EntriesRead
            ),
            deferred=True,
        ),
    ]


class DFS_INFO_ENUM_STRUCT(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_1_CONTAINER(),
                            DFS_INFO_1_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_2_CONTAINER(),
                            DFS_INFO_2_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_3_CONTAINER(),
                            DFS_INFO_3_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_4_CONTAINER(),
                            DFS_INFO_4_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_5_CONTAINER(),
                            DFS_INFO_5_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 5),
                        (lambda _, val: val.tag == 5),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_6_CONTAINER(),
                            DFS_INFO_6_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 6),
                        (lambda _, val: val.tag == 6),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_8_CONTAINER(),
                            DFS_INFO_8_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 8),
                        (lambda _, val: val.tag == 8),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_9_CONTAINER(),
                            DFS_INFO_9_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 9),
                        (lambda _, val: val.tag == 9),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_200_CONTAINER(),
                            DFS_INFO_200_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 200),
                        (lambda _, val: val.tag == 200),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "DfsInfoContainer",
                            DFS_INFO_300_CONTAINER(),
                            DFS_INFO_300_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 300),
                        (lambda _, val: val.tag == 300),
                    ),
                ),
            ],
            StrFixedLenField("DfsInfoContainer", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class NetrDfsEnum_Request(NDRPacket):
    fields_desc = [
        NDRIntField("Level", 0),
        NDRIntField("PrefMaxLen", 0),
        NDRFullPointerField(
            NDRPacketField("DfsEnum", DFS_INFO_ENUM_STRUCT(), DFS_INFO_ENUM_STRUCT)
        ),
        NDRFullPointerField(NDRIntField("ResumeHandle", 0)),
    ]


class NetrDfsEnum_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("DfsEnum", DFS_INFO_ENUM_STRUCT(), DFS_INFO_ENUM_STRUCT)
        ),
        NDRFullPointerField(NDRIntField("ResumeHandle", 0)),
        NDRIntField("status", 0),
    ]


class NetrDfsMove_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRConfVarStrNullFieldUtf16("NewDfsEntryPath", ""),
        NDRIntField("Flags", 0),
    ]


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


class DFSM_ROOT_LIST_ENTRY(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ServerShare", ""), deferred=True
        )
    ]


class DFSM_ROOT_LIST(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["Entry"]
    fields_desc = [
        NDRIntField("cEntries", None, size_of="Entry"),
        NDRConfPacketListField(
            "Entry",
            [],
            DFSM_ROOT_LIST_ENTRY,
            size_is=lambda pkt: pkt.cEntries,
            conformant_in_struct=True,
        ),
    ]


class NetrDfsAddFtRoot_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRConfVarStrNullFieldUtf16("RootShare", ""),
        NDRConfVarStrNullFieldUtf16("FtDfsName", ""),
        NDRConfVarStrNullFieldUtf16("Comment", ""),
        NDRConfVarStrNullFieldUtf16("ConfigDN", ""),
        NDRByteField("NewFtDfs", 0),
        NDRIntField("ApiFlags", 0),
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
    ]


class NetrDfsAddFtRoot_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
        NDRIntField("status", 0),
    ]


class NetrDfsRemoveFtRoot_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRConfVarStrNullFieldUtf16("RootShare", ""),
        NDRConfVarStrNullFieldUtf16("FtDfsName", ""),
        NDRIntField("ApiFlags", 0),
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
    ]


class NetrDfsRemoveFtRoot_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
        NDRIntField("status", 0),
    ]


class NetrDfsAddStdRoot_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRConfVarStrNullFieldUtf16("RootShare", ""),
        NDRConfVarStrNullFieldUtf16("Comment", ""),
        NDRIntField("ApiFlags", 0),
    ]


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


class NetrDfsRemoveStdRoot_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRConfVarStrNullFieldUtf16("RootShare", ""),
        NDRIntField("ApiFlags", 0),
    ]


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


class NetrDfsManagerInitialize_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRIntField("Flags", 0),
    ]


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


class NetrDfsAddStdRootForced_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRConfVarStrNullFieldUtf16("RootShare", ""),
        NDRConfVarStrNullFieldUtf16("Comment", ""),
        NDRConfVarStrNullFieldUtf16("Share", ""),
    ]


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


class NetrDfsGetDcAddress_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("DcName", "")),
        NDRByteField("IsRoot", 0),
        NDRIntField("Timeout", 0),
    ]


class NetrDfsGetDcAddress_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("DcName", "")),
        NDRByteField("IsRoot", 0),
        NDRIntField("Timeout", 0),
        NDRIntField("status", 0),
    ]


class NetrDfsSetDcAddress_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRIntField("Timeout", 0),
        NDRIntField("Flags", 0),
    ]


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


class NetrDfsFlushFtTable_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRConfVarStrNullFieldUtf16("wszFtDfsName", ""),
    ]


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


class NetrDfsAdd2_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRConfVarStrNullFieldUtf16("ServerName", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Comment", "")),
        NDRIntField("Flags", 0),
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
    ]


class NetrDfsAdd2_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
        NDRIntField("status", 0),
    ]


class NetrDfsRemove2_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
    ]


class NetrDfsRemove2_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
        NDRIntField("status", 0),
    ]


class NetrDfsEnumEx_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRIntField("Level", 0),
        NDRIntField("PrefMaxLen", 0),
        NDRFullPointerField(
            NDRPacketField("DfsEnum", DFS_INFO_ENUM_STRUCT(), DFS_INFO_ENUM_STRUCT)
        ),
        NDRFullPointerField(NDRIntField("ResumeHandle", 0)),
    ]


class NetrDfsEnumEx_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("DfsEnum", DFS_INFO_ENUM_STRUCT(), DFS_INFO_ENUM_STRUCT)
        ),
        NDRFullPointerField(NDRIntField("ResumeHandle", 0)),
        NDRIntField("status", 0),
    ]


class NetrDfsSetInfo2_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("DfsEntryPath", ""),
        NDRConfVarStrNullFieldUtf16("DcName", ""),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ShareName", "")),
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_1(), DFS_INFO_1)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 1),
                        (lambda _, val: val.tag == 1),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_2(), DFS_INFO_2)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 2),
                        (lambda _, val: val.tag == 2),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_3(), DFS_INFO_3)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 3),
                        (lambda _, val: val.tag == 3),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_4(), DFS_INFO_4)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 4),
                        (lambda _, val: val.tag == 4),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_5(), DFS_INFO_5)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 5),
                        (lambda _, val: val.tag == 5),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_6(), DFS_INFO_6)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 6),
                        (lambda _, val: val.tag == 6),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_7(), DFS_INFO_7)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 7),
                        (lambda _, val: val.tag == 7),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_8(), DFS_INFO_8)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 8),
                        (lambda _, val: val.tag == 8),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_9(), DFS_INFO_9)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 9),
                        (lambda _, val: val.tag == 9),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_50(), DFS_INFO_50)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 50),
                        (lambda _, val: val.tag == 50),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_100(), DFS_INFO_100)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 100),
                        (lambda _, val: val.tag == 100),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_101(), DFS_INFO_101)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 101),
                        (lambda _, val: val.tag == 101),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_102(), DFS_INFO_102)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 102),
                        (lambda _, val: val.tag == 102),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_103(), DFS_INFO_103)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 103),
                        (lambda _, val: val.tag == 103),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_104(), DFS_INFO_104)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 104),
                        (lambda _, val: val.tag == 104),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_105(), DFS_INFO_105)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 105),
                        (lambda _, val: val.tag == 105),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_106(), DFS_INFO_106)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 106),
                        (lambda _, val: val.tag == 106),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_107(), DFS_INFO_107)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 107),
                        (lambda _, val: val.tag == 107),
                    ),
                ),
                (
                    NDRFullPointerField(
                        NDRPacketField("pDfsInfo", DFS_INFO_150(), DFS_INFO_150)
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 150),
                        (lambda _, val: val.tag == 150),
                    ),
                ),
            ],
            StrFixedLenField("pDfsInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
    ]


class NetrDfsSetInfo2_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRFullPointerField(
                NDRPacketField("ppRootList", DFSM_ROOT_LIST(), DFSM_ROOT_LIST)
            )
        ),
        NDRIntField("status", 0),
    ]


class NetrDfsAddRootTarget_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDfsPath", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pTargetPath", "")),
        NDRIntField("MajorVersion", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pComment", "")),
        NDRByteField("NewNamespace", 0),
        NDRIntField("Flags", 0),
    ]


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


class NetrDfsRemoveRootTarget_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDfsPath", "")),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pTargetPath", "")),
        NDRIntField("Flags", 0),
    ]


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


class DFS_NAMESPACE_VERSION_ORIGIN(IntEnum):
    DFS_NAMESPACE_VERSION_ORIGIN_COMBINED = 0
    DFS_NAMESPACE_VERSION_ORIGIN_SERVER = 1
    DFS_NAMESPACE_VERSION_ORIGIN_DOMAIN = 2


class PDFS_SUPPORTED_NAMESPACE_VERSION_INFO(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("DomainDfsMajorVersion", 0),
        NDRIntField("DomainDfsMinorVersion", 0),
        NDRLongField("DomainDfsCapabilities", 0),
        NDRIntField("StandaloneDfsMajorVersion", 0),
        NDRIntField("StandaloneDfsMinorVersion", 0),
        NDRLongField("StandaloneDfsCapabilities", 0),
    ]


class NetrDfsGetSupportedNamespaceVersion_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("Origin", 0, DFS_NAMESPACE_VERSION_ORIGIN),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pName", "")),
    ]


class NetrDfsGetSupportedNamespaceVersion_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "pVersionInfo",
            PDFS_SUPPORTED_NAMESPACE_VERSION_INFO(),
            PDFS_SUPPORTED_NAMESPACE_VERSION_INFO,
        ),
        NDRIntField("status", 0),
    ]


NETDFS_OPNUMS = {
    0: DceRpcOp(NetrDfsManagerGetVersion_Request, NetrDfsManagerGetVersion_Response),
    1: DceRpcOp(NetrDfsAdd_Request, NetrDfsAdd_Response),
    2: DceRpcOp(NetrDfsRemove_Request, NetrDfsRemove_Response),
    3: DceRpcOp(NetrDfsSetInfo_Request, NetrDfsSetInfo_Response),
    4: DceRpcOp(NetrDfsGetInfo_Request, NetrDfsGetInfo_Response),
    5: DceRpcOp(NetrDfsEnum_Request, NetrDfsEnum_Response),
    6: DceRpcOp(NetrDfsMove_Request, NetrDfsMove_Response),
    # 7: Opnum7NotUsedOnWire,
    # 8: Opnum8NotUsedOnWire,
    # 9: Opnum9NotUsedOnWire,
    10: DceRpcOp(NetrDfsAddFtRoot_Request, NetrDfsAddFtRoot_Response),
    11: DceRpcOp(NetrDfsRemoveFtRoot_Request, NetrDfsRemoveFtRoot_Response),
    12: DceRpcOp(NetrDfsAddStdRoot_Request, NetrDfsAddStdRoot_Response),
    13: DceRpcOp(NetrDfsRemoveStdRoot_Request, NetrDfsRemoveStdRoot_Response),
    14: DceRpcOp(NetrDfsManagerInitialize_Request, NetrDfsManagerInitialize_Response),
    15: DceRpcOp(NetrDfsAddStdRootForced_Request, NetrDfsAddStdRootForced_Response),
    16: DceRpcOp(NetrDfsGetDcAddress_Request, NetrDfsGetDcAddress_Response),
    17: DceRpcOp(NetrDfsSetDcAddress_Request, NetrDfsSetDcAddress_Response),
    18: DceRpcOp(NetrDfsFlushFtTable_Request, NetrDfsFlushFtTable_Response),
    19: DceRpcOp(NetrDfsAdd2_Request, NetrDfsAdd2_Response),
    20: DceRpcOp(NetrDfsRemove2_Request, NetrDfsRemove2_Response),
    21: DceRpcOp(NetrDfsEnumEx_Request, NetrDfsEnumEx_Response),
    22: DceRpcOp(NetrDfsSetInfo2_Request, NetrDfsSetInfo2_Response),
    23: DceRpcOp(NetrDfsAddRootTarget_Request, NetrDfsAddRootTarget_Response),
    24: DceRpcOp(NetrDfsRemoveRootTarget_Request, NetrDfsRemoveRootTarget_Response),
    25: DceRpcOp(
        NetrDfsGetSupportedNamespaceVersion_Request,
        NetrDfsGetSupportedNamespaceVersion_Response,
    ),
}
register_dcerpc_interface(
    name="netdfs",
    uuid=uuid.UUID("4fc742e0-4a10-11cf-8273-00aa004ae673"),
    version="3.0",
    opnums=NETDFS_OPNUMS,
)
