PageRenderTime 58ms CodeModel.GetById 25ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/net/wireless/tiwlan1251/common/src/core/data_ctrl/Ctrl/4X/ackEmulDb.c

https://bitbucket.org/cyanogenmod/cm-kernel
C | 1348 lines | 564 code | 172 blank | 612 comment | 71 complexity | 751d9ba7a9581d706a3a3be80f115426 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0

Large files files are truncated, but you can click here to view the full file

  1. /****************************************************************************
  2. **+-----------------------------------------------------------------------+**
  3. **| |**
  4. **| Copyright(c) 1998 - 2008 Texas Instruments. All rights reserved. |**
  5. **| All rights reserved. |**
  6. **| |**
  7. **| Redistribution and use in source and binary forms, with or without |**
  8. **| modification, are permitted provided that the following conditions |**
  9. **| are met: |**
  10. **| |**
  11. **| * Redistributions of source code must retain the above copyright |**
  12. **| notice, this list of conditions and the following disclaimer. |**
  13. **| * Redistributions in binary form must reproduce the above copyright |**
  14. **| notice, this list of conditions and the following disclaimer in |**
  15. **| the documentation and/or other materials provided with the |**
  16. **| distribution. |**
  17. **| * Neither the name Texas Instruments nor the names of its |**
  18. **| contributors may be used to endorse or promote products derived |**
  19. **| from this software without specific prior written permission. |**
  20. **| |**
  21. **| THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |**
  22. **| "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |**
  23. **| LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |**
  24. **| A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |**
  25. **| OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |**
  26. **| SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |**
  27. **| LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |**
  28. **| DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |**
  29. **| THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |**
  30. **| (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |**
  31. **| OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |**
  32. **| |**
  33. **+-----------------------------------------------------------------------+**
  34. ****************************************************************************/
  35. /***************************************************************************/
  36. /* */
  37. /* MODULE: ackEmulDb.c */
  38. /* PURPOSE: Ack emulation database */
  39. /* */
  40. /***************************************************************************/
  41. #include "osApi.h"
  42. #include "802_11Defs.h"
  43. #include "ackEmulDb.h"
  44. #include "report.h"
  45. #include "utils.h"
  46. static void wdrv_aeFindFreeActiveIndex(ackEmulDB_t* ackEmulDB,UINT8 *freeIndex);
  47. static void wdrv_aeWTargetDbInit(ackEmulDB_t* ackEmulDB);
  48. static void wdrv_aeWSourceDbInit(ackEmulDB_t* ackEmulDB);
  49. static void wdrv_aeWSourceDbResetstation(ackEmulDB_t* ackEmulDB,int stationIndex);
  50. /*
  51. ULONG rt_osTimerGetTick(void)
  52. {
  53. ULONG sysuptime;
  54. #if (TIWLN_MAJOR_VERSION >= 5)
  55. NdisGetSystemUpTime(&sysuptime);
  56. #else
  57. LARGE_INTEGER systime;
  58. NdisGetCurrentSystemTime(&systime);
  59. sysuptime = (((UINT32)systime.LowPart >> 10) | ((UINT32)systime.HighPart << 22))/10;
  60. #endif
  61. return sysuptime;
  62. }
  63. */
  64. ackEmulDB_t* ackEmulDb_create(TI_HANDLE hOs)
  65. {
  66. ackEmulDB_t* ackEmulDB;
  67. if( hOs == NULL )
  68. {
  69. WLAN_OS_REPORT(("FATAL ERROR: ackEmulDb_create(): OS handle Error - Aborting\n"));
  70. return NULL;
  71. }
  72. /* alocate concatenator block */
  73. ackEmulDB = os_memoryAlloc(hOs, (sizeof(ackEmulDB_t)));
  74. if ( (!ackEmulDB) )
  75. {
  76. utils_nullMemoryFree(hOs, ackEmulDB, sizeof(ackEmulDB_t));
  77. WLAN_OS_REPORT(("FATAL ERROR: ackEmulDb_create(): Error Creating ackEmulDB module- Aborting\n"));
  78. return(NULL);
  79. }
  80. /* reset control module control block */
  81. os_memoryZero(hOs, ackEmulDB, (sizeof(ackEmulDB_t)));
  82. ackEmulDB->hOs = hOs;
  83. return(ackEmulDB);
  84. }
  85. TI_STATUS ackEmulDb_config(ackEmulDB_t* ackEmulDB,
  86. TI_HANDLE hOs,
  87. TI_HANDLE hReport)
  88. {
  89. /* check parameters validity */
  90. if( (ackEmulDB == NULL) || (hOs == NULL) || (hReport == NULL) )
  91. {
  92. WLAN_OS_REPORT(("FATAL ERROR: ackEmulDb_config(): Parameters Error - Aborting\n"));
  93. return NOK;
  94. }
  95. /* set objects handles */
  96. ackEmulDB->hOs = hOs;
  97. ackEmulDB->hReport = hReport;
  98. wdrv_aeDbInit(ackEmulDB);
  99. WLAN_REPORT_INIT(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG,
  100. (".....ackEmulDB configured successfully\n"));
  101. return OK;
  102. }
  103. TI_STATUS ackEmulDb_destroy(ackEmulDB_t* ackEmulDB)
  104. {
  105. /* free control module controll block */
  106. os_memoryFree(ackEmulDB->hOs, ackEmulDB, sizeof(ackEmulDB_t));
  107. return OK;
  108. }
  109. /****************************************************************************
  110. * wdrv_aeDbInit()
  111. ****************************************************************************
  112. * DESCRIPTION: Initialize the WTarget and WSource database
  113. *
  114. * INPUTS: None
  115. *
  116. * OUTPUT: None
  117. *
  118. * RETURNS: None
  119. ****************************************************************************/
  120. void wdrv_aeDbInit(ackEmulDB_t* ackEmulDB)
  121. {
  122. wdrv_aeWTargetDbInit(ackEmulDB);
  123. wdrv_aeWSourceDbInit(ackEmulDB);
  124. }
  125. /****************************************************************************
  126. * wdrv_aeWTargetDbInit()
  127. ****************************************************************************
  128. * DESCRIPTION: Initialize the WTarget database
  129. *
  130. * INPUTS: None
  131. *
  132. * OUTPUT: None
  133. *
  134. * RETURNS: None
  135. ****************************************************************************/
  136. static void wdrv_aeWTargetDbInit(ackEmulDB_t* ackEmulDB)
  137. {
  138. int index;
  139. for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
  140. wdrv_aeWTargetDbResetTuple(ackEmulDB,index);
  141. for(index=0 ; index< MAX_ACIVE_SESSION; index++)
  142. {
  143. ackEmulDB->activeIndexTable[index].status = INDEX_FREE;
  144. ackEmulDB->activeIndexTable[index].monitorIndex = 0xff;
  145. }
  146. ackEmulDB->sessionsTableManager.currentActiveState =0;
  147. ackEmulDB->sessionsTableManager.currentStandbyState =0;
  148. }
  149. /****************************************************************************
  150. * wdrv_aeWTargetDbAddSession()
  151. ****************************************************************************
  152. * DESCRIPTION: ADD new session to WTarget database
  153. *
  154. * INPUTS: pktBuf - Pointer to packet IP header
  155. * stationIndex - The station index of the packet source
  156. *
  157. * OUTPUT: None
  158. *
  159. * RETURNS: Session index if added, otherwise 0xff
  160. ****************************************************************************/
  161. int wdrv_aeWTargetDbAddSession(ackEmulDB_t* ackEmulDB,UINT8 *pktBuf)
  162. {
  163. int index;
  164. int freeIndex = 0xff;
  165. UINT32 currentTimeTick;
  166. UINT32 oldestTimeTick;
  167. UINT8 oldestTimeIndex;
  168. /* find free index */
  169. for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
  170. {
  171. if(ackEmulDB->wdrv_aeWTargetTable[index].sPorts == 0)
  172. {
  173. freeIndex = index;
  174. break;
  175. }
  176. }
  177. if (freeIndex == 0xff)
  178. {
  179. /* find old session to delete */
  180. currentTimeTick = oldestTimeTick = os_timeStampUs(ackEmulDB->hOs);
  181. oldestTimeIndex = 0xff;
  182. for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
  183. {
  184. if(ackEmulDB->wdrv_aeWTargetTable[index].timeStamp < oldestTimeTick)
  185. {
  186. oldestTimeTick = ackEmulDB->wdrv_aeWTargetTable[index].timeStamp;
  187. oldestTimeIndex = index;
  188. }
  189. }
  190. if((WTARGET_TERMINATE_TIME_OUT) < (currentTimeTick - oldestTimeTick))
  191. {
  192. wdrv_aeWTargetDbResetTuple(ackEmulDB, oldestTimeIndex);
  193. freeIndex = oldestTimeIndex;
  194. }
  195. }
  196. if (freeIndex != 0xff)
  197. {
  198. /* Add new session */
  199. int ipHeaderLen = ((*(unsigned char*)pktBuf & 0x0f) * 4);
  200. ackEmulDB->wdrv_aeWTargetTable[freeIndex].sPorts = wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen));
  201. ackEmulDB->wdrv_aeWTargetTable[freeIndex].dPorts = wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen+DEST_PORT_FIELD));
  202. ackEmulDB->wdrv_aeWTargetTable[freeIndex].srcIPAddr = wlan_ntohl(*(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD));
  203. ackEmulDB->wdrv_aeWTargetTable[freeIndex].destIPAddr = wlan_ntohl(*(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD));
  204. ackEmulDB->wdrv_aeWTargetTable[freeIndex].segmentSize =0;
  205. ackEmulDB->wdrv_aeWTargetTable[freeIndex].sequenceNumber = wlan_ntohl(*(unsigned long*)(pktBuf+ipHeaderLen+TCP_SEQUENCE_NUMBER_FIELD));
  206. ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackNumber =0;
  207. ackEmulDB->wdrv_aeWTargetTable[freeIndex].timeStamp =os_timeStampUs(ackEmulDB->hOs);
  208. ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackCounter =0;
  209. ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackTemplate.ipHeaderLen =0;
  210. ackEmulDB->wdrv_aeWTargetTable[freeIndex].ackTemplate.tcpHeaderLen =0;
  211. ackEmulDB->wdrv_aeWTargetTable[freeIndex].monitorState = AE_STANDBY;
  212. ackEmulDB->wdrv_aeWTargetTable[freeIndex].equalSegmentSizeCounter =0;
  213. ackEmulDB->wdrv_aeWTargetTable[freeIndex].yTagFlag =FALSE;
  214. ackEmulDB->wdrv_aeWTargetTable[freeIndex].activeIndex = 0xff;
  215. ackEmulDB->sessionsTableManager.currentStandbyState ++;
  216. }
  217. return freeIndex;
  218. }
  219. /****************************************************************************
  220. * wdrv_aeWTargetDbFindDataSession()
  221. ****************************************************************************
  222. * DESCRIPTION: Find existing session index for data packet at
  223. * WTarget database.
  224. *
  225. * INPUTS: pktBuf - Pointer to packet IP header
  226. * stationIndex - The station index of the packet source
  227. *
  228. * OUTPUT: monitorState - The monitor state
  229. *
  230. * RETURNS: Ok if exist otherwise NOK
  231. ****************************************************************************/
  232. int wdrv_aeWTargetDbFindDataSession(ackEmulDB_t* ackEmulDB, UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState)
  233. {
  234. int index;
  235. int ipHeaderLen;
  236. ipHeaderLen = ((*(unsigned char*)pktBuf & 0x0f) * 4);
  237. *monitorState = AE_INACTIVE;
  238. for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
  239. {
  240. if (ackEmulDB->wdrv_aeWTargetTable[index].sPorts == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen)) &&
  241. ackEmulDB->wdrv_aeWTargetTable[index].dPorts == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen + DEST_PORT_FIELD)) &&
  242. ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr == wlan_ntohl(*(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD)) &&
  243. ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr == wlan_ntohl(*(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD)))
  244. {
  245. *sessionIndex = index;
  246. *monitorState = ackEmulDB->wdrv_aeWTargetTable[index].monitorState;
  247. return OK;
  248. }
  249. }
  250. return NOK;
  251. }
  252. /****************************************************************************
  253. * wdrv_aeWTargetDbFindDataSession()
  254. ****************************************************************************
  255. * DESCRIPTION: Find existing session index for Ack packet at
  256. * WTarget database.
  257. *
  258. * INPUTS: pktBuf - Pointer to packet IP header
  259. * stationIndex - The station index of the packet source
  260. *
  261. * OUTPUT: monitorState - The monitor state
  262. *
  263. * RETURNS: Ok if exist otherwise NOK
  264. ****************************************************************************/
  265. int wdrv_aeWTargetDbFindAckSession(ackEmulDB_t* ackEmulDB, UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState)
  266. {
  267. int index;
  268. int ipHeaderLen;
  269. ipHeaderLen = ((*(unsigned char*)pktBuf & 0x0f) * 4);
  270. *monitorState = AE_INACTIVE;
  271. for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
  272. {
  273. if (ackEmulDB->wdrv_aeWTargetTable[index].sPorts == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen + DEST_PORT_FIELD)) &&
  274. ackEmulDB->wdrv_aeWTargetTable[index].dPorts == wlan_ntohs(*(UINT16*)(pktBuf +ipHeaderLen )) &&
  275. ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr == wlan_ntohl(*(unsigned long*)(pktBuf+IP_DEST_ADDRESS_FIELD)) &&
  276. ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr == wlan_ntohl(*(unsigned long*)(pktBuf+IP_SRC_ADDRESS_FIELD)))
  277. {
  278. *sessionIndex = index;
  279. *monitorState = ackEmulDB->wdrv_aeWTargetTable[index].monitorState;
  280. return OK;
  281. }
  282. }
  283. return NOK;
  284. }
  285. /****************************************************************************
  286. * wdrv_aeWTargetDbResetTuple()
  287. ****************************************************************************
  288. * DESCRIPTION: reset tuple at WTarget database
  289. *
  290. * INPUTS: index - the tuple index
  291. *
  292. * OUTPUT: None
  293. *
  294. * RETURNS: None
  295. ****************************************************************************/
  296. void wdrv_aeWTargetDbResetTuple(ackEmulDB_t* ackEmulDB, int index)
  297. {
  298. UINT8 freeActiveIndex = ackEmulDB->wdrv_aeWTargetTable[index].activeIndex;
  299. if (ackEmulDB->wdrv_aeWTargetTable[index].monitorState == AE_ACTIVE)
  300. {
  301. ackEmulDB->sessionsTableManager.currentActiveState --;
  302. }
  303. else
  304. {
  305. ackEmulDB->sessionsTableManager.currentStandbyState --;
  306. }
  307. ackEmulDB->wdrv_aeWTargetTable[index].sPorts =0;
  308. ackEmulDB->wdrv_aeWTargetTable[index].dPorts =0;
  309. ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr =0;
  310. ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr =0;
  311. ackEmulDB->wdrv_aeWTargetTable[index].segmentSize =0;
  312. ackEmulDB->wdrv_aeWTargetTable[index].sequenceNumber =0;
  313. ackEmulDB->wdrv_aeWTargetTable[index].ackNumber =0;
  314. ackEmulDB->wdrv_aeWTargetTable[index].timeStamp =0;
  315. ackEmulDB->wdrv_aeWTargetTable[index].ackCounter =0;
  316. ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.ipHeaderLen =0;
  317. ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.tcpHeaderLen =0;
  318. ackEmulDB->wdrv_aeWTargetTable[index].monitorState =AE_INACTIVE;
  319. ackEmulDB->wdrv_aeWTargetTable[index].equalSegmentSizeCounter =0;
  320. ackEmulDB->wdrv_aeWTargetTable[index].yTagFlag =FALSE;
  321. ackEmulDB->wdrv_aeWTargetTable[index].activeIndex = 0xff;
  322. if(freeActiveIndex != 0xff)
  323. {
  324. ackEmulDB->activeIndexTable[freeActiveIndex].status = INDEX_FREE;
  325. ackEmulDB->activeIndexTable[freeActiveIndex].monitorIndex = 0xff;
  326. }
  327. }
  328. /****************************************************************************
  329. * wdrv_aeWTargetDbPrint()
  330. ****************************************************************************
  331. * DESCRIPTION: Print the WTarget database
  332. *
  333. * INPUTS: None
  334. *
  335. * OUTPUT: None
  336. *
  337. * RETURNS: None
  338. ****************************************************************************/
  339. void wdrv_aeWTargetDbPrint(ackEmulDB_t* ackEmulDB)
  340. {
  341. int index;
  342. unsigned char* sipByte;
  343. unsigned char* dipByte;
  344. WLAN_OS_REPORT(("\n current Active State = %d\n", ackEmulDB->sessionsTableManager.currentActiveState));
  345. WLAN_OS_REPORT((" current Standby State = %d\n", ackEmulDB->sessionsTableManager.currentStandbyState));
  346. WLAN_OS_REPORT((" --------------------------\n"));
  347. WLAN_OS_REPORT(("| | SOURCE IP | DEST IP |SPORT|DPORT|St|Seg Size |AI|AC\n"));
  348. WLAN_OS_REPORT(("|------------------------------------------------------------------------| \n"));
  349. for(index=0 ; index< MAX_ACIVE_SESSION+MAX_STANDBY_SESSION; index++)
  350. {
  351. sipByte = (unsigned char*) &ackEmulDB->wdrv_aeWTargetTable[index].srcIPAddr;
  352. dipByte = (unsigned char*) &ackEmulDB->wdrv_aeWTargetTable[index].destIPAddr;
  353. WLAN_OS_REPORT(("|%02.2u|%03.3u.%03.3u.%03.3u.%03.3u|%03.3u.%03.3u.%03.3u.%03.3u|%05u|%05u|%02x|%09lu|%02x|%x|\n",
  354. index,
  355. sipByte[3],sipByte[2],sipByte[1],sipByte[0],
  356. dipByte[3],dipByte[2],dipByte[1],dipByte[0],
  357. ackEmulDB->wdrv_aeWTargetTable[index].sPorts,
  358. ackEmulDB->wdrv_aeWTargetTable[index].dPorts,
  359. (UINT8)ackEmulDB->wdrv_aeWTargetTable[index].monitorState,
  360. ackEmulDB->wdrv_aeWTargetTable[index].segmentSize,
  361. (UINT8)ackEmulDB->wdrv_aeWTargetTable[index].activeIndex,
  362. (UINT8)ackEmulDB->wdrv_aeWTargetTable[index].ackCounter));
  363. }
  364. }
  365. /****************************************************************************
  366. * wdrv_aeWTargetDbSetSessionSequenceNumber()
  367. ****************************************************************************
  368. * DESCRIPTION: Set the Sequence Number fild at WTarget data base
  369. *
  370. * INPUTS: index - session index
  371. * sequenceNumber - Tcp sequence number
  372. *
  373. * OUTPUT: None
  374. *
  375. * RETURNS: None
  376. ****************************************************************************/
  377. void wdrv_aeWTargetDbSetSessionSequenceNumber(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 sequenceNumber)
  378. {
  379. ackEmulDB->wdrv_aeWTargetTable[index].sequenceNumber = sequenceNumber;
  380. }
  381. /****************************************************************************
  382. * wdrv_aeWTargetDbGetSessionSequenceNumber()
  383. ****************************************************************************
  384. * DESCRIPTION: Get the Sequence Number fild from WTarget data base
  385. *
  386. * INPUTS: index - session index
  387. *
  388. * OUTPUT: *sequenceNumber - Tcp sequence number
  389. *
  390. * RETURNS: None
  391. ****************************************************************************/
  392. void wdrv_aeWTargetDbGetSessionSequenceNumber(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 *sequenceNumber)
  393. {
  394. *sequenceNumber = ackEmulDB->wdrv_aeWTargetTable[index].sequenceNumber;
  395. }
  396. /****************************************************************************
  397. * wdrv_aeWTargetDbSetSessionSegmentSize()
  398. ****************************************************************************
  399. * DESCRIPTION: Set the Segmen tSize fild at WTarget data base
  400. *
  401. * INPUTS: index - session index
  402. * segmentSize - Tcp segment size
  403. *
  404. * OUTPUT: None
  405. *
  406. * RETURNS: None
  407. ****************************************************************************/
  408. void wdrv_aeWTargetDbSetSessionSegmentSize(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 segmentSize)
  409. {
  410. ackEmulDB->wdrv_aeWTargetTable[index].segmentSize = segmentSize;
  411. }
  412. /****************************************************************************
  413. * wdrv_aeWTargetDbGetSessionSegmentSize()
  414. ****************************************************************************
  415. * DESCRIPTION: Get the SegmentSize fild from WTarget data base
  416. *
  417. * INPUTS: index - session index
  418. *
  419. * OUTPUT: *segmentSize - Tcp sequence number
  420. *
  421. * RETURNS: None
  422. ****************************************************************************/
  423. void wdrv_aeWTargetDbGetSessionSegmentSize(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 *segmentSize)
  424. {
  425. *segmentSize = ackEmulDB->wdrv_aeWTargetTable[index].segmentSize;
  426. }
  427. /****************************************************************************
  428. * wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter()
  429. ****************************************************************************
  430. * DESCRIPTION: Set the number of sequential packet
  431. * with the same Segment Size.
  432. * INPUTS: index - session index
  433. * equalSegmentSizeCounter - the number of sequential packet
  434. * with the same Segment Size
  435. *
  436. * OUTPUT: None
  437. *
  438. * RETURNS: None
  439. ****************************************************************************/
  440. void wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter(ackEmulDB_t* ackEmulDB, UINT8 index, UINT8 equalSegmentSizeCounter)
  441. {
  442. ackEmulDB->wdrv_aeWTargetTable[index].equalSegmentSizeCounter = equalSegmentSizeCounter;
  443. }
  444. /****************************************************************************
  445. * wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter()
  446. ****************************************************************************
  447. * DESCRIPTION: Increase and return the number of sequential packet
  448. * with the same Segment Size.
  449. *
  450. * INPUTS: index - session index
  451. *
  452. * OUTPUT: *equalSegmentSizeCounter - the number of sequential packet
  453. * with the same Segment Size
  454. *
  455. * RETURNS: None
  456. ****************************************************************************/
  457. void wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter(ackEmulDB_t* ackEmulDB, UINT8 index, UINT8 *equalSegmentSizeCounter)
  458. {
  459. *equalSegmentSizeCounter = (ackEmulDB->wdrv_aeWTargetTable[index].equalSegmentSizeCounter ++);
  460. }
  461. /****************************************************************************
  462. * wdrv_aeWTargetDbSetActiveState()
  463. ****************************************************************************
  464. * DESCRIPTION: Find free active index and update the WTarget DB with
  465. * this index
  466. *
  467. * INPUTS: index - monitor session index
  468. *
  469. * OUTPUT: *activeIndex - the active index
  470. *
  471. * RETURNS: Ok if change state to active, otherwise NOK
  472. ****************************************************************************/
  473. int wdrv_aeWTargetDbSetActiveState(ackEmulDB_t* ackEmulDB, UINT8 index , UINT8 *activeIndex)
  474. {
  475. UINT8 monitorState = AE_ACTIVE ;
  476. UINT8 freeIndex ,aIndex;
  477. wdrv_aeFindFreeActiveIndex(ackEmulDB, &freeIndex);
  478. if(freeIndex == 0xff)
  479. {
  480. /* We don't have free active index we try find old active session to delete */
  481. UINT32 currentTimeTick;
  482. UINT32 oldestTimeTick;
  483. UINT8 oldestTimeIndex;
  484. currentTimeTick = oldestTimeTick = os_timeStampUs(ackEmulDB->hOs);
  485. oldestTimeIndex = 0xff;
  486. for(aIndex=0 ; aIndex< MAX_ACIVE_SESSION; aIndex++)
  487. {
  488. if(ackEmulDB->wdrv_aeWTargetTable[ackEmulDB->activeIndexTable[aIndex].monitorIndex].timeStamp <
  489. oldestTimeTick)
  490. {
  491. oldestTimeTick = ackEmulDB->wdrv_aeWTargetTable[ackEmulDB->activeIndexTable[aIndex].monitorIndex].timeStamp;
  492. oldestTimeIndex = aIndex;
  493. }
  494. }
  495. if((WTARGET_TERMINATE_TIME_OUT) < (currentTimeTick - oldestTimeTick))
  496. {
  497. wdrv_aeWTargetDbResetTuple(ackEmulDB, ackEmulDB->activeIndexTable[oldestTimeIndex].monitorIndex);
  498. freeIndex = oldestTimeIndex;
  499. }
  500. }
  501. if (freeIndex == 0xff)
  502. {
  503. *activeIndex = 0xff;
  504. return NOK;
  505. }
  506. /* we have new active index */
  507. ackEmulDB->activeIndexTable[freeIndex].status = INDEX_BUSY;
  508. ackEmulDB->activeIndexTable[freeIndex].monitorIndex = index;
  509. ackEmulDB->wdrv_aeWTargetTable[index].activeIndex = freeIndex;
  510. *activeIndex = freeIndex;
  511. ackEmulDB->sessionsTableManager.currentActiveState ++;
  512. ackEmulDB->sessionsTableManager.currentStandbyState --;
  513. /* set the monitor session state to ACTIVE */
  514. wdrv_aeWTargetDbSetSessionMonitorState(ackEmulDB, index, monitorState);
  515. return OK;
  516. }
  517. /****************************************************************************
  518. * wdrv_aeWTargetDbSetSessionMonitorState()
  519. ****************************************************************************
  520. * DESCRIPTION: Set the state of monitor session.
  521. *
  522. * INPUTS: index - session index
  523. *
  524. *
  525. * OUTPUT: monitorState - the new monitor state
  526. *
  527. * RETURNS: None
  528. ****************************************************************************/
  529. void wdrv_aeWTargetDbSetSessionMonitorState(ackEmulDB_t* ackEmulDB, UINT8 index, UINT8 monitorState)
  530. {
  531. ackEmulDB->wdrv_aeWTargetTable[index].monitorState = monitorState;
  532. }
  533. /****************************************************************************
  534. * wdrv_aeWTargetDbGetSessionAckNumber()
  535. ****************************************************************************
  536. * DESCRIPTION: Get the monitor session ack number
  537. *
  538. * INPUTS: index - monitor session index
  539. *
  540. * OUTPUT: *ackNumber - The ack number
  541. *
  542. * RETURNS:None
  543. ****************************************************************************/
  544. void wdrv_aeWTargetDbGetSessionAckNumber(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 *ackNumber)
  545. {
  546. *ackNumber = ackEmulDB->wdrv_aeWTargetTable[index].ackNumber;
  547. }
  548. /****************************************************************************
  549. * wdrv_aeWTargetDbSetSessionAckNumber()
  550. ****************************************************************************
  551. * DESCRIPTION: Set the monitor session ack number
  552. *
  553. * INPUTS: index - monitor session index
  554. * ackNumber - The ack number
  555. *
  556. * OUTPUT: ackNumber - The ack number
  557. *
  558. * RETURNS:None
  559. ****************************************************************************/
  560. void wdrv_aeWTargetDbSetSessionAckNumber(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 ackNumber)
  561. {
  562. ackEmulDB->wdrv_aeWTargetTable[index].ackNumber = ackNumber;
  563. }
  564. /****************************************************************************
  565. * wdrv_aeWTargetDbGetSessionAckCounter()
  566. ****************************************************************************
  567. * DESCRIPTION: Get the monitor session ack counter
  568. *
  569. * INPUTS: index - monitor session index
  570. *
  571. * OUTPUT: *ackCounter - The ack counter
  572. *
  573. * RETURNS:None
  574. ****************************************************************************/
  575. void wdrv_aeWTargetDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 *ackCounter)
  576. {
  577. *ackCounter = ackEmulDB->wdrv_aeWTargetTable[index].ackCounter;
  578. }
  579. /****************************************************************************
  580. * wdrv_aeWTargetDbSetSessionAckCounter()
  581. ****************************************************************************
  582. * DESCRIPTION: Set the monitor session ack counter
  583. *
  584. * INPUTS: index - monitor session index
  585. * ackCounter - The ack counter
  586. *
  587. * OUTPUT: None
  588. *
  589. * RETURNS:None
  590. ****************************************************************************/
  591. void wdrv_aeWTargetDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 ackCounter)
  592. {
  593. ackEmulDB->wdrv_aeWTargetTable[index].ackCounter = ackCounter;
  594. }
  595. /****************************************************************************
  596. * wdrv_aeWTargetDbGetSessionActiveIndex()
  597. ****************************************************************************
  598. * DESCRIPTION: Get the monitor session active index
  599. *
  600. * INPUTS: index - monitor session index
  601. *
  602. * OUTPUT: *activeIndex - The session active index
  603. *
  604. * RETURNS:None
  605. ****************************************************************************/
  606. void wdrv_aeWTargetDbGetSessionActiveIndex(ackEmulDB_t* ackEmulDB, UINT8 index, UINT8 *activeIndex)
  607. {
  608. *activeIndex = ackEmulDB->wdrv_aeWTargetTable[index].activeIndex;
  609. }
  610. /****************************************************************************
  611. * wdrv_aeWTargetDbGetLastWackInfo()
  612. ****************************************************************************
  613. * DESCRIPTION: Get the last wack info for this monitor session.
  614. *
  615. * INPUTS: index - monitor session index
  616. *
  617. * OUTPUT: *lastWackInfo - the last wack info
  618. *
  619. * RETURNS:None
  620. ****************************************************************************/
  621. void wdrv_aeWTargetDbGetSessionTimeStamp(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 *timeStamp)
  622. {
  623. *timeStamp = ackEmulDB->wdrv_aeWTargetTable[index].timeStamp;
  624. }
  625. /****************************************************************************
  626. * wdrv_aeWTargetDbSetSessionTimeStamp()
  627. ****************************************************************************
  628. * DESCRIPTION: Set the time stamp for this monitor session.
  629. *
  630. * INPUTS: index - monitor session index
  631. * timeStamp - the time stamp info
  632. *
  633. * OUTPUT: None
  634. *
  635. * RETURNS:None
  636. ****************************************************************************/
  637. void wdrv_aeWTargetDbSetSessionTimeStamp(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 timeStamp)
  638. {
  639. ackEmulDB->wdrv_aeWTargetTable[index].timeStamp= timeStamp;
  640. }
  641. /****************************************************************************
  642. * wdrv_aeFindFreeActiveIndex()
  643. ****************************************************************************
  644. * DESCRIPTION: find if there is free index for active session.
  645. *
  646. * INPUTS: None.
  647. *
  648. * OUTPUT: *freeIndex - index of free tuple in table activeIndexTable
  649. *
  650. * RETURNS:None
  651. ****************************************************************************/
  652. static void wdrv_aeFindFreeActiveIndex(ackEmulDB_t* ackEmulDB, UINT8 *freeIndex)
  653. {
  654. UINT8 index;
  655. *freeIndex = 0xff;
  656. for(index=0 ; index< MAX_ACIVE_SESSION; index++)
  657. {
  658. if(ackEmulDB->activeIndexTable[index].status == INDEX_FREE)
  659. {
  660. *freeIndex = index;
  661. return;
  662. }
  663. }
  664. }
  665. /****************************************************************************
  666. * wdrv_aeWTargetDbSaveAckTemplate()
  667. ****************************************************************************
  668. * DESCRIPTION: save the Tcp ack template for the WTarget side.
  669. *
  670. * INPUTS: index - monitor session index.
  671. * *pIpHeader - Pointer to packet IP header
  672. *
  673. *
  674. * OUTPUT: None
  675. *
  676. * RETURNS:None
  677. ****************************************************************************/
  678. void wdrv_aeWTargetDbSaveAckTemplate(ackEmulDB_t* ackEmulDB, UINT8 index, UINT8 *pIpHeader)
  679. {
  680. UINT8 ipHeaderLen;
  681. UINT8 tcpHeaderLen;
  682. ipHeaderLen = ((*(unsigned char*)pIpHeader & 0x0f) * 4);
  683. tcpHeaderLen = ((((*(unsigned char*)(pIpHeader + ipHeaderLen+TCP_OFFSET_FIELD))& 0xf0)>>4) * 4);
  684. os_memoryCopy(NULL, ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.data, pIpHeader, ipHeaderLen+tcpHeaderLen);
  685. ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.ipHeaderLen = ipHeaderLen;
  686. ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.tcpHeaderLen = tcpHeaderLen;
  687. }
  688. /****************************************************************************
  689. * wdrv_aeWTargetDbUpdateAckTemplate()
  690. ****************************************************************************
  691. * DESCRIPTION: Update the Tcp ack template for the WTarget side.
  692. *
  693. * INPUTS: index - monitor session index.
  694. * sequenceNumber - New sequence number
  695. *
  696. * OUTPUT: None
  697. *
  698. * RETURNS:None
  699. ****************************************************************************/
  700. void wdrv_aeWTargetDbUpdateAckTemplate(ackEmulDB_t* ackEmulDB, UINT8 index, UINT32 sequenceNumber)
  701. {
  702. UINT8 *pSequenceNumber;
  703. /* Update Template Sequence Number */
  704. pSequenceNumber = ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.data +
  705. ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.tcpHeaderLen +TCP_SEQUENCE_NUMBER_FIELD;
  706. *(unsigned long*)(pSequenceNumber) = wlan_ntohl(sequenceNumber);
  707. }
  708. /****************************************************************************
  709. * wdrv_aeWTargetDbCmpAckTemplate()
  710. ****************************************************************************
  711. * DESCRIPTION: comper the current tcp ack with ack template.
  712. *
  713. * INPUTS: index - monitor session index.
  714. * *pIpHeader - Pointer to packet IP header
  715. *
  716. * OUTPUT: None
  717. *
  718. * RETURNS:None
  719. ****************************************************************************/
  720. int wdrv_aeWTargetDbCmpAckTemplate(ackEmulDB_t* ackEmulDB, UINT8 index, UINT8 *pIpHeader)
  721. {
  722. UINT8 ipHeaderLen;
  723. UINT8 *pTcpHeader;
  724. UINT8 *pIpHeaderTemplate;
  725. UINT8 *pTcpHeaderTemplate;
  726. UINT8 ipHeaderTemplateLen;
  727. ipHeaderLen = ((*(unsigned char*)pIpHeader & 0x0f) * 4);
  728. pIpHeaderTemplate = ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.data;
  729. ipHeaderTemplateLen = ackEmulDB->wdrv_aeWTargetTable[index].ackTemplate.ipHeaderLen;
  730. /* Comprer IP field: Version ,Header Length, Precedence, TOS , Unused, Total Length */
  731. if((*(UINT32*)(pIpHeaderTemplate))!=(*(UINT32*)pIpHeader))
  732. {
  733. WLAN_OS_REPORT(("\nCompare field: Version,Header Length, Precedence, TOS, Total Length fail \n"));
  734. return NOK;
  735. }
  736. /* Comprer IP field:Fragmentation Flags, Fragment Offset, TTL */
  737. if((*(UINT32*)(pIpHeaderTemplate+IP_IDENTIFIER_FIELD+2))!=
  738. (*(UINT32*)(pIpHeader+IP_IDENTIFIER_FIELD+2)))
  739. {
  740. WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG,
  741. ("Compare IP field:Fragmentation Flags, Fragment Offset, TTL fail \n"));
  742. return NOK;
  743. }
  744. pTcpHeader = pIpHeader + ipHeaderLen;
  745. pTcpHeaderTemplate = pIpHeaderTemplate + ipHeaderTemplateLen;
  746. /* Comprer TCP field: Offset, Reserved, Code, Window */
  747. if((*(UINT32*)(pTcpHeaderTemplate+TCP_ACK_NUMBER_FIELD+4))!=
  748. (*(UINT32*)(pTcpHeader+TCP_ACK_NUMBER_FIELD+4)))
  749. {
  750. WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG,
  751. ("Compare TCP field: Offset, Reserved, Code, Window fail\n"));
  752. return NOK;
  753. }
  754. /* Comprer TCP field: Urgent */
  755. if((*(UINT16*)(pTcpHeaderTemplate+TCP_CHECKSUM_FIELD+2))!=
  756. (*(UINT16*)(pTcpHeader+TCP_CHECKSUM_FIELD+2)))
  757. {
  758. WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG,
  759. ("Compare TCP field: Urgent fail\n\n"));
  760. return NOK;
  761. }
  762. /* Comprer TCP field: Sequence Number */
  763. if((*(UINT32*)(pTcpHeaderTemplate+TCP_SEQUENCE_NUMBER_FIELD))!=
  764. (*(UINT32*)(pTcpHeader+TCP_SEQUENCE_NUMBER_FIELD)))
  765. {
  766. WLAN_REPORT_WARNING(ackEmulDB->hReport, ACK_EMUL_MODULE_LOG,
  767. ("Comprare TCP field: Sequence Number fail\n\n"));
  768. /* add Ytag */
  769. return NOK;
  770. }
  771. return OK;
  772. }
  773. /****************************************************************************
  774. * wdrv_aeDbGetXTagStatus()
  775. ****************************************************************************
  776. * DESCRIPTION: Get the Xtag status of the source station for this
  777. * session index.
  778. *
  779. * INPUTS: sessionIndex - monitor session index
  780. *
  781. * OUTPUT: *status - Xtag status
  782. *
  783. * RETURNS:None
  784. ****************************************************************************/
  785. void wdrv_aeDbGetXTagStatus(ackEmulDB_t* ackEmulDB, UINT8 sessionIndex, UINT8 *status)
  786. {
  787. UINT16 stationIndex = ackEmulDB->wdrv_aeWTargetTable[sessionIndex].sourceStationIndex;
  788. if(stationIndex != 0xff)
  789. *status = ackEmulDB->ackEmulationXTagTable[stationIndex];
  790. }
  791. /****************************************************************************
  792. * wdrv_aeDbSetXTagStatus()
  793. ****************************************************************************
  794. * DESCRIPTION: Set the Xtag status of the source station for this
  795. * session index.
  796. *
  797. * INPUTS: sessionIndex - monitor session index
  798. *
  799. * OUTPUT: status - Xtag status
  800. *
  801. * RETURNS:None
  802. ****************************************************************************/
  803. void wdrv_aeDbSetXTagStatus(ackEmulDB_t* ackEmulDB, UINT8 sessionIndex, UINT8 status)
  804. {
  805. UINT16 stationIndex = ackEmulDB->wdrv_aeWTargetTable[sessionIndex].sourceStationIndex;
  806. if(stationIndex != 0xff)
  807. ackEmulDB->ackEmulationXTagTable[stationIndex] = status;
  808. }
  809. /******************************* WSource Data base *************************************/
  810. /****************************************************************************
  811. * wdrv_aeWSourceDbInit()
  812. ****************************************************************************
  813. * DESCRIPTION: Initialize the WSource database
  814. *
  815. * INPUTS: None
  816. *
  817. * OUTPUT: None
  818. *
  819. * RETURNS: None
  820. ****************************************************************************/
  821. static void wdrv_aeWSourceDbInit(ackEmulDB_t* ackEmulDB)
  822. {
  823. int stationIndex;
  824. for (stationIndex =0;stationIndex < MAX_AE_STATIONS;stationIndex++)
  825. wdrv_aeWSourceDbResetstation(ackEmulDB, stationIndex);
  826. }
  827. /****************************************************************************
  828. * wdrv_aeWSourceDbResetstation()
  829. ****************************************************************************
  830. * DESCRIPTION: Reset all the WSource tuple for specific station.
  831. *
  832. * INPUTS: stationIndex - index of station to reset
  833. *
  834. * OUTPUT: None
  835. *
  836. * RETURNS: None
  837. ****************************************************************************/
  838. static void wdrv_aeWSourceDbResetstation(ackEmulDB_t* ackEmulDB, int stationIndex)
  839. {
  840. int activeIndex;
  841. for (activeIndex =0;activeIndex < MAX_ACIVE_SESSION;activeIndex++)
  842. {
  843. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize=0;
  844. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber =0;
  845. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter =0;
  846. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp =0;
  847. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem = REORDER_PROBLEM_OFF;
  848. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen =0;
  849. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen =0;
  850. }
  851. }
  852. /****************************************************************************
  853. * wdrv_aeWSourceDbResetSession()
  854. ****************************************************************************
  855. * DESCRIPTION: Reset specific WSource session tuple for specific station.
  856. *
  857. * INPUTS: stationIndex - index of station to reset
  858. * activeIndex - the index of the WSource tcp session
  859. *
  860. * OUTPUT: None
  861. *
  862. * RETURNS: None
  863. ****************************************************************************/
  864. void wdrv_aeWSourceDbResetSession(ackEmulDB_t* ackEmulDB, int stationIndex,int activeIndex)
  865. {
  866. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize=0;
  867. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber =0;
  868. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter =0;
  869. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp =0;
  870. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem = REORDER_PROBLEM_OFF;
  871. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen =0;
  872. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen =0;
  873. }
  874. /****************************************************************************
  875. * wdrv_aeWSourceSaveAckTemplate()
  876. ****************************************************************************
  877. * DESCRIPTION: save the Tcp ack template for the WSource side.
  878. *
  879. * INPUTS: stationIndex - station index.
  880. * activeIndex - session index
  881. * *dataBuf - Packet data
  882. * dataLen - data len
  883. * segmentSize - segment Size
  884. *
  885. *
  886. * OUTPUT: None
  887. *
  888. * RETURNS:None
  889. ****************************************************************************/
  890. void wdrv_aeWSourceSaveAckTemplate(ackEmulDB_t* ackEmulDB, UINT8 stationIndex,UINT8 activeIndex,
  891. UINT8* pDot11Header, UINT8 *pWlanSnapHeader, UINT8 *pIpHeader
  892. ,UINT16 dataLen,UINT16 segmentSize)
  893. {
  894. UINT8 *pTcpHeader;
  895. UINT8 *pTemplateData;
  896. UINT8 ipHeaderLen;
  897. UINT8 tcpHeaderLen;
  898. UINT32 ackNumber;
  899. WLAN_OS_REPORT(("wdrv_aeWSourceSaveAckTemplate datalen = %d\n",dataLen));
  900. wdrv_aeWSourceDbSetSessionTimeStamp(ackEmulDB, stationIndex,activeIndex,os_timeStampUs(ackEmulDB->hOs));
  901. ipHeaderLen = ((*(unsigned char*)pIpHeader & 0x0f) * 4);
  902. pTcpHeader = pIpHeader + ipHeaderLen;
  903. tcpHeaderLen = ((((*(unsigned char*)(pTcpHeader+TCP_OFFSET_FIELD))& 0xf0)>>4) * 4);
  904. pTemplateData = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.data;
  905. os_memoryCopy(ackEmulDB->hOs, pTemplateData,pDot11Header, WLAN_HDR_LEN);
  906. os_memoryCopy(ackEmulDB->hOs, pTemplateData+WLAN_HDR_LEN,pWlanSnapHeader, WLAN_SNAP_HDR_LEN);
  907. WLAN_OS_REPORT((" osMoveMemory 2 \n"));
  908. /* osMoveMemory(pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN,pIpHeader, dataLen-WLAN_HDR_LEN-WLAN_SNAP_HDR_LEN);*/
  909. os_memoryCopy(ackEmulDB->hOs, pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN,pIpHeader, dataLen);
  910. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.ipHeaderLen = ipHeaderLen;
  911. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackTemplate.tcpHeaderLen = tcpHeaderLen;
  912. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize = segmentSize;
  913. ackNumber = wlan_ntohl(*(unsigned long*)(pIpHeader+ipHeaderLen+TCP_ACK_NUMBER_FIELD));
  914. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber = ackNumber;
  915. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter = ackNumber/(segmentSize*2);
  916. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem = REORDER_PROBLEM_OFF;
  917. /* reset the Ip & TCP Checksum */
  918. *(UINT16*)(pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN+IP_CHECKSUM_FIELD) = 0x0000;
  919. *(UINT16*)(pTemplateData+WLAN_HDR_LEN+WLAN_SNAP_HDR_LEN+ipHeaderLen+TCP_CHECKSUM_FIELD) = 0x0000;
  920. }
  921. /****************************************************************************
  922. * wdrv_aeWSourceDbGetSessionAckCounter()
  923. ****************************************************************************
  924. * DESCRIPTION: Get the ackCounter fild from WSource data base.
  925. *
  926. * INPUTS: stationIndex - station index.
  927. * activeIndex - session index
  928. *
  929. * OUTPUT: *ackCounter - - the Ack Counter
  930. *
  931. * RETURNS:None
  932. ****************************************************************************/
  933. void wdrv_aeWSourceDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackCounter)
  934. {
  935. *ackCounter = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter;
  936. }
  937. /****************************************************************************
  938. * wdrv_aeWSourceDbGetSessionAckCounter()
  939. ****************************************************************************
  940. * DESCRIPTION: Set the ackCounter fild at WSource data base.
  941. *
  942. * INPUTS: stationIndex - station index.
  943. * activeIndex - session index
  944. * ackCounter - - the Ack Counter
  945. *
  946. * OUTPUT: None
  947. *
  948. * RETURNS:None
  949. ****************************************************************************/
  950. void wdrv_aeWSourceDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 ackCounter)
  951. {
  952. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackCounter= ackCounter;
  953. }
  954. /****************************************************************************
  955. * wdrv_aeWSourceDbGetSessionAckNumber()
  956. ****************************************************************************
  957. * DESCRIPTION: Get the AckNumber fild from WSource data base.
  958. *
  959. * INPUTS: stationIndex - station index.
  960. * activeIndex - session index
  961. *
  962. * OUTPUT: *ackNumber - - the ack number
  963. *
  964. * RETURNS:None
  965. ****************************************************************************/
  966. void wdrv_aeWSourceDbGetSessionAckNumber(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackNumber)
  967. {
  968. *ackNumber = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber;
  969. }
  970. /****************************************************************************
  971. * wdrv_aeWSourceDbSetSessionAckNumber()
  972. ****************************************************************************
  973. * DESCRIPTION: Set the ackNumber fild at WSource data base.
  974. *
  975. * INPUTS: stationIndex - station index.
  976. * activeIndex - session index
  977. * ackNumber - - the ack number
  978. *
  979. * OUTPUT: None
  980. *
  981. * RETURNS:None
  982. ****************************************************************************/
  983. void wdrv_aeWSourceDbSetSessionAckNumber(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 ackNumber)
  984. {
  985. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackNumber= ackNumber;
  986. }
  987. /****************************************************************************
  988. * wdrv_aeWSourceDbGetSessionSegmentSize()
  989. ****************************************************************************
  990. * DESCRIPTION: Get the SegmentSize fild from WSource data base.
  991. *
  992. * INPUTS: stationIndex - station index.
  993. * activeIndex - session index
  994. *
  995. * OUTPUT: *segmentSize - - the ack segment size
  996. *
  997. * RETURNS:None
  998. ****************************************************************************/
  999. void wdrv_aeWSourceDbGetSessionSegmentSize(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *segmentSize)
  1000. {
  1001. *segmentSize = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize;
  1002. }
  1003. /****************************************************************************
  1004. * wdrv_aeWSourceDbSetSessionSegmentSize()
  1005. ****************************************************************************
  1006. * DESCRIPTION: Set the segmentSize fild at WSource data base.
  1007. *
  1008. * INPUTS: stationIndex - station index.
  1009. * activeIndex - session index
  1010. * segmentSize - - the segment size
  1011. *
  1012. * OUTPUT: None
  1013. *
  1014. * RETURNS:None
  1015. ****************************************************************************/
  1016. void wdrv_aeWSourceDbSetSessionSegmentSize(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 segmentSize)
  1017. {
  1018. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].segmentSize= segmentSize;
  1019. }
  1020. /****************************************************************************
  1021. * wdrv_aeWSourceDbGetSessionTimeStamp()
  1022. ****************************************************************************
  1023. * DESCRIPTION: Get the timeStamp fild from WSource data base.
  1024. *
  1025. * INPUTS: stationIndex - station index.
  1026. * activeIndex - session index
  1027. *
  1028. * OUTPUT: *timeStamp - - the time stamp
  1029. *
  1030. * RETURNS:None
  1031. ****************************************************************************/
  1032. void wdrv_aeWSourceDbGetSessionTimeStamp(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *timeStamp)
  1033. {
  1034. *timeStamp = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp;
  1035. }
  1036. /****************************************************************************
  1037. * wdrv_aeWSourceDbSetSessionTimeStamp()
  1038. ****************************************************************************
  1039. * DESCRIPTION: Set the timeStamp fild at WSource data base.
  1040. *
  1041. * INPUTS: stationIndex - station index.
  1042. * activeIndex - session index
  1043. * timeStamp - - the time stamp
  1044. *
  1045. * OUTPUT: None
  1046. *
  1047. * RETURNS:None
  1048. ****************************************************************************/
  1049. void wdrv_aeWSourceDbSetSessionTimeStamp(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 timeStamp)
  1050. {
  1051. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].timeStamp= timeStamp;
  1052. }
  1053. /****************************************************************************
  1054. * wdrv_aeWSourceDbGetSessionAckReorderProblem()
  1055. ****************************************************************************
  1056. * DESCRIPTION: Get the ack reorder problem fild from WSource data base.
  1057. *
  1058. * INPUTS: stationIndex - station index.
  1059. * activeIndex - session index
  1060. *
  1061. * OUTPUT: *ackReorderProblem - the ack reorder problem
  1062. *
  1063. * RETURNS:None
  1064. ****************************************************************************/
  1065. void wdrv_aeWSourceDbGetSessionAckReorderProblem(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackReorderProblem)
  1066. {
  1067. *ackReorderProblem = ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem;
  1068. }
  1069. /****************************************************************************
  1070. * wdrv_aeWSourceDbSetSessionAckReorderProblem()
  1071. ****************************************************************************
  1072. * DESCRIPTION: Set the timeStamp fild at WSource data base.
  1073. *
  1074. * INPUTS: stationIndex - station index.
  1075. * activeIndex - session index
  1076. * ackReorderProblem - the ack reorder problem
  1077. *
  1078. * OUTPUT: None
  1079. *
  1080. * RETURNS:None
  1081. ****************************************************************************/
  1082. void wdrv_aeWSourceDbSetSessionAckReorderProblem(ackEmulDB_t* ackEmulDB, UINT16 stationIndex, UINT8 activeIndex, UINT32 ackReorderProblem)
  1083. {
  1084. ackEmulDB->wdrv_aeWSourceTable[stationIndex][activeIndex].ackReorderProblem= ackReorderProblem;
  1085. }
  1086. /********************…

Large files files are truncated, but you can click here to view the full file