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 1443382998 Lines: 45 45 100.0 %
Date: 2015-09-27 Functions: 8 8 100.0 %

          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             : #include "hostapd.h"
      20             : 
      21             : 
      22             : #ifndef CONFIG_NO_HOSTAPD_LOGGER
      23        3258 : static const char * mlme_auth_alg_str(int alg)
      24             : {
      25        3258 :         switch (alg) {
      26             :         case WLAN_AUTH_OPEN:
      27        3045 :                 return "OPEN_SYSTEM";
      28             :         case WLAN_AUTH_SHARED_KEY:
      29          26 :                 return "SHARED_KEY";
      30             :         case WLAN_AUTH_FT:
      31         119 :                 return "FT";
      32             :         }
      33             : 
      34          68 :         return "unknown";
      35             : }
      36             : #endif /* CONFIG_NO_HOSTAPD_LOGGER */
      37             : 
      38             : 
      39             : /**
      40             :  * mlme_authenticate_indication - Report the establishment of an authentication
      41             :  * relationship with a specific peer MAC entity
      42             :  * @hapd: BSS data
      43             :  * @sta: peer STA data
      44             :  *
      45             :  * MLME calls this function as a result of the establishment of an
      46             :  * authentication relationship with a specific peer MAC entity that
      47             :  * resulted from an authentication procedure that was initiated by
      48             :  * that specific peer MAC entity.
      49             :  *
      50             :  * PeerSTAAddress = sta->addr
      51             :  * AuthenticationType = sta->auth_alg (WLAN_AUTH_OPEN / WLAN_AUTH_SHARED_KEY)
      52             :  */
      53        3258 : void mlme_authenticate_indication(struct hostapd_data *hapd,
      54             :                                   struct sta_info *sta)
      55             : {
      56       22806 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
      57             :                        HOSTAPD_LEVEL_DEBUG,
      58             :                        "MLME-AUTHENTICATE.indication(" MACSTR ", %s)",
      59       22806 :                        MAC2STR(sta->addr), mlme_auth_alg_str(sta->auth_alg));
      60        3258 :         if (sta->auth_alg != WLAN_AUTH_FT && !(sta->flags & WLAN_STA_MFP))
      61        3127 :                 mlme_deletekeys_request(hapd, sta);
      62        3258 : }
      63             : 
      64             : 
      65             : /**
      66             :  * mlme_deauthenticate_indication - Report the invalidation of an
      67             :  * authentication relationship with a specific peer MAC entity
      68             :  * @hapd: BSS data
      69             :  * @sta: Peer STA data
      70             :  * @reason_code: ReasonCode from Deauthentication frame
      71             :  *
      72             :  * MLME calls this function as a result of the invalidation of an
      73             :  * authentication relationship with a specific peer MAC entity.
      74             :  *
      75             :  * PeerSTAAddress = sta->addr
      76             :  */
      77        3074 : void mlme_deauthenticate_indication(struct hostapd_data *hapd,
      78             :                                     struct sta_info *sta, u16 reason_code)
      79             : {
      80       21518 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
      81             :                        HOSTAPD_LEVEL_DEBUG,
      82             :                        "MLME-DEAUTHENTICATE.indication(" MACSTR ", %d)",
      83       18444 :                        MAC2STR(sta->addr), reason_code);
      84        3074 :         if (!hapd->iface->driver_ap_teardown)
      85        2860 :                 mlme_deletekeys_request(hapd, sta);
      86        3074 : }
      87             : 
      88             : 
      89             : /**
      90             :  * mlme_associate_indication - Report the establishment of an association with
      91             :  * a specific peer MAC entity
      92             :  * @hapd: BSS data
      93             :  * @sta: peer STA data
      94             :  *
      95             :  * MLME calls this function as a result of the establishment of an
      96             :  * association with a specific peer MAC entity that resulted from an
      97             :  * association procedure that was initiated by that specific peer MAC entity.
      98             :  *
      99             :  * PeerSTAAddress = sta->addr
     100             :  */
     101        2998 : void mlme_associate_indication(struct hostapd_data *hapd, struct sta_info *sta)
     102             : {
     103       17988 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     104             :                        HOSTAPD_LEVEL_DEBUG,
     105             :                        "MLME-ASSOCIATE.indication(" MACSTR ")",
     106       17988 :                        MAC2STR(sta->addr));
     107        2998 :         if (sta->auth_alg != WLAN_AUTH_FT)
     108        2998 :                 mlme_deletekeys_request(hapd, sta);
     109        2998 : }
     110             : 
     111             : 
     112             : /**
     113             :  * mlme_reassociate_indication - Report the establishment of an reassociation
     114             :  * with a specific peer MAC entity
     115             :  * @hapd: BSS data
     116             :  * @sta: peer STA data
     117             :  *
     118             :  * MLME calls this function as a result of the establishment of an
     119             :  * reassociation with a specific peer MAC entity that resulted from a
     120             :  * reassociation procedure that was initiated by that specific peer MAC entity.
     121             :  *
     122             :  * PeerSTAAddress = sta->addr
     123             :  */
     124         308 : void mlme_reassociate_indication(struct hostapd_data *hapd,
     125             :                                  struct sta_info *sta)
     126             : {
     127        1848 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     128             :                        HOSTAPD_LEVEL_DEBUG,
     129             :                        "MLME-REASSOCIATE.indication(" MACSTR ")",
     130        1848 :                        MAC2STR(sta->addr));
     131         308 :         if (sta->auth_alg != WLAN_AUTH_FT)
     132          85 :                 mlme_deletekeys_request(hapd, sta);
     133         308 : }
     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          14 : void mlme_disassociate_indication(struct hostapd_data *hapd,
     149             :                                   struct sta_info *sta, u16 reason_code)
     150             : {
     151          98 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     152             :                        HOSTAPD_LEVEL_DEBUG,
     153             :                        "MLME-DISASSOCIATE.indication(" MACSTR ", %d)",
     154          84 :                        MAC2STR(sta->addr), reason_code);
     155          14 :         mlme_deletekeys_request(hapd, sta);
     156          14 : }
     157             : 
     158             : 
     159           2 : void mlme_michaelmicfailure_indication(struct hostapd_data *hapd,
     160             :                                        const u8 *addr)
     161             : {
     162          12 :         hostapd_logger(hapd, addr, HOSTAPD_MODULE_MLME,
     163             :                        HOSTAPD_LEVEL_DEBUG,
     164             :                        "MLME-MichaelMICFailure.indication(" MACSTR ")",
     165          12 :                        MAC2STR(addr));
     166           2 : }
     167             : 
     168             : 
     169        9084 : void mlme_deletekeys_request(struct hostapd_data *hapd, struct sta_info *sta)
     170             : {
     171       54504 :         hostapd_logger(hapd, sta->addr, HOSTAPD_MODULE_MLME,
     172             :                        HOSTAPD_LEVEL_DEBUG,
     173             :                        "MLME-DELETEKEYS.request(" MACSTR ")",
     174       54504 :                        MAC2STR(sta->addr));
     175             : 
     176        9084 :         if (sta->wpa_sm)
     177        3925 :                 wpa_remove_ptk(sta->wpa_sm);
     178        9084 : }

Generated by: LCOV version 1.10