### ms-fax_fax.idl
"""
RPC definitions for the following interfaces:
- fax (v4.0): ea0a3165-4834-11d2-a6f8-00c04fa346cc
This file is auto-generated by midl-to-scapy, do not modify.
"""

from enum import IntEnum
import uuid


from scapy.layers.dcerpc import (
    NDRPacket,
    DceRpcOp,
    NDRByteField,
    NDRConfFieldListField,
    NDRConfStrLenField,
    NDRConfVarStrNullField,
    NDRConfVarStrNullFieldUtf16,
    NDRContextHandle,
    NDRFieldListField,
    NDRFullPointerField,
    NDRInt3264EnumField,
    NDRInt3264Field,
    NDRIntField,
    NDRLongField,
    NDRPacketField,
    NDRShortField,
    NDRSignedIntField,
    NDRUnionField,
    register_dcerpc_interface,
)


class FAX_GetServicePrinters_Request(NDRPacket):
    fields_desc = []


class FAX_GetServicePrinters_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lpBuffer", "", size_is=lambda pkt: pkt.lpdwBufferSize),
        NDRIntField("lpdwBufferSize", None, size_of="lpBuffer"),
        NDRIntField("lpdwPrintersReturned", 0),
        NDRIntField("status", 0),
    ]


class FAX_ConnectionRefCount_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("Handle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("Connect", 0),
    ]


class FAX_ConnectionRefCount_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("Handle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("CanShare", 0),
        NDRIntField("status", 0),
    ]


class FAX_OpenPort_Request(NDRPacket):
    fields_desc = [NDRIntField("DeviceId", 0), NDRIntField("Flags", 0)]


class FAX_OpenPort_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_ClosePort_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle)
    ]


class FAX_ClosePort_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_EnumJobs_Request(NDRPacket):
    fields_desc = []


class FAX_EnumJobs_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("JobsReturned", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetJob_Request(NDRPacket):
    fields_desc = [NDRIntField("JobId", 0)]


class FAX_GetJob_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_SetJob_Request(NDRPacket):
    fields_desc = [NDRIntField("JobId", 0), NDRIntField("Command", 0)]


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


class FAX_GetPageData_Request(NDRPacket):
    fields_desc = [
        NDRIntField("JobId", 0),
        NDRIntField("ImageWidth", 0),
        NDRIntField("ImageHeight", 0),
    ]


class FAX_GetPageData_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("ImageWidth", 0),
        NDRIntField("ImageHeight", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetDeviceStatus_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle)
    ]


class FAX_GetDeviceStatus_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("StatusBuffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="StatusBuffer"),
        NDRIntField("status", 0),
    ]


class FAX_Abort_Request(NDRPacket):
    fields_desc = [NDRIntField("JobId", 0)]


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


class FAX_EnumPorts_Request(NDRPacket):
    fields_desc = []


class FAX_EnumPorts_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("PortBuffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="PortBuffer"),
        NDRIntField("PortsReturned", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetPort_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle)
    ]


class FAX_GetPort_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("PortBuffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="PortBuffer"),
        NDRIntField("status", 0),
    ]


class FAX_PORT_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("SizeOfStruct", 0),
        NDRIntField("DeviceId", 0),
        NDRIntField("State", 0),
        NDRIntField("Flags", 0),
        NDRIntField("Rings", 0),
        NDRIntField("Priority", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("DeviceName", ""), deferred=True
        ),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Tsid", ""), deferred=True),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Csid", ""), deferred=True),
    ]


class FAX_SetPort_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle),
        NDRPacketField("PortInfo", FAX_PORT_INFO(), FAX_PORT_INFO),
    ]


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


class FAX_EnumRoutingMethods_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle)
    ]


class FAX_EnumRoutingMethods_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "RoutingInfoBuffer", "", size_is=lambda pkt: pkt.RoutingInfoBufferSize
        ),
        NDRIntField("RoutingInfoBufferSize", None, size_of="RoutingInfoBuffer"),
        NDRIntField("PortsReturned", 0),
        NDRIntField("status", 0),
    ]


class FAX_EnableRoutingMethod_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("RoutingGuid", "")),
        NDRSignedIntField("Enabled", 0),
    ]


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


class FAX_GetRoutingInfo_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("RoutingGuid", "")),
    ]


class FAX_GetRoutingInfo_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "RoutingInfoBuffer", "", size_is=lambda pkt: pkt.RoutingInfoBufferSize
        ),
        NDRIntField("RoutingInfoBufferSize", None, size_of="RoutingInfoBuffer"),
        NDRIntField("status", 0),
    ]


class FAX_SetRoutingInfo_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxPortHandle", NDRContextHandle(), NDRContextHandle),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("RoutingGuid", "")),
        NDRConfStrLenField(
            "RoutingInfoBuffer", "", size_is=lambda pkt: pkt.RoutingInfoBufferSize
        ),
        NDRIntField("RoutingInfoBufferSize", None, size_of="RoutingInfoBuffer"),
    ]


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


class FAX_EnumGlobalRoutingInfo_Request(NDRPacket):
    fields_desc = []


class FAX_EnumGlobalRoutingInfo_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "RoutingInfoBuffer", "", size_is=lambda pkt: pkt.RoutingInfoBufferSize
        ),
        NDRIntField("RoutingInfoBufferSize", None, size_of="RoutingInfoBuffer"),
        NDRIntField("MethodsReturned", 0),
        NDRIntField("status", 0),
    ]


class FAX_GLOBAL_ROUTING_INFOW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("SizeOfStruct", 0),
        NDRIntField("Priority", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("Guid", ""), deferred=True),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("FriendlyName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("FunctionName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ExtensionImageName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ExtensionFriendlyName", ""), deferred=True
        ),
    ]


class FAX_SetGlobalRoutingInfo_Request(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "RoutingInfo", FAX_GLOBAL_ROUTING_INFOW(), FAX_GLOBAL_ROUTING_INFOW
        )
    ]


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


class FAX_GetConfiguration_Request(NDRPacket):
    fields_desc = []


class FAX_GetConfiguration_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_TIME(NDRPacket):
    ALIGNMENT = (2, 2)
    fields_desc = [NDRShortField("Hour", 0), NDRShortField("Minute", 0)]


class FAX_CONFIGURATIONW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("SizeOfStruct", 0),
        NDRIntField("Retries", 0),
        NDRIntField("RetryDelay", 0),
        NDRIntField("DirtyDays", 0),
        NDRSignedIntField("Branding", 0),
        NDRSignedIntField("UseDeviceTsid", 0),
        NDRSignedIntField("ServerCp", 0),
        NDRSignedIntField("PauseServerQueue", 0),
        NDRPacketField("StartCheapTime", FAX_TIME(), FAX_TIME),
        NDRPacketField("StopCheapTime", FAX_TIME(), FAX_TIME),
        NDRSignedIntField("ArchiveOutgoingFaxes", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ArchiveDirectory", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("ProfileName", ""), deferred=True
        ),
    ]


class FAX_SetConfiguration_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("FaxConfig", FAX_CONFIGURATIONW(), FAX_CONFIGURATIONW)
    ]


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


class FAX_GetLoggingCategories_Request(NDRPacket):
    fields_desc = []


class FAX_GetLoggingCategories_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("NumberCategories", 0),
        NDRIntField("status", 0),
    ]


class FAX_SetLoggingCategories_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(
            NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize)
        ),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("NumberCategories", 0),
    ]


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


class FAX_GetSecurity_Request(NDRPacket):
    fields_desc = []


class FAX_GetSecurity_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "pSecurityDescriptor", "", size_is=lambda pkt: pkt.lpdwBufferSize
        ),
        NDRIntField("lpdwBufferSize", None, size_of="pSecurityDescriptor"),
        NDRIntField("status", 0),
    ]


class FAX_SetSecurity_Request(NDRPacket):
    fields_desc = [
        NDRIntField("SecurityInformation", 0),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor", "", size_is=lambda pkt: pkt.dwBufferSize
            )
        ),
        NDRIntField("dwBufferSize", None, size_of="pSecurityDescriptor"),
    ]


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


class FAX_AccessCheck_Request(NDRPacket):
    fields_desc = [
        NDRIntField("AccessMask", 0),
        NDRFullPointerField(NDRIntField("lpdwRights", 0)),
    ]


class FAX_AccessCheck_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("pfAccess", 0),
        NDRFullPointerField(NDRIntField("lpdwRights", 0)),
        NDRIntField("status", 0),
    ]


class FAX_CheckServerProtSeq_Request(NDRPacket):
    fields_desc = [NDRFullPointerField(NDRIntField("lpdwProtSeq", 0))]


class FAX_CheckServerProtSeq_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRIntField("lpdwProtSeq", 0)),
        NDRIntField("status", 0),
    ]


class LPCFAX_COVERPAGE_INFO_EXW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRIntField("dwCoverPageFormat", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrCoverPageFileName", ""), deferred=True
        ),
        NDRSignedIntField("bServerBased", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrNote", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrSubject", ""), deferred=True
        ),
    ]


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 FAX_ENUM_PRIORITY_TYPE(IntEnum):
    FAX_PRIORITY_TYPE_LOW = 0
    FAX_PRIORITY_TYPE_NORMAL = 1
    FAX_PRIORITY_TYPE_HIGH = 2


class LPCFAX_JOB_PARAM_EXW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRIntField("dwScheduleAction", 0),
        NDRPacketField("tmSchedule", SYSTEMTIME(), SYSTEMTIME),
        NDRIntField("dwReceiptDeliveryType", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrReceiptDeliveryAddress", ""),
            deferred=True,
        ),
        NDRInt3264EnumField("Priority", 0, FAX_ENUM_PRIORITY_TYPE),
        NDRIntField("hCall", 0),
        NDRFieldListField(
            "dwReserved", [], NDRInt3264Field("", 0), length_is=lambda _: 4
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrDocumentName", ""), deferred=True
        ),
        NDRIntField("dwPageCount", 0),
    ]


class FAX_SendDocumentEx_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpcwstrFileName", "")),
        NDRPacketField(
            "lpcCoverPageInfo", LPCFAX_COVERPAGE_INFO_EXW(), LPCFAX_COVERPAGE_INFO_EXW
        ),
        NDRByteField("lpcSenderProfile", 0),
        NDRIntField("dwNumRecipients", None, size_of="lpcRecipientList"),
        NDRConfStrLenField(
            "lpcRecipientList", "", size_is=lambda pkt: pkt.dwNumRecipients
        ),
        NDRPacketField("lpJobParams", LPCFAX_JOB_PARAM_EXW(), LPCFAX_JOB_PARAM_EXW),
        NDRFullPointerField(NDRIntField("lpdwJobId", 0)),
    ]


class FAX_SendDocumentEx_Response(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRIntField("lpdwJobId", 0)),
        NDRLongField("lpdwlMessageId", 0),
        NDRConfFieldListField(
            "lpdwlRecipientMessageIds",
            [],
            NDRLongField,
            size_is=lambda pkt: pkt.dwNumRecipients,
        ),
        NDRIntField("status", 0),
    ]


class FAX_EnumJobsEx_Request(NDRPacket):
    fields_desc = [NDRIntField("dwJobTypes", 0)]


class FAX_EnumJobsEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("lpdwJobs", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetJobEx_Request(NDRPacket):
    fields_desc = [NDRLongField("dwlMessageID", 0)]


class FAX_GetJobEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_GetCountryList_Request(NDRPacket):
    fields_desc = []


class FAX_GetCountryList_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_ENUM_MESSAGE_FOLDER(IntEnum):
    FAX_MESSAGE_FOLDER_INBOX = 0
    FAX_MESSAGE_FOLDER_SENTITEMS = 1
    FAX_MESSAGE_FOLDER_QUEUE = 2


class FAX_ENUM_PERSONAL_PROF_TYPES(IntEnum):
    RECIPIENT_PERSONAL_PROF = 1
    SENDER_PERSONAL_PROF = 2


class FAX_GetPersonalProfileInfo_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRInt3264EnumField("dwFolder", 0, FAX_ENUM_MESSAGE_FOLDER),
        NDRInt3264EnumField("ProfType", 0, FAX_ENUM_PERSONAL_PROF_TYPES),
    ]


class FAX_GetPersonalProfileInfo_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_GetQueueStates_Request(NDRPacket):
    fields_desc = []


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


class FAX_SetQueue_Request(NDRPacket):
    fields_desc = [NDRIntField("dwQueueStates", 0)]


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


class FAX_GetReceiptsConfiguration_Request(NDRPacket):
    fields_desc = []


class FAX_GetReceiptsConfiguration_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_ENUM_SMTP_AUTH_OPTIONS(IntEnum):
    FAX_SMTP_AUTH_ANONYMOUS = 0
    FAX_SMTP_AUTH_BASIC = 1
    FAX_SMTP_AUTH_NTLM = 2


class PFAX_RECEIPTS_CONFIGW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRIntField("dwAllowedReceipts", 0),
        NDRInt3264EnumField("SMTPAuthOption", 0, FAX_ENUM_SMTP_AUTH_OPTIONS),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrReserved", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrSMTPServer", ""), deferred=True
        ),
        NDRIntField("dwSMTPPort", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrSMTPFrom", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrSMTPUserName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrSMTPPassword", ""), deferred=True
        ),
        NDRSignedIntField("bIsToUseForMSRouteThroughEmailMethod", 0),
    ]


class FAX_SetReceiptsConfiguration_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pReceipts", PFAX_RECEIPTS_CONFIGW(), PFAX_RECEIPTS_CONFIGW)
    ]


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


class FAX_GetReceiptsOptions_Request(NDRPacket):
    fields_desc = []


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


class PFAX_VERSION(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRSignedIntField("bValid", 0),
        NDRShortField("wMajorVersion", 0),
        NDRShortField("wMinorVersion", 0),
        NDRShortField("wMajorBuildNumber", 0),
        NDRShortField("wMinorBuildNumber", 0),
        NDRIntField("dwFlags", 0),
    ]


class FAX_GetVersion_Request(NDRPacket):
    fields_desc = [NDRPacketField("pVersion", PFAX_VERSION(), PFAX_VERSION)]


class FAX_GetVersion_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pVersion", PFAX_VERSION(), PFAX_VERSION),
        NDRIntField("status", 0),
    ]


class FAX_GetOutboxConfiguration_Request(NDRPacket):
    fields_desc = []


class FAX_GetOutboxConfiguration_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class PFAX_OUTBOX_CONFIG(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRSignedIntField("bAllowPersonalCP", 0),
        NDRSignedIntField("bUseDeviceTSID", 0),
        NDRIntField("dwRetries", 0),
        NDRIntField("dwRetryDelay", 0),
        NDRPacketField("dtDiscountStart", FAX_TIME(), FAX_TIME),
        NDRPacketField("dtDiscountEnd", FAX_TIME(), FAX_TIME),
        NDRIntField("dwAgeLimit", 0),
        NDRSignedIntField("bBranding", 0),
    ]


class FAX_SetOutboxConfiguration_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pOutboxCfg", PFAX_OUTBOX_CONFIG(), PFAX_OUTBOX_CONFIG)
    ]


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


class FAX_GetPersonalCoverPagesOption_Request(NDRPacket):
    fields_desc = []


class FAX_GetPersonalCoverPagesOption_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("lpbPersonalCPAllowed", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetArchiveConfiguration_Request(NDRPacket):
    fields_desc = [NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER)]


class FAX_GetArchiveConfiguration_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_SetArchiveConfiguration_Request(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
        NDRByteField("pArchiveCfg", 0),
    ]


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


class FAX_GetActivityLoggingConfiguration_Request(NDRPacket):
    fields_desc = []


class FAX_GetActivityLoggingConfiguration_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class PFAX_ACTIVITY_LOGGING_CONFIGW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRSignedIntField("bLogIncoming", 0),
        NDRSignedIntField("bLogOutgoing", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrDBPath", ""), deferred=True
        ),
    ]


class FAX_SetActivityLoggingConfiguration_Request(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "pActivLogCfg",
            PFAX_ACTIVITY_LOGGING_CONFIGW(),
            PFAX_ACTIVITY_LOGGING_CONFIGW,
        )
    ]


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


class FAX_EnumerateProviders_Request(NDRPacket):
    fields_desc = []


class FAX_EnumerateProviders_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("lpdwNumProviders", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetPortEx_Request(NDRPacket):
    fields_desc = [NDRIntField("dwDeviceId", 0)]


class FAX_GetPortEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_ENUM_DEVICE_RECEIVE_MODE(IntEnum):
    FAX_DEVICE_RECEIVE_MODE_OFF = 0
    FAX_DEVICE_RECEIVE_MODE_AUTO = 1
    FAX_DEVICE_RECEIVE_MODE_MANUAL = 2


class PFAX_PORT_INFO_EXW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRIntField("dwDeviceID", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrDeviceName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrDescription", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrProviderName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrProviderGUID", ""), deferred=True
        ),
        NDRSignedIntField("bSend", 0),
        NDRInt3264EnumField("ReceiveMode", 0, FAX_ENUM_DEVICE_RECEIVE_MODE),
        NDRIntField("dwStatus", 0),
        NDRIntField("dwRings", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrCsid", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrTsid", ""), deferred=True
        ),
    ]


class FAX_SetPortEx_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwDeviceId", 0),
        NDRPacketField("pPortInfo", PFAX_PORT_INFO_EXW(), PFAX_PORT_INFO_EXW),
    ]


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


class FAX_EnumPortsEx_Request(NDRPacket):
    fields_desc = []


class FAX_EnumPortsEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("lpdwNumPorts", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetExtensionData_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwDeviceId", 0),
        NDRConfVarStrNullFieldUtf16("lpcwstrNameGUID", ""),
    ]


class FAX_GetExtensionData_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("ppData", "", size_is=lambda pkt: pkt.lpdwDataSize),
        NDRIntField("lpdwDataSize", None, size_of="ppData"),
        NDRIntField("status", 0),
    ]


class FAX_SetExtensionData_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpcwstrComputerName", ""),
        NDRIntField("dwDeviceId", 0),
        NDRConfVarStrNullFieldUtf16("lpcwstrNameGUID", ""),
        NDRConfStrLenField("pData", "", size_is=lambda pkt: pkt.dwDataSize),
        NDRIntField("dwDataSize", None, size_of="pData"),
    ]


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


class FAX_AddOutboundGroup_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("lpwstrGroupName", "")]


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


class FAX_ENUM_GROUP_STATUS(IntEnum):
    FAX_GROUP_STATUS_ALL_DEV_VALID = 0
    FAX_GROUP_STATUS_EMPTY = 1
    FAX_GROUP_STATUS_ALL_DEV_NOT_VALID = 2
    FAX_GROUP_STATUS_SOME_DEV_NOT_VALID = 3


class PRPC_FAX_OUTBOUND_ROUTING_GROUPW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrGroupName", ""), deferred=True
        ),
        NDRIntField("dwNumDevices", None, size_of="lpdwDevices"),
        NDRFullPointerField(
            NDRConfFieldListField(
                "lpdwDevices", [], NDRIntField, size_is=lambda pkt: pkt.dwNumDevices
            ),
            deferred=True,
        ),
        NDRInt3264EnumField("Status", 0, FAX_ENUM_GROUP_STATUS),
    ]


class FAX_SetOutboundGroup_Request(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "pGroup",
            PRPC_FAX_OUTBOUND_ROUTING_GROUPW(),
            PRPC_FAX_OUTBOUND_ROUTING_GROUPW,
        )
    ]


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


class FAX_RemoveOutboundGroup_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("lpwstrGroupName", "")]


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


class FAX_EnumOutboundGroups_Request(NDRPacket):
    fields_desc = []


class FAX_EnumOutboundGroups_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("ppData", "", size_is=lambda pkt: pkt.lpdwDataSize),
        NDRIntField("lpdwDataSize", None, size_of="ppData"),
        NDRIntField("lpdwNumGroups", 0),
        NDRIntField("status", 0),
    ]


class FAX_SetDeviceOrderInGroup_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpwstrGroupName", ""),
        NDRIntField("dwDeviceId", 0),
        NDRIntField("dwNewOrder", 0),
    ]


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


class FAX_AddOutboundRule_Request(NDRPacket):
    fields_desc = [
        NDRIntField("dwAreaCode", 0),
        NDRIntField("dwCountryCode", 0),
        NDRIntField("dwDeviceId", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpwstrGroupName", "")),
        NDRSignedIntField("bUseGroup", 0),
    ]


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


class FAX_RemoveOutboundRule_Request(NDRPacket):
    fields_desc = [NDRIntField("dwAreaCode", 0), NDRIntField("dwCountryCode", 0)]


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


class RPC_FAX_OUTBOUND_ROUTING_RULEW(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRIntField("dwAreaCode", 0),
        NDRIntField("dwCountryCode", 0),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpwstrCountryName", ""), deferred=True
        ),
        NDRUnionField(
            [
                (
                    NDRIntField("Destination", 0),
                    (
                        (lambda pkt: getattr(pkt, "bUseGroup", None) == 0),
                        (lambda _, val: val.tag == 0),
                    ),
                )
            ],
            NDRFullPointerField(
                NDRConfVarStrNullFieldUtf16("Destination", ""), deferred=True
            ),
            align=(4, 8),
            switch_fmt=("l", "l"),
        ),
        NDRSignedIntField("bUseGroup", 0),
    ]


class FAX_SetOutboundRule_Request(NDRPacket):
    fields_desc = [
        NDRPacketField(
            "pRule", RPC_FAX_OUTBOUND_ROUTING_RULEW(), RPC_FAX_OUTBOUND_ROUTING_RULEW
        )
    ]


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


class FAX_EnumOutboundRules_Request(NDRPacket):
    fields_desc = []


class FAX_EnumOutboundRules_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("ppData", "", size_is=lambda pkt: pkt.lpdwDataSize),
        NDRIntField("lpdwDataSize", None, size_of="ppData"),
        NDRIntField("lpdwNumRules", 0),
        NDRIntField("status", 0),
    ]


class FAX_RegisterServiceProviderEx_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpcwstrGUID", ""),
        NDRConfVarStrNullFieldUtf16("lpcwstrFriendlyName", ""),
        NDRConfVarStrNullFieldUtf16("lpcwstrImageName", ""),
        NDRConfVarStrNullFieldUtf16("lpcwstrTspName", ""),
        NDRIntField("dwFSPIVersion", 0),
        NDRIntField("dwCapabilities", 0),
    ]


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


class FAX_UnregisterServiceProviderEx_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("lpcwstrGUID", "")]


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


class FAX_UnregisterRoutingExtension_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("lpcwstrExtensionName", "")]


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


class FAX_StartMessagesEnum_Request(NDRPacket):
    fields_desc = [NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER)]


class FAX_StartMessagesEnum_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_EndMessagesEnum_Request(NDRPacket):
    fields_desc = [NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle)]


class FAX_EndMessagesEnum_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_EnumMessages_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hEnum", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwNumMessages", 0),
    ]


class FAX_EnumMessages_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lppBuffer", "", size_is=lambda pkt: pkt.lpdwBufferSize),
        NDRIntField("lpdwBufferSize", None, size_of="lppBuffer"),
        NDRIntField("lpdwNumMessagesRetrieved", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetMessage_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
    ]


class FAX_GetMessage_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lppBuffer", "", size_is=lambda pkt: pkt.lpdwBufferSize),
        NDRIntField("lpdwBufferSize", None, size_of="lppBuffer"),
        NDRIntField("status", 0),
    ]


class FAX_RemoveMessage_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
    ]


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


class FAX_StartCopyToServer_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpcwstrFileExt", ""),
        NDRConfVarStrNullFieldUtf16("lpwstrServerFileName", ""),
    ]


class FAX_StartCopyToServer_Response(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpwstrServerFileName", ""),
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_StartCopyMessageFromServer_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
    ]


class FAX_StartCopyMessageFromServer_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_WriteFile_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hCopy", NDRContextHandle(), NDRContextHandle),
        NDRConfStrLenField("lpbData", "", size_is=lambda pkt: pkt.dwDataSize),
        NDRIntField("dwDataSize", None, size_of="lpbData"),
    ]


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


class FAX_ReadFile_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hCopy", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwMaxDataSize", 0),
        NDRIntField("lpdwDataSize", 0),
    ]


class FAX_ReadFile_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lpbData", "", size_is=lambda pkt: pkt.lpdwDataSize),
        NDRIntField("lpdwDataSize", None, size_of="lpbData"),
        NDRIntField("status", 0),
    ]


class FAX_EndCopy_Request(NDRPacket):
    fields_desc = [NDRPacketField("lphCopy", NDRContextHandle(), NDRContextHandle)]


class FAX_EndCopy_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lphCopy", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_StartServerNotification_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpcwstrMachineName", ""),
        NDRConfVarStrNullFieldUtf16("lpcwstrEndPoint", ""),
        NDRLongField("Context", 0),
        NDRConfVarStrNullFieldUtf16("lpcwstrProtseqString", ""),
        NDRSignedIntField("bEventEx", 0),
        NDRIntField("dwEventTypes", 0),
    ]


class FAX_StartServerNotification_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_StartServerNotificationEx_Request(NDRPacket):
    fields_desc = [
        NDRConfVarStrNullFieldUtf16("lpcwstrMachineName", ""),
        NDRConfVarStrNullFieldUtf16("lpcwstrEndPoint", ""),
        NDRLongField("Context", 0),
        NDRConfVarStrNullFieldUtf16("lpcwstrProtSeq", ""),
        NDRSignedIntField("bEventEx", 0),
        NDRIntField("dwEventTypes", 0),
    ]


class FAX_StartServerNotificationEx_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_EndServerNotification_Request(NDRPacket):
    fields_desc = [NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle)]


class FAX_EndServerNotification_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class PFAX_SERVER_ACTIVITY(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [
        NDRIntField("dwSizeOfStruct", 0),
        NDRIntField("dwIncomingMessages", 0),
        NDRIntField("dwRoutingMessages", 0),
        NDRIntField("dwOutgoingMessages", 0),
        NDRIntField("dwDelegatedOutgoingMessages", 0),
        NDRIntField("dwQueuedMessages", 0),
        NDRIntField("dwErrorEvents", 0),
        NDRIntField("dwWarningEvents", 0),
        NDRIntField("dwInformationEvents", 0),
    ]


class FAX_GetServerActivity_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("pServerActivity", PFAX_SERVER_ACTIVITY(), PFAX_SERVER_ACTIVITY)
    ]


class FAX_GetServerActivity_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("pServerActivity", PFAX_SERVER_ACTIVITY(), PFAX_SERVER_ACTIVITY),
        NDRIntField("status", 0),
    ]


class FAX_SetConfigWizardUsed_Request(NDRPacket):
    fields_desc = [NDRSignedIntField("bConfigWizardUsed", 0)]


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


class FAX_EnumRoutingExtensions_Request(NDRPacket):
    fields_desc = []


class FAX_EnumRoutingExtensions_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("lpdwNumExts", 0),
        NDRIntField("status", 0),
    ]


class FAX_ConnectFaxServer_Request(NDRPacket):
    fields_desc = [NDRIntField("dwClientAPIVersion", 0)]


class FAX_ConnectFaxServer_Response(NDRPacket):
    fields_desc = [
        NDRIntField("lpdwServerAPIVersion", 0),
        NDRPacketField("pHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_GetSecurityEx_Request(NDRPacket):
    fields_desc = [NDRIntField("SecurityInformation", 0)]


class FAX_GetSecurityEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "pSecurityDescriptor", "", size_is=lambda pkt: pkt.lpdwBufferSize
        ),
        NDRIntField("lpdwBufferSize", None, size_of="pSecurityDescriptor"),
        NDRIntField("status", 0),
    ]


class FAX_RefreshArchive_Request(NDRPacket):
    fields_desc = [NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER)]


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


class FAX_SetRecipientsLimit_Request(NDRPacket):
    fields_desc = [NDRIntField("dwRecipientsLimit", 0)]


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


class FAX_GetRecipientsLimit_Request(NDRPacket):
    fields_desc = []


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


class PRODUCT_SKU_TYPE(IntEnum):
    PRODUCT_SKU_UNKNOWN = 0
    PRODUCT_SKU_PERSONAL = 1
    PRODUCT_SKU_PROFESSIONAL = 2
    PRODUCT_SKU_SERVER = 4
    PRODUCT_SKU_ADVANCED_SERVER = 8
    PRODUCT_SKU_DATA_CENTER = 16
    PRODUCT_SKU_DESKTOP_EMBEDDED = 32
    PRODUCT_SKU_SERVER_EMBEDDED = 64
    PRODUCT_SKU_WEB_SERVER = 128


class FAX_GetServerSKU_Request(NDRPacket):
    fields_desc = []


class FAX_GetServerSKU_Response(NDRPacket):
    fields_desc = [
        NDRInt3264EnumField("pServerSKU", 0, PRODUCT_SKU_TYPE),
        NDRIntField("status", 0),
    ]


class FAX_CheckValidFaxFolder_Request(NDRPacket):
    fields_desc = [NDRConfVarStrNullFieldUtf16("lpcwstrPath", "")]


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


class FAX_GetJobEx2_Request(NDRPacket):
    fields_desc = [NDRLongField("dwlMessageID", 0), NDRIntField("level", 0)]


class FAX_GetJobEx2_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_EnumJobsEx2_Request(NDRPacket):
    fields_desc = [
        NDRSignedIntField("fAllAccounts", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpcwstrAccountName", "")),
        NDRIntField("dwJobTypes", 0),
        NDRIntField("level", 0),
    ]


class FAX_EnumJobsEx2_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("lpdwJobs", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetMessageEx_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
        NDRIntField("level", 0),
    ]


class FAX_GetMessageEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lppBuffer", "", size_is=lambda pkt: pkt.lpdwBufferSize),
        NDRIntField("lpdwBufferSize", None, size_of="lppBuffer"),
        NDRIntField("status", 0),
    ]


class FAX_StartMessagesEnumEx_Request(NDRPacket):
    fields_desc = [
        NDRSignedIntField("fAllAccounts", 0),
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpcwstrAccountName", "")),
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
        NDRIntField("level", 0),
    ]


class FAX_StartMessagesEnumEx_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_EnumMessagesEx_Request(NDRPacket):
    fields_desc = [
        NDRPacketField("hEnum", NDRContextHandle(), NDRContextHandle),
        NDRIntField("dwNumMessages", 0),
    ]


class FAX_EnumMessagesEx_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("lppBuffer", "", size_is=lambda pkt: pkt.lpdwBufferSize),
        NDRIntField("lpdwBufferSize", None, size_of="lppBuffer"),
        NDRIntField("lpdwNumMessagesRetrieved", 0),
        NDRIntField("lpdwLevel", 0),
        NDRIntField("status", 0),
    ]


class FAX_StartServerNotificationEx2_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpcwstrAccountName", "")),
        NDRConfVarStrNullFieldUtf16("lpcwstrMachineName", ""),
        NDRConfVarStrNullFieldUtf16("lpcwstrEndPoint", ""),
        NDRLongField("Context", 0),
        NDRConfVarStrNullFieldUtf16("lpcwstrProtseqString", ""),
        NDRIntField("dwEventTypes", 0),
        NDRIntField("level", 0),
    ]


class FAX_StartServerNotificationEx2_Response(NDRPacket):
    fields_desc = [
        NDRPacketField("lpHandle", NDRContextHandle(), NDRContextHandle),
        NDRIntField("status", 0),
    ]


class FAX_CreateAccount_Request(NDRPacket):
    fields_desc = [
        NDRIntField("level", 0),
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
    ]


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


class FAX_DeleteAccount_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpcwstrAccountName", ""))
    ]


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


class FAX_EnumAccounts_Request(NDRPacket):
    fields_desc = [NDRIntField("level", 0)]


class FAX_EnumAccounts_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("lpdwAccounts", 0),
        NDRIntField("status", 0),
    ]


class FAX_GetAccountInfo_Request(NDRPacket):
    fields_desc = [
        NDRFullPointerField(NDRConfVarStrNullFieldUtf16("lpcwstrAccountName", "")),
        NDRIntField("level", 0),
    ]


class FAX_GetAccountInfo_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_GetGeneralConfiguration_Request(NDRPacket):
    fields_desc = [NDRIntField("level", 0)]


class FAX_GetGeneralConfiguration_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
        NDRIntField("status", 0),
    ]


class FAX_SetGeneralConfiguration_Request(NDRPacket):
    fields_desc = [
        NDRIntField("level", 0),
        NDRConfStrLenField("Buffer", "", size_is=lambda pkt: pkt.BufferSize),
        NDRIntField("BufferSize", None, size_of="Buffer"),
    ]


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


class FAX_GetSecurityEx2_Request(NDRPacket):
    fields_desc = [NDRIntField("SecurityInformation", 0)]


class FAX_GetSecurityEx2_Response(NDRPacket):
    fields_desc = [
        NDRConfStrLenField(
            "pSecurityDescriptor", "", size_is=lambda pkt: pkt.lpdwBufferSize
        ),
        NDRIntField("lpdwBufferSize", None, size_of="pSecurityDescriptor"),
        NDRIntField("status", 0),
    ]


class FAX_SetSecurityEx2_Request(NDRPacket):
    fields_desc = [
        NDRIntField("SecurityInformation", 0),
        NDRFullPointerField(
            NDRConfStrLenField(
                "pSecurityDescriptor", "", size_is=lambda pkt: pkt.dwBufferSize
            )
        ),
        NDRIntField("dwBufferSize", None, size_of="pSecurityDescriptor"),
    ]


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


class FAX_AccessCheckEx2_Request(NDRPacket):
    fields_desc = [
        NDRIntField("AccessMask", 0),
        NDRFullPointerField(NDRIntField("lpdwRights", 0)),
    ]


class FAX_AccessCheckEx2_Response(NDRPacket):
    fields_desc = [
        NDRSignedIntField("pfAccess", 0),
        NDRFullPointerField(NDRIntField("lpdwRights", 0)),
        NDRIntField("status", 0),
    ]


class PFAX_REASSIGN_INFO(NDRPacket):
    ALIGNMENT = (4, 8)
    fields_desc = [
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrRecipients", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrSenderName", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrSenderFaxNumber", ""), deferred=True
        ),
        NDRFullPointerField(
            NDRConfVarStrNullFieldUtf16("lpcwstrSubject", ""), deferred=True
        ),
        NDRSignedIntField("bHasCoverPage", 0),
    ]


class FAX_ReAssignMessage_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRPacketField("pReAssignInfo", PFAX_REASSIGN_INFO(), PFAX_REASSIGN_INFO),
    ]


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


class PFAX_MESSAGE_PROPS(NDRPacket):
    ALIGNMENT = (4, 4)
    fields_desc = [NDRIntField("dwValidityMask", 0), NDRIntField("dwMsgFlags", 0)]


class FAX_SetMessage_Request(NDRPacket):
    fields_desc = [
        NDRLongField("dwlMessageId", 0),
        NDRInt3264EnumField("Folder", 0, FAX_ENUM_MESSAGE_FOLDER),
        NDRPacketField("lpMessageProps", PFAX_MESSAGE_PROPS(), PFAX_MESSAGE_PROPS),
    ]


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


class FAX_ENUM_CONFIG_OPTION(IntEnum):
    FAX_CONFIG_OPTION_ALLOW_PERSONAL_CP = 0
    FAX_CONFIG_OPTION_QUEUE_STATE = 1
    FAX_CONFIG_OPTION_ALLOWED_RECEIPTS = 2
    FAX_CONFIG_OPTION_INCOMING_FAXES_PUBLIC = 3


class FAX_GetConfigOption_Request(NDRPacket):
    fields_desc = [NDRInt3264EnumField("option", 0, FAX_ENUM_CONFIG_OPTION)]


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


FAX_OPNUMS = {
    0: DceRpcOp(FAX_GetServicePrinters_Request, FAX_GetServicePrinters_Response),
    1: DceRpcOp(FAX_ConnectionRefCount_Request, FAX_ConnectionRefCount_Response),
    2: DceRpcOp(FAX_OpenPort_Request, FAX_OpenPort_Response),
    3: DceRpcOp(FAX_ClosePort_Request, FAX_ClosePort_Response),
    4: DceRpcOp(FAX_EnumJobs_Request, FAX_EnumJobs_Response),
    5: DceRpcOp(FAX_GetJob_Request, FAX_GetJob_Response),
    6: DceRpcOp(FAX_SetJob_Request, FAX_SetJob_Response),
    7: DceRpcOp(FAX_GetPageData_Request, FAX_GetPageData_Response),
    8: DceRpcOp(FAX_GetDeviceStatus_Request, FAX_GetDeviceStatus_Response),
    9: DceRpcOp(FAX_Abort_Request, FAX_Abort_Response),
    10: DceRpcOp(FAX_EnumPorts_Request, FAX_EnumPorts_Response),
    11: DceRpcOp(FAX_GetPort_Request, FAX_GetPort_Response),
    12: DceRpcOp(FAX_SetPort_Request, FAX_SetPort_Response),
    13: DceRpcOp(FAX_EnumRoutingMethods_Request, FAX_EnumRoutingMethods_Response),
    14: DceRpcOp(FAX_EnableRoutingMethod_Request, FAX_EnableRoutingMethod_Response),
    15: DceRpcOp(FAX_GetRoutingInfo_Request, FAX_GetRoutingInfo_Response),
    16: DceRpcOp(FAX_SetRoutingInfo_Request, FAX_SetRoutingInfo_Response),
    17: DceRpcOp(FAX_EnumGlobalRoutingInfo_Request, FAX_EnumGlobalRoutingInfo_Response),
    18: DceRpcOp(FAX_SetGlobalRoutingInfo_Request, FAX_SetGlobalRoutingInfo_Response),
    19: DceRpcOp(FAX_GetConfiguration_Request, FAX_GetConfiguration_Response),
    20: DceRpcOp(FAX_SetConfiguration_Request, FAX_SetConfiguration_Response),
    21: DceRpcOp(FAX_GetLoggingCategories_Request, FAX_GetLoggingCategories_Response),
    22: DceRpcOp(FAX_SetLoggingCategories_Request, FAX_SetLoggingCategories_Response),
    23: DceRpcOp(FAX_GetSecurity_Request, FAX_GetSecurity_Response),
    24: DceRpcOp(FAX_SetSecurity_Request, FAX_SetSecurity_Response),
    25: DceRpcOp(FAX_AccessCheck_Request, FAX_AccessCheck_Response),
    26: DceRpcOp(FAX_CheckServerProtSeq_Request, FAX_CheckServerProtSeq_Response),
    27: DceRpcOp(FAX_SendDocumentEx_Request, FAX_SendDocumentEx_Response),
    28: DceRpcOp(FAX_EnumJobsEx_Request, FAX_EnumJobsEx_Response),
    29: DceRpcOp(FAX_GetJobEx_Request, FAX_GetJobEx_Response),
    30: DceRpcOp(FAX_GetCountryList_Request, FAX_GetCountryList_Response),
    31: DceRpcOp(
        FAX_GetPersonalProfileInfo_Request, FAX_GetPersonalProfileInfo_Response
    ),
    32: DceRpcOp(FAX_GetQueueStates_Request, FAX_GetQueueStates_Response),
    33: DceRpcOp(FAX_SetQueue_Request, FAX_SetQueue_Response),
    34: DceRpcOp(
        FAX_GetReceiptsConfiguration_Request, FAX_GetReceiptsConfiguration_Response
    ),
    35: DceRpcOp(
        FAX_SetReceiptsConfiguration_Request, FAX_SetReceiptsConfiguration_Response
    ),
    36: DceRpcOp(FAX_GetReceiptsOptions_Request, FAX_GetReceiptsOptions_Response),
    37: DceRpcOp(FAX_GetVersion_Request, FAX_GetVersion_Response),
    38: DceRpcOp(
        FAX_GetOutboxConfiguration_Request, FAX_GetOutboxConfiguration_Response
    ),
    39: DceRpcOp(
        FAX_SetOutboxConfiguration_Request, FAX_SetOutboxConfiguration_Response
    ),
    40: DceRpcOp(
        FAX_GetPersonalCoverPagesOption_Request,
        FAX_GetPersonalCoverPagesOption_Response,
    ),
    41: DceRpcOp(
        FAX_GetArchiveConfiguration_Request, FAX_GetArchiveConfiguration_Response
    ),
    42: DceRpcOp(
        FAX_SetArchiveConfiguration_Request, FAX_SetArchiveConfiguration_Response
    ),
    43: DceRpcOp(
        FAX_GetActivityLoggingConfiguration_Request,
        FAX_GetActivityLoggingConfiguration_Response,
    ),
    44: DceRpcOp(
        FAX_SetActivityLoggingConfiguration_Request,
        FAX_SetActivityLoggingConfiguration_Response,
    ),
    45: DceRpcOp(FAX_EnumerateProviders_Request, FAX_EnumerateProviders_Response),
    46: DceRpcOp(FAX_GetPortEx_Request, FAX_GetPortEx_Response),
    47: DceRpcOp(FAX_SetPortEx_Request, FAX_SetPortEx_Response),
    48: DceRpcOp(FAX_EnumPortsEx_Request, FAX_EnumPortsEx_Response),
    49: DceRpcOp(FAX_GetExtensionData_Request, FAX_GetExtensionData_Response),
    50: DceRpcOp(FAX_SetExtensionData_Request, FAX_SetExtensionData_Response),
    51: DceRpcOp(FAX_AddOutboundGroup_Request, FAX_AddOutboundGroup_Response),
    52: DceRpcOp(FAX_SetOutboundGroup_Request, FAX_SetOutboundGroup_Response),
    53: DceRpcOp(FAX_RemoveOutboundGroup_Request, FAX_RemoveOutboundGroup_Response),
    54: DceRpcOp(FAX_EnumOutboundGroups_Request, FAX_EnumOutboundGroups_Response),
    55: DceRpcOp(FAX_SetDeviceOrderInGroup_Request, FAX_SetDeviceOrderInGroup_Response),
    56: DceRpcOp(FAX_AddOutboundRule_Request, FAX_AddOutboundRule_Response),
    57: DceRpcOp(FAX_RemoveOutboundRule_Request, FAX_RemoveOutboundRule_Response),
    58: DceRpcOp(FAX_SetOutboundRule_Request, FAX_SetOutboundRule_Response),
    59: DceRpcOp(FAX_EnumOutboundRules_Request, FAX_EnumOutboundRules_Response),
    60: DceRpcOp(
        FAX_RegisterServiceProviderEx_Request, FAX_RegisterServiceProviderEx_Response
    ),
    61: DceRpcOp(
        FAX_UnregisterServiceProviderEx_Request,
        FAX_UnregisterServiceProviderEx_Response,
    ),
    62: DceRpcOp(
        FAX_UnregisterRoutingExtension_Request, FAX_UnregisterRoutingExtension_Response
    ),
    63: DceRpcOp(FAX_StartMessagesEnum_Request, FAX_StartMessagesEnum_Response),
    64: DceRpcOp(FAX_EndMessagesEnum_Request, FAX_EndMessagesEnum_Response),
    65: DceRpcOp(FAX_EnumMessages_Request, FAX_EnumMessages_Response),
    66: DceRpcOp(FAX_GetMessage_Request, FAX_GetMessage_Response),
    67: DceRpcOp(FAX_RemoveMessage_Request, FAX_RemoveMessage_Response),
    68: DceRpcOp(FAX_StartCopyToServer_Request, FAX_StartCopyToServer_Response),
    69: DceRpcOp(
        FAX_StartCopyMessageFromServer_Request, FAX_StartCopyMessageFromServer_Response
    ),
    70: DceRpcOp(FAX_WriteFile_Request, FAX_WriteFile_Response),
    71: DceRpcOp(FAX_ReadFile_Request, FAX_ReadFile_Response),
    72: DceRpcOp(FAX_EndCopy_Request, FAX_EndCopy_Response),
    73: DceRpcOp(
        FAX_StartServerNotification_Request, FAX_StartServerNotification_Response
    ),
    74: DceRpcOp(
        FAX_StartServerNotificationEx_Request, FAX_StartServerNotificationEx_Response
    ),
    75: DceRpcOp(FAX_EndServerNotification_Request, FAX_EndServerNotification_Response),
    76: DceRpcOp(FAX_GetServerActivity_Request, FAX_GetServerActivity_Response),
    77: DceRpcOp(FAX_SetConfigWizardUsed_Request, FAX_SetConfigWizardUsed_Response),
    78: DceRpcOp(FAX_EnumRoutingExtensions_Request, FAX_EnumRoutingExtensions_Response),
    79: DceRpcOp(FAX_ConnectFaxServer_Request, FAX_ConnectFaxServer_Response),
    80: DceRpcOp(FAX_GetSecurityEx_Request, FAX_GetSecurityEx_Response),
    81: DceRpcOp(FAX_RefreshArchive_Request, FAX_RefreshArchive_Response),
    82: DceRpcOp(FAX_SetRecipientsLimit_Request, FAX_SetRecipientsLimit_Response),
    83: DceRpcOp(FAX_GetRecipientsLimit_Request, FAX_GetRecipientsLimit_Response),
    84: DceRpcOp(FAX_GetServerSKU_Request, FAX_GetServerSKU_Response),
    85: DceRpcOp(FAX_CheckValidFaxFolder_Request, FAX_CheckValidFaxFolder_Response),
    86: DceRpcOp(FAX_GetJobEx2_Request, FAX_GetJobEx2_Response),
    87: DceRpcOp(FAX_EnumJobsEx2_Request, FAX_EnumJobsEx2_Response),
    88: DceRpcOp(FAX_GetMessageEx_Request, FAX_GetMessageEx_Response),
    89: DceRpcOp(FAX_StartMessagesEnumEx_Request, FAX_StartMessagesEnumEx_Response),
    90: DceRpcOp(FAX_EnumMessagesEx_Request, FAX_EnumMessagesEx_Response),
    91: DceRpcOp(
        FAX_StartServerNotificationEx2_Request, FAX_StartServerNotificationEx2_Response
    ),
    92: DceRpcOp(FAX_CreateAccount_Request, FAX_CreateAccount_Response),
    93: DceRpcOp(FAX_DeleteAccount_Request, FAX_DeleteAccount_Response),
    94: DceRpcOp(FAX_EnumAccounts_Request, FAX_EnumAccounts_Response),
    95: DceRpcOp(FAX_GetAccountInfo_Request, FAX_GetAccountInfo_Response),
    96: DceRpcOp(
        FAX_GetGeneralConfiguration_Request, FAX_GetGeneralConfiguration_Response
    ),
    97: DceRpcOp(
        FAX_SetGeneralConfiguration_Request, FAX_SetGeneralConfiguration_Response
    ),
    98: DceRpcOp(FAX_GetSecurityEx2_Request, FAX_GetSecurityEx2_Response),
    99: DceRpcOp(FAX_SetSecurityEx2_Request, FAX_SetSecurityEx2_Response),
    100: DceRpcOp(FAX_AccessCheckEx2_Request, FAX_AccessCheckEx2_Response),
    101: DceRpcOp(FAX_ReAssignMessage_Request, FAX_ReAssignMessage_Response),
    102: DceRpcOp(FAX_SetMessage_Request, FAX_SetMessage_Response),
    103: DceRpcOp(FAX_GetConfigOption_Request, FAX_GetConfigOption_Response),
}
register_dcerpc_interface(
    name="fax",
    uuid=uuid.UUID("ea0a3165-4834-11d2-a6f8-00c04fa346cc"),
    version="4.0",
    opnums=FAX_OPNUMS,
)
