hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/** @file supplicant.c
 *
 *  @brief This file defines the API for supplicant
 *
 * Copyright (C) 2014-2017, Marvell International Ltd.
 *
 * This software file (the "File") is distributed by Marvell International
 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
 * (the "License").  You may use, redistribute and/or modify this File in
 * accordance with the terms and conditions of the License, a copy of which
 * is available by writing to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
 *
 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
 * ARE EXPRESSLY DISCLAIMED.  The License provides additional details about
 * this warranty disclaimer.
 */
 
/******************************************************
Change log:
    03/07/2014: Initial version
******************************************************/
 
#include "wltypes.h"
#include "keyMgmtSta.h"
#include "keyCommonDef.h"
#include "keyMgmtSta.h"
#include "pmkCache.h"
 
t_u8
EAPoLKeyPkt_Validation(mlan_buffer *pmbuf)
{
   t_u32 recvd_pkt_len, eapol_pkt_len;
   EAPOL_KeyMsg_t *pKeyMsg = NULL;
 
   pKeyMsg =
       (EAPOL_KeyMsg_t *)(pmbuf->pbuf + pmbuf->data_offset +
                  sizeof(ether_hdr_t));
   /* Received eapol pkt length: DataLen - 802.3 header */
   recvd_pkt_len = pmbuf->data_len - sizeof(ether_hdr_t);
   /* 8021.X header + EAPOL key pkt header */
   eapol_pkt_len = sizeof(EAPOL_KeyMsg_t) - sizeof(pKeyMsg->key_data);
 
   if (recvd_pkt_len < eapol_pkt_len) {
       PRINTM(MERROR,
              "Invalid EAPOL Key Msg, received length: %u, least length: %u\n",
              recvd_pkt_len, eapol_pkt_len);
       return 1;
   }
   /* Todo: other validation check */
 
   return 0;
}
 
static __inline void
ProcessEAPoLKeyPkt(phostsa_private priv, mlan_buffer *pmbuf,
          IEEEtypes_MacAddr_t *sa, IEEEtypes_MacAddr_t *da)
{
   hostsa_mlan_fns *pm_fns = &priv->mlan_fns;
   t_u8 bss_role = pm_fns->Hostsa_get_bss_role(pm_fns->pmlan_private);
 
   PRINTM(MMSG, "ProcessEAPoLKeyPk bss_type=%x bss_role=%x\n",
          pm_fns->bss_type, bss_role);
 
#ifdef MIB_STATS
   INC_MIB_STAT(connPtr, eapolRxForESUPPCnt);
#endif
 
   if (EAPoLKeyPkt_Validation(pmbuf) != 0)
       return;
 
   switch (bss_role) {
#ifdef BTAMP
   case CONNECTION_TYPE_BTAMP:
       ProcessKeyMgmtDataAmp(bufDesc);
       break;
#endif
 
   case MLAN_BSS_ROLE_STA:
       /*key data */
       ProcessKeyMgmtDataSta(priv, pmbuf, sa, da);
       break;
 
   default:
#ifdef AUTHENTICATOR
       if (WIFI_DIRECT_MODE_GO == connPtr->DeviceMode) {
           ProcessKeyMgmtDataAp(bufDesc);
       }
#endif
 
       break;
   }
}
 
t_u8
ProcessEAPoLPkt(void *priv, mlan_buffer *pmbuf)
{
   phostsa_private psapriv = (phostsa_private)priv;
   ether_hdr_t *pEthHdr =
       (ether_hdr_t *)(pmbuf->pbuf + pmbuf->data_offset);
   EAP_PacketMsg_t *pEapPkt = NULL;
   UINT8 fPacketProcessed = 0;
 
   pEapPkt = (EAP_PacketMsg_t *)((t_u8 *)pEthHdr + sizeof(ether_hdr_t));
   switch (pEapPkt->hdr_8021x.pckt_type) {
   case IEEE_8021X_PACKET_TYPE_EAPOL_KEY:
       ProcessEAPoLKeyPkt(psapriv, pmbuf,
                  (IEEEtypes_MacAddr_t *)pEthHdr->sa,
                  (IEEEtypes_MacAddr_t *)pEthHdr->da);
       fPacketProcessed = 1;
       break;
 
#if 0
   case IEEE_8021X_PACKET_TYPE_EAP_PACKET:
       {
           if (WIFI_DIRECT_MODE_CLIENT == connPtr->DeviceMode
               || WIFI_DIRECT_MODE_DEVICE == connPtr->DeviceMode) {
               if (pEapPkt->code ==
                   IEEE_8021X_CODE_TYPE_REQUEST) {
                   assocAgent_eapRequestRx(sa);
               }
           }
       }
       break;
#endif
   default:
       break;
   }
//    CLEAN_FLUSH_CACHED_SQMEM((UINT32)(pEapPkt), bufDesc->DataLen);
   return fPacketProcessed;
}
 
Status_e
supplicantRestoreDefaults(void *priv)
{
   pmkCacheInit(priv);
   return SUCCESS;
}
 
/* This can also be removed*/
//#pragma arm section code = ".init"
void
supplicantFuncInit(void *priv)
{
   supplicantRestoreDefaults(priv);
}
 
//#pragma arm section code
//#endif /* PSK_SUPPLICANT */