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 /* */ 38 /* MODULE: ackEmulDb.h */ 39 /* PURPOSE: Ack emulation database */ 40 /* */ 41 /***************************************************************************/ 42 #ifndef _ACK_EMULATION_DB_H_ 43 #define _ACK_EMULATION_DB_H_ 44 45 #include "osTIType.h" 46 47 #define ACK_EMUL_MODULE_LOG CTRL_DATA_MODULE_LOG 48 void ackEGetPktType(unsigned char* pPacket , UINT16 *packetInclude, UINT16 *tcpDataSize); 49 50 #define TCP_LOOKAHEAD_SIZE 64 51 #define MAX_ACK_TEMPLATE_SIZE 100 52 #define MAX_AE_STATIONS 1 53 54 55 #define IP_PROTOCOL_NUMBER 0x0800 56 #define TCP_PROTOCOL 0x06 57 #define IP_TOTAL_LEN_FIELD 2 58 #define IP_IDENTIFIER_FIELD 4 59 60 #define IP_PROTOCOL_FIELD 9 61 #define IP_CHECKSUM_FIELD 10 62 #define DEST_PORT_FIELD 2 63 #define IP_SRC_ADDRESS_FIELD 12 64 #define IP_DEST_ADDRESS_FIELD 16 65 66 67 #define TCP_SEQUENCE_NUMBER_FIELD 4 68 #define TCP_ACK_NUMBER_FIELD 8 69 #define TCP_OFFSET_FIELD 12 70 #define TCP_CHECKSUM_FIELD 16 71 72 #define WTARGET_ACTIVE_TIME_OUT 500000 /* was 500 */ 73 #define WTARGET_TERMINATE_TIME_OUT 1000 74 #define WSOURCE_SESSION_TIME_OUT 700 75 76 #define MAX_ACIVE_SESSION 2 77 #define MAX_STANDBY_SESSION 8 78 79 #define INDEX_FREE 0 80 #define INDEX_BUSY 1 81 82 83 typedef struct { 84 int lastUsedIndex; 85 int currentActiveState; 86 int currentStandbyState; 87 } sessionsTableManager_T; 88 89 typedef struct { 90 int status; /* INDEX_FREE or INDEX_BUSY */ 91 int monitorIndex ; /* Index in wdrv_aeWTargetTable */ 92 }activeIndexTable_T; 93 94 95 96 typedef struct { 97 UINT8 data[MAX_ACK_TEMPLATE_SIZE]; 98 UINT8 ipHeaderLen; 99 UINT8 tcpHeaderLen; 100 } ackTemplate_T; 101 102 typedef struct { 103 UINT16 sPorts; /* Include source port */ 104 UINT16 dPorts; /* Include destination port */ 105 UINT32 srcIPAddr; /* source ip address */ 106 UINT32 destIPAddr; /* destination ip address */ 107 UINT32 segmentSize; /* Stable segment size */ 108 UINT32 sequenceNumber; /* The data sequence number */ 109 UINT32 ackNumber; /* Specifies the next byte expected.*/ 110 UINT32 timeStamp; /* */ 111 UINT32 ackCounter; /* The number of 2 * Segement_size in ACK number */ 112 ackTemplate_T ackTemplate; /* Ack template block */ 113 UINT8 monitorState; /* current monitor state */ 114 UINT8 equalSegmentSizeCounter; /* count the number of equal segment size. */ 115 UINT8 yTagFlag; /* True if send Y tag */ 116 UINT8 activeIndex; /* Active session index */ 117 UINT16 sourceStationIndex; /* Source station index */ 118 119 } ackEmulationWTargetDbTyple_T; 120 121 122 typedef struct { 123 UINT32 segmentSize; /* Stable segment size */ 124 UINT32 ackNumber; /* Specifies the next byte expected.*/ 125 UINT32 ackCounter; /* The number of 2 * Segement_size in ACK number */ 126 UINT32 timeStamp; /* The number of 2 * Segement_size in ACK number */ 127 UINT32 ackReorderProblem; 128 ackTemplate_T ackTemplate; /* Ack template block */ 129 }ackEmulationWSourceDbTyple_T; 130 131 132 /* Ack emulation monitor states */ 133 typedef enum { 134 REORDER_PROBLEM_OFF =0, 135 REORDER_PROBLEM_ON, 136 REORDER_PROBLEM_PRE, 137 } wdrv_eaAckReorderProblem_T; 138 139 140 typedef enum { 141 AE_INACTIVE =0, 142 AE_STANDBY, 143 AE_CANDIDATE_ACTIVE, 144 AE_ACTIVE, 145 AE_TERMINATE, 146 } wdrv_eaMonitorStatus_T; 147 148 149 typedef struct 150 { 151 TI_HANDLE hOs; 152 TI_HANDLE hReport; 153 154 155 /* This table store the WTarget monitor session */ 156 ackEmulationWTargetDbTyple_T wdrv_aeWTargetTable[MAX_ACIVE_SESSION+MAX_STANDBY_SESSION]; 157 sessionsTableManager_T sessionsTableManager; 158 159 /* This table store the WSource monitor session */ 160 ackEmulationWSourceDbTyple_T wdrv_aeWSourceTable[MAX_AE_STATIONS][MAX_ACIVE_SESSION]; 161 162 /* This table store the Xtag status */ 163 UINT8 ackEmulationXTagTable[MAX_AE_STATIONS]; 164 165 /* This table store the active monitor session index */ 166 activeIndexTable_T activeIndexTable[MAX_ACIVE_SESSION]; 167 168 }ackEmulDB_t; 169 170 171 ackEmulDB_t* ackEmulDb_create(TI_HANDLE hOs); 172 173 TI_STATUS ackEmulDb_config(ackEmulDB_t* ackEmulDB, 174 TI_HANDLE hOs, 175 TI_HANDLE hReport); 176 177 TI_STATUS ackEmulDb_destroy(ackEmulDB_t* ackEmulDB); 178 179 void wdrv_aeDbInit(ackEmulDB_t* ackEmulDB); 180 void wdrv_aeWTargetDbPrint(ackEmulDB_t* ackEmulDB); 181 int wdrv_aeWTargetDbFindDataSession(ackEmulDB_t* ackEmulDB,UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState); 182 int wdrv_aeWTargetDbFindAckSession(ackEmulDB_t* ackEmulDB,UINT8 *pktBuf,UINT8 *sessionIndex, UINT8 *monitorState); 183 int wdrv_aeWTargetDbAddSession(ackEmulDB_t* ackEmulDB,UINT8 *pktBuf); 184 185 int wdrv_aeWTargetDbDelSession(ackEmulDB_t* ackEmulDB,UINT8 SessionIndex); 186 int wdrv_aeWTargetDbSetActiveState(ackEmulDB_t* ackEmulDB,UINT8 index , UINT8 *activeIndex); 187 void wdrv_aeWTargetDbSaveAckTemplate(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 *pIpHeader); 188 void wdrv_aeWTargetDbUpdateAckTemplate(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 sequenceNumber); 189 int wdrv_aeWTargetDbCmpAckTemplate(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 *pIpHeader); 190 void wdrv_aeWTargetDbResetTuple(ackEmulDB_t* ackEmulDB,int index); 191 192 void wdrv_aeWTargetDbGetSessionSequenceNumber(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 *sequenceNumber); 193 void wdrv_aeWTargetDbGetSessionAckNumber(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 *ackNumber); 194 void wdrv_aeWTargetDbGetSessionSegmentSize(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 *segmentSize); 195 void wdrv_aeWTargetDbGetIncrSessionEqualSegmentSizeCounter(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 *equalSegmentSizeCounter); 196 void wdrv_aeWTargetDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 *ackCounter); 197 void wdrv_aeWTargetDbGetSessionMmonitorState(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 *monitorState); 198 void wdrv_aeWTargetDbGetSessionActiveIndex(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 *activeIndex); 199 200 void wdrv_aeWTargetDbSetSessionSequenceNumber(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 sequenceNumber); 201 void wdrv_aeWTargetDbSetSessionAckNumber(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 ackNumber); 202 void wdrv_aeWTargetDbSetSessionSegmentSize(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 segmentSize); 203 void wdrv_aeWTargetDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 ackCounter); 204 void wdrv_aeWTargetDbSetSessionMonitorState(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 monitorState); 205 void wdrv_aeWTargetDbSetSessionEqualSegmentSizeCounter(ackEmulDB_t* ackEmulDB,UINT8 index, UINT8 equalSegmentSizeCounter); 206 void wdrv_aeWTargetDbGetSessionTimeStamp(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 *timeStamp); 207 void wdrv_aeWTargetDbSetSessionTimeStamp(ackEmulDB_t* ackEmulDB,UINT8 index, UINT32 timeStamp); 208 209 void wdrv_aeWSourceDbUpdateTemplate(ackEmulDB_t* ackEmulDB,UINT8 *pktBuf,UINT8 stationIndex,UINT8 *sessionIndex); 210 void wdrv_aeWSourceDbResetSession(ackEmulDB_t* ackEmulDB,int stationIndex,int activeIndex); 211 212 void wdrv_aeWSourceSaveAckTemplate(ackEmulDB_t* ackEmulDB,UINT8 stationIndex,UINT8 activeIndex, 213 UINT8* pDot11Header, UINT8 *pWlanSnapHeader, UINT8 *pIpHeader 214 ,UINT16 dataLen,UINT16 segmentSize); 215 216 void wdrv_aeWSourceDbGetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackCounter); 217 218 void wdrv_aeWSourceDbSetSessionAckCounter(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 ackCounter); 219 220 void wdrv_aeWSourceDbGetSessionAckNumber(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackNumber); 221 void wdrv_aeWSourceDbSetSessionAckNumber(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 ackNumber); 222 223 void wdrv_aeWSourceDbGetSessionSegmentSize(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *segmentSize); 224 void wdrv_aeWSourceDbSetSessionSegmentSize(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 segmentSize); 225 226 void wdrv_aeWSourceDbGetSessionTimeStamp(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *timeStamp); 227 void wdrv_aeWSourceDbSetSessionTimeStamp(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 timeStamp); 228 229 void wdrv_aeWSourceDbGetSessionAckReorderProblem(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 *ackReorderProblem); 230 void wdrv_aeWSourceDbSetSessionAckReorderProblem(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT32 ackReorderProblem); 231 232 233 void wdrv_aeWSourceDbGetAckTemplate(ackEmulDB_t* ackEmulDB,UINT16 stationIndex, UINT8 activeIndex, UINT8 **pTeplate, 234 UINT8 *ipHeaderLen, UINT8 *tcpHeaderLen); 235 236 237 void wdrv_aeDbGetXTagStatus(ackEmulDB_t* ackEmulDB,UINT8 sessionIndex, UINT8 *status); 238 void wdrv_aeDbSetXTagStatus(ackEmulDB_t* ackEmulDB,UINT8 sessionIndex, UINT8 status); 239 240 #endif 241