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 * file osClsfr.c
38 */
39
40#include "osAdapter.h"
41#include "srcApi.h"
42
43#define ETHERNET_HEADER_SIZE    14
44
45/************************************************************************
46 *                        os_txClassifier   			                *
47 ************************************************************************
48DESCRIPTION: the function demonstrate qos classification from UDP port
49             number.
50
51INPUT:      pData	         -	void pointer to Msdu.
52
53OUTPUT:
54
55RETURN:     OK on success, NOK otherwise
56
57************************************************************************/
58
59
60TI_STATUS os_txClassifier(mem_MSDU_T *pMsdu,UINT8 *pQosClassifierTable)
61{
62    UINT8              i;
63    UINT8              *pUdpHeader;
64    UINT8              *pIpHeader;
65    UINT8              ipHeaderLen;
66    UINT16             dstPortNum;
67    UINT32             ipAddr;
68    NWIF_CLSFR_ENTRY  *pCt;
69
70    pCt = (NWIF_CLSFR_ENTRY *)pQosClassifierTable;
71    /*pEthHeader = (EthernetHeader_t*)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr));*/
72    pIpHeader = (UINT8 *)(memMgr_BufData(pMsdu->firstBDPtr)+memMgr_BufOffset(pMsdu->firstBDPtr)) + ETHERNET_HEADER_SIZE;
73    ipHeaderLen = ((*(unsigned char*)pIpHeader  & 0x0f) * 4);
74    pUdpHeader = pIpHeader + ipHeaderLen;
75
76    dstPortNum = *((UINT16 *)(pUdpHeader + 2));
77    ipAddr = *((UINT32 *)(pIpHeader + 16));
78
79	dstPortNum = ((dstPortNum >> 8) | (dstPortNum << 8));
80
81
82    pMsdu->qosTag = 0;
83    for(i = 0; i < NWIF_MAX_QOS_CONNS; i++ )
84    {
85        if ((pCt[i].ip == ipAddr) && (pCt[i].port == dstPortNum) )
86        {
87            pMsdu->qosTag = (UINT8)pCt[i].pri;
88            /*printk(KERN_ALERT "Found classifier match for ip=0x%x, port=%d, prio=%d \n",ipAddr, dstPortNum, pCt[i].pri);*/
89            break;
90        }
91    }
92
93
94    return OK;
95
96}
97
98/************************************************************************
99 *                        os_txSetClassifier   			                *
100 ************************************************************************
101DESCRIPTION: the function demonstrate setting qos classification table.
102
103INPUT:      pData	         -	void pointer to Msdu.
104
105OUTPUT:
106
107RETURN:     OK on success, NOK otherwise
108
109************************************************************************/
110TI_STATUS osSend_ConfigTxClassifier(PTIWLN_ADAPTER_T pAdapter,UINT32 bufferLength, UINT8 *pQosClassifierBuffer)
111{
112	NWIF_CLSFR_ENTRY *pSrc, *pDest;
113	UINT8 clsfrIndex;
114	UINT8 NumOfEntries;
115
116	if(bufferLength >  NWIF_MAX_QOS_CONNS * sizeof(NWIF_CLSFR_ENTRY))
117	{
118		return NOK;
119	}
120
121	if((pAdapter == NULL) || (pQosClassifierBuffer == NULL))
122	{
123		return NOK;
124	}
125
126	pDest = (NWIF_CLSFR_ENTRY *)(pAdapter->qosClassifierTable);
127	pSrc = (NWIF_CLSFR_ENTRY *)pQosClassifierBuffer;
128
129	NumOfEntries = bufferLength / sizeof(NWIF_CLSFR_ENTRY);
130	for(clsfrIndex = 0; clsfrIndex <NumOfEntries ; clsfrIndex++)
131	{
132		pDest[clsfrIndex].ip = pSrc[clsfrIndex].ip;
133		pDest[clsfrIndex].port = pSrc[clsfrIndex].port;
134		pDest[clsfrIndex].pri = pSrc[clsfrIndex].pri;
135	}
136
137	return OK;
138
139}
140
141
142
143
144
145