LCOV - code coverage report
Current view: top level - wpa_supplicant - notify.c (source / functions) Hit Total Coverage
Test: wpa_supplicant/hostapd combined for hwsim test run 1388338050 Lines: 170 236 72.0 %
Date: 2013-12-29 Functions: 45 59 76.3 %
Branches: 23 46 50.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * wpa_supplicant - Event notifications
       3                 :            :  * Copyright (c) 2009-2010, 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 "utils/includes.h"
      10                 :            : 
      11                 :            : #include "utils/common.h"
      12                 :            : #include "common/wpa_ctrl.h"
      13                 :            : #include "config.h"
      14                 :            : #include "wpa_supplicant_i.h"
      15                 :            : #include "wps_supplicant.h"
      16                 :            : #include "dbus/dbus_common.h"
      17                 :            : #include "dbus/dbus_old.h"
      18                 :            : #include "dbus/dbus_new.h"
      19                 :            : #include "rsn_supp/wpa.h"
      20                 :            : #include "driver_i.h"
      21                 :            : #include "scan.h"
      22                 :            : #include "p2p_supplicant.h"
      23                 :            : #include "sme.h"
      24                 :            : #include "notify.h"
      25                 :            : 
      26                 :          3 : int wpas_notify_supplicant_initialized(struct wpa_global *global)
      27                 :            : {
      28                 :            : #ifdef CONFIG_DBUS
      29         [ -  + ]:          3 :         if (global->params.dbus_ctrl_interface) {
      30                 :          0 :                 global->dbus = wpas_dbus_init(global);
      31         [ #  # ]:          0 :                 if (global->dbus == NULL)
      32                 :          0 :                         return -1;
      33                 :            :         }
      34                 :            : #endif /* CONFIG_DBUS */
      35                 :            : 
      36                 :          3 :         return 0;
      37                 :            : }
      38                 :            : 
      39                 :            : 
      40                 :          3 : void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
      41                 :            : {
      42                 :            : #ifdef CONFIG_DBUS
      43         [ -  + ]:          3 :         if (global->dbus)
      44                 :          0 :                 wpas_dbus_deinit(global->dbus);
      45                 :            : #endif /* CONFIG_DBUS */
      46                 :          3 : }
      47                 :            : 
      48                 :            : 
      49                 :         22 : int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
      50                 :            : {
      51         [ -  + ]:         22 :         if (wpas_dbus_register_iface(wpa_s))
      52                 :          0 :                 return -1;
      53                 :            : 
      54         [ -  + ]:         22 :         if (wpas_dbus_register_interface(wpa_s))
      55                 :          0 :                 return -1;
      56                 :            : 
      57                 :         22 :         return 0;
      58                 :            : }
      59                 :            : 
      60                 :            : 
      61                 :         22 : void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
      62                 :            : {
      63                 :            :         /* unregister interface in old DBus ctrl iface */
      64                 :         22 :         wpas_dbus_unregister_iface(wpa_s);
      65                 :            : 
      66                 :            :         /* unregister interface in new DBus ctrl iface */
      67                 :         22 :         wpas_dbus_unregister_interface(wpa_s);
      68                 :         22 : }
      69                 :            : 
      70                 :            : 
      71                 :       3537 : void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
      72                 :            :                                enum wpa_states new_state,
      73                 :            :                                enum wpa_states old_state)
      74                 :            : {
      75                 :            :         /* notify the old DBus API */
      76                 :       3537 :         wpa_supplicant_dbus_notify_state_change(wpa_s, new_state,
      77                 :            :                                                 old_state);
      78                 :            : 
      79                 :            :         /* notify the new DBus API */
      80                 :       3537 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
      81                 :            : 
      82                 :            : #ifdef CONFIG_P2P
      83         [ +  + ]:       3537 :         if (new_state == WPA_COMPLETED)
      84                 :        399 :                 wpas_p2p_notif_connected(wpa_s);
      85 [ +  + ][ +  + ]:       3138 :         else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED)
      86                 :        514 :                 wpas_p2p_notif_disconnected(wpa_s);
      87                 :            : #endif /* CONFIG_P2P */
      88                 :            : 
      89                 :       3537 :         sme_state_changed(wpa_s);
      90                 :            : 
      91                 :            : #ifdef ANDROID
      92                 :            :         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
      93                 :            :                      "id=%d state=%d BSSID=" MACSTR " SSID=%s",
      94                 :            :                      wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
      95                 :            :                      new_state,
      96                 :            :                      MAC2STR(wpa_s->bssid),
      97                 :            :                      wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
      98                 :            :                      wpa_ssid_txt(wpa_s->current_ssid->ssid,
      99                 :            :                                   wpa_s->current_ssid->ssid_len) : "");
     100                 :            : #endif /* ANDROID */
     101                 :       3537 : }
     102                 :            : 
     103                 :            : 
     104                 :        749 : void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
     105                 :            : {
     106                 :        749 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
     107                 :        749 : }
     108                 :            : 
     109                 :            : 
     110                 :        252 : void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
     111                 :            : {
     112                 :        252 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
     113                 :        252 : }
     114                 :            : 
     115                 :            : 
     116                 :          0 : void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
     117                 :            : {
     118                 :          0 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
     119                 :          0 : }
     120                 :            : 
     121                 :            : 
     122                 :        851 : void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
     123                 :            : {
     124                 :        851 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
     125                 :        851 : }
     126                 :            : 
     127                 :            : 
     128                 :        798 : void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
     129                 :            : {
     130                 :        798 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
     131                 :        798 : }
     132                 :            : 
     133                 :            : 
     134                 :        210 : void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
     135                 :            :                                          struct wpa_ssid *ssid)
     136                 :            : {
     137                 :        210 :         wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
     138                 :        210 : }
     139                 :            : 
     140                 :            : 
     141                 :        219 : void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
     142                 :            :                                   struct wpa_ssid *ssid)
     143                 :            : {
     144                 :        219 :         wpas_dbus_signal_network_selected(wpa_s, ssid->id);
     145                 :        219 : }
     146                 :            : 
     147                 :            : 
     148                 :          2 : void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
     149                 :            :                                  struct wpa_ssid *ssid,
     150                 :            :                                  enum wpa_ctrl_req_type rtype,
     151                 :            :                                  const char *default_txt)
     152                 :            : {
     153                 :          2 :         wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
     154                 :          2 : }
     155                 :            : 
     156                 :            : 
     157                 :        870 : void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
     158                 :            : {
     159                 :            :         /* notify the old DBus API */
     160                 :        870 :         wpa_supplicant_dbus_notify_scanning(wpa_s);
     161                 :            : 
     162                 :            :         /* notify the new DBus API */
     163                 :        870 :         wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
     164                 :        870 : }
     165                 :            : 
     166                 :            : 
     167                 :        399 : void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
     168                 :            : {
     169                 :        399 :         wpas_dbus_signal_scan_done(wpa_s, success);
     170                 :        399 : }
     171                 :            : 
     172                 :            : 
     173                 :        399 : void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
     174                 :            : {
     175                 :            :         /* notify the old DBus API */
     176                 :        399 :         wpa_supplicant_dbus_notify_scan_results(wpa_s);
     177                 :            : 
     178                 :        399 :         wpas_wps_notify_scan_results(wpa_s);
     179                 :        399 : }
     180                 :            : 
     181                 :            : 
     182                 :          0 : void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
     183                 :            :                                 const struct wps_credential *cred)
     184                 :            : {
     185                 :            : #ifdef CONFIG_WPS
     186                 :            :         /* notify the old DBus API */
     187                 :          0 :         wpa_supplicant_dbus_notify_wps_cred(wpa_s, cred);
     188                 :            :         /* notify the new DBus API */
     189                 :          0 :         wpas_dbus_signal_wps_cred(wpa_s, cred);
     190                 :            : #endif /* CONFIG_WPS */
     191                 :          0 : }
     192                 :            : 
     193                 :            : 
     194                 :          5 : void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
     195                 :            :                                struct wps_event_m2d *m2d)
     196                 :            : {
     197                 :            : #ifdef CONFIG_WPS
     198                 :          5 :         wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
     199                 :            : #endif /* CONFIG_WPS */
     200                 :          5 : }
     201                 :            : 
     202                 :            : 
     203                 :         12 : void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
     204                 :            :                                 struct wps_event_fail *fail)
     205                 :            : {
     206                 :            : #ifdef CONFIG_WPS
     207                 :         12 :         wpas_dbus_signal_wps_event_fail(wpa_s, fail);
     208                 :            : #endif /* CONFIG_WPS */
     209                 :         12 : }
     210                 :            : 
     211                 :            : 
     212                 :         76 : void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
     213                 :            : {
     214                 :            : #ifdef CONFIG_WPS
     215                 :         76 :         wpas_dbus_signal_wps_event_success(wpa_s);
     216                 :            : #endif /* CONFIG_WPS */
     217                 :         76 : }
     218                 :            : 
     219                 :            : 
     220                 :        327 : void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
     221                 :            :                                struct wpa_ssid *ssid)
     222                 :            : {
     223                 :            :         /*
     224                 :            :          * Networks objects created during any P2P activities should not be
     225                 :            :          * exposed out. They might/will confuse certain non-P2P aware
     226                 :            :          * applications since these network objects won't behave like
     227                 :            :          * regular ones.
     228                 :            :          */
     229 [ +  - ][ +  + ]:        327 :         if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
     230                 :        277 :                 wpas_dbus_register_network(wpa_s, ssid);
     231                 :        327 : }
     232                 :            : 
     233                 :            : 
     234                 :         15 : void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
     235                 :            :                                         struct wpa_ssid *ssid)
     236                 :            : {
     237                 :            : #ifdef CONFIG_P2P
     238                 :         15 :         wpas_dbus_register_persistent_group(wpa_s, ssid);
     239                 :            : #endif /* CONFIG_P2P */
     240                 :         15 : }
     241                 :            : 
     242                 :            : 
     243                 :          0 : void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
     244                 :            :                                           struct wpa_ssid *ssid)
     245                 :            : {
     246                 :            : #ifdef CONFIG_P2P
     247                 :          0 :         wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
     248                 :            : #endif /* CONFIG_P2P */
     249                 :          0 : }
     250                 :            : 
     251                 :            : 
     252                 :        312 : void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
     253                 :            :                                  struct wpa_ssid *ssid)
     254                 :            : {
     255         [ +  - ]:        312 :         if (wpa_s->wpa)
     256                 :        312 :                 wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
     257 [ +  + ][ +  - ]:        312 :         if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s)
     258                 :        277 :                 wpas_dbus_unregister_network(wpa_s, ssid->id);
     259                 :            : #ifdef CONFIG_P2P
     260                 :        312 :         wpas_p2p_network_removed(wpa_s, ssid);
     261                 :            : #endif /* CONFIG_P2P */
     262                 :        312 : }
     263                 :            : 
     264                 :            : 
     265                 :        983 : void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
     266                 :            :                            u8 bssid[], unsigned int id)
     267                 :            : {
     268                 :        983 :         wpas_dbus_register_bss(wpa_s, bssid, id);
     269                 :        983 :         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
     270                 :       5898 :                      id, MAC2STR(bssid));
     271                 :        983 : }
     272                 :            : 
     273                 :            : 
     274                 :        983 : void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
     275                 :            :                              u8 bssid[], unsigned int id)
     276                 :            : {
     277                 :        983 :         wpas_dbus_unregister_bss(wpa_s, bssid, id);
     278                 :        983 :         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
     279                 :       5898 :                      id, MAC2STR(bssid));
     280                 :        983 : }
     281                 :            : 
     282                 :            : 
     283                 :          3 : void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
     284                 :            :                                   unsigned int id)
     285                 :            : {
     286                 :          3 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
     287                 :          3 : }
     288                 :            : 
     289                 :            : 
     290                 :          0 : void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
     291                 :            :                                     unsigned int id)
     292                 :            : {
     293                 :          0 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
     294                 :            :                                           id);
     295                 :          0 : }
     296                 :            : 
     297                 :            : 
     298                 :          7 : void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
     299                 :            :                                      unsigned int id)
     300                 :            : {
     301                 :          7 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
     302                 :            :                                           id);
     303                 :          7 : }
     304                 :            : 
     305                 :            : 
     306                 :          0 : void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
     307                 :            :                                   unsigned int id)
     308                 :            : {
     309                 :          0 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
     310                 :          0 : }
     311                 :            : 
     312                 :            : 
     313                 :          7 : void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
     314                 :            :                                    unsigned int id)
     315                 :            : {
     316                 :          7 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
     317                 :          7 : }
     318                 :            : 
     319                 :            : 
     320                 :          9 : void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
     321                 :            :                                    unsigned int id)
     322                 :            : {
     323                 :          9 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
     324                 :          9 : }
     325                 :            : 
     326                 :            : 
     327                 :         21 : void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
     328                 :            :                                  unsigned int id)
     329                 :            : {
     330                 :            : #ifdef CONFIG_WPS
     331                 :         21 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
     332                 :            : #endif /* CONFIG_WPS */
     333                 :         21 : }
     334                 :            : 
     335                 :            : 
     336                 :         35 : void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
     337                 :            :                                    unsigned int id)
     338                 :            : {
     339                 :         35 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
     340                 :         35 : }
     341                 :            : 
     342                 :            : 
     343                 :          0 : void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
     344                 :            :                                    unsigned int id)
     345                 :            : {
     346                 :          0 :         wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
     347                 :          0 : }
     348                 :            : 
     349                 :            : 
     350                 :          0 : void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
     351                 :            : {
     352                 :          0 :         wpas_dbus_signal_blob_added(wpa_s, name);
     353                 :          0 : }
     354                 :            : 
     355                 :            : 
     356                 :          0 : void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
     357                 :            : {
     358                 :          0 :         wpas_dbus_signal_blob_removed(wpa_s, name);
     359                 :          0 : }
     360                 :            : 
     361                 :            : 
     362                 :          0 : void wpas_notify_debug_level_changed(struct wpa_global *global)
     363                 :            : {
     364                 :          0 :         wpas_dbus_signal_debug_level_changed(global);
     365                 :          0 : }
     366                 :            : 
     367                 :            : 
     368                 :          0 : void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
     369                 :            : {
     370                 :          0 :         wpas_dbus_signal_debug_timestamp_changed(global);
     371                 :          0 : }
     372                 :            : 
     373                 :            : 
     374                 :          0 : void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
     375                 :            : {
     376                 :          0 :         wpas_dbus_signal_debug_show_keys_changed(global);
     377                 :          0 : }
     378                 :            : 
     379                 :            : 
     380                 :          0 : void wpas_notify_suspend(struct wpa_global *global)
     381                 :            : {
     382                 :            :         struct wpa_supplicant *wpa_s;
     383                 :            : 
     384                 :          0 :         os_get_time(&global->suspend_time);
     385                 :          0 :         wpa_printf(MSG_DEBUG, "System suspend notification");
     386         [ #  # ]:          0 :         for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
     387                 :          0 :                 wpa_drv_suspend(wpa_s);
     388                 :          0 : }
     389                 :            : 
     390                 :            : 
     391                 :          0 : void wpas_notify_resume(struct wpa_global *global)
     392                 :            : {
     393                 :            :         struct os_time now;
     394                 :            :         int slept;
     395                 :            :         struct wpa_supplicant *wpa_s;
     396                 :            : 
     397         [ #  # ]:          0 :         if (global->suspend_time.sec == 0)
     398                 :          0 :                 slept = -1;
     399                 :            :         else {
     400                 :          0 :                 os_get_time(&now);
     401                 :          0 :                 slept = now.sec - global->suspend_time.sec;
     402                 :            :         }
     403                 :          0 :         wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
     404                 :            :                    slept);
     405                 :            : 
     406         [ #  # ]:          0 :         for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
     407                 :          0 :                 wpa_drv_resume(wpa_s);
     408         [ #  # ]:          0 :                 if (wpa_s->wpa_state == WPA_DISCONNECTED)
     409                 :          0 :                         wpa_supplicant_req_scan(wpa_s, 0, 100000);
     410                 :            :         }
     411                 :          0 : }
     412                 :            : 
     413                 :            : 
     414                 :            : #ifdef CONFIG_P2P
     415                 :            : 
     416                 :        132 : void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
     417                 :            :                                   const u8 *dev_addr, int new_device)
     418                 :            : {
     419         [ +  - ]:        132 :         if (new_device) {
     420                 :            :                 /* Create the new peer object */
     421                 :        132 :                 wpas_dbus_register_peer(wpa_s, dev_addr);
     422                 :            :         }
     423                 :            : 
     424                 :            :         /* Notify a new peer has been detected*/
     425                 :        132 :         wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
     426                 :        132 : }
     427                 :            : 
     428                 :            : 
     429                 :        132 : void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
     430                 :            :                                  const u8 *dev_addr)
     431                 :            : {
     432                 :        132 :         wpas_dbus_unregister_peer(wpa_s, dev_addr);
     433                 :            : 
     434                 :            :         /* Create signal on interface object*/
     435                 :        132 :         wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
     436                 :        132 : }
     437                 :            : 
     438                 :            : 
     439                 :        114 : void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
     440                 :            :                                    const struct wpa_ssid *ssid,
     441                 :            :                                    const char *role)
     442                 :            : {
     443                 :        114 :         wpas_dbus_unregister_p2p_group(wpa_s, ssid);
     444                 :            : 
     445                 :        114 :         wpas_dbus_signal_p2p_group_removed(wpa_s, role);
     446                 :        114 : }
     447                 :            : 
     448                 :            : 
     449                 :          5 : void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
     450                 :            :                                 const u8 *src, u16 dev_passwd_id)
     451                 :            : {
     452                 :          5 :         wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id);
     453                 :          5 : }
     454                 :            : 
     455                 :            : 
     456                 :         69 : void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
     457                 :            :                                       struct p2p_go_neg_results *res)
     458                 :            : {
     459                 :         69 :         wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
     460                 :         69 : }
     461                 :            : 
     462                 :            : 
     463                 :         11 : void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
     464                 :            :                                        int status, const u8 *bssid)
     465                 :            : {
     466                 :         11 :         wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
     467                 :         11 : }
     468                 :            : 
     469                 :            : 
     470                 :          6 : void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
     471                 :            :                                 int freq, const u8 *sa, u8 dialog_token,
     472                 :            :                                 u16 update_indic, const u8 *tlvs,
     473                 :            :                                 size_t tlvs_len)
     474                 :            : {
     475                 :          6 :         wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
     476                 :            :                                         update_indic, tlvs, tlvs_len);
     477                 :          6 : }
     478                 :            : 
     479                 :            : 
     480                 :          6 : void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
     481                 :            :                                  const u8 *sa, u16 update_indic,
     482                 :            :                                  const u8 *tlvs, size_t tlvs_len)
     483                 :            : {
     484                 :          6 :         wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
     485                 :            :                                          tlvs, tlvs_len);
     486                 :          6 : }
     487                 :            : 
     488                 :            : 
     489                 :            : /**
     490                 :            :  * wpas_notify_p2p_provision_discovery - Notification of provision discovery
     491                 :            :  * @dev_addr: Who sent the request or responded to our request.
     492                 :            :  * @request: Will be 1 if request, 0 for response.
     493                 :            :  * @status: Valid only in case of response (0 in case of success)
     494                 :            :  * @config_methods: WPS config methods
     495                 :            :  * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
     496                 :            :  *
     497                 :            :  * This can be used to notify:
     498                 :            :  * - Requests or responses
     499                 :            :  * - Various config methods
     500                 :            :  * - Failure condition in case of response
     501                 :            :  */
     502                 :         24 : void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
     503                 :            :                                          const u8 *dev_addr, int request,
     504                 :            :                                          enum p2p_prov_disc_status status,
     505                 :            :                                          u16 config_methods,
     506                 :            :                                          unsigned int generated_pin)
     507                 :            : {
     508                 :         24 :         wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
     509                 :            :                                                  status, config_methods,
     510                 :            :                                                  generated_pin);
     511                 :         24 : }
     512                 :            : 
     513                 :            : 
     514                 :        113 : void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
     515                 :            :                                    struct wpa_ssid *ssid, int network_id,
     516                 :            :                                    int client)
     517                 :            : {
     518                 :            :         /* Notify a group has been started */
     519                 :        113 :         wpas_dbus_register_p2p_group(wpa_s, ssid);
     520                 :            : 
     521                 :        113 :         wpas_dbus_signal_p2p_group_started(wpa_s, ssid, client, network_id);
     522                 :        113 : }
     523                 :            : 
     524                 :            : 
     525                 :          0 : void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
     526                 :            :                                 struct wps_event_fail *fail)
     527                 :            : {
     528                 :          0 :         wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
     529                 :          0 : }
     530                 :            : 
     531                 :            : #endif /* CONFIG_P2P */
     532                 :            : 
     533                 :            : 
     534                 :         60 : static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
     535                 :            :                                           const u8 *sta,
     536                 :            :                                           const u8 *p2p_dev_addr)
     537                 :            : {
     538                 :            : #ifdef CONFIG_P2P
     539                 :         60 :         wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
     540                 :            : 
     541                 :            :         /*
     542                 :            :          * Register a group member object corresponding to this peer and
     543                 :            :          * emit a PeerJoined signal. This will check if it really is a
     544                 :            :          * P2P group.
     545                 :            :          */
     546                 :         60 :         wpas_dbus_register_p2p_groupmember(wpa_s, sta);
     547                 :            : 
     548                 :            :         /*
     549                 :            :          * Create 'peer-joined' signal on group object -- will also
     550                 :            :          * check P2P itself.
     551                 :            :          */
     552                 :         60 :         wpas_dbus_signal_p2p_peer_joined(wpa_s, sta);
     553                 :            : #endif /* CONFIG_P2P */
     554                 :            : 
     555                 :            :         /* Notify listeners a new station has been authorized */
     556                 :         60 :         wpas_dbus_signal_sta_authorized(wpa_s, sta);
     557                 :         60 : }
     558                 :            : 
     559                 :            : 
     560                 :         60 : static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
     561                 :            :                                             const u8 *sta)
     562                 :            : {
     563                 :            : #ifdef CONFIG_P2P
     564                 :            :         /*
     565                 :            :          * Unregister a group member object corresponding to this peer
     566                 :            :          * if this is a P2P group.
     567                 :            :          */
     568                 :         60 :         wpas_dbus_unregister_p2p_groupmember(wpa_s, sta);
     569                 :            : 
     570                 :            :         /*
     571                 :            :          * Create 'peer-disconnected' signal on group object if this
     572                 :            :          * is a P2P group.
     573                 :            :          */
     574                 :         60 :         wpas_dbus_signal_p2p_peer_disconnected(wpa_s, sta);
     575                 :            : #endif /* CONFIG_P2P */
     576                 :            : 
     577                 :            :         /* Notify listeners a station has been deauthorized */
     578                 :         60 :         wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
     579                 :         60 : }
     580                 :            : 
     581                 :            : 
     582                 :        120 : void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
     583                 :            :                                 const u8 *mac_addr, int authorized,
     584                 :            :                                 const u8 *p2p_dev_addr)
     585                 :            : {
     586         [ +  + ]:        120 :         if (authorized)
     587                 :         60 :                 wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr);
     588                 :            :         else
     589                 :         60 :                 wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr);
     590                 :        120 : }
     591                 :            : 
     592                 :            : 
     593                 :        109 : void wpas_notify_certification(struct wpa_supplicant *wpa_s, int depth,
     594                 :            :                                const char *subject, const char *cert_hash,
     595                 :            :                                const struct wpabuf *cert)
     596                 :            : {
     597 [ -  + ][ -  + ]:        109 :         wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
     598                 :            :                 "depth=%d subject='%s'%s%s",
     599                 :            :                 depth, subject,
     600                 :            :                 cert_hash ? " hash=" : "",
     601                 :            :                 cert_hash ? cert_hash : "");
     602                 :            : 
     603         [ -  + ]:        109 :         if (cert) {
     604                 :            :                 char *cert_hex;
     605                 :          0 :                 size_t len = wpabuf_len(cert) * 2 + 1;
     606                 :          0 :                 cert_hex = os_malloc(len);
     607         [ #  # ]:          0 :                 if (cert_hex) {
     608                 :          0 :                         wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert),
     609                 :            :                                          wpabuf_len(cert));
     610                 :          0 :                         wpa_msg_ctrl(wpa_s, MSG_INFO,
     611                 :            :                                      WPA_EVENT_EAP_PEER_CERT
     612                 :            :                                      "depth=%d subject='%s' cert=%s",
     613                 :            :                                      depth, subject, cert_hex);
     614                 :          0 :                         os_free(cert_hex);
     615                 :            :                 }
     616                 :            :         }
     617                 :            : 
     618                 :            :         /* notify the old DBus API */
     619                 :        109 :         wpa_supplicant_dbus_notify_certification(wpa_s, depth, subject,
     620                 :            :                                                  cert_hash, cert);
     621                 :            :         /* notify the new DBus API */
     622                 :        109 :         wpas_dbus_signal_certification(wpa_s, depth, subject, cert_hash, cert);
     623                 :        109 : }
     624                 :            : 
     625                 :            : 
     626                 :        100 : void wpas_notify_preq(struct wpa_supplicant *wpa_s,
     627                 :            :                       const u8 *addr, const u8 *dst, const u8 *bssid,
     628                 :            :                       const u8 *ie, size_t ie_len, u32 ssi_signal)
     629                 :            : {
     630                 :            : #ifdef CONFIG_AP
     631                 :        100 :         wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
     632                 :            : #endif /* CONFIG_AP */
     633                 :        100 : }
     634                 :            : 
     635                 :            : 
     636                 :        645 : void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
     637                 :            :                             const char *parameter)
     638                 :            : {
     639                 :        645 :         wpas_dbus_signal_eap_status(wpa_s, status, parameter);
     640                 :        645 :         wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
     641                 :            :                      "status='%s' parameter='%s'",
     642                 :            :                      status, parameter);
     643                 :        645 : }

Generated by: LCOV version 1.9