LCOV - code coverage report
Current view: top level - src/ap - ap_mlme.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1393793999 Lines: 40 44 90.9 %
Date: 2014-03-02 Functions: 7 8 87.5 %
Branches: 12 14 85.7 %

           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                 :        670 : static const char * mlme_auth_alg_str(int alg)
      23                 :            : {
      24   [ +  +  +  + ]:        670 :         switch (alg) {
      25                 :            :         case WLAN_AUTH_OPEN:
      26                 :        640 :                 return "OPEN_SYSTEM";
      27                 :            :         case WLAN_AUTH_SHARED_KEY:
      28                 :          4 :                 return "SHARED_KEY";
      29                 :            :         case WLAN_AUTH_FT:
      30                 :         10 :                 return "FT";
      31                 :            :         }
      32                 :            : 
      33                 :        670 :         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                 :        670 : void mlme_authenticate_indication(struct hostapd_data *hapd,
      53                 :            :                                   struct sta_info *sta)
      54                 :            : {
      55                 :        670 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
      56                 :            :                        HOSTAPD_LEVEL_DEBUG,
      57                 :            :                        "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
      58                 :       4690 :                        MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
      59 [ +  - ][ +  + ]:        670 :         if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
      60                 :        660 :                 mlme_deletekeys_request(hapd, sta);
      61                 :        670 : }
      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                 :        657 : void mlme_deauthenticate_indication(struct hostapd_data *hapd,
      77                 :            :                                     struct sta_info *sta, u16 reason_code)
      78                 :            : {
      79                 :        657 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
      80                 :            :                        HOSTAPD_LEVEL_DEBUG,
      81                 :            :                        "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
      82                 :       3942 :                        MAC2STR(sta->addr), reason_code);
      83                 :        657 :         mlme_deletekeys_request(hapd, sta);
      84                 :        657 : }
      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                 :        648 : void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
     100                 :            : {
     101                 :        648 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     102                 :            :                        HOSTAPD_LEVEL_DEBUG,
     103                 :            :                        "MLME-ASSOCIATE.indication(" MACSTR ")",
     104                 :       3888 :                        MAC2STR(sta->addr));
     105         [ +  - ]:        648 :         if (sta->auth_alg != WLAN_AUTH_FT)
     106                 :        648 :                 mlme_deletekeys_request(hapd, sta);
     107                 :        648 : }
     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                 :         26 : void mlme_reassociate_indication(struct hostapd_data *hapd,
     125                 :            :                                  struct sta_info *sta)
     126                 :            : {
     127                 :         26 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     128                 :            :                        HOSTAPD_LEVEL_DEBUG,
     129                 :            :                        "MLME-REASSOCIATE.indication(" MACSTR ")",
     130                 :        156 :                        MAC2STR(sta->addr));
     131         [ +  + ]:         26 :         if (sta->auth_alg != WLAN_AUTH_FT)
     132                 :         10 :                 mlme_deletekeys_request(hapd, sta);
     133                 :         26 : }
     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                 :          1 : void mlme_disassociate_indication(struct hostapd_data *hapd,
     149                 :            :                                   struct sta_info *sta, u16 reason_code)
     150                 :            : {
     151                 :          1 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     152                 :            :                        HOSTAPD_LEVEL_DEBUG,
     153                 :            :                        "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
     154                 :          6 :                        MAC2STR(sta->addr), reason_code);
     155                 :          1 :         mlme_deletekeys_request(hapd, sta);
     156                 :          1 : }
     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                 :       1976 : void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
     170                 :            : {
     171                 :       1976 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     172                 :            :                        HOSTAPD_LEVEL_DEBUG,
     173                 :            :                        "MLME-DELETEKEYS.request(" MACSTR ")",
     174                 :      11856 :                        MAC2STR(sta->addr));
     175                 :            : 
     176         [ +  + ]:       1976 :         if (sta->wpa_sm)
     177                 :        841 :                 wpa_remove_ptk(sta->wpa_sm);
     178                 :       1976 : }

Generated by: LCOV version 1.9