### ms-tsrap.idl
"""
RPC definitions for the following interfaces:
- IManageTelnetSessions (v0.0): 034634FD-BA3F-11D1-856A-00A0C944138C
This file is auto-generated by midl-to-scapy, do not modify.
"""

import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRConfStrLenField,
    NDRConfStrLenFieldUtf16,
    NDRFullPointerField,
    NDRIntField,
    NDRPacketField,
    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 GetTelnetSessions_Request(NDRPacket):
    fields_desc = []


class GetTelnetSessions_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField("pszSessionData", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB)
        ),
        NDRIntField("status", 0),
    ]


class TerminateSession_Request(NDRPacket):
    fields_desc = [NDRIntField("dwUniqueId", 0)]


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


class SendMsgToASession_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwUniqueId", 0),
        NDRPacketField("szMsg", FLAGGED_WORD_BLOB(), FLAGGED_WORD_BLOB),
    ]


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


IMANAGETELNETSESSIONS_OPNUMS = {
    0: DceRpcOp(GetTelnetSessions_Request, GetTelnetSessions_Response),
    1: DceRpcOp(TerminateSession_Request, TerminateSession_Response),
    2: DceRpcOp(SendMsgToASession_Request, SendMsgToASession_Response),
}
register_com_interface(
    name="IManageTelnetSessions",
    uuid=uuid.UUID("034634FD-BA3F-11D1-856A-00A0C944138C"),
    opnums=IMANAGETELNETSESSIONS_OPNUMS,
)
