### ms-dfsrh.idl
"""
RPC definitions for the following interfaces:
- IADProxy (v0.0): 4BB8AB1D-9EF9-4100-8EB6-DD4B4E418B72
- IADProxy2 (v0.0): C4B0C7D9-ABE0-4733-A1E1-9FDEDF260C7A
- IServerHealthReport (v0.0): E65E8028-83E8-491b-9AF7-AAF6BD51A0CE
- IServerHealthReport2 (v0.0): 20D15747-6C48-4254-A358-65039FD8C63C
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,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRRecursiveField,
    NDRRefEmbPointerField,
    NDRShortField,
    NDRSignedIntField,
    NDRSignedLongField,
    register_com_interface,
)


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


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


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


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


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


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


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


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


class SAFEARRAYBOUND(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("cElements", 0), NDRSignedIntField("lLbound", 0)]


class SAFEARRAY(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["rgsabound"]
    fields_desc = [
        NDRShortField("cDims", None, size_of="rgsabound"),
        NDRShortField("fFeatures", 0),
        NDRIntField("cbElements", 0),
        NDRIntField("cLocks", 0),
        NDRRecursiveField("uArrayStructs"),
        NDRConfPacketListField(
            "rgsabound",
            [],
            SAFEARRAYBOUND,
            size_is=lambda pkt: pkt.cDims,
            conformant_in_struct=True,
        ),
    ]


class CreateObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("domainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("distinguishedName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(NDRPacketField("attributes", SAFEARRAY(), SAFEARRAY)),
        NDRPacketField(
            "verifyNameDomainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB
        ),
    ]


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


class DeleteObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("domainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("distinguishedName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
    ]


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


class ModifyObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("domainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("distinguishedName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(NDRPacketField("attributes", SAFEARRAY(), SAFEARRAY)),
    ]


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


IADPROXY_OPNUMS = {
    0: DceRpcOp(CreateObject_Request, CreateObject_Response),
    1: DceRpcOp(DeleteObject_Request, DeleteObject_Response),
    2: DceRpcOp(ModifyObject_Request, ModifyObject_Response),
}
register_com_interface(
    name="IADProxy",
    uuid=uuid.UUID("4BB8AB1D-9EF9-4100-8EB6-DD4B4E418B72"),
    opnums=IADPROXY_OPNUMS,
)


class CreateObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("domainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("distinguishedName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(NDRPacketField("attributes", SAFEARRAY(), SAFEARRAY)),
        NDRPacketField(
            "verifyNameDomainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB
        ),
        NDRPacketField(
            "networkNameResourceName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB
        ),
    ]


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


class DeleteObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("domainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("distinguishedName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField(
            "networkNameResourceName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB
        ),
    ]


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


class ModifyObject_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("domainControllerName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("distinguishedName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(NDRPacketField("attributes", SAFEARRAY(), SAFEARRAY)),
        NDRPacketField(
            "networkNameResourceName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB
        ),
    ]


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


IADPROXY2_OPNUMS = {
    0: DceRpcOp(CreateObject_Request, CreateObject_Response),
    1: DceRpcOp(DeleteObject_Request, DeleteObject_Response),
    2: DceRpcOp(ModifyObject_Request, ModifyObject_Response),
}
register_com_interface(
    name="IADProxy2",
    uuid=uuid.UUID("C4B0C7D9-ABE0-4733-A1E1-9FDEDF260C7A"),
    opnums=IADPROXY2_OPNUMS,
)


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


class GetReport_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("replicationGroupGuid", GUID(), GUID),
        NDRPacketField("referenceMember", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(
            NDRPacketField("referenceVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRSignedIntField("flags", 0),
    ]


class GetReport_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("memberVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRFullPointerField(
            NDRPacketField("reportXML", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class GetCompressedReport_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("replicationGroupGuid", GUID(), GUID),
        NDRPacketField("referenceMember", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(
            NDRPacketField("referenceVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRSignedIntField("flags", 0),
    ]


class GetCompressedReport_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("memberVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRFullPointerField(
            NDRPacketField("reportCompressed", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRSignedIntField("uncompressedReportSize", 0),
        NDRIntField("status", 0),
    ]


class GetRawReportEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("replicationGroupGuid", GUID(), GUID),
        NDRFullPointerField(NDRPacketField("reportOptions", SAFEARRAY(), SAFEARRAY)),
    ]


class GetRawReportEx_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("report", SAFEARRAY(), SAFEARRAY)),
        NDRIntField("status", 0),
    ]


class GetReferenceVersionVectors_Request(NDRPacket):
    fields_desc = [NDRPacketField("replicationGroupGuid", GUID(), GUID)]


class GetReferenceVersionVectors_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("referenceVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRIntField("status", 0),
    ]


class GetReferenceBacklogCounts_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("flatMemberVersionVectors", SAFEARRAY(), SAFEARRAY)
        )
    ]


class GetReferenceBacklogCounts_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("backlogCounts", SAFEARRAY(), SAFEARRAY)),
        NDRIntField("status", 0),
    ]


ISERVERHEALTHREPORT_OPNUMS = {
    0: DceRpcOp(GetReport_Request, GetReport_Response),
    1: DceRpcOp(GetCompressedReport_Request, GetCompressedReport_Response),
    2: DceRpcOp(GetRawReportEx_Request, GetRawReportEx_Response),
    3: DceRpcOp(
        GetReferenceVersionVectors_Request, GetReferenceVersionVectors_Response
    ),
    # 4: Opnum7NotUsedOnWire,
    5: DceRpcOp(GetReferenceBacklogCounts_Request, GetReferenceBacklogCounts_Response),
}
register_com_interface(
    name="IServerHealthReport",
    uuid=uuid.UUID("E65E8028-83E8-491b-9AF7-AAF6BD51A0CE"),
    opnums=ISERVERHEALTHREPORT_OPNUMS,
)


class GetReport_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("replicationGroupGuid", GUID(), GUID),
        NDRPacketField("referenceMember", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("serverName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(
            NDRPacketField("referenceVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRSignedIntField("flags", 0),
    ]


class GetReport_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("memberVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRFullPointerField(
            NDRPacketField("reportXML", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class GetCompressedReport_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("replicationGroupGuid", GUID(), GUID),
        NDRPacketField("referenceMember", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRPacketField("serverName", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
        NDRFullPointerField(
            NDRPacketField("referenceVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRSignedIntField("flags", 0),
    ]


class GetCompressedReport_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("memberVersionVectors", SAFEARRAY(), SAFEARRAY)
        ),
        NDRFullPointerField(
            NDRPacketField("reportCompressed", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRSignedIntField("uncompressedReportSize", 0),
        NDRIntField("status", 0),
    ]


ISERVERHEALTHREPORT2_OPNUMS = {
    0: DceRpcOp(GetReport_Request, GetReport_Response),
    1: DceRpcOp(GetCompressedReport_Request, GetCompressedReport_Response),
}
register_com_interface(
    name="IServerHealthReport2",
    uuid=uuid.UUID("20D15747-6C48-4254-A358-65039FD8C63C"),
    opnums=ISERVERHEALTHREPORT2_OPNUMS,
)
