### ms-capr.idl
"""
RPC definitions for the following interfaces:
- lsacap (v1.0): afc07e2e-311c-4435-808c-c483ffeec7c9
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,
    NDRByteField,
    NDRConfFieldListField,
    NDRConfPacketListField,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    register_dcerpc_interface,
)


class RPC_SID_IDENTIFIER_AUTHORITY(NDRPacket):
    fields_desc = [StrFixedLenField("Value", "", length=6)]


class PRPC_SID(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["SubAuthority"]
    fields_desc = [
        NDRByteField("Revision", 0),
        NDRByteField("SubAuthorityCount", None, size_of="SubAuthority"),
        NDRPacketField(
            "IdentifierAuthority",
            RPC_SID_IDENTIFIER_AUTHORITY(),
            RPC_SID_IDENTIFIER_AUTHORITY,
        ),
        NDRConfFieldListField(
            "SubAuthority",
            [],
            NDRIntField("", 0),
            size_is=lambda pkt: pkt.SubAuthorityCount,
            conformant_in_struct=True,
        ),
    ]


class LSAPR_SID_INFORMATION(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRPacketField("Sid", PRPC_SID(), PRPC_SID), deferred=True)
    ]


class LSAPR_WRAPPED_CAPID_SET(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Entries", None, size_of="SidInfo"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "SidInfo", [], LSAPR_SID_INFORMATION, size_is=lambda pkt: pkt.Entries
            ),
            deferred=True,
        ),
    ]


class LsarGetAvailableCAPIDs_Request(NDRPacket):
    fields_desc = []


class LsarGetAvailableCAPIDs_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "WrappedCAPIDs", LSAPR_WRAPPED_CAPID_SET(), LSAPR_WRAPPED_CAPID_SET
        ),
        NDRIntField("status", 0),
    ]


LSACAP_OPNUMS = {
    0: DceRpcOp(LsarGetAvailableCAPIDs_Request, LsarGetAvailableCAPIDs_Response)
}
register_dcerpc_interface(
    name="lsacap",
    uuid=uuid.UUID("afc07e2e-311c-4435-808c-c483ffeec7c9"),
    version="1.0",
    opnums=LSACAP_OPNUMS,
)
