LCOV - code coverage report
Current view: top level - src/ap - ap_mlme.c (source / functions) Hit Total Coverage
Test: wpa_supplicant hwsim test run 1388338050 Lines: 27 44 61.4 %
Date: 2013-12-29 Functions: 5 8 62.5 %
Branches: 6 14 42.9 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * hostapd / IEEE 802.11 MLME
       3                 :            :  * Copyright 2003-2006, Jouni Malinen <j@w1.fi>
       4                 :            :  * Copyright 2003-2004, Instant802 Networks, Inc.
       5                 :            :  * Copyright 2005-2006, Devicescape Software, Inc.
       6                 :            :  *
       7                 :            :  * This software may be distributed under the terms of the BSD license.
       8                 :            :  * See README for more details.
       9                 :            :  */
      10                 :            : 
      11                 :            : #include "utils/includes.h"
      12                 :            : 
      13                 :            : #include "utils/common.h"
      14                 :            : #include "common/ieee802_11_defs.h"
      15                 :            : #include "ieee802_11.h"
      16                 :            : #include "wpa_auth.h"
      17                 :            : #include "sta_info.h"
      18                 :            : #include "ap_mlme.h"
      19                 :            : 
      20                 :            : 
      21                 :            : #ifndef CONFIG_NO_HOSTAPD_LOGGER
      22                 :        117 : static const char * mlme_auth_alg_str(int alg)
      23                 :            : {
      24   [ +  -  -  - ]:        117 :         switch (alg) {
      25                 :            :         case WLAN_AUTH_OPEN:
      26                 :        117 :                 return "OPEN_SYSTEM";
      27                 :            :         case WLAN_AUTH_SHARED_KEY:
      28                 :          0 :                 return "SHARED_KEY";
      29                 :            :         case WLAN_AUTH_FT:
      30                 :          0 :                 return "FT";
      31                 :            :         }
      32                 :            : 
      33                 :        117 :         return "unknown";
      34                 :            : }
      35                 :            : #endif /* CONFIG_NO_HOSTAPD_LOGGER */
      36                 :            : 
      37                 :            : 
      38                 :            : /**
      39                 :            :  * mlme_authenticate_indication - Report the establishment of an authentication
      40                 :            :  * relationship with a specific peer MAC entity
      41                 :            :  * @hapd: BSS data
      42                 :            :  * @sta: peer STA data
      43                 :            :  *
      44                 :            :  * MLME calls this function as a result of the establishment of an
      45                 :            :  * authentication relationship with a specific peer MAC entity that
      46                 :            :  * resulted from an authentication procedure that was initiated by
      47                 :            :  * that specific peer MAC entity.
      48                 :            :  *
      49                 :            :  * PeerSTAAddress = sta->addr
      50                 :            :  * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
      51                 :            :  */
      52                 :        117 : void mlme_authenticate_indication(struct hostapd_data *hapd,
      53                 :            :                                   struct sta_info *sta)
      54                 :            : {
      55                 :        117 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
      56                 :            :                        HOSTAPD_LEVEL_DEBUG,
      57                 :            :                        "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
      58                 :        819 :                        MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
      59 [ +  - ][ +  - ]:        117 :         if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
      60                 :        117 :                 mlme_deletekeys_request(hapd, sta);
      61                 :        117 : }
      62                 :            : 
      63                 :            : 
      64                 :            : /**
      65                 :            :  * mlme_deauthenticate_indication - Report the invalidation of an
      66                 :            :  * authentication relationship with a specific peer MAC entity
      67                 :            :  * @hapd: BSS data
      68                 :            :  * @sta: Peer STA data
      69                 :            :  * @reason_code: ReasonCode from Deauthentication frame
      70                 :            :  *
      71                 :            :  * MLME calls this function as a result of the invalidation of an
      72                 :            :  * authentication relationship with a specific peer MAC entity.
      73                 :            :  *
      74                 :            :  * PeerSTAAddress = sta->addr
      75                 :            :  */
      76                 :        117 : void mlme_deauthenticate_indication(struct hostapd_data *hapd,
      77                 :            :                                     struct sta_info *sta, u16 reason_code)
      78                 :            : {
      79                 :        117 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
      80                 :            :                        HOSTAPD_LEVEL_DEBUG,
      81                 :            :                        "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
      82                 :        702 :                        MAC2STR(sta->addr), reason_code);
      83                 :        117 :         mlme_deletekeys_request(hapd, sta);
      84                 :        117 : }
      85                 :            : 
      86                 :            : 
      87                 :            : /**
      88                 :            :  * mlme_associate_indication - Report the establishment of an association with
      89                 :            :  * a specific peer MAC entity
      90                 :            :  * @hapd: BSS data
      91                 :            :  * @sta: peer STA data
      92                 :            :  *
      93                 :            :  * MLME calls this function as a result of the establishment of an
      94                 :            :  * association with a specific peer MAC entity that resulted from an
      95                 :            :  * association procedure that was initiated by that specific peer MAC entity.
      96                 :            :  *
      97                 :            :  * PeerSTAAddress = sta->addr
      98                 :            :  */
      99                 :        117 : void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
     100                 :            : {
     101                 :        117 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     102                 :            :                        HOSTAPD_LEVEL_DEBUG,
     103                 :            :                        "MLME-ASSOCIATE.indication(" MACSTR ")",
     104                 :        702 :                        MAC2STR(sta->addr));
     105         [ +  - ]:        117 :         if (sta->auth_alg != WLAN_AUTH_FT)
     106                 :        117 :                 mlme_deletekeys_request(hapd, sta);
     107                 :        117 : }
     108                 :            : 
     109                 :            : 
     110                 :            : /**
     111                 :            :  * mlme_reassociate_indication - Report the establishment of an reassociation
     112                 :            :  * with a specific peer MAC entity
     113                 :            :  * @hapd: BSS data
     114                 :            :  * @sta: peer STA data
     115                 :            :  *
     116                 :            :  * MLME calls this function as a result of the establishment of an
     117                 :            :  * reassociation with a specific peer MAC entity that resulted from a
     118                 :            :  * reassociation procedure that was initiated by that specific peer MAC entity.
     119                 :            :  *
     120                 :            :  * PeerSTAAddress = sta->addr
     121                 :            :  *
     122                 :            :  * sta->previous_ap contains the "Current AP" information from ReassocReq.
     123                 :            :  */
     124                 :          0 : void mlme_reassociate_indication(struct hostapd_data *hapd,
     125                 :            :                                  struct sta_info *sta)
     126                 :            : {
     127                 :          0 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     128                 :            :                        HOSTAPD_LEVEL_DEBUG,
     129                 :            :                        "MLME-REASSOCIATE.indication(" MACSTR ")",
     130                 :          0 :                        MAC2STR(sta->addr));
     131         [ #  # ]:          0 :         if (sta->auth_alg != WLAN_AUTH_FT)
     132                 :          0 :                 mlme_deletekeys_request(hapd, sta);
     133                 :          0 : }
     134                 :            : 
     135                 :            : 
     136                 :            : /**
     137                 :            :  * mlme_disassociate_indication - Report disassociation with a specific peer
     138                 :            :  * MAC entity
     139                 :            :  * @hapd: BSS data
     140                 :            :  * @sta: Peer STA data
     141                 :            :  * @reason_code: ReasonCode from Disassociation frame
     142                 :            :  *
     143                 :            :  * MLME calls this function as a result of the invalidation of an association
     144                 :            :  * relationship with a specific peer MAC entity.
     145                 :            :  *
     146                 :            :  * PeerSTAAddress = sta->addr
     147                 :            :  */
     148                 :          0 : void mlme_disassociate_indication(struct hostapd_data *hapd,
     149                 :            :                                   struct sta_info *sta, u16 reason_code)
     150                 :            : {
     151                 :          0 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     152                 :            :                        HOSTAPD_LEVEL_DEBUG,
     153                 :            :                        "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
     154                 :          0 :                        MAC2STR(sta->addr), reason_code);
     155                 :          0 :         mlme_deletekeys_request(hapd, sta);
     156                 :          0 : }
     157                 :            : 
     158                 :            : 
     159                 :          0 : void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
     160                 :            :                                        const u8 *addr)
     161                 :            : {
     162                 :          0 :         hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
     163                 :            :                        HOSTAPD_LEVEL_DEBUG,
     164                 :            :                        "MLME-MichaelMICFailure.indication(" MACSTR ")",
     165                 :          0 :                        MAC2STR(addr));
     166                 :          0 : }
     167                 :            : 
     168                 :            : 
     169                 :        351 : void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
     170                 :            : {
     171                 :        351 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     172                 :            :                        HOSTAPD_LEVEL_DEBUG,
     173                 :            :                        "MLME-DELETEKEYS.request(" MACSTR ")",
     174                 :       2106 :                        MAC2STR(sta->addr));
     175                 :            : 
     176         [ +  + ]:        351 :         if (sta->wpa_sm)
     177                 :        136 :                 wpa_remove_ptk(sta->wpa_sm);
     178                 :        351 : }

Generated by: LCOV version 1.9