LCOV - code coverage report
Current view: top level - wpa_supplicant - autoscan_exponential.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1393793999 Lines: 0 35 0.0 %
Date: 2014-03-02 Functions: 0 4 0.0 %
Branches: 0 14 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * WPA Supplicant - auto scan exponential module
       3                 :            :  * Copyright (c) 2012, Intel Corporation. All rights reserved.
       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 "wpa_supplicant_i.h"
      13                 :            : #include "autoscan.h"
      14                 :            : 
      15                 :            : struct autoscan_exponential_data {
      16                 :            :         struct wpa_supplicant *wpa_s;
      17                 :            :         int base;
      18                 :            :         int limit;
      19                 :            :         int interval;
      20                 :            : };
      21                 :            : 
      22                 :            : 
      23                 :            : static int
      24                 :          0 : autoscan_exponential_get_params(struct autoscan_exponential_data *data,
      25                 :            :                                 const char *params)
      26                 :            : {
      27                 :            :         const char *pos;
      28                 :            : 
      29         [ #  # ]:          0 :         if (params == NULL)
      30                 :          0 :                 return -1;
      31                 :            : 
      32                 :          0 :         data->base = atoi(params);
      33                 :            : 
      34                 :          0 :         pos = os_strchr(params, ':');
      35         [ #  # ]:          0 :         if (pos == NULL)
      36                 :          0 :                 return -1;
      37                 :            : 
      38                 :          0 :         pos++;
      39                 :          0 :         data->limit = atoi(pos);
      40                 :            : 
      41                 :          0 :         return 0;
      42                 :            : }
      43                 :            : 
      44                 :            : 
      45                 :          0 : static void * autoscan_exponential_init(struct wpa_supplicant *wpa_s,
      46                 :            :                                         const char *params)
      47                 :            : {
      48                 :            :         struct autoscan_exponential_data *data;
      49                 :            : 
      50                 :          0 :         data = os_zalloc(sizeof(struct autoscan_exponential_data));
      51         [ #  # ]:          0 :         if (data == NULL)
      52                 :          0 :                 return NULL;
      53                 :            : 
      54         [ #  # ]:          0 :         if (autoscan_exponential_get_params(data, params) < 0) {
      55                 :          0 :                 os_free(data);
      56                 :          0 :                 return NULL;
      57                 :            :         }
      58                 :            : 
      59                 :          0 :         wpa_printf(MSG_DEBUG, "autoscan exponential: base exponential is %d "
      60                 :            :                    "and limit is %d", data->base, data->limit);
      61                 :            : 
      62                 :          0 :         data->wpa_s = wpa_s;
      63                 :            : 
      64                 :          0 :         return data;
      65                 :            : }
      66                 :            : 
      67                 :            : 
      68                 :          0 : static void autoscan_exponential_deinit(void *priv)
      69                 :            : {
      70                 :          0 :         struct autoscan_exponential_data *data = priv;
      71                 :            : 
      72                 :          0 :         os_free(data);
      73                 :          0 : }
      74                 :            : 
      75                 :            : 
      76                 :          0 : static int autoscan_exponential_notify_scan(void *priv,
      77                 :            :                                             struct wpa_scan_results *scan_res)
      78                 :            : {
      79                 :          0 :         struct autoscan_exponential_data *data = priv;
      80                 :            : 
      81                 :          0 :         wpa_printf(MSG_DEBUG, "autoscan exponential: scan result "
      82                 :            :                    "notification");
      83                 :            : 
      84         [ #  # ]:          0 :         if (data->interval >= data->limit)
      85                 :          0 :                 return data->limit;
      86                 :            : 
      87         [ #  # ]:          0 :         if (data->interval <= 0)
      88                 :          0 :                 data->interval = data->base;
      89                 :            :         else {
      90                 :          0 :                 data->interval = data->interval * data->base;
      91         [ #  # ]:          0 :                 if (data->interval > data->limit)
      92                 :          0 :                         return data->limit;
      93                 :            :         }
      94                 :            : 
      95                 :          0 :         return data->interval;
      96                 :            : }
      97                 :            : 
      98                 :            : 
      99                 :            : const struct autoscan_ops autoscan_exponential_ops = {
     100                 :            :         .name = "exponential",
     101                 :            :         .init = autoscan_exponential_init,
     102                 :            :         .deinit = autoscan_exponential_deinit,
     103                 :            :         .notify_scan = autoscan_exponential_notify_scan,
     104                 :            : };

Generated by: LCOV version 1.9