WIFI(wince)驱动

来源:互联网 发布:闪图制作软件下载 编辑:程序博客网 时间:2024/05/16 15:05


http://bluefish.blog.51cto.com/214870/474656

WIRELESS NETWORK:

 

OID-object identifier

SSID-service set identifier

BSS-basic service set

ESS-extended service set

RSSI-received signal strength indication

NIC-Network Interface Cards

NDIS-Network Driver Interface Specification

 

The following list shows the operating modes that the IEEE 802.11 standard defines:

 

Ad hoc mode

Infrastructure mode

 

In ad hoc mode, wireless clients communicate directly with each other without the use of a wireless access point (AP) or a wired network. Ad hoc mode connects wireless clients together when there is no wireless AP present, when the wireless AP rejects an association due to failed authentication, or when the wireless client is explicitly configured to use ad hoc mode.

 

In infrastructure mode, wireless and possibly wired clients communicate with each other through a wireless AP. The wireless client uses the wireless AP to access the resources of a wired network. The wired network can be an organization intranet or the Internet, depending on the placement of the wireless AP.

 

A single wireless AP supporting one or multiple wireless clients is known as a Basic Service Set (BSS). A set of two or more wireless APs connected to the same wired network is known as an Extended Service Set (ESS). An ESS is a single logical network segment, also known as a subnet, and is identified by its Service Set Identifier (SSID).

 

When a wireless network adapter is powered on, it begins to scan across the wireless frequencies for wireless APs and other wireless clients. Assuming that it is in infrastructure mode, after scanning, a wireless adapter chooses a wireless AP with which to associate. This selection is made automatically by using the SSID of the wireless network and the wireless AP with the best signal strength. Next, the wireless client switches to the assigned channel of the chosen wireless AP and negotiates the use of a logical wireless port. This step is known as an association.

 

The settings of the wireless client determine whether the wireless client prefers to associate with wireless APs or with individual wireless clients. If the signal strength of the wireless AP is too low, if the error rate is too high, or if it is instructed by the operating system, the wireless client scans for other wireless APs to determine whether a different wireless AP can provide a stronger signal to the same wireless network. If so, the wireless client switches to the channel of that wireless AP. This is known as re-association.

 

By switching to another wireless AP, the wireless client can distribute the load over other wireless APs, increasing the performance for other wireless clients. You can achieve wireless connectivity for large areas by placing wireless APs so that their coverage areas overlap slightly but their channels do not. As a wireless client moves its physical location, it can associate and re-associate from one wireless AP to another, and maintain a continuous connection during physical relocation.

 

If the coverage areas of the wireless APs within an ESS overlap, a wireless client can roam, or move from one location with a wireless AP to another location with a different wireless AP, and still maintain network layer connectivity.

 

 

Due to the nature of wireless LAN networks, implementing a security infrastructure that monitors physical access to the network is difficult. Unlike a wired network where a physical connection is required, anyone within range of a wireless AP can conceivably send and receive frames as well as listen for other frames being sent. This makes eavesdropping and remote sniffing of wireless LAN frames very easy. Wired Equivalent Privacy (WEP) is defined by the IEEE 802.11 standard and is intended to provide a level of data confidentiality that is equivalent to a wired network.

 

WEP provides data confidentiality services by encrypting the data sent between wireless nodes. WEP encryption for an 802.11 frame is indicated by setting a WEP flag in the MAC header of the 802.11 frame. WEP provides data integrity for random errors by including an integrity check value (ICV) in the encrypted portion of the wireless frame.

 

The following tables shows the two shared keys that WEP defines.

 

Key type

Description

Multicast/global key

Encryption key that helps to protect multicast and broadcast traffic from a wireless AP to all of its connected wireless clients.

Unicast session key

Encryption key that helps to protect unicast traffic between a wireless client and a wireless AP and multicast and broadcast traffic sent by a wireless client to the wireless AP.

 

WEP encryption uses the RC4 symmetric stream cipher with 40-bit and 104-bit encryption keys. 104-bit encryption keys are not standard, however, many wireless AP vendors support them.

 

网络的驱动,无线和有线都是去填充NDIS的预留接口

 

一,   DriverEntry

 

wince下的任何网络驱动都要实现的函数有DriverEntry。在该函数中初始化一个NDIS_MINIPORT_CHARACTERISTICS变量。这是一个关键的变量,它的类型是一个结构体,并且具有很多函数指针的元素,几乎所有的adapter的功能函数都是通过这个变量来开放给NDIS来调用。接着就是用NdisMRegisterMiniport这个NDIS提供的函数来注册这个变量,其实就是相当于注册了一个adapterdriver了,在这个函数返回之前,上述结构体变量的InitializeHandler函数指针(被赋值为MrvDrvInitialize)被调用,以初始化adapter设备(This routine will check medium support and call resource allocation and HW initialization routines to set up the staion.

 

DriverEntry只做了两件事:NdisMInitializeWrapperNdisMRegisterMiniport

 

NdisMInitializeWrapper通知NDIS一个新的miniport正在初始化。NIC(网络接口卡)驱动在调用其他NdisXXX函数之前必须要先调用该函数。在这个函数中有一个out参数NdisWrapperHandlein which NDIS returns a handle that represents itself。根据MS的操作习惯,可以知道这个HANDLE是要用来指示下面很多操作的。

 

NdisMRegisterMiniport:每一个网卡驱动都必须用它自己提供的MiniportXXX函数来填充一个NDIS_MINIPORT_CHARACTERISTICS结构体变量。这个变量在注册的时候被拷贝到NDIS库的内部以存储,所以在注册以后,miniport driver不能改变它的handler函数。在注册完成,该函数返回之前会调用MiniportInitialize函数,也就是这里的MrvDrvInitialize,它的调用是在ndis库中被间接调用的。

 

二, InitializeHandler

 

InitializeHandler函数中最重要的就是分配一个Adapter变量的空间,并初始化该结构变量的元素,以后的操作几乎都是基于该变量进行的。

 

MrvDrvInitialize

 

在这里第一个重要的函数就是If_Initializesdio_Initialization】,接口配置初始化函数,这里也就是对SDIO的配置与初始化。

 

If_FirmwareDownload,这个就是要说的第二个重要的函数,从名字可以看出也是接口函数,这个就是SDIOsdio_FirmwareDownload:通过SDIO接口下载了imagedevice。不明白了,这个image是什么?是每次都要这么download一下?imageWIFI设备运行的image

 

InitializeWirelessConfig,这个函数就不得不说了,从名字知道,这是对无线的初始配置。首先通过SDIO发送HostCmd_CMD_GET_HW_SPEC命令,并等待device的响应。这个命令应该是获取填充Adapter->PermanentAddr的值。接着是通过PrepareAndSendCommand来设置fragmentation thresholdRTS threshold。最后是通过PrepareAndSendCommand来设置对Mac的控制值,值为Adapter->CurrentMacControl(接收、发送、广播、多播)。

 

InitSyncObjects,这个函数进一步初始化了Adapter的元素,创建了一系列的事件和时间变量。最后创建了一个Adapter->hControllerInterruptThread控制器中断线程,该线程的主体是MrvIstThread函数。在此函数体中可以看到它等待的事件是pAdapter->hControllerInterruptEvent。这个事件是在多个地方被Set的,不过主要是在SDNdisInterruptCallback中。SDNdisInterruptCallback是在SDIOInitialization的时候被设置用来关联某个设备的:

sdStatus=SDIOConnectInterrupt(pAdapter->hDevice,(PSD_INTERRUPT_CALLBACK)SDNdisInterruptCallback);

SDIOConnectInterrupt函数是一个系统函数,它的解释是:

This function specifies a function to be called when an SDIO card interrupt occurs.

MrvIstThread中处理两类中断:soft_inthost_intsoft中断包括:chipresetauto_deep_sleeptx_requestHost中断包括:uploaddownload两类。Upload包括:接收的数据包、命令包以及各事件;download包括:数据包和命令包的发送。

 

本文出自 “bluefish” 博客,请务必保留此出处http://bluefish.blog.51cto.com/214870/474656

0 0
原创粉丝点击