### ms-brwsa.idl
"""
RPC definitions for the following interfaces:
- browser (v0.0): 6BFFD098-A112-3610-9833-012892020162
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,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    NDRUnionField,
    register_dcerpc_interface,
)


class LPSERVER_INFO_100(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("sv100_platform_id", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("sv100_name", ""), deferred=True
        ),
    ]


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


class LPSERVER_ENUM_STRUCT(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("Level", 0),
        NDRUnionField(
            [
                (
                    NDRFullPointerField(
                        NDRPacketField(
                            "ServerInfo",
                            LPSERVER_INFO_100_CONTAINER(),
                            LPSERVER_INFO_100_CONTAINER,
                        ),
                        deferred=True,
                    ),
                    (
                        (lambda pkt: getattr(pkt, "Level", None) == 100),
                        (lambda _, val: val.tag == 100),
                    ),
                )
            ],
            StrFixedLenField("ServerInfo", "", length=0),
            align=(4, 8),
            switch_fmt=("L", "L"),
        ),
    ]


class I_BrowserrQueryOtherDomains_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRPacketField("InfoStruct", LPSERVER_ENUM_STRUCT(), LPSERVER_ENUM_STRUCT),
    ]


class I_BrowserrQueryOtherDomains_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("InfoStruct", LPSERVER_ENUM_STRUCT(), LPSERVER_ENUM_STRUCT),
        NDRIntField("TotalEntries", 0),
        NDRIntField("status", 0),
    ]


BROWSER_OPNUMS = {  # 0: Opnum0NotUsedOnWire,
    # 1: Opnum1NotUsedOnWire,
    2: DceRpcOp(
        I_BrowserrQueryOtherDomains_Request, I_BrowserrQueryOtherDomains_Response
    ),
    # 3: Opnum3NotUsedOnWire,
    # 4: Opnum4NotUsedOnWire,
    # 5: Opnum5NotUsedOnWire,
    # 6: Opnum6NotUsedOnWire,
    # 7: Opnum7NotUsedOnWire,
    # 8: Opnum8NotUsedOnWire,
    # 9: Opnum9NotUsedOnWire,
    # 10: Opnum10NotUsedOnWire,
    # 11: Opnum11NotUsedOnWire
}
register_dcerpc_interface(
    name="browser",
    uuid=uuid.UUID("6BFFD098-A112-3610-9833-012892020162"),
    version="0.0",
    opnums=BROWSER_OPNUMS,
)
