LCOV - code coverage report
Current view: top level - src/ap - utils.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1393793999 Lines: 28 29 96.6 %
Date: 2014-03-02 Functions: 3 3 100.0 %
Branches: 10 12 83.3 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * AP mode helper functions
       3                 :            :  * Copyright (c) 2009, Jouni Malinen <j@w1.fi>
       4                 :            :  *
       5                 :            :  * This software may be distributed under the terms of the BSD license.
       6                 :            :  * See README for more details.
       7                 :            :  */
       8                 :            : 
       9                 :            : #include "includes.h"
      10                 :            : 
      11                 :            : #include "common.h"
      12                 :            : #include "common/ieee802_11_defs.h"
      13                 :            : #include "sta_info.h"
      14                 :            : #include "hostapd.h"
      15                 :            : 
      16                 :            : 
      17                 :        222 : int hostapd_register_probereq_cb(struct hostapd_data *hapd,
      18                 :            :                                  int (*cb)(void *ctx, const u8 *sa,
      19                 :            :                                            const u8 *da, const u8 *bssid,
      20                 :            :                                            const u8 *ie, size_t ie_len,
      21                 :            :                                            int ssi_signal),
      22                 :            :                                  void *ctx)
      23                 :            : {
      24                 :            :         struct hostapd_probereq_cb *n;
      25                 :            : 
      26                 :        222 :         n = os_realloc_array(hapd->probereq_cb, hapd->num_probereq_cb + 1,
      27                 :            :                              sizeof(struct hostapd_probereq_cb));
      28         [ -  + ]:        222 :         if (n == NULL)
      29                 :          0 :                 return -1;
      30                 :            : 
      31                 :        222 :         hapd->probereq_cb = n;
      32                 :        222 :         n = &hapd->probereq_cb[hapd->num_probereq_cb];
      33                 :        222 :         hapd->num_probereq_cb++;
      34                 :            : 
      35                 :        222 :         n->cb = cb;
      36                 :        222 :         n->ctx = ctx;
      37                 :            : 
      38                 :        222 :         return 0;
      39                 :            : }
      40                 :            : 
      41                 :            : 
      42                 :            : struct prune_data {
      43                 :            :         struct hostapd_data *hapd;
      44                 :            :         const u8 *addr;
      45                 :            : };
      46                 :            : 
      47                 :        553 : static int prune_associations(struct hostapd_iface *iface, void *ctx)
      48                 :            : {
      49                 :        553 :         struct prune_data *data = ctx;
      50                 :            :         struct sta_info *osta;
      51                 :            :         struct hostapd_data *ohapd;
      52                 :            :         size_t j;
      53                 :            : 
      54         [ +  + ]:       1178 :         for (j = 0; j < iface->num_bss; j++) {
      55                 :        625 :                 ohapd = iface->bss[j];
      56         [ +  + ]:        625 :                 if (ohapd == data->hapd)
      57                 :        481 :                         continue;
      58                 :        144 :                 osta = ap_get_sta(ohapd, data->addr);
      59         [ +  + ]:        144 :                 if (!osta)
      60                 :        118 :                         continue;
      61                 :            : 
      62                 :         26 :                 ap_sta_disassociate(ohapd, osta, WLAN_REASON_UNSPECIFIED);
      63                 :            :         }
      64                 :            : 
      65                 :        553 :         return 0;
      66                 :            : }
      67                 :            : 
      68                 :            : /**
      69                 :            :  * hostapd_prune_associations - Remove extraneous associations
      70                 :            :  * @hapd: Pointer to BSS data for the most recent association
      71                 :            :  * @addr: Associated STA address
      72                 :            :  *
      73                 :            :  * This function looks through all radios and BSS's for previous
      74                 :            :  * (stale) associations of STA. If any are found they are removed.
      75                 :            :  */
      76                 :        674 : void hostapd_prune_associations(struct hostapd_data *hapd, const u8 *addr)
      77                 :            : {
      78                 :            :         struct prune_data data;
      79                 :        674 :         data.hapd = hapd;
      80                 :        674 :         data.addr = addr;
      81 [ +  + ][ +  - ]:        674 :         if (hapd->iface->interfaces &&
      82                 :        481 :             hapd->iface->interfaces->for_each_interface)
      83                 :        481 :                 hapd->iface->interfaces->for_each_interface(
      84                 :        481 :                         hapd->iface->interfaces, prune_associations, &data);
      85                 :        674 : }

Generated by: LCOV version 1.9