### mgmt.idl
"""
RPC definitions for the following interfaces:
- mgmt (v1.0): afa8bd80-7d8a-11c9-bef4-08002b102989
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,
    NDRConfFieldListField,
    NDRConfPacketListField,
    NDRConfVarStrLenField,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    register_dcerpc_interface,
)


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


class RPC_IF_ID(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("Uuid", UUID(), UUID),
        NDRShortField("VersMajor", 0),
        NDRShortField("VersMinor", 0),
    ]


class rpc_if_id_vector_p_t(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Count", None, size_of="IfId"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "IfId", [], RPC_IF_ID, size_is=lambda pkt: pkt.Count, ptr_pack=True
            ),
            deferred=True,
        ),
    ]


class rpc__mgmt_inq_if_ids_Request(NDRPacket):
    fields_desc = []


class rpc__mgmt_inq_if_ids_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("if_id_vector", rpc_if_id_vector_p_t(), rpc_if_id_vector_p_t)
        ),
        NDRIntField("status", 0),
    ]


class rpc_mgmt_inq_stats_Request(NDRPacket):
    fields_desc = [NDRIntField("count", 0)]


class rpc_mgmt_inq_stats_Response(NDRPacket):
    fields_desc = [
        NDRIntField("count", None, size_of="statistics"),
        NDRConfFieldListField(
            "statistics", [], NDRIntField("", 0), size_is=lambda pkt: pkt.count
        ),
        NDRIntField("status", 0),
    ]


class rpc__mgmt_is_server_listening_Request(NDRPacket):
    fields_desc = []


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


class rpc__mgmt_stop_server_listening_Request(NDRPacket):
    fields_desc = []


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


class rpc_mgmt_inq_princ_name_Request(NDRPacket):
    fields_desc = [NDRIntField("authn_proto", 0), NDRIntField("princ_name_size", 0)]


class rpc_mgmt_inq_princ_name_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrLenField(
            "princ_name", "", size_is=lambda pkt: pkt.princ_name_size
        ),
        NDRIntField("status", 0),
    ]


MGMT_OPNUMS = {
    0: DceRpcOp(rpc__mgmt_inq_if_ids_Request, rpc__mgmt_inq_if_ids_Response),
    1: DceRpcOp(rpc_mgmt_inq_stats_Request, rpc_mgmt_inq_stats_Response),
    2: DceRpcOp(
        rpc__mgmt_is_server_listening_Request, rpc__mgmt_is_server_listening_Response
    ),
    3: DceRpcOp(
        rpc__mgmt_stop_server_listening_Request,
        rpc__mgmt_stop_server_listening_Response,
    ),
    4: DceRpcOp(rpc_mgmt_inq_princ_name_Request, rpc_mgmt_inq_princ_name_Response),
}
register_dcerpc_interface(
    name="mgmt",
    uuid=uuid.UUID("afa8bd80-7d8a-11c9-bef4-08002b102989"),
    version="1.0",
    opnums=MGMT_OPNUMS,
)
