### ms-raiw_winsif.idl
"""
RPC definitions for the following interfaces:
- winsif (v1.0): 45F52C28-7F9F-101A-B52B-08002B2EFABE
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid

from scapy.fields import PacketListField
from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfPacketListField,
    NDRConfStrLenField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRInt3264Field,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedLongField,
    NDRSignedShortField,
    register_dcerpc_interface,
)


class WINSINTF_ACT_E(IntEnum):
    WINSINTF_E_INSERT = 0
    WINSINTF_E_DELETE = 1
    WINSINTF_E_RELEASE = 2
    WINSINTF_E_MODIFY = 3
    WINSINTF_E_QUERY = 4


class PWINSINTF_ADD_T(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRByteField("Type", 0),
        NDRIntField("Len", 0),
        NDRIntField("IPAdd", 0),
    ]


class WINSINTF_ADD_T(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRByteField("Type", 0),
        NDRIntField("Len", 0),
        NDRIntField("IPAdd", 0),
    ]


class LARGE_INTEGER(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [NDRSignedLongField("QuadPart", 0)]


class PWINSINTF_RECORD_ACTION_T(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRInt3264EnumField("Cmd_e", 0, WINSINTF_ACT_E),
        NDRFullPointerField(
            NDRConfStrLenField("pName", "", size_is=lambda pkt: (pkt.NameLen + 1)),
            deferred=True,
        ),
        NDRIntField("NameLen", None, size_of="pName", adjust=lambda _, x: (x - 1)),
        NDRIntField("TypOfRec_e", 0),
        NDRIntField("NoOfAdds", None, size_of="pAdd"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "pAdd",
                [PWINSINTF_ADD_T()],
                PWINSINTF_ADD_T,
                size_is=lambda pkt: pkt.NoOfAdds,
            ),
            deferred=True,
        ),
        NDRPacketField("Add", WINSINTF_ADD_T(), WINSINTF_ADD_T),
        NDRPacketField("VersNo", LARGE_INTEGER(), LARGE_INTEGER),
        NDRByteField("NodeTyp", 0),
        NDRIntField("OwnerId", 0),
        NDRIntField("State_e", 0),
        NDRIntField("fStatic", 0),
        NDRInt3264Field("TimeStamp", 0),
    ]


class R_WinsRecordAction_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRFullPointerField(
            NDRPacketField(
                "ppRecAction", PWINSINTF_RECORD_ACTION_T(), PWINSINTF_RECORD_ACTION_T
            )
        ),
    ]


class R_WinsRecordAction_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRPacketField(
                "ppRecAction", PWINSINTF_RECORD_ACTION_T(), PWINSINTF_RECORD_ACTION_T
            )
        ),
        NDRIntField("status", 0),
    ]


class WINSINTF_CMD_E(IntEnum):
    WINSINTF_E_ADDVERSMAP = 0
    WINSINTF_E_CONFIG = 1
    WINSINTF_E_STAT = 2
    WINSINTF_E_CONFIG_ALL_MAPS = 3


class WINSINTF_ADD_VERS_MAP_T(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("Add", WINSINTF_ADD_T(), WINSINTF_ADD_T),
        NDRPacketField("VersNo", LARGE_INTEGER(), LARGE_INTEGER),
    ]


class Counters_WINSINTF_STAT_T(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("NoOfUniqueReg", 0),
        NDRIntField("NoOfGroupReg", 0),
        NDRIntField("NoOfQueries", 0),
        NDRIntField("NoOfSuccQueries", 0),
        NDRIntField("NoOfFailQueries", 0),
        NDRIntField("NoOfUniqueRef", 0),
        NDRIntField("NoOfGroupRef", 0),
        NDRIntField("NoOfRel", 0),
        NDRIntField("NoOfSuccRel", 0),
        NDRIntField("NoOfFailRel", 0),
        NDRIntField("NoOfUniqueCnf", 0),
        NDRIntField("NoOfGroupCnf", 0),
    ]


class SYSTEMTIME(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRShortField("wYear", 0),
        NDRShortField("wMonth", 0),
        NDRShortField("wDayOfWeek", 0),
        NDRShortField("wDay", 0),
        NDRShortField("wHour", 0),
        NDRShortField("wMinute", 0),
        NDRShortField("wSecond", 0),
        NDRShortField("wMilliseconds", 0),
    ]


class TimeStamps_WINSINTF_STAT_T(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [
        NDRPacketField("WINSStartTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastPScvTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastATScvTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastTombScvTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastVerifyScvTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastPRplTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastATRplTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastNTRplTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastACTRplTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("LastInitDbTime", SYSTEMTIME(), SYSTEMTIME),
        NDRPacketField("CounterResetTime", SYSTEMTIME(), SYSTEMTIME),
    ]


class PWINSINTF_RPL_COUNTERS_T(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRPacketField("Add", WINSINTF_ADD_T(), WINSINTF_ADD_T),
        NDRIntField("NoOfRpls", 0),
        NDRIntField("NoOfCommFails", 0),
    ]


class WINSINTF_STAT_T(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRPacketField(
            "Counters_WINSINTF_STAT_T",
            Counters_WINSINTF_STAT_T(),
            Counters_WINSINTF_STAT_T,
        ),
        NDRPacketField(
            "TimeStamps_WINSINTF_STAT_T",
            TimeStamps_WINSINTF_STAT_T(),
            TimeStamps_WINSINTF_STAT_T,
        ),
        NDRIntField("NoOfPnrs", None, size_of="pRplPnrs"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "pRplPnrs",
                [PWINSINTF_RPL_COUNTERS_T()],
                PWINSINTF_RPL_COUNTERS_T,
                size_is=lambda pkt: pkt.NoOfPnrs,
            ),
            deferred=True,
        ),
    ]


class PWINSINTF_RESULTS_T(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("NoOfOwners", 0),
        PacketListField(
            "AddVersMaps", [], WINSINTF_ADD_VERS_MAP_T, count_from=lambda _: 25
        ),
        NDRPacketField("MyMaxVersNo", LARGE_INTEGER(), LARGE_INTEGER),
        NDRIntField("RefreshInterval", 0),
        NDRIntField("TombstoneInterval", 0),
        NDRIntField("TombstoneTimeout", 0),
        NDRIntField("VerifyInterval", 0),
        NDRIntField("WINSPriorityClass", 0),
        NDRIntField("NoOfWorkerThds", 0),
        NDRPacketField("WINSStat", WINSINTF_STAT_T(), WINSINTF_STAT_T),
    ]


class R_WinsStatus_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRInt3264EnumField("Cmd_e", 0, WINSINTF_CMD_E),
        NDRPacketField("pResults", PWINSINTF_RESULTS_T(), PWINSINTF_RESULTS_T),
    ]


class R_WinsStatus_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pResults", PWINSINTF_RESULTS_T(), PWINSINTF_RESULTS_T),
        NDRIntField("status", 0),
    ]


class WINSINTF_TRIG_TYPE_E(IntEnum):
    WINSINTF_E_PULL = 0
    WINSINTF_E_PUSH = 1
    WINSINTF_E_PUSH_PROP = 2


class R_WinsTrigger_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
        NDRInt3264EnumField("TrigType_e", 0, WINSINTF_TRIG_TYPE_E),
    ]


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


class R_WinsDoStaticInit_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("pDataFilePath", "")),
        NDRIntField("fDel", 0),
    ]


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


class R_WinsDoScavenging_Request(NDRPacket):
    fields_desc = [NDRLongField("ServerHdl", 0)]


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


class PWINSINTF_RECS_T(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("BuffSize", 0),
        NDRFullPointerField(
            NDRConfPacketListField(
                "pRow",
                [PWINSINTF_RECORD_ACTION_T()],
                PWINSINTF_RECORD_ACTION_T,
                size_is=lambda pkt: pkt.NoOfRecs,
            ),
            deferred=True,
        ),
        NDRIntField("NoOfRecs", None, size_of="pRow"),
        NDRIntField("TotalNoOfRecs", 0),
    ]


class R_WinsGetDbRecs_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
        NDRPacketField("MinVersNo", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("MaxVersNo", LARGE_INTEGER(), LARGE_INTEGER),
    ]


class R_WinsGetDbRecs_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pRecs", PWINSINTF_RECS_T(), PWINSINTF_RECS_T),
        NDRIntField("status", 0),
    ]


class R_WinsTerm_Request(NDRPacket):
    fields_desc = [NDRSignedShortField("fAbruptTem", 0)]


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


class R_WinsBackup_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRConfVarStrNullField("pBackupPath", ""),
        NDRSignedShortField("fIncremental", 0),
    ]


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


class R_WinsDelDbRecs_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
        NDRPacketField("MinVersNo", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("MaxVersNo", LARGE_INTEGER(), LARGE_INTEGER),
    ]


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


class R_WinsPullRange_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
        NDRPacketField("pOwnerAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
        NDRPacketField("MinVersNo", LARGE_INTEGER(), LARGE_INTEGER),
        NDRPacketField("MaxVersNo", LARGE_INTEGER(), LARGE_INTEGER),
    ]


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


class WINSINTF_PRIORITY_CLASS_E(IntEnum):
    WINSINTF_E_NORMAL = 0
    WINSINTF_E_HIGH = 1


class R_WinsSetPriorityClass_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRInt3264EnumField("PrCls_e", 0, WINSINTF_PRIORITY_CLASS_E),
    ]


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


class R_WinsResetCounters_Request(NDRPacket):
    fields_desc = [NDRLongField("ServerHdl", 0)]


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


class R_WinsWorkerThdUpd_Request(NDRPacket):
    fields_desc = [NDRLongField("ServerHdl", 0), NDRIntField("NewNoOfNbtThds", 0)]


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


class R_WinsGetNameAndAdd_Request(NDRPacket):
    fields_desc = [NDRLongField("ServerHdl", 0)]


class R_WinsGetNameAndAdd_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
        NDRConfVarStrNullField("pUncName", ""),
        NDRIntField("status", 0),
    ]


class PWINSINTF_BROWSER_INFO_T(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwNameLen", 0),
        NDRFullPointerField(NDRConfVarStrNullField("pName", ""), deferred=True),
    ]


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


class R_WinsGetBrowserNames_Old_Request(NDRPacket):
    fields_desc = [NDRLongField("ServerHdl", 0)]


class R_WinsGetBrowserNames_Old_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "pNames", PWINSINTF_BROWSER_NAMES_T(), PWINSINTF_BROWSER_NAMES_T
        ),
        NDRIntField("status", 0),
    ]


class R_WinsDeleteWins_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T),
    ]


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


class R_WinsSetFlags_Request(NDRPacket):
    fields_desc = [NDRLongField("ServerHdl", 0), NDRIntField("fFlags", 0)]


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


class PWINSINTF_BIND_DATA_T(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("fTcpIp", 0),
        NDRFullPointerField(NDRConfVarStrNullField("pServerAdd", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullField("pPipeName", ""), deferred=True),
    ]


class R_WinsGetBrowserNames_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHdl", PWINSINTF_BIND_DATA_T(), PWINSINTF_BIND_DATA_T)
    ]


class R_WinsGetBrowserNames_Response(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "pNames", PWINSINTF_BROWSER_NAMES_T(), PWINSINTF_BROWSER_NAMES_T
        ),
        NDRIntField("status", 0),
    ]


class R_WinsGetDbRecsByName_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRFullPointerField(
            NDRPacketField("pWinsAdd", PWINSINTF_ADD_T(), PWINSINTF_ADD_T)
        ),
        NDRIntField("Location", 0),
        NDRFullPointerField(
            NDRConfStrLenField("pName", "", size_is=lambda pkt: (pkt.NameLen + 1))
        ),
        NDRIntField("NameLen", None, size_of="pName", adjust=lambda _, x: (x - 1)),
        NDRIntField("NoOfRecsDesired", 0),
        NDRIntField("fOnlyStatic", 0),
    ]


class R_WinsGetDbRecsByName_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pRecs", PWINSINTF_RECS_T(), PWINSINTF_RECS_T),
        NDRIntField("status", 0),
    ]


class PWINSINTF_ADD_VERS_MAP_T(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRPacketField("Add", WINSINTF_ADD_T(), WINSINTF_ADD_T),
        NDRPacketField("VersNo", LARGE_INTEGER(), LARGE_INTEGER),
    ]


class PWINSINTF_RESULTS_NEW_T(NDRPacket):
    ALIGNMENT = (8, 8)
    fields_desc = [
        NDRIntField("NoOfOwners", None, size_of="pAddVersMaps"),
        NDRFullPointerField(
            NDRConfPacketListField(
                "pAddVersMaps",
                [PWINSINTF_ADD_VERS_MAP_T()],
                PWINSINTF_ADD_VERS_MAP_T,
                size_is=lambda pkt: pkt.NoOfOwners,
            ),
            deferred=True,
        ),
        NDRPacketField("MyMaxVersNo", LARGE_INTEGER(), LARGE_INTEGER),
        NDRIntField("RefreshInterval", 0),
        NDRIntField("TombstoneInterval", 0),
        NDRIntField("TombstoneTimeout", 0),
        NDRIntField("VerifyInterval", 0),
        NDRIntField("WINSPriorityClass", 0),
        NDRIntField("NoOfWorkerThds", 0),
        NDRPacketField("WINSStat", WINSINTF_STAT_T(), WINSINTF_STAT_T),
    ]


class R_WinsStatusNew_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRInt3264EnumField("Cmd_e", 0, WINSINTF_CMD_E),
    ]


class R_WinsStatusNew_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pResults", PWINSINTF_RESULTS_NEW_T(), PWINSINTF_RESULTS_NEW_T),
        NDRIntField("status", 0),
    ]


class R_WinsStatusWHdl_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("ServerHdl", PWINSINTF_BIND_DATA_T(), PWINSINTF_BIND_DATA_T),
        NDRInt3264EnumField("Cmd_e", 0, WINSINTF_CMD_E),
        NDRPacketField("pResults", PWINSINTF_RESULTS_NEW_T(), PWINSINTF_RESULTS_NEW_T),
    ]


class R_WinsStatusWHdl_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pResults", PWINSINTF_RESULTS_NEW_T(), PWINSINTF_RESULTS_NEW_T),
        NDRIntField("status", 0),
    ]


class WINSINTF_SCV_OPC_E(IntEnum):
    WINSINTF_E_SCV_GENERAL = 1
    WINSINTF_E_SCV_VERIFY = 2


class PWINSINTF_SCV_REQ_T(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRInt3264EnumField("Opcode_e", 0, WINSINTF_SCV_OPC_E),
        NDRIntField("Age", 0),
        NDRIntField("fForce", 0),
    ]


class R_WinsDoScavengingNew_Request(NDRPacket):
    fields_desc = [
        NDRLongField("ServerHdl", 0),
        NDRPacketField("pScvReq", PWINSINTF_SCV_REQ_T(), PWINSINTF_SCV_REQ_T),
    ]


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


WINSIF_OPNUMS = {
    0: DceRpcOp(R_WinsRecordAction_Request, R_WinsRecordAction_Response),
    1: DceRpcOp(R_WinsStatus_Request, R_WinsStatus_Response),
    2: DceRpcOp(R_WinsTrigger_Request, R_WinsTrigger_Response),
    3: DceRpcOp(R_WinsDoStaticInit_Request, R_WinsDoStaticInit_Response),
    4: DceRpcOp(R_WinsDoScavenging_Request, R_WinsDoScavenging_Response),
    5: DceRpcOp(R_WinsGetDbRecs_Request, R_WinsGetDbRecs_Response),
    6: DceRpcOp(R_WinsTerm_Request, R_WinsTerm_Response),
    7: DceRpcOp(R_WinsBackup_Request, R_WinsBackup_Response),
    8: DceRpcOp(R_WinsDelDbRecs_Request, R_WinsDelDbRecs_Response),
    9: DceRpcOp(R_WinsPullRange_Request, R_WinsPullRange_Response),
    10: DceRpcOp(R_WinsSetPriorityClass_Request, R_WinsSetPriorityClass_Response),
    11: DceRpcOp(R_WinsResetCounters_Request, R_WinsResetCounters_Response),
    12: DceRpcOp(R_WinsWorkerThdUpd_Request, R_WinsWorkerThdUpd_Response),
    13: DceRpcOp(R_WinsGetNameAndAdd_Request, R_WinsGetNameAndAdd_Response),
    14: DceRpcOp(R_WinsGetBrowserNames_Old_Request, R_WinsGetBrowserNames_Old_Response),
    15: DceRpcOp(R_WinsDeleteWins_Request, R_WinsDeleteWins_Response),
    16: DceRpcOp(R_WinsSetFlags_Request, R_WinsSetFlags_Response),
    17: DceRpcOp(R_WinsGetBrowserNames_Request, R_WinsGetBrowserNames_Response),
    18: DceRpcOp(R_WinsGetDbRecsByName_Request, R_WinsGetDbRecsByName_Response),
    19: DceRpcOp(R_WinsStatusNew_Request, R_WinsStatusNew_Response),
    20: DceRpcOp(R_WinsStatusWHdl_Request, R_WinsStatusWHdl_Response),
    21: DceRpcOp(R_WinsDoScavengingNew_Request, R_WinsDoScavengingNew_Response),
}
register_dcerpc_interface(
    name="winsif",
    uuid=uuid.UUID("45F52C28-7F9F-101A-B52B-08002B2EFABE"),
    version="1.0",
    opnums=WINSIF_OPNUMS,
)
