### ms-tsch_ATSvc.idl
"""
RPC definitions for the following interfaces:
- atsvc (v1.0): 1FF70682-0A51-30E8-076D-740BE8CEE98B
This file is auto-generated by midl-to-scapy, do not modify.
"""

import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfPacketListField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRInt3264Field,
    NDRIntField,
    NDRPacketField,
    NDRShortField,
    register_dcerpc_interface,
)


class LPAT_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRInt3264Field("JobTime", 0),
        NDRIntField("DaysOfMonth", 0),
        NDRByteField("DaysOfWeek", 0),
        NDRByteField("Flags", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Command", ""), deferred=True),
    ]


class NetrJobAdd_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRPacketField("pAtInfo", LPAT_INFO(), LPAT_INFO),
    ]


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


class NetrJobDel_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRIntField("MinJobId", 0),
        NDRIntField("MaxJobId", 0),
    ]


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


class LPAT_ENUM(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("JobId", 0),
        NDRInt3264Field("JobTime", 0),
        NDRIntField("DaysOfMonth", 0),
        NDRByteField("DaysOfWeek", 0),
        NDRByteField("Flags", 0),
        NDRFullPointerField(NDRShortField("Command", 0), deferred=True),
    ]


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


class NetrJobEnum_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRPacketField("pEnumContainer", LPAT_ENUM_CONTAINER(), LPAT_ENUM_CONTAINER),
        NDRIntField("PreferedMaximumLength", 0),
        NDRFullPointerField(NDRIntField("pResumeHandle", 0)),
    ]


class NetrJobEnum_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pEnumContainer", LPAT_ENUM_CONTAINER(), LPAT_ENUM_CONTAINER),
        NDRIntField("pTotalEntries", 0),
        NDRFullPointerField(NDRIntField("pResumeHandle", 0)),
        NDRIntField("status", 0),
    ]


class NetrJobGetInfo_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("ServerName", "")),
        NDRIntField("JobId", 0),
    ]


class NetrJobGetInfo_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRPacketField("ppAtInfo", LPAT_INFO(), LPAT_INFO)),
        NDRIntField("status", 0),
    ]


ATSVC_OPNUMS = {
    0: DceRpcOp(NetrJobAdd_Request, NetrJobAdd_Response),
    1: DceRpcOp(NetrJobDel_Request, NetrJobDel_Response),
    2: DceRpcOp(NetrJobEnum_Request, NetrJobEnum_Response),
    3: DceRpcOp(NetrJobGetInfo_Request, NetrJobGetInfo_Response),
}
register_dcerpc_interface(
    name="atsvc",
    uuid=uuid.UUID("1FF70682-0A51-30E8-076D-740BE8CEE98B"),
    version="1.0",
    opnums=ATSVC_OPNUMS,
)
