Coverage Report

Created: 2025-10-10 06:31

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hostap/wpa_supplicant/notify.c
Line
Count
Source
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 "common/nan_de.h"
14
#include "config.h"
15
#include "wpa_supplicant_i.h"
16
#include "wps_supplicant.h"
17
#include "binder/binder.h"
18
#include "dbus/dbus_common.h"
19
#include "dbus/dbus_new.h"
20
#include "rsn_supp/wpa.h"
21
#include "rsn_supp/pmksa_cache.h"
22
#include "fst/fst.h"
23
#include "crypto/tls.h"
24
#include "bss.h"
25
#include "driver_i.h"
26
#include "scan.h"
27
#include "p2p_supplicant.h"
28
#include "sme.h"
29
#include "notify.h"
30
31
int wpas_notify_supplicant_initialized(struct wpa_global *global)
32
0
{
33
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
34
  if (global->params.dbus_ctrl_interface) {
35
    global->dbus = wpas_dbus_init(global);
36
    if (global->dbus == NULL)
37
      return -1;
38
  }
39
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
40
41
#ifdef CONFIG_BINDER
42
  global->binder = wpas_binder_init(global);
43
  if (!global->binder)
44
    return -1;
45
#endif /* CONFIG_BINDER */
46
47
0
  return 0;
48
0
}
49
50
51
void wpas_notify_supplicant_deinitialized(struct wpa_global *global)
52
0
{
53
#ifdef CONFIG_CTRL_IFACE_DBUS_NEW
54
  if (global->dbus)
55
    wpas_dbus_deinit(global->dbus);
56
#endif /* CONFIG_CTRL_IFACE_DBUS_NEW */
57
58
#ifdef CONFIG_BINDER
59
  if (global->binder)
60
    wpas_binder_deinit(global->binder);
61
#endif /* CONFIG_BINDER */
62
0
}
63
64
65
int wpas_notify_iface_added(struct wpa_supplicant *wpa_s)
66
0
{
67
0
  if (wpa_s->p2p_mgmt)
68
0
    return 0;
69
70
0
  if (wpas_dbus_register_interface(wpa_s))
71
0
    return -1;
72
73
0
  return 0;
74
0
}
75
76
77
void wpas_notify_iface_removed(struct wpa_supplicant *wpa_s)
78
0
{
79
0
  if (wpa_s->p2p_mgmt)
80
0
    return;
81
82
  /* unregister interface in new DBus ctrl iface */
83
0
  wpas_dbus_unregister_interface(wpa_s);
84
0
}
85
86
87
void wpas_notify_state_changed(struct wpa_supplicant *wpa_s,
88
             enum wpa_states new_state,
89
             enum wpa_states old_state)
90
0
{
91
0
  struct wpa_ssid *ssid = wpa_s->current_ssid;
92
93
0
  if (wpa_s->p2p_mgmt)
94
0
    return;
95
96
  /* notify the new DBus API */
97
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_STATE);
98
99
#ifdef CONFIG_FST
100
  if (wpa_s->fst && !is_zero_ether_addr(wpa_s->bssid)) {
101
    if (new_state == WPA_COMPLETED)
102
      fst_notify_peer_connected(wpa_s->fst, wpa_s->bssid);
103
    else if (old_state >= WPA_ASSOCIATED &&
104
       new_state < WPA_ASSOCIATED)
105
      fst_notify_peer_disconnected(wpa_s->fst, wpa_s->bssid);
106
  }
107
#endif /* CONFIG_FST */
108
109
0
  if (new_state == WPA_COMPLETED) {
110
0
    wpas_p2p_notif_connected(wpa_s);
111
0
    if (ssid && !wpa_s->sta_roaming_disabled)
112
0
      wpa_drv_roaming(wpa_s, !ssid->bssid_set,
113
0
          ssid->bssid_set ? ssid->bssid : NULL);
114
0
  } else if (old_state >= WPA_ASSOCIATED && new_state < WPA_ASSOCIATED) {
115
0
    wpas_p2p_notif_disconnected(wpa_s);
116
0
  }
117
118
0
  sme_state_changed(wpa_s);
119
120
#ifdef ANDROID
121
  wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_STATE_CHANGE
122
         "id=%d state=%d BSSID=" MACSTR " SSID=%s",
123
         wpa_s->current_ssid ? wpa_s->current_ssid->id : -1,
124
         new_state,
125
         MAC2STR(wpa_s->bssid),
126
         wpa_s->current_ssid && wpa_s->current_ssid->ssid ?
127
         wpa_ssid_txt(wpa_s->current_ssid->ssid,
128
          wpa_s->current_ssid->ssid_len) : "");
129
#endif /* ANDROID */
130
0
}
131
132
133
void wpas_notify_disconnect_reason(struct wpa_supplicant *wpa_s)
134
0
{
135
0
  if (wpa_s->p2p_mgmt)
136
0
    return;
137
138
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_DISCONNECT_REASON);
139
0
}
140
141
142
void wpas_notify_auth_status_code(struct wpa_supplicant *wpa_s)
143
0
{
144
0
  if (wpa_s->p2p_mgmt)
145
0
    return;
146
147
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AUTH_STATUS_CODE);
148
0
}
149
150
151
void wpas_notify_assoc_status_code(struct wpa_supplicant *wpa_s)
152
0
{
153
0
  if (wpa_s->p2p_mgmt)
154
0
    return;
155
156
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ASSOC_STATUS_CODE);
157
0
}
158
159
160
void wpas_notify_roam_time(struct wpa_supplicant *wpa_s)
161
0
{
162
0
  if (wpa_s->p2p_mgmt)
163
0
    return;
164
165
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_TIME);
166
0
}
167
168
169
void wpas_notify_roam_complete(struct wpa_supplicant *wpa_s)
170
0
{
171
0
  if (wpa_s->p2p_mgmt)
172
0
    return;
173
174
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_ROAM_COMPLETE);
175
0
}
176
177
178
void wpas_notify_scan_in_progress_6ghz(struct wpa_supplicant *wpa_s)
179
0
{
180
0
  if (wpa_s->p2p_mgmt)
181
0
    return;
182
183
0
  wpas_dbus_signal_prop_changed(wpa_s,
184
0
              WPAS_DBUS_PROP_SCAN_IN_PROGRESS_6GHZ);
185
0
}
186
187
188
void wpas_notify_session_length(struct wpa_supplicant *wpa_s)
189
0
{
190
0
  if (wpa_s->p2p_mgmt)
191
0
    return;
192
193
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SESSION_LENGTH);
194
0
}
195
196
197
void wpas_notify_bss_tm_status(struct wpa_supplicant *wpa_s)
198
15
{
199
15
  if (wpa_s->p2p_mgmt)
200
0
    return;
201
202
15
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_BSS_TM_STATUS);
203
15
}
204
205
206
void wpas_notify_network_changed(struct wpa_supplicant *wpa_s)
207
0
{
208
0
  if (wpa_s->p2p_mgmt)
209
0
    return;
210
211
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_NETWORK);
212
0
}
213
214
215
void wpas_notify_ap_scan_changed(struct wpa_supplicant *wpa_s)
216
0
{
217
0
  if (wpa_s->p2p_mgmt)
218
0
    return;
219
220
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_AP_SCAN);
221
0
}
222
223
224
void wpas_notify_bssid_changed(struct wpa_supplicant *wpa_s)
225
0
{
226
0
  if (wpa_s->p2p_mgmt)
227
0
    return;
228
229
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_BSS);
230
0
}
231
232
233
void wpas_notify_mac_address_changed(struct wpa_supplicant *wpa_s)
234
0
{
235
0
  if (wpa_s->p2p_mgmt)
236
0
    return;
237
238
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_MAC_ADDRESS);
239
0
}
240
241
242
void wpas_notify_auth_changed(struct wpa_supplicant *wpa_s)
243
0
{
244
0
  if (wpa_s->p2p_mgmt)
245
0
    return;
246
247
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_CURRENT_AUTH_MODE);
248
0
}
249
250
251
void wpas_notify_network_enabled_changed(struct wpa_supplicant *wpa_s,
252
           struct wpa_ssid *ssid)
253
0
{
254
0
  if (wpa_s->p2p_mgmt)
255
0
    return;
256
257
0
  wpas_dbus_signal_network_enabled_changed(wpa_s, ssid);
258
0
}
259
260
261
void wpas_notify_network_selected(struct wpa_supplicant *wpa_s,
262
          struct wpa_ssid *ssid)
263
0
{
264
0
  if (wpa_s->p2p_mgmt)
265
0
    return;
266
267
0
  wpas_dbus_signal_network_selected(wpa_s, ssid->id);
268
0
}
269
270
271
void wpas_notify_network_request(struct wpa_supplicant *wpa_s,
272
         struct wpa_ssid *ssid,
273
         enum wpa_ctrl_req_type rtype,
274
         const char *default_txt)
275
0
{
276
0
  if (wpa_s->p2p_mgmt)
277
0
    return;
278
279
0
  wpas_dbus_signal_network_request(wpa_s, ssid, rtype, default_txt);
280
0
}
281
282
283
void wpas_notify_scanning(struct wpa_supplicant *wpa_s)
284
0
{
285
0
  if (wpa_s->p2p_mgmt)
286
0
    return;
287
288
  /* notify the new DBus API */
289
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SCANNING);
290
0
}
291
292
293
void wpas_notify_scan_done(struct wpa_supplicant *wpa_s, int success)
294
0
{
295
0
  if (wpa_s->p2p_mgmt)
296
0
    return;
297
298
0
  wpas_dbus_signal_scan_done(wpa_s, success);
299
0
}
300
301
302
void wpas_notify_scan_results(struct wpa_supplicant *wpa_s)
303
0
{
304
0
  if (wpa_s->p2p_mgmt)
305
0
    return;
306
307
0
  wpas_wps_notify_scan_results(wpa_s);
308
0
}
309
310
311
void wpas_notify_wps_credential(struct wpa_supplicant *wpa_s,
312
        const struct wps_credential *cred)
313
0
{
314
0
  if (wpa_s->p2p_mgmt)
315
0
    return;
316
317
#ifdef CONFIG_WPS
318
  /* notify the new DBus API */
319
  wpas_dbus_signal_wps_cred(wpa_s, cred);
320
#endif /* CONFIG_WPS */
321
0
}
322
323
324
void wpas_notify_wps_event_m2d(struct wpa_supplicant *wpa_s,
325
             struct wps_event_m2d *m2d)
326
0
{
327
0
  if (wpa_s->p2p_mgmt)
328
0
    return;
329
330
#ifdef CONFIG_WPS
331
  wpas_dbus_signal_wps_event_m2d(wpa_s, m2d);
332
#endif /* CONFIG_WPS */
333
0
}
334
335
336
void wpas_notify_wps_event_fail(struct wpa_supplicant *wpa_s,
337
        struct wps_event_fail *fail)
338
0
{
339
0
  if (wpa_s->p2p_mgmt)
340
0
    return;
341
342
#ifdef CONFIG_WPS
343
  wpas_dbus_signal_wps_event_fail(wpa_s, fail);
344
#endif /* CONFIG_WPS */
345
0
}
346
347
348
void wpas_notify_wps_event_success(struct wpa_supplicant *wpa_s)
349
0
{
350
0
  if (wpa_s->p2p_mgmt)
351
0
    return;
352
353
#ifdef CONFIG_WPS
354
  wpas_dbus_signal_wps_event_success(wpa_s);
355
#endif /* CONFIG_WPS */
356
0
}
357
358
void wpas_notify_wps_event_pbc_overlap(struct wpa_supplicant *wpa_s)
359
0
{
360
0
  if (wpa_s->p2p_mgmt)
361
0
    return;
362
363
#ifdef CONFIG_WPS
364
  wpas_dbus_signal_wps_event_pbc_overlap(wpa_s);
365
#endif /* CONFIG_WPS */
366
0
}
367
368
369
void wpas_notify_network_added(struct wpa_supplicant *wpa_s,
370
             struct wpa_ssid *ssid)
371
0
{
372
0
  if (wpa_s->p2p_mgmt)
373
0
    return;
374
375
  /*
376
   * Networks objects created during any P2P activities should not be
377
   * exposed out. They might/will confuse certain non-P2P aware
378
   * applications since these network objects won't behave like
379
   * regular ones.
380
   */
381
0
  if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s) {
382
0
    wpas_dbus_register_network(wpa_s, ssid);
383
0
    wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_ADDED "%d",
384
0
           ssid->id);
385
0
  }
386
0
}
387
388
389
void wpas_notify_persistent_group_added(struct wpa_supplicant *wpa_s,
390
          struct wpa_ssid *ssid)
391
0
{
392
#ifdef CONFIG_P2P
393
  wpas_dbus_register_persistent_group(wpa_s, ssid);
394
#endif /* CONFIG_P2P */
395
0
}
396
397
398
void wpas_notify_persistent_group_removed(struct wpa_supplicant *wpa_s,
399
            struct wpa_ssid *ssid)
400
0
{
401
#ifdef CONFIG_P2P
402
  wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
403
#endif /* CONFIG_P2P */
404
0
}
405
406
407
void wpas_notify_network_removed(struct wpa_supplicant *wpa_s,
408
         struct wpa_ssid *ssid)
409
0
{
410
0
  if (wpa_s->next_ssid == ssid)
411
0
    wpa_s->next_ssid = NULL;
412
0
  if (wpa_s->last_ssid == ssid)
413
0
    wpa_s->last_ssid = NULL;
414
0
  if (wpa_s->current_ssid == ssid)
415
0
    wpa_s->current_ssid = NULL;
416
0
  if (wpa_s->ml_connect_probe_ssid == ssid) {
417
0
    wpa_s->ml_connect_probe_ssid = NULL;
418
0
    wpa_s->ml_connect_probe_bss = NULL;
419
0
  }
420
0
  if (wpa_s->connect_without_scan == ssid)
421
0
    wpa_s->connect_without_scan = NULL;
422
#if defined(CONFIG_SME) && defined(CONFIG_SAE)
423
  if (wpa_s->sme.ext_auth_wpa_ssid == ssid)
424
    wpa_s->sme.ext_auth_wpa_ssid = NULL;
425
#endif /* CONFIG_SME && CONFIG_SAE */
426
0
  if (wpa_s->wpa) {
427
0
    if ((wpa_key_mgmt_sae(ssid->key_mgmt) &&
428
0
         (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_SAE_OFFLOAD_STA)) ||
429
0
        ((ssid->key_mgmt & WPA_KEY_MGMT_OWE) &&
430
0
         (wpa_s->drv_flags2 & WPA_DRIVER_FLAGS2_OWE_OFFLOAD_STA))) {
431
      /* For cases when PMK is generated at the driver */
432
0
      struct wpa_pmkid_params params;
433
434
0
      os_memset(&params, 0, sizeof(params));
435
0
      params.ssid = ssid->ssid;
436
0
      params.ssid_len = ssid->ssid_len;
437
0
      wpa_drv_remove_pmkid(wpa_s, &params);
438
0
    }
439
0
    wpa_sm_pmksa_cache_flush(wpa_s->wpa, ssid);
440
0
  }
441
0
  if (!ssid->p2p_group && wpa_s->global->p2p_group_formation != wpa_s &&
442
0
      !wpa_s->p2p_mgmt) {
443
0
    wpas_dbus_unregister_network(wpa_s, ssid->id);
444
0
    wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_NETWORK_REMOVED "%d",
445
0
           ssid->id);
446
0
  }
447
0
  if (network_is_persistent_group(ssid))
448
0
    wpas_notify_persistent_group_removed(wpa_s, ssid);
449
450
0
  wpas_p2p_network_removed(wpa_s, ssid);
451
0
}
452
453
454
void wpas_notify_bss_added(struct wpa_supplicant *wpa_s,
455
         u8 bssid[], unsigned int id)
456
0
{
457
0
  if (wpa_s->p2p_mgmt)
458
0
    return;
459
460
0
  wpas_dbus_register_bss(wpa_s, bssid, id);
461
0
  wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_ADDED "%u " MACSTR,
462
0
         id, MAC2STR(bssid));
463
0
}
464
465
466
void wpas_notify_bss_removed(struct wpa_supplicant *wpa_s,
467
           u8 bssid[], unsigned int id)
468
0
{
469
0
  if (wpa_s->p2p_mgmt)
470
0
    return;
471
472
0
  wpas_dbus_unregister_bss(wpa_s, bssid, id);
473
0
  wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_BSS_REMOVED "%u " MACSTR,
474
0
         id, MAC2STR(bssid));
475
0
}
476
477
478
void wpas_notify_bss_freq_changed(struct wpa_supplicant *wpa_s,
479
          unsigned int id)
480
0
{
481
0
  if (wpa_s->p2p_mgmt)
482
0
    return;
483
484
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_FREQ, id);
485
0
}
486
487
488
void wpas_notify_bss_signal_changed(struct wpa_supplicant *wpa_s,
489
            unsigned int id)
490
0
{
491
0
  if (wpa_s->p2p_mgmt)
492
0
    return;
493
494
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_SIGNAL,
495
0
            id);
496
0
}
497
498
499
void wpas_notify_bss_privacy_changed(struct wpa_supplicant *wpa_s,
500
             unsigned int id)
501
0
{
502
0
  if (wpa_s->p2p_mgmt)
503
0
    return;
504
505
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_PRIVACY,
506
0
            id);
507
0
}
508
509
510
void wpas_notify_bss_mode_changed(struct wpa_supplicant *wpa_s,
511
          unsigned int id)
512
0
{
513
0
  if (wpa_s->p2p_mgmt)
514
0
    return;
515
516
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_MODE, id);
517
0
}
518
519
520
void wpas_notify_bss_wpaie_changed(struct wpa_supplicant *wpa_s,
521
           unsigned int id)
522
0
{
523
0
  if (wpa_s->p2p_mgmt)
524
0
    return;
525
526
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPA, id);
527
0
}
528
529
530
void wpas_notify_bss_rsnie_changed(struct wpa_supplicant *wpa_s,
531
           unsigned int id)
532
0
{
533
0
  if (wpa_s->p2p_mgmt)
534
0
    return;
535
536
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RSN, id);
537
0
}
538
539
540
void wpas_notify_bss_wps_changed(struct wpa_supplicant *wpa_s,
541
         unsigned int id)
542
0
{
543
0
  if (wpa_s->p2p_mgmt)
544
0
    return;
545
546
#ifdef CONFIG_WPS
547
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_WPS, id);
548
#endif /* CONFIG_WPS */
549
0
}
550
551
552
void wpas_notify_bss_ies_changed(struct wpa_supplicant *wpa_s,
553
           unsigned int id)
554
0
{
555
0
  if (wpa_s->p2p_mgmt)
556
0
    return;
557
558
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_IES, id);
559
0
}
560
561
562
void wpas_notify_bss_rates_changed(struct wpa_supplicant *wpa_s,
563
           unsigned int id)
564
0
{
565
0
  if (wpa_s->p2p_mgmt)
566
0
    return;
567
568
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_RATES, id);
569
0
}
570
571
572
void wpas_notify_bss_seen(struct wpa_supplicant *wpa_s, unsigned int id)
573
0
{
574
0
  if (wpa_s->p2p_mgmt)
575
0
    return;
576
577
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_AGE, id);
578
0
}
579
580
581
void wpas_notify_bss_anqp_changed(struct wpa_supplicant *wpa_s, unsigned int id)
582
0
{
583
0
  if (wpa_s->p2p_mgmt)
584
0
    return;
585
586
0
  wpas_dbus_bss_signal_prop_changed(wpa_s, WPAS_DBUS_BSS_PROP_ANQP, id);
587
0
}
588
589
590
void wpas_notify_blob_added(struct wpa_supplicant *wpa_s, const char *name)
591
0
{
592
0
  if (wpa_s->p2p_mgmt)
593
0
    return;
594
595
0
  wpas_dbus_signal_blob_added(wpa_s, name);
596
0
}
597
598
599
void wpas_notify_blob_removed(struct wpa_supplicant *wpa_s, const char *name)
600
0
{
601
0
  if (wpa_s->p2p_mgmt)
602
0
    return;
603
604
0
  wpas_dbus_signal_blob_removed(wpa_s, name);
605
0
}
606
607
608
void wpas_notify_debug_level_changed(struct wpa_global *global)
609
0
{
610
0
  wpas_dbus_signal_debug_level_changed(global);
611
0
}
612
613
614
void wpas_notify_debug_timestamp_changed(struct wpa_global *global)
615
0
{
616
0
  wpas_dbus_signal_debug_timestamp_changed(global);
617
0
}
618
619
620
void wpas_notify_debug_show_keys_changed(struct wpa_global *global)
621
0
{
622
0
  wpas_dbus_signal_debug_show_keys_changed(global);
623
0
}
624
625
626
void wpas_notify_suspend(struct wpa_global *global)
627
0
{
628
0
  struct wpa_supplicant *wpa_s;
629
630
0
  os_get_time(&global->suspend_time);
631
0
  wpa_printf(MSG_DEBUG, "System suspend notification");
632
0
  for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next)
633
0
    wpa_drv_suspend(wpa_s);
634
0
}
635
636
637
void wpas_notify_resume(struct wpa_global *global)
638
0
{
639
0
  struct os_time now;
640
0
  int slept;
641
0
  struct wpa_supplicant *wpa_s;
642
643
0
  if (global->suspend_time.sec == 0)
644
0
    slept = -1;
645
0
  else {
646
0
    os_get_time(&now);
647
0
    slept = now.sec - global->suspend_time.sec;
648
0
  }
649
0
  wpa_printf(MSG_DEBUG, "System resume notification (slept %d seconds)",
650
0
       slept);
651
652
0
  for (wpa_s = global->ifaces; wpa_s; wpa_s = wpa_s->next) {
653
0
    wpa_drv_resume(wpa_s);
654
0
    if (wpa_s->wpa_state == WPA_DISCONNECTED)
655
0
      wpa_supplicant_req_scan(wpa_s, 0, 100000);
656
0
  }
657
0
}
658
659
660
#ifdef CONFIG_P2P
661
662
void wpas_notify_p2p_find_stopped(struct wpa_supplicant *wpa_s)
663
{
664
  /* Notify P2P find has stopped */
665
  wpas_dbus_signal_p2p_find_stopped(wpa_s);
666
}
667
668
669
void wpas_notify_p2p_device_found(struct wpa_supplicant *wpa_s,
670
          const u8 *dev_addr, int new_device)
671
{
672
  if (new_device) {
673
    /* Create the new peer object */
674
    wpas_dbus_register_peer(wpa_s, dev_addr);
675
  }
676
677
  /* Notify a new peer has been detected*/
678
  wpas_dbus_signal_peer_device_found(wpa_s, dev_addr);
679
}
680
681
682
void wpas_notify_p2p_device_lost(struct wpa_supplicant *wpa_s,
683
         const u8 *dev_addr)
684
{
685
  wpas_dbus_unregister_peer(wpa_s, dev_addr);
686
687
  /* Create signal on interface object*/
688
  wpas_dbus_signal_peer_device_lost(wpa_s, dev_addr);
689
}
690
691
692
void wpas_notify_p2p_group_removed(struct wpa_supplicant *wpa_s,
693
           const struct wpa_ssid *ssid,
694
           const char *role)
695
{
696
  wpas_dbus_signal_p2p_group_removed(wpa_s, role);
697
698
  wpas_dbus_unregister_p2p_group(wpa_s, ssid);
699
}
700
701
702
void wpas_notify_p2p_go_neg_req(struct wpa_supplicant *wpa_s,
703
        const u8 *src, u16 dev_passwd_id, u8 go_intent)
704
{
705
  wpas_dbus_signal_p2p_go_neg_req(wpa_s, src, dev_passwd_id, go_intent);
706
}
707
708
709
void wpas_notify_p2p_go_neg_completed(struct wpa_supplicant *wpa_s,
710
              struct p2p_go_neg_results *res)
711
{
712
  wpas_dbus_signal_p2p_go_neg_resp(wpa_s, res);
713
}
714
715
716
void wpas_notify_p2p_invitation_result(struct wpa_supplicant *wpa_s,
717
               int status, const u8 *bssid)
718
{
719
  wpas_dbus_signal_p2p_invitation_result(wpa_s, status, bssid);
720
}
721
722
723
void wpas_notify_p2p_sd_request(struct wpa_supplicant *wpa_s,
724
        int freq, const u8 *sa, u8 dialog_token,
725
        u16 update_indic, const u8 *tlvs,
726
        size_t tlvs_len)
727
{
728
  wpas_dbus_signal_p2p_sd_request(wpa_s, freq, sa, dialog_token,
729
          update_indic, tlvs, tlvs_len);
730
}
731
732
733
void wpas_notify_p2p_sd_response(struct wpa_supplicant *wpa_s,
734
         const u8 *sa, u16 update_indic,
735
         const u8 *tlvs, size_t tlvs_len)
736
{
737
  wpas_dbus_signal_p2p_sd_response(wpa_s, sa, update_indic,
738
           tlvs, tlvs_len);
739
}
740
741
742
/**
743
 * wpas_notify_p2p_provision_discovery - Notification of provision discovery
744
 * @dev_addr: Who sent the request or responded to our request.
745
 * @request: Will be 1 if request, 0 for response.
746
 * @status: Valid only in case of response (0 in case of success)
747
 * @config_methods: WPS config methods
748
 * @generated_pin: PIN to be displayed in case of WPS_CONFIG_DISPLAY method
749
 *
750
 * This can be used to notify:
751
 * - Requests or responses
752
 * - Various config methods
753
 * - Failure condition in case of response
754
 */
755
void wpas_notify_p2p_provision_discovery(struct wpa_supplicant *wpa_s,
756
           const u8 *dev_addr, int request,
757
           enum p2p_prov_disc_status status,
758
           u16 config_methods,
759
           unsigned int generated_pin)
760
{
761
  wpas_dbus_signal_p2p_provision_discovery(wpa_s, dev_addr, request,
762
             status, config_methods,
763
             generated_pin);
764
}
765
766
767
void wpas_notify_p2p_group_started(struct wpa_supplicant *wpa_s,
768
           struct wpa_ssid *ssid, int persistent,
769
           int client, const u8 *ip)
770
{
771
  /* Notify a group has been started */
772
  wpas_dbus_register_p2p_group(wpa_s, ssid);
773
774
  wpas_dbus_signal_p2p_group_started(wpa_s, client, persistent, ip);
775
}
776
777
778
void wpas_notify_p2p_group_formation_failure(struct wpa_supplicant *wpa_s,
779
               const char *reason)
780
{
781
  /* Notify a group formation failed */
782
  wpas_dbus_signal_p2p_group_formation_failure(wpa_s, reason);
783
}
784
785
786
void wpas_notify_p2p_wps_failed(struct wpa_supplicant *wpa_s,
787
        struct wps_event_fail *fail)
788
{
789
  wpas_dbus_signal_p2p_wps_failed(wpa_s, fail);
790
}
791
792
793
void wpas_notify_p2p_invitation_received(struct wpa_supplicant *wpa_s,
794
           const u8 *sa, const u8 *go_dev_addr,
795
           const u8 *bssid, int id, int op_freq)
796
{
797
  /* Notify a P2P Invitation Request */
798
  wpas_dbus_signal_p2p_invitation_received(wpa_s, sa, go_dev_addr, bssid,
799
             id, op_freq);
800
}
801
802
void wpas_notify_p2p_bootstrap_req(struct wpa_supplicant *wpa_s,
803
           const u8 *src, u16 bootstrap_method)
804
{
805
  wpas_dbus_signal_p2p_bootstrap_req(wpa_s, src, bootstrap_method);
806
}
807
808
void wpas_notify_p2p_bootstrap_rsp(struct wpa_supplicant *wpa_s,
809
           const u8 *src, int status,
810
           u16 bootstrap_method)
811
{
812
  wpas_dbus_signal_p2p_bootstrap_rsp(wpa_s, src, status,
813
             bootstrap_method);
814
}
815
816
#endif /* CONFIG_P2P */
817
818
819
static void wpas_notify_ap_sta_authorized(struct wpa_supplicant *wpa_s,
820
            const u8 *sta,
821
            const u8 *p2p_dev_addr, const u8 *ip)
822
0
{
823
#ifdef CONFIG_P2P
824
  wpas_p2p_notify_ap_sta_authorized(wpa_s, p2p_dev_addr);
825
826
  /*
827
   * Create 'peer-joined' signal on group object -- will also
828
   * check P2P itself.
829
   */
830
  if (p2p_dev_addr)
831
    wpas_dbus_signal_p2p_peer_joined(wpa_s, p2p_dev_addr);
832
#endif /* CONFIG_P2P */
833
834
  /* Register the station */
835
0
  wpas_dbus_register_sta(wpa_s, sta);
836
837
  /* Notify listeners a new station has been authorized */
838
0
  wpas_dbus_signal_sta_authorized(wpa_s, sta);
839
0
}
840
841
842
static void wpas_notify_ap_sta_deauthorized(struct wpa_supplicant *wpa_s,
843
              const u8 *sta,
844
              const u8 *p2p_dev_addr)
845
0
{
846
#ifdef CONFIG_P2P
847
  /*
848
   * Create 'peer-disconnected' signal on group object if this
849
   * is a P2P group.
850
   */
851
  if (p2p_dev_addr)
852
    wpas_dbus_signal_p2p_peer_disconnected(wpa_s, p2p_dev_addr);
853
#endif /* CONFIG_P2P */
854
855
  /* Notify listeners a station has been deauthorized */
856
0
  wpas_dbus_signal_sta_deauthorized(wpa_s, sta);
857
858
  /* Unregister the station */
859
0
  wpas_dbus_unregister_sta(wpa_s, sta);
860
0
}
861
862
863
void wpas_notify_sta_authorized(struct wpa_supplicant *wpa_s,
864
        const u8 *mac_addr, int authorized,
865
        const u8 *p2p_dev_addr, const u8 *ip)
866
0
{
867
0
  if (authorized)
868
0
    wpas_notify_ap_sta_authorized(wpa_s, mac_addr, p2p_dev_addr,
869
0
                ip);
870
0
  else
871
0
    wpas_notify_ap_sta_deauthorized(wpa_s, mac_addr, p2p_dev_addr);
872
0
}
873
874
875
void wpas_notify_certification(struct wpa_supplicant *wpa_s,
876
             struct tls_cert_data *cert,
877
             const char *cert_hash)
878
0
{
879
0
  int i;
880
881
0
  wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_CERT
882
0
    "depth=%d subject='%s'%s%s%s%s",
883
0
    cert->depth, cert->subject, cert_hash ? " hash=" : "",
884
0
    cert_hash ? cert_hash : "",
885
0
    cert->tod == 2 ? " tod=2" : "",
886
0
    cert->tod == 1 ? " tod=1" : "");
887
888
0
  if (cert->cert) {
889
0
    char *cert_hex;
890
0
    size_t len = wpabuf_len(cert->cert) * 2 + 1;
891
0
    cert_hex = os_malloc(len);
892
0
    if (cert_hex) {
893
0
      wpa_snprintf_hex(cert_hex, len, wpabuf_head(cert->cert),
894
0
           wpabuf_len(cert->cert));
895
0
      wpa_msg_ctrl(wpa_s, MSG_INFO,
896
0
             WPA_EVENT_EAP_PEER_CERT
897
0
             "depth=%d subject='%s' cert=%s",
898
0
             cert->depth, cert->subject, cert_hex);
899
0
      os_free(cert_hex);
900
0
    }
901
0
  }
902
903
0
  for (i = 0; i < cert->num_altsubject; i++)
904
0
    wpa_msg(wpa_s, MSG_INFO, WPA_EVENT_EAP_PEER_ALT
905
0
      "depth=%d %s", cert->depth, cert->altsubject[i]);
906
907
  /* notify the new DBus API */
908
0
  wpas_dbus_signal_certification(wpa_s, cert->depth, cert->subject,
909
0
               cert->altsubject, cert->num_altsubject,
910
0
               cert_hash, cert->cert);
911
0
}
912
913
914
void wpas_notify_preq(struct wpa_supplicant *wpa_s,
915
          const u8 *addr, const u8 *dst, const u8 *bssid,
916
          const u8 *ie, size_t ie_len, u32 ssi_signal)
917
0
{
918
#ifdef CONFIG_AP
919
  wpas_dbus_signal_preq(wpa_s, addr, dst, bssid, ie, ie_len, ssi_signal);
920
#endif /* CONFIG_AP */
921
0
}
922
923
924
void wpas_notify_eap_status(struct wpa_supplicant *wpa_s, const char *status,
925
          const char *parameter)
926
0
{
927
0
  wpas_dbus_signal_eap_status(wpa_s, status, parameter);
928
0
  wpa_msg_ctrl(wpa_s, MSG_INFO, WPA_EVENT_EAP_STATUS
929
0
         "status='%s' parameter='%s'",
930
0
         status, parameter);
931
0
}
932
933
934
void wpas_notify_eap_error(struct wpa_supplicant *wpa_s, int error_code)
935
0
{
936
0
  wpa_msg(wpa_s, MSG_ERROR, WPA_EVENT_EAP_ERROR_CODE "%d", error_code);
937
0
}
938
939
940
void wpas_notify_psk_mismatch(struct wpa_supplicant *wpa_s)
941
0
{
942
0
  wpas_dbus_signal_psk_mismatch(wpa_s);
943
0
}
944
945
946
void wpas_notify_network_bssid_set_changed(struct wpa_supplicant *wpa_s,
947
             struct wpa_ssid *ssid)
948
0
{
949
0
  if (wpa_s->current_ssid != ssid)
950
0
    return;
951
952
0
  wpa_dbg(wpa_s, MSG_DEBUG,
953
0
    "Network bssid config changed for the current network - within-ESS roaming %s",
954
0
    ssid->bssid_set ? "disabled" : "enabled");
955
956
0
  wpa_drv_roaming(wpa_s, !ssid->bssid_set,
957
0
      ssid->bssid_set ? ssid->bssid : NULL);
958
0
}
959
960
961
void wpas_notify_network_type_changed(struct wpa_supplicant *wpa_s,
962
              struct wpa_ssid *ssid)
963
0
{
964
#ifdef CONFIG_P2P
965
  if (ssid->disabled == 2) {
966
    /* Changed from normal network profile to persistent group */
967
    ssid->disabled = 0;
968
    wpas_dbus_unregister_network(wpa_s, ssid->id);
969
    ssid->disabled = 2;
970
    ssid->p2p_persistent_group = 1;
971
    wpas_dbus_register_persistent_group(wpa_s, ssid);
972
  } else {
973
    /* Changed from persistent group to normal network profile */
974
    wpas_dbus_unregister_persistent_group(wpa_s, ssid->id);
975
    ssid->p2p_persistent_group = 0;
976
    wpas_dbus_register_network(wpa_s, ssid);
977
  }
978
#endif /* CONFIG_P2P */
979
0
}
980
981
982
#ifdef CONFIG_MESH
983
984
void wpas_notify_mesh_group_started(struct wpa_supplicant *wpa_s,
985
            struct wpa_ssid *ssid)
986
{
987
  if (wpa_s->p2p_mgmt)
988
    return;
989
990
  wpas_dbus_signal_mesh_group_started(wpa_s, ssid);
991
}
992
993
994
void wpas_notify_mesh_group_removed(struct wpa_supplicant *wpa_s,
995
            const u8 *meshid, u8 meshid_len,
996
            u16 reason_code)
997
{
998
  if (wpa_s->p2p_mgmt)
999
    return;
1000
1001
  wpas_dbus_signal_mesh_group_removed(wpa_s, meshid, meshid_len,
1002
              reason_code);
1003
}
1004
1005
1006
void wpas_notify_mesh_peer_connected(struct wpa_supplicant *wpa_s,
1007
             const u8 *peer_addr)
1008
{
1009
  if (wpa_s->p2p_mgmt)
1010
    return;
1011
1012
  wpa_msg(wpa_s, MSG_INFO, MESH_PEER_CONNECTED MACSTR,
1013
    MAC2STR(peer_addr));
1014
  wpas_dbus_signal_mesh_peer_connected(wpa_s, peer_addr);
1015
}
1016
1017
1018
void wpas_notify_mesh_peer_disconnected(struct wpa_supplicant *wpa_s,
1019
          const u8 *peer_addr, u16 reason_code)
1020
{
1021
  if (wpa_s->p2p_mgmt)
1022
    return;
1023
1024
  wpa_msg(wpa_s, MSG_INFO, MESH_PEER_DISCONNECTED MACSTR,
1025
    MAC2STR(peer_addr));
1026
  wpas_dbus_signal_mesh_peer_disconnected(wpa_s, peer_addr, reason_code);
1027
}
1028
1029
#endif /* CONFIG_MESH */
1030
1031
1032
#ifdef CONFIG_INTERWORKING
1033
1034
void wpas_notify_interworking_ap_added(struct wpa_supplicant *wpa_s,
1035
               struct wpa_bss *bss,
1036
               struct wpa_cred *cred, int excluded,
1037
               const char *type, int bh, int bss_load,
1038
               int conn_capab)
1039
0
{
1040
0
  wpa_msg(wpa_s, MSG_INFO, "%s" MACSTR " type=%s%s%s%s id=%d priority=%d sp_priority=%d",
1041
0
    excluded ? INTERWORKING_EXCLUDED : INTERWORKING_AP,
1042
0
    MAC2STR(bss->bssid), type,
1043
0
    bh ? " below_min_backhaul=1" : "",
1044
0
    bss_load ? " over_max_bss_load=1" : "",
1045
0
    conn_capab ? " conn_capab_missing=1" : "",
1046
0
    cred->id, cred->priority, cred->sp_priority);
1047
1048
0
  wpas_dbus_signal_interworking_ap_added(wpa_s, bss, cred, type, excluded,
1049
0
                 bh, bss_load, conn_capab);
1050
0
}
1051
1052
1053
void wpas_notify_interworking_select_done(struct wpa_supplicant *wpa_s)
1054
0
{
1055
0
  wpas_dbus_signal_interworking_select_done(wpa_s);
1056
0
}
1057
1058
1059
void wpas_notify_anqp_query_done(struct wpa_supplicant *wpa_s,
1060
         const u8 *dst, const char *result)
1061
0
{
1062
0
  wpa_msg(wpa_s, MSG_INFO, ANQP_QUERY_DONE "addr=" MACSTR " result=%s",
1063
0
    MAC2STR(dst), result);
1064
1065
0
  wpas_dbus_signal_anqp_query_done(wpa_s, dst, result);
1066
0
}
1067
1068
#endif /* CONFIG_INTERWORKING */
1069
1070
1071
void wpas_notify_pmk_cache_added(struct wpa_supplicant *wpa_s,
1072
         struct rsn_pmksa_cache_entry *entry)
1073
0
{
1074
  /* TODO: Notify external entities of the added PMKSA cache entry */
1075
0
}
1076
1077
1078
void wpas_notify_signal_change(struct wpa_supplicant *wpa_s)
1079
0
{
1080
0
  wpas_dbus_signal_prop_changed(wpa_s, WPAS_DBUS_PROP_SIGNAL_CHANGE);
1081
0
}
1082
1083
1084
#ifdef CONFIG_HS20
1085
void wpas_notify_hs20_t_c_acceptance(struct wpa_supplicant *wpa_s,
1086
             const char *url)
1087
0
{
1088
0
  wpa_msg(wpa_s, MSG_INFO, HS20_T_C_ACCEPTANCE "%s", url);
1089
0
  wpas_dbus_signal_hs20_t_c_acceptance(wpa_s, url);
1090
0
}
1091
#endif /* CONFIG_HS20 */
1092
1093
1094
#ifdef CONFIG_NAN_USD
1095
1096
void wpas_notify_nan_discovery_result(struct wpa_supplicant *wpa_s,
1097
              enum nan_service_protocol_type
1098
              srv_proto_type,
1099
              int subscribe_id, int peer_publish_id,
1100
              const u8 *peer_addr,
1101
              bool fsd, bool fsd_gas,
1102
              const u8 *ssi, size_t ssi_len)
1103
{
1104
  char *ssi_hex;
1105
1106
  ssi_hex = os_zalloc(2 * ssi_len + 1);
1107
  if (!ssi_hex)
1108
    return;
1109
  if (ssi)
1110
    wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1111
  wpa_msg_global(wpa_s, MSG_INFO, NAN_DISCOVERY_RESULT
1112
           "subscribe_id=%d publish_id=%d address=" MACSTR
1113
           " fsd=%d fsd_gas=%d srv_proto_type=%u ssi=%s",
1114
           subscribe_id, peer_publish_id, MAC2STR(peer_addr),
1115
           fsd, fsd_gas, srv_proto_type, ssi_hex);
1116
  os_free(ssi_hex);
1117
1118
  wpas_dbus_signal_nan_discovery_result(wpa_s, srv_proto_type,
1119
                subscribe_id, peer_publish_id,
1120
                peer_addr, fsd, fsd_gas,
1121
                ssi, ssi_len);
1122
}
1123
1124
1125
void wpas_notify_nan_replied(struct wpa_supplicant *wpa_s,
1126
           enum nan_service_protocol_type srv_proto_type,
1127
           int publish_id, int peer_subscribe_id,
1128
           const u8 *peer_addr,
1129
           const u8 *ssi, size_t ssi_len)
1130
{
1131
  char *ssi_hex;
1132
1133
  ssi_hex = os_zalloc(2 * ssi_len + 1);
1134
  if (!ssi_hex)
1135
    return;
1136
  if (ssi)
1137
    wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1138
  wpa_msg_global(wpa_s, MSG_INFO, NAN_REPLIED
1139
           "publish_id=%d address=" MACSTR
1140
           " subscribe_id=%d srv_proto_type=%u ssi=%s",
1141
           publish_id, MAC2STR(peer_addr), peer_subscribe_id,
1142
           srv_proto_type, ssi_hex);
1143
  os_free(ssi_hex);
1144
1145
  wpas_dbus_signal_nan_replied(wpa_s, srv_proto_type, publish_id,
1146
             peer_subscribe_id, peer_addr,
1147
             ssi, ssi_len);
1148
}
1149
1150
1151
void wpas_notify_nan_receive(struct wpa_supplicant *wpa_s, int id,
1152
           int peer_instance_id, const u8 *peer_addr,
1153
           const u8 *ssi, size_t ssi_len)
1154
{
1155
  char *ssi_hex;
1156
1157
  ssi_hex = os_zalloc(2 * ssi_len + 1);
1158
  if (!ssi_hex)
1159
    return;
1160
  if (ssi)
1161
    wpa_snprintf_hex(ssi_hex, 2 * ssi_len + 1, ssi, ssi_len);
1162
  wpa_msg_global(wpa_s, MSG_INFO, NAN_RECEIVE
1163
           "id=%d peer_instance_id=%d address=" MACSTR " ssi=%s",
1164
           id, peer_instance_id, MAC2STR(peer_addr), ssi_hex);
1165
  os_free(ssi_hex);
1166
1167
  wpas_dbus_signal_nan_receive(wpa_s, id, peer_instance_id, peer_addr,
1168
             ssi, ssi_len);
1169
}
1170
1171
1172
static const char * nan_reason_txt(enum nan_de_reason reason)
1173
{
1174
  switch (reason) {
1175
  case NAN_DE_REASON_TIMEOUT:
1176
    return "timeout";
1177
  case NAN_DE_REASON_USER_REQUEST:
1178
    return "user-request";
1179
  case NAN_DE_REASON_FAILURE:
1180
    return "failure";
1181
  }
1182
1183
  return "unknown";
1184
}
1185
1186
1187
void wpas_notify_nan_publish_terminated(struct wpa_supplicant *wpa_s,
1188
          int publish_id,
1189
          enum nan_de_reason reason)
1190
{
1191
  wpa_msg_global(wpa_s, MSG_INFO, NAN_PUBLISH_TERMINATED
1192
           "publish_id=%d reason=%s",
1193
           publish_id, nan_reason_txt(reason));
1194
  wpas_dbus_signal_nan_publish_terminated(wpa_s, publish_id,
1195
            nan_reason_txt(reason));
1196
}
1197
1198
1199
void wpas_notify_nan_subscribe_terminated(struct wpa_supplicant *wpa_s,
1200
            int subscribe_id,
1201
            enum nan_de_reason reason)
1202
{
1203
  wpa_msg_global(wpa_s, MSG_INFO, NAN_SUBSCRIBE_TERMINATED
1204
           "subscribe_id=%d reason=%s",
1205
           subscribe_id, nan_reason_txt(reason));
1206
  wpas_dbus_signal_nan_subscribe_terminated(wpa_s, subscribe_id,
1207
              nan_reason_txt(reason));
1208
}
1209
1210
#endif /* CONFIG_NAN_USD */