API Guide Home
(Online version only)

PalmWiFiCommon.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  * Copyright (c) 2004 palmOne, Inc. or its subsidiaries.
00003  * All rights reserved.
00004  *****************************************************************************/
00005 /**
00006  * @ingroup Network
00007  */
00008 
00009 /**
00010  * @file    PalmWiFiCommon.h
00011  * @version 1.0
00012  *
00013  * @brief Constants and structures common to the wifi network panel and driver.
00014  *
00015  */
00016 
00017 #ifndef PALM_WIFI_COMMON_H_
00018 #define PALM_WIFI_COMMON_H_
00019 
00020 #include <NetMgr.h>
00021 
00022 /** Define the appropriate minimum OS version we support */
00023 #define WIFI_MIN_OS_VERSION  sysMakeROMVersion(3,0,0,sysROMStageDevelopment,0)
00024 /** Define the appropriate minimum OS version we support */
00025 #define PALM_OS_20_VERSION   sysMakeROMVersion(2,0,0,sysROMStageDevelopment,0)
00026 
00027 /** WiFi creator ID. */
00028 #define WIFI_CREATOR_ID    'WiFi'
00029 /** WiFi configuration name */
00030 #define WIFI_CONFIG_NAME   "WiFi Config"
00031 
00032 /** WiFi database type */
00033 #define WIFI_DB_TYPE       'DATA'
00034 /** WiFi database name */
00035 #define WIFI_DB_NAME       "WiFiDB"
00036 
00037 /** WiFi driver prefix */
00038 #define WIFI_DRIVER_PREFIX "wi"
00039 /** WiFi driver name */
00040 #define WIFI_DRIVER_NAME   "WiFi Prism3"
00041 
00042 /// @name Event Notifications
00043 /// Event notifications from the WiFi -- can be used for SysNotifyRegister
00044 /*@{*/
00045 #define WIFI_ASSOCIATED_EVENT               'WiAs'
00046 #define WIFI_DISASSOCIATED_EVENT            'WiDi'
00047 #define WIFI_SCAN_COMPLETE_EVENT            'WiSc'
00048 #define WIFI_IF_UP_EVENT                    'WiUp'
00049 #define WIFI_IF_DOWN_EVENT                  'WiDn'
00050 /*@}*/
00051 
00052 
00053 /** Supported Query requests for WiFi driver. */
00054 typedef enum
00055 {
00056     netQuery80211SignalStrength = 0x100,
00057     netQuery80211SignalQuality,
00058     netQuery80211AuthenticationMode,
00059     netQuery80211BssScan,
00060     netQuery80211BssScanList,
00061     netQuery80211Channel,
00062     netQuery80211PowerState,
00063     netQuery80211RadioState,
00064     netQuery80211SSID,
00065     netQuery80211Key,
00066     netQuery80211KeyIndex,
00067     netQuery80211ResetKeys,
00068     netQuery80211OperatingMode,
00069     netQuery80211WepStatus,
00070     netQuery80211FirmwareVersion,
00071     netQuery80211SerialNumber,
00072     netQuery80211FWName,
00073     netQuery80211DriverDate,
00074     netQuery80211WEPRequired,
00075     netQuery80211ChannelList,
00076     netQuery80211BSSID,
00077     netQueryCancel,
00078     netQuery80211MediaState,
00079     netQuery80211SecurityMode, // use security mode #defines
00080     netQuery80211StartConnection,
00081     netQuery80211Last
00082 } NetQueryId;
00083 
00084 
00085 /** IP address allocation strategies */
00086 enum IPAllocType
00087 {
00088     IPAllocType_DHCP   = 0,
00089     IPAllocType_APIPA  = 1,
00090     IPAllocType_STATIC = 2
00091 };
00092 
00093 enum SecurityModeType
00094 {
00095     SecurityModeOpenSystem = 0,
00096     SecurityModeWEP,
00097     SecurityModeWPAPSK,
00098     SecurityModeLast
00099 };
00100 
00101 /// @name Encryption Algorithm
00102 /*@{*/
00103 #define AUTHENTICATION_ALGORITHM_OPEN_SYSTEM    1
00104 #define AUTHENTICATION_ALGORITHM_SHARED_KEY     2 //40 bit
00105 #define AUTHENTICATION_ALGORITHM_SHARED_KEY_128 3
00106 /*@}*/
00107 
00108 /** Operating mode, referred to as port type in the configuration. */
00109 #define ESS     1
00110 
00111 
00112 
00113 #define IBSS    4
00114 
00115 /** @name ESS TX power mode. */
00116 /*@{*/
00117 #define AUTO_TX_POWER           0
00118 #define ENHANCED_TX_POWER       1
00119 /*@}*/
00120 
00121 /** @name AdHoc power modes. */
00122 /*@{*/
00123 #define FULL_TX_POWER           0
00124 #define _30_MW_TX_POWER         1
00125 #define _15_MW_TX_POWER         2
00126 #define _5_MW_TX_POWER          3
00127 #define _1_MW_TX_POWER          4
00128 /*@}*/
00129 
00130 /** @name AP density constants.
00131  *  @brief Referred as netIFSetting80211Environment in configuration.
00132  */
00133 /*@{*/
00134 #define AP_DENSITY_LOW  0
00135 #define AP_DENSITY_MED  1
00136 #define AP_DENSITY_HIGH 2
00137 /*@}*/
00138 
00139 /** @name Adapter Preamble */
00140 /*@{*/
00141 #define LONG_PREAMBLE       0
00142 #define SHORT_PREAMBLE      1
00143 #define AUTO_PREAMBLE       2
00144 /*@}*/
00145 
00146 /** Special code required to be passed to reset wep keys */
00147 #define net80211ResetWepPasscode    0x41149339
00148 
00149 /** Definitions of media states returned from netQuery80211MediaState */
00150 #define netMediaDisconnected        0
00151 /** Definitions of media states returned from netQuery80211MediaState */
00152 #define netMediaConnected           1
00153 
00154 enum WiFiCustomIFSettings
00155 {
00156     netIFSetting80211PowerMode = netIFSettingCustom,
00157     netIFSetting80211Diversity,
00158     netIFSetting80211Channel,
00159     netIFSetting80211EncryptionKey1,
00160     netIFSetting80211EncryptionKey2,
00161     netIFSetting80211EncryptionKey3,
00162     netIFSetting80211EncryptionKey4,
00163     netIFSetting80211EncryptionKeyID,
00164     netIFSetting80211MandatoryBSSId,
00165     netIFSetting80211MUEncryptionAlgorithm,
00166     netIFSetting80211PortType,  // ESS, PsIBBS, IBSS
00167     netIFSetting80211EssTxPower,
00168     netIFSetting80211AdhocTxPower,
00169     netIFSetting80211StationName,
00170     netIFSetting80211Environment,
00171     netIFSetting80211LongPreamble,
00172     netIFSetting80211Gateway,
00173     netIFSettingPrimaryDNS,
00174     netIFSettingSecondaryDNS,
00175     netIFSettingDHCPRequestDNS,
00176     netIFSettingIPAllocType, // 0,1,2=DHCP,APIPA,STATIC
00177     netIFSetting80211SmartConnect,
00178     netIFSettingUIProgHoldOff,
00179     netIFSettingWiFiHideProgress,
00180     netIFSettingAutoPowerDownOnClose,
00181     netIFSettingInterfaceQSize,
00182     netIFSettingDriverQSize,
00183     netIFSetting8021x,
00184     netIFSetting80211MediaDisconnectLingerTime,
00185     netIFSetting80211MobileIP,
00186 
00187 #ifdef WIFI_DOT1X_SUPPORT
00188     netIFSettingDot1XWPPICreator,
00189     netIFSettingDot1XAuthenticationMethodID,
00190     netIFSettingDot1XAuthenticationCookie,
00191 #endif // WIFI_DOT1X_SUPPORT
00192 
00193     netIFSetting80211Last
00194 };
00195 
00196 #define netMacAddrLength        6   /**< max length MAC address */
00197 #define netSSIDMaxLength        32  /**< max length SSID */
00198 #define netNum80211Rates        8   /**< no definition */
00199 
00200 /** Wep status codes */
00201 enum NetWepStatus
00202 {
00203     netWEPEnabled,
00204     netWEPDisabled,
00205     netWEPKeyAbsent,
00206     netWEPNotSupported
00207 };
00208 
00209 /** @name Network Device Driver Interface Error Codes */
00210 /*@{*/
00211 #define errNetQueryBufTooSmall  11
00212 #define errNetOutOfMemory       12
00213 #define errNetLibMissing        13
00214 #define errNetInterfaceNotFound 14
00215 /*@}*/
00216 
00217 // The following are added to support a structure independent method
00218 // for presenting the BSS Scan data to an application.  Macros
00219 // are also provide to access data within a buffer.
00220 // NOTE:  These offsets do not account for the first 4 bytes which
00221 // must always precede the data.  This count field indicates the
00222 // number of BSS structures will follow
00223 
00224 /** Offset = 0.  Present/validity flags for each of the entities defined below */
00225 /*@{*/
00226 #define BSSINFO_VFLAG                   0
00227 #define BSSINFO_VFLAG_SIZE              4
00228 /*@}*/
00229 
00230 /** Offset = 4.  MAC/HW Address for device. */
00231 /*@{*/
00232 #define BSSINFO_MAC_ADDR_OFFSET         (BSSINFO_VFLAG + BSSINFO_VFLAG_SIZE)
00233 #define BSSINFO_MAC_ADDR_SIZE           8               // Add padding to allow easy access for structure definiton.
00234 #define BSSINFO_MAC_ADDR_VFLAG          0x00000001L
00235 /*@}*/
00236 
00237 /** Offset = 12.  Length of the following SSID */
00238 /*@{*/
00239 #define BSSINFO_SSIDLENGTH_OFFSET       (BSSINFO_MAC_ADDR_OFFSET + BSSINFO_MAC_ADDR_SIZE)
00240 #define BSSINFO_SSIDLENGTH_SIZE         4
00241 #define BSSINFO_SSIDLENGTH_VFLAG        0x00000002L
00242 /*@}*/
00243 
00244 /** Offset = 16 (0x10).  SSID */
00245 /*@{*/
00246 #define BSSINFO_SSID_OFFSET             (BSSINFO_SSIDLENGTH_OFFSET + BSSINFO_SSIDLENGTH_SIZE)
00247 #define BSSINFO_SSID_SIZE               netSSIDMaxLength
00248 #define BSSINFO_SSID_VFLAG              0x00000004L
00249 /*@}*/
00250 
00251 /** Offset = 48 (0x30).  WEP enabled boolean */
00252 /*@{*/
00253 #define BSSINFO_WEP_OFFSET              (BSSINFO_SSID_OFFSET + BSSINFO_SSID_SIZE)
00254 #define BSSINFO_WEP_SIZE                4
00255 #define BSSINFO_WEP_VFLAG               0x00000008L
00256 /*@}*/
00257 
00258 /** Offset = 52 (0x34).   Received Signal Strength */
00259 /*@{*/
00260 #define BSSINFO_RSSI_OFFSET             (BSSINFO_WEP_OFFSET + BSSINFO_WEP_SIZE)
00261 #define BSSINFO_RSSI_SIZE               4
00262 #define BSSINFO_RSSI_VFLAG              0x00000010L
00263 /*@}*/
00264 
00265 /** Offset = 56 (0x38).  Network type in use (Freq. hopping, DSS) */
00266 /*@{*/
00267 #define BSSINFO_NETWORK_TYPE_OFFSET     (BSSINFO_RSSI_OFFSET + BSSINFO_RSSI_SIZE)
00268 #define BSSINFO_NETWORK_TYPE_SIZE       4
00269 #define BSSINFO_NETWORK_TYPE_VFLAG      0x00000020L
00270 /*@}*/
00271 
00272 /** Offset = 60 (0x3C).  Beacon period (in KuSec) */
00273 /*@{*/
00274 #define BSSINFO_BEACON_PERIOD_OFFSET    (BSSINFO_NETWORK_TYPE_OFFSET + BSSINFO_NETWORK_TYPE_SIZE)
00275 #define BSSINFO_BEACON_PERIOD_SIZE      4
00276 #define BSSINFO_BEACON_PERIOD_VFLAG     0x00000040L
00277 /*@}*/
00278 
00279 /** Offset = 64 (0x40).  ATim window (in KuSec) */
00280 /*@{*/
00281 #define BSSINFO_ATIM_WINDOW_OFFSET      (BSSINFO_BEACON_PERIOD_OFFSET + BSSINFO_BEACON_PERIOD_SIZE)
00282 #define BSSINFO_ATIM_WINDOW_SIZE        4
00283 #define BSSINFO_ATIM_WINDOW_VFLAG       0x00000080L
00284 /*@}*/
00285 
00286 /** Offset = 68 (0x44). DS frequency (in kHz) */
00287 /*@{*/
00288 #define BSSINFO_DSFREQ_OFFSET           (BSSINFO_ATIM_WINDOW_OFFSET + BSSINFO_ATIM_WINDOW_SIZE)
00289 #define BSSINFO_DSFREQ_SIZE             4
00290 #define BSSINFO_DSFREQ_VFLAG            0x00000100L
00291 /*@}*/
00292 
00293 /** Offset = 72 (0x48).  Frequency hopping pattern */
00294 /*@{*/
00295 #define BSSINFO_HOPPATTERN_OFFSET       (BSSINFO_DSFREQ_OFFSET + BSSINFO_DSFREQ_SIZE)
00296 #define BSSINFO_HOPPATTERN_SIZE         4
00297 #define BSSINFO_HOPPATTERN_VFLAG        0x00000200L
00298 /*@}*/
00299 
00300 /** Offset = 76 (0x4C).  Frequency hopping set */
00301 /*@{*/
00302 #define BSSINFO_HOPSET_OFFSET           (BSSINFO_HOPPATTERN_OFFSET + BSSINFO_HOPPATTERN_SIZE)
00303 #define BSSINFO_HOPSET_SIZE             4
00304 #define BSSINFO_HOPSET_VFLAG            0x00000400L
00305 /*@}*/
00306 
00307 /** Offset = 80 (0x50). Frequency hopping dwell time */
00308 /*@{*/
00309 #define BSSINFO_HOPDWELL_OFFSET         (BSSINFO_HOPSET_OFFSET + BSSINFO_HOPSET_SIZE)
00310 #define BSSINFO_HOPDWELL_SIZE           4
00311 #define BSSINFO_HOPDWELL_VFLAG          0x00000800L
00312 /*@}*/
00313 
00314 /** Offset = 84 (0x54).  802.11 network mode */
00315 /*@{*/
00316 #define BSSINFO_NETWORK_MODE_OFFSET     (BSSINFO_HOPDWELL_OFFSET + BSSINFO_HOPDWELL_SIZE)
00317 #define BSSINFO_NETWORK_MODE_SIZE       4
00318 #define BSSINFO_NETWORK_MODE_VFLAG      0x00001000L
00319 /*@}*/
00320 
00321 /** Offset = 88 (0x58).  Supported rates on interface. */
00322 /*@{*/
00323 #define BSSINFO_SUPPORTED_RATES_OFFSET  (BSSINFO_NETWORK_MODE_OFFSET + BSSINFO_NETWORK_MODE_SIZE)
00324 #define BSSINFO_SUPPORTED_RATES_SIZE    8
00325 #define BSSINFO_SUPPORTED_RATES_VFLAG   0x00002000L
00326 /*@}*/
00327 
00328 /** Offset = 96 (0x60).  Channel ID */
00329 /*@{*/
00330 #define BSSINFO_CHID_OFFSET             (BSSINFO_SUPPORTED_RATES_OFFSET + BSSINFO_SUPPORTED_RATES_SIZE)
00331 #define BSSINFO_CHID_SIZE               4
00332 #define BSSINFO_CHID_VFLAG              0x00004000L
00333 /*@}*/
00334 
00335 /** Offset = 96 (0x60).  Channel ID */
00336 /*@{*/
00337 #define BSSINFO_ANL_OFFSET              (BSSINFO_CHID_OFFSET + BSSINFO_CHID_SIZE)
00338 #define BSSINFO_ANL_SIZE                4
00339 #define BSSINFO_ANL_VFLAG               0x00008000L
00340 /*@}*/
00341 
00342 /** Total size of the BSS info supplied. */
00343 #define BSSINFO_SIZE                    (BSSINFO_ANL_OFFSET + BSSINFO_ANL_SIZE)
00344 
00345 /// @name Macros for accessing individual fields
00346 /*@{*/
00347 #define BssInfoMacAddr( infoP, destP )  MemMove( destP, &((UInt8 *) infoP)[BSSINFO_MAC_ADDR_OFFSET], BSSINFO_MAC_ADDR_SIZE )
00348 #define BssInfoSsidLength( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_SSIDLENGTH_OFFSET], BSSINFO_SSIDLENGTH_SIZE )
00349 #define BssInfoSsid( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_SSID_OFFSET], BSSINFO_SSID_SIZE )
00350 #define BssInfoWep( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_WEP_OFFSET], BSSINFO_WEP_SIZE )
00351 #define BssInfoRssi( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_RSSI_OFFSET], BSSINFO_RSSI_SIZE )
00352 #define BssInfoNetworkType( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_NETWORK_TYPE_OFFSET], BSSINFO_NETWORK_TYPE_SIZE )
00353 #define BssInfoBeaconPeriod( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_BEACON_PERIOD_OFFSET], BSSINFO_BEACON_PERIOD_SIZE )
00354 #define BssInfoAtimWindow( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_ATIM_WINDOW_OFFSET], BSSINFO_ATIM_WINDOW_SIZE )
00355 #define BssInfoDSFreq( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_DSFREQ_OFFSET], BSSINFO_DSFREQ_SIZE )
00356 #define BssInfoHopPattern( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_HOPPATTERN_OFFSET], BSSINFO_HOPPATTERN_SIZE )
00357 #define BssInfoHopSet( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_HOPSET_OFFSET], BSSINFO_HOPSET_SIZE )
00358 #define BssInfoHopDwell( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_HOPDWELL_OFFSET], BSSINFO_HOPDWELL_SIZE )
00359 #define BssInfoNetworkMode( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_NETWORK_MODE_OFFSET], BSSINFO_NETWORK_MODE_SIZE )
00360 #define BssInfoSupportedRates( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_SUPPORTED_RATES_OFFSET], BSSINFO_SUPPORTED_RATES_SIZE )
00361 #define BssInfoChannelId( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_CHID_OFFSET], BSSINFO_CHID_SIZE )
00362 #define BssInfoANL( infoP, destP ) MemMove( destP, &((UInt8 *) infoP)[BSSINFO_ANL_OFFSET], BSSINFO_ANL_SIZE )
00363 /*@}*/
00364 
00365 /**
00366  *  @brief Structure to hold BSS Info data
00367  *
00368  *  Accessing the BSS scan info returned via the network interface via
00369  *  the following structure needs to be verified for each specific toolchain
00370  *  and compiler.  It has been verified with the combination of ADS V1.2 and
00371  *  CW 8.3.  The data format has been done to be as toolchain/architecture/alignment
00372  *  independent as possible, however, if a different combination other than the
00373  *  one listed is used, the format must be verified.  The macro's defined
00374  *  above can also be used to access the individual entities of the returned
00375  *  BSS scan data.
00376  */
00377 typedef struct NetBssInfoType
00378 {
00379     UInt32  validFlag;
00380     UInt8   bssMacAddr[BSSINFO_MAC_ADDR_SIZE];
00381     UInt32  bssSsidLength;
00382     UInt8   bssSsid[BSSINFO_SSID_SIZE];
00383     UInt32  bssWepEnabled;
00384     Int32   bssRssi;
00385     UInt32  bssNetworkType;                     // Net80211NetworkType
00386     UInt32  bssBeaconPeriod;
00387     UInt32  bssAtimWindow;
00388     UInt32  bssDSFreq;
00389     UInt32  bssHopPattern;
00390     UInt32  bssHopSet;
00391     UInt32  bssHopDwell;
00392     UInt32  bssNetworkMode;                     // Net80211InfrastructureModeType
00393     UInt8   bssSupportedRates[BSSINFO_SUPPORTED_RATES_SIZE];
00394     UInt32  bssChannelId;
00395     Int32   bssANL;
00396 } NetBssInfoType, *NetBssInfoTypeP;
00397 
00398 /**
00399  * @brief Structure to hold network query data
00400  */
00401 typedef struct NetworkDeviceQueryData
00402 {
00403     UInt32  qid;
00404     void    *InfoBuffer;
00405     UInt32  InfoBufferLength;
00406     UInt32  InfoSize;
00407     UInt32  InfoSizeRequired;
00408 
00409     /**
00410      * Added a link pointer. This is required if the driver needs to provide
00411      * an intermediate buffer space as a translation process.
00412      */
00413     struct NetworkDeviceQueryData   *linkP;
00414 
00415 } NetQueryType, *NetQueryTypeP;
00416 
00417 typedef enum _80211NetworkTypeEnum
00418 {
00419     net80211_FH,
00420     net80211_DS,
00421     net80211_Max            // Never returned from scan.  Can be used for bounds checking
00422 } Net80211NetworkType;
00423 
00424 /** Infrastructure mode info returned from a BSS scan */
00425 typedef enum _80211InfrastructureEnum
00426 {
00427     net80211Bss,
00428     net80211Infrastructure,
00429     net80211AutoUnknown,
00430     net80211InfrastructureMax           // Never returned from scan.  Can be used for bounds checking.
00431 } Net80211InfrastructureModeType;
00432 
00433 /**
00434  * @brief BSS list.
00435  *
00436  * This data structure is returned from a BSS scan.  The count field indicates
00437  * how many BSS structures are provide.
00438  */
00439 typedef struct BSSListStruct
00440 {
00441     UInt32          count;
00442     NetBssInfoType  BSS[1];
00443 } NetBssListType;
00444 
00445 /**
00446  * @brief Structure used to get and set the current SSID for the driver (not the Network interface)
00447  */
00448 typedef struct NetSSID
00449 {
00450     UInt32      ssidLength;
00451     UInt8       ssid[32];
00452 } NetSSID, *NetSSIDP;
00453 
00454 /**
00455  * @brief Structure used to set the wep keys.
00456  *
00457  * The API's do not return the wep keys via a query.
00458  */
00459 typedef struct NetWepKey
00460 {
00461     UInt32      keyIndex;
00462     UInt32      keyLength;
00463     UInt8       key[16];
00464 } NetWepKey, *NetWepKeyP;
00465 
00466 
00467 
00468 
00469 
00470 
00471 #endif // PALM_WIFI_COMMON_H_

Top Palm Developer Network
© 2004-2008, Palm, Inc. All rights reserved.
Generated on Fri Jun 13 10:06:55 2008 for Palm API Guide