/*++
Copyright(c) 1992-2000 Microsoft Corporation
Module Name:
protocol.c
Abstract:
Ndis Intermediate Miniport driver sample. This is a passthru driver.
Author:
Environment:
Revision History:
--*/
#include "precomp.h"
#pragma hdrstop
#define MAX_PACKET_POOL_SIZE 0x0000FFFF
#define MIN_PACKET_POOL_SIZE 0x000000FF
NDIS_STATUS AnalysisPacket(PNDIS_PACKET Packet, BOOLEAN bRecOrSend);
//
// NDIS version as 0xMMMMmmmm, where M=Major/m=minor (0x00050001 = 5.1);
// initially unknown (0)
//
ULONG NdisDotSysVersion = 0x0;
#define NDIS_SYS_VERSION_51 0x00050001
VOID
PtBindAdapter(
OUT PNDIS_STATUS Status,
IN NDIS_HANDLE BindContext,
IN PNDIS_STRING DeviceName,
IN PVOID SystemSpecific1,
IN PVOID SystemSpecific2
)
/*++
Routine Description:
Called by NDIS to bind to a miniport below.
Arguments:
Status - Return status of bind here.
BindContext - Can be passed to NdisCompleteBindAdapter if this call is pended.
DeviceName - Device name to bind to. This is passed to NdisOpenAdapter.
SystemSpecific1 - Can be passed to NdisOpenProtocolConfiguration to read per-binding information
SystemSpecific2 - Unused
Return Value:
NDIS_STATUS_PENDING if this call is pended. In this case call NdisCompleteBindAdapter
to complete.
Anything else Completes this call synchronously
--*/
{
NDIS_HANDLE ConfigHandle = NULL;
PNDIS_CONFIGURATION_PARAMETER Param;
NDIS_STRING DeviceStr = NDIS_STRING_CONST("UpperBindings");
NDIS_STRING NdisVersionStr = NDIS_STRING_CONST("NdisVersion");
PADAPT pAdapt = NULL;
NDIS_STATUS Sts;
UINT MediumIndex;
ULONG TotalSize;
BOOLEAN NoCleanUpNeeded = FALSE;
UNREFERENCED_PARAMETER(BindContext);
UNREFERENCED_PARAMETER(SystemSpecific2);
DBGPRINT(("==> Protocol BindAdapter\n"));
do
{
//
// Access the configuration section for our binding-specific
// parameters.
//
NdisOpenProtocolConfiguration(Status,
&ConfigHandle,
SystemSpecific1);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
if (NdisDotSysVersion == 0)
{
NdisReadConfiguration(Status,
&Param,
ConfigHandle,
&NdisVersionStr, // "NdisVersion"
NdisParameterInteger);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
NdisDotSysVersion = Param->ParameterData.IntegerData;
}
//
// Read the "UpperBindings" reserved key that contains a list
// of device names representing our miniport instances corresponding
// to this lower binding. Since this is a 1:1 IM driver, this key
// contains exactly one name.
//
// If we want to implement a N:1 mux driver (N adapter instances
// over a single lower binding), then UpperBindings will be a
// MULTI_SZ containing a list of device names - we would loop through
// this list, calling NdisIMInitializeDeviceInstanceEx once for
// each name in it.
//
NdisReadConfiguration(Status,
&Param,
ConfigHandle,
&DeviceStr,
NdisParameterString);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Allocate memory for the Adapter structure. This represents both the
// protocol context as well as the adapter structure when the miniport
// is initialized.
//
// In addition to the base structure, allocate space for the device
// instance string.
//
TotalSize = sizeof(ADAPT) + Param->ParameterData.StringData.MaximumLength;
NdisAllocateMemoryWithTag(&pAdapt, TotalSize, TAG);
if (pAdapt == NULL)
{
*Status = NDIS_STATUS_RESOURCES;
break;
}
//
// Initialize the adapter structure. We copy in the IM device
// name as well, because we may need to use it in a call to
// NdisIMCancelInitializeDeviceInstance. The string returned
// by NdisReadConfiguration is active (i.e. available) only
// for the duration of this call to our BindAdapter handler.
//
NdisZeroMemory(pAdapt, TotalSize);
pAdapt->DeviceName.MaximumLength = Param->ParameterData.StringData.MaximumLength;
pAdapt->DeviceName.Length = Param->ParameterData.StringData.Length;
pAdapt->DeviceName.Buffer = (PWCHAR)((ULONG_PTR)pAdapt + sizeof(ADAPT));
NdisMoveMemory(pAdapt->DeviceName.Buffer,
Param->ParameterData.StringData.Buffer,
Param->ParameterData.StringData.MaximumLength);
NdisInitializeEvent(&pAdapt->Event);
NdisAllocateSpinLock(&pAdapt->Lock);
//
// Allocate a packet pool for sends. We need this to pass sends down.
// We cannot use the same packet descriptor that came down to our send
// handler (see also NDIS 5.1 packet stacking).
//
NdisAllocatePacketPoolEx(Status,
&pAdapt->SendPacketPoolHandle,
MIN_PACKET_POOL_SIZE,
MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
sizeof(SEND_RSVD));
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Allocate a packet pool for receives. We need this to indicate receives.
// Same consideration as sends (see also NDIS 5.1 packet stacking).
//
NdisAllocatePacketPoolEx(Status,
&pAdapt->RecvPacketPoolHandle,
MIN_PACKET_POOL_SIZE,
MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
PROTOCOL_RESERVED_SIZE_IN_PACKET);
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
//
// Now open the adapter below and complete the initialization
//
NdisOpenAdapter(Status,
&Sts,
&pAdapt->BindingHandle,
&MediumIndex,
MediumArray,
sizeof(MediumArray)/sizeof(NDIS_MEDIUM),
ProtHandle,
pAdapt,
DeviceName,
0,
NULL);
if (*Status == NDIS_STATUS_PENDING)
{
NdisWaitEvent(&pAdapt->Event, 0);
*Status = pAdapt->Status;
}
if (*Status != NDIS_STATUS_SUCCESS)
{
break;
}
PtReferenceAdapt(pAdapt);
#pragma prefast(suppress: __WARNING_POTENTIAL_BUFFER_OVERFLOW, "Ndis guarantees MediumIndex to be within bounds");
pAdapt->Medium = MediumArray[MediumIndex];
//
// Now ask NDIS to initialize our miniport (upper) edge.
// Set the flag below to synchronize with a
huangjinli73
- 粉丝: 1
- 资源: 2
最新资源
- FocusAny v0.4.0 一键锁屏、局域网IP、开机启动、交互优化、自定义协议
- 基于DSPf28335设计的FIR滤波器,包括MATLAB和CCS源码
- C#使用MVC框架创建WebApi服务接口
- 30个资深java热门面试题
- 毕业设计-python二维码识别系统(毕业全套文档+源代码).zip
- 三相电力电子变压器PET 输入级三相PWM整流器10kV 双闭环控制输出15kv 中间级DAB输入15kv输出700V 输出级三相逆变器输出380V交流 开关频率20k
- 西门子博途1200 1500 PLC PID双输出功能(制冷+加热)
- 质子交膜燃料电池PEMFC Matlab simulink滑模控制模型,过氧比控制,温度控制,阴,阳极气压控制 赠学习资料
- 计算机网络实验四 思科小型小型校园网的搭建
- Matlab实现CNN-GRU多特征分类预测 1.Matlab实现CNN-GRU多特征分类预测,运行环境Matlab2020b及以上 2.数据为Excel数据,直接替数据就可以运行程序 3.程序经
- “人力资源+大数据+薪酬报告+涨薪调薪”
- “人力资源+大数据+薪酬报告+涨薪调薪”
- “人力资源+大数据+薪酬报告+涨薪调薪”
- “人力资源+大数据+薪酬报告+涨薪调薪”
- 电动车驱动装置市场规模:预计到2030年年复合增长率(CAGR)高达9.6%
- 微信小程序开发的初级知识解析
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈