### ms-rpcl.idl
"""
RPC definitions for the following interfaces:
- LocToLoc (v1.0): e33c0cc4-0482-101a-bc0c-02608c6ba218
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,
    NDRConfPacketListField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    register_dcerpc_interface,
)


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


class RPC_VERSION(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [NDRShortField("MajorVersion", 0), NDRShortField("MinorVersion", 0)]


class RPC_SYNTAX_IDENTIFIER(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("SyntaxGUID", GUID(), GUID),
        NDRPacketField("SyntaxVersion", RPC_VERSION(), RPC_VERSION),
    ]


class I_nsi_lookup_begin_Request(NDRPacket):
    fields_desc = [
        NDRIntField("entry_name_syntax", 0),
        NDRConfVarStrNullFieldUtf16("entry_name", ""),
        NDRFullPointerField(
            NDRPacketField(
                "interfaceid", RPC_SYNTAX_IDENTIFIER(), RPC_SYNTAX_IDENTIFIER
            )
        ),
        NDRFullPointerField(
            NDRPacketField("xfersyntax", RPC_SYNTAX_IDENTIFIER(), RPC_SYNTAX_IDENTIFIER)
        ),
        NDRPacketField("obj_uuid", GUID(), GUID),
        NDRIntField("binding_max_count", 0),
        NDRIntField("MaxCacheAge", 0),
    ]


class I_nsi_lookup_begin_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("import_context", NDRContextHandle(), NDRContextHandle),
        NDRShortField("status", 0),
        NDRIntField("comm_status", 0),
    ]


class I_nsi_lookup_done_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("import_context", NDRContextHandle(), NDRContextHandle)
    ]


class I_nsi_lookup_done_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("import_context", NDRContextHandle(), NDRContextHandle),
        NDRShortField("status", 0),
        NDRIntField("comm_status", 0),
    ]


class NSI_BINDING_T(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("string", ""), deferred=True),
        NDRIntField("entry_name_syntax", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("entry_name", ""), deferred=True
        ),
    ]


class NSI_BINDING_VECTOR_T(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["binding"]
    fields_desc = [
        NDRIntField("count", None, size_of="binding"),
        NDRConfPacketListField(
            "binding",
            [],
            NSI_BINDING_T,
            size_is=lambda pkt: pkt.count,
            conformant_in_struct=True,
        ),
    ]


class I_nsi_lookup_next_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("import_context", NDRContextHandle(), NDRContextHandle)
    ]


class I_nsi_lookup_next_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "binding_vector", NSI_BINDING_VECTOR_T(), NSI_BINDING_VECTOR_T
            )
        ),
        NDRShortField("status", 0),
        NDRIntField("comm_status", 0),
    ]


class NSI_UUID_VECTOR_T(NDRPacket):
    ALIGNMENT = (4, 8)
    DEPORTED_CONFORMANTS = ["uuid"]
    fields_desc = [
        NDRIntField("count", None, size_of="uuid"),
        NDRConfPacketListField(
            "uuid",
            [],
            GUID,
            size_is=lambda pkt: pkt.count,
            conformant_in_struct=True,
            ptr_pack=True,
        ),
    ]


class I_nsi_entry_object_inq_next_Request(NDRPacket):
    fields_desc = [NDRPacketField("InqContext", NDRContextHandle(), NDRContextHandle)]


class I_nsi_entry_object_inq_next_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("uuid_vec", NSI_UUID_VECTOR_T(), NSI_UUID_VECTOR_T)
        ),
        NDRShortField("status", 0),
        NDRIntField("comm_status", 0),
    ]


class I_nsi_ping_locator_Request(NDRPacket):
    fields_desc = []


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


class I_nsi_entry_object_inq_done_Request(NDRPacket):
    fields_desc = [NDRPacketField("InqContext", NDRContextHandle(), NDRContextHandle)]


class I_nsi_entry_object_inq_done_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("InqContext", NDRContextHandle(), NDRContextHandle),
        NDRShortField("status", 0),
        NDRIntField("comm_status", 0),
    ]


class I_nsi_entry_object_inq_begin_Request(NDRPacket):
    fields_desc = [
        NDRIntField("EntryNameSyntax", 0),
        NDRConfVarStrNullFieldUtf16("EntryName", ""),
    ]


class I_nsi_entry_object_inq_begin_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("InqContext", NDRContextHandle(), NDRContextHandle),
        NDRShortField("status", 0),
        NDRIntField("comm_status", 0),
    ]


LOCTOLOC_OPNUMS = {
    0: DceRpcOp(I_nsi_lookup_begin_Request, I_nsi_lookup_begin_Response),
    1: DceRpcOp(I_nsi_lookup_done_Request, I_nsi_lookup_done_Response),
    2: DceRpcOp(I_nsi_lookup_next_Request, I_nsi_lookup_next_Response),
    3: DceRpcOp(
        I_nsi_entry_object_inq_next_Request, I_nsi_entry_object_inq_next_Response
    ),
    4: DceRpcOp(I_nsi_ping_locator_Request, I_nsi_ping_locator_Response),
    5: DceRpcOp(
        I_nsi_entry_object_inq_done_Request, I_nsi_entry_object_inq_done_Response
    ),
    6: DceRpcOp(
        I_nsi_entry_object_inq_begin_Request, I_nsi_entry_object_inq_begin_Response
    ),
}
register_dcerpc_interface(
    name="LocToLoc",
    uuid=uuid.UUID("e33c0cc4-0482-101a-bc0c-02608c6ba218"),
    version="1.0",
    opnums=LOCTOLOC_OPNUMS,
)
