⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 irsirp.h

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 H
字号:
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.
Copyright (c) 1995-1998  Microsoft Corporation

Module Name:

    irsirp.h

Abstract:

    This file contains the IrDA Serial IR NDIS MAC driver
    definitions.  This is provided as a sample to platform writers and is
    expected to be able to be used without modification on most (if not
    all) hardware platforms.

Functions:


Notes:


--*/

#ifndef _IRSIRP_H_
#define _IRSIRP_H_

#include <windows.h>
#include <ndis.h>
#include <ntddndis.h>
#include <linklist.h>
#include <ceddk.h>

#include "irmacutl.h"

#include "mem.h"
#include "dongle.h"
#include "device.h"
#include "settings.h"
#include "externs.h"
#include "esi.h"
#include "fir.h"

#ifdef DEBUG
#define ZONE_INIT       DEBUGZONE(0)
#define ZONE_FCS        DEBUGZONE(1)
#define ZONE_RECV       DEBUGZONE(2)
#define ZONE_SEND       DEBUGZONE(3)
#define ZONE_SETINFO    DEBUGZONE(4)
#define ZONE_QUERYINFO  DEBUGZONE(5)
#define ZONE_DONGLE     DEBUGZONE(6)
#define ZONE_SNIFFIR    DEBUGZONE(7) // Decodes TX/RX IR packets.
#define ZONE_RAWRXTX    DEBUGZONE(8) // Shows raw RX/TX packets with BOFS/EOF..
#define ZONE_COMMMASK   DEBUGZONE(9) // Changing state of comm mask.
#define ZONE_MISC       DEBUGZONE(11)
#define ZONE_ALLOC      DEBUGZONE(12)
#define ZONE_FUNCTION   DEBUGZONE(13)
#define ZONE_WARN       DEBUGZONE(14)
#define ZONE_ERROR      DEBUGZONE(15)
#endif

//
// NDIS compatibility version.
//

#define NDIS_MAJOR_VERSION 0x04
#define NDIS_MINOR_VERSION 0x00

//
// IRSIR compatibility version.
//

#define IRSIR_MAJOR_VERSION 0x01
#define IRSIR_MINOR_VERSION 0x00

//
// Logging capabilities.
//

#ifdef LOGDEV
#include "logdev.h"

#define LOG_TXFRAME     LOG_SUBTYPE_IRSIR_TX
#define LOG_RXFRAME     LOG_SUBTYPE_IRSIR_RX

#define IRSIR_LOG_INIT() LogInit()

__inline VOID IRSIR_LOG_DATA(
    USHORT wSubType,
    USHORT wDataType,
    USHORT wLength,
    PBYTE  pData
    )
{
    LogData(LOG_TYPE_IRDA,
            wSubType,
            wDataType,
            wLength,
            pData);
}

__inline VOID 
IRSIR_LOG_NDIS_PACKET(
    IN UINT         FrameType,                        
    IN PNDIS_PACKET pNdisPacket
    )
{
    BYTE         pbContigBuf[MAX_NDIS_DATA_SIZE];
    PNDIS_BUFFER pNdisBuffer;
    DWORD        cbNdisPacket;
    DWORD        cbContigBuf;

    NdisQueryPacket(pNdisPacket, NULL, NULL, &pNdisBuffer, &cbNdisPacket);

    if (cbNdisPacket > MAX_NDIS_DATA_SIZE)
    {
        IRSIR_LOG_DATA(FrameType, 
                       LOG_DTYPE_ASCII,
                       0,
                       "Ndis packet too large to log.");
        return;
    }

    cbContigBuf = 0;
    while (pNdisBuffer)
    {
        PVOID pData;
        DWORD cbData;

        NdisQueryBuffer(pNdisBuffer, &pData, &cbData);

        if ((cbContigBuf + cbData) > cbNdisPacket)
        {
            // Packet was corrupt - misreported its size.
            IRSIR_LOG_DATA(FrameType,
                           LOG_DTYPE_ASCII,
                           0,
                           "Ndis packet misreported its size");
            return;
        }

        NdisMoveMemory((PVOID)(pbContigBuf + cbContigBuf), pData, cbData);
        cbContigBuf += cbData;

        NdisGetNextBuffer(pNdisBuffer, &pNdisBuffer);
    }

    IRSIR_LOG_DATA(FrameType,
                   LOG_DTYPE_IR_DATA,
                   (USHORT)cbContigBuf,
                   pbContigBuf);

    return;
}

#else // LOGDEV

#define LOG_TXFRAME     0
#define LOG_RXFRAME     0

#define IRSIR_LOG_INIT()                                    (0)
#define IRSIR_LOG_DATA(wSubType, wDataType, wLength, pData) (0)
#define IRSIR_LOG_NDIS_PACKET(d, _pNdisPacket)              (0)

#endif // !LOGDEV

#ifdef DEBUG

#define DEBUG_PACKET(zone, pNdisPacket) if (zone) DebugNdisPacket(pNdisPacket)

__inline VOID 
DebugNdisPacket(
    IN PNDIS_PACKET pNdisPacket
    )
{
    BYTE         pbContigBuf[MAX_NDIS_DATA_SIZE];
    TCHAR        lpszOut[4096];
    PNDIS_BUFFER pNdisBuffer;
    DWORD        cbNdisPacket;
    DWORD        cbContigBuf;
    DWORD        FrameType;

    NdisQueryPacket(pNdisPacket, NULL, NULL, &pNdisBuffer, &cbNdisPacket);

    if (cbNdisPacket > MAX_NDIS_DATA_SIZE)
    {
        DEBUGMSG(ZONE_SNIFFIR,
            (TEXT("Ndis packet too large to dump!!\r\n")));
        return;
    }

    cbContigBuf = 0;
    while (pNdisBuffer)
    {
        PVOID pData;
        DWORD cbData;

        NdisQueryBuffer(pNdisBuffer, &pData, &cbData);

        if ((cbContigBuf + cbData) > cbNdisPacket)
        {
            // Packet was corrupt - misreported its size.
            DEBUGMSG(ZONE_SNIFFIR,
                (TEXT("Ndis packet misreported its size!!\r\n")));
            return;
        }

        NdisMoveMemory((PVOID)(pbContigBuf + cbContigBuf), pData, cbData);
        cbContigBuf += cbData;

        NdisGetNextBuffer(pNdisBuffer, &pNdisBuffer);
    }

    DecodeIRDA(
        &FrameType,
        pbContigBuf,
        cbContigBuf,
        lpszOut,
        4, // LAP/LMP/TTP
        FALSE,
        DISP_ASCII);

    DEBUGMSG(ZONE_SNIFFIR, (TEXT("%s\r\n"), lpszOut));
    return;
}

#else // DEBUG

#define DEBUG_PACKET(zone, ndispacket) ((void)0)

#endif // !DEBUG

#endif // _IRSIRP_H_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -