1 /* 2 * Copyright (c) 2023 Nordic Semiconductor ASA 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #ifndef __SUPP_EVENTS_H__ 8 #define __SUPP_EVENTS_H__ 9 10 #include <zephyr/net/wifi_mgmt.h> 11 12 /* Connectivity Events */ 13 #define _NET_MGMT_SUPPLICANT_LAYER NET_MGMT_LAYER_L3 14 #define _NET_MGMT_SUPPLICANT_CODE 0x157 15 #define _NET_MGMT_SUPPLICANT_BASE (NET_MGMT_LAYER(_NET_MGMT_SUPPLICANT_LAYER) | \ 16 NET_MGMT_LAYER_CODE(_NET_MGMT_SUPPLICANT_CODE) | \ 17 NET_MGMT_IFACE_BIT) 18 #define _NET_MGMT_SUPPLICANT_EVENT (NET_MGMT_EVENT_BIT | _NET_MGMT_SUPPLICANT_BASE) 19 20 enum net_event_supplicant_cmd { 21 NET_EVENT_SUPPLICANT_CMD_READY = 1, 22 NET_EVENT_SUPPLICANT_CMD_NOT_READY, 23 NET_EVENT_SUPPLICANT_CMD_IFACE_ADDED, 24 NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVING, 25 NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVED, 26 NET_EVENT_SUPPLICANT_CMD_INT_EVENT, 27 NET_EVENT_WIFI_CMD_MAX 28 }; 29 30 #define NET_EVENT_SUPPLICANT_READY \ 31 (_NET_MGMT_SUPPLICANT_EVENT | NET_EVENT_SUPPLICANT_CMD_READY) 32 33 #define NET_EVENT_SUPPLICANT_NOT_READY \ 34 (_NET_MGMT_SUPPLICANT_EVENT | NET_EVENT_SUPPLICANT_CMD_NOT_READY) 35 36 #define NET_EVENT_SUPPLICANT_IFACE_ADDED \ 37 (_NET_MGMT_SUPPLICANT_EVENT | NET_EVENT_SUPPLICANT_CMD_IFACE_ADDED) 38 39 #define NET_EVENT_SUPPLICANT_IFACE_REMOVED \ 40 (_NET_MGMT_SUPPLICANT_EVENT | NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVED) 41 42 #define NET_EVENT_SUPPLICANT_IFACE_REMOVING \ 43 (_NET_MGMT_SUPPLICANT_EVENT | NET_EVENT_SUPPLICANT_CMD_IFACE_REMOVING) 44 45 #define NET_EVENT_SUPPLICANT_INT_EVENT \ 46 (_NET_MGMT_SUPPLICANT_EVENT | NET_EVENT_SUPPLICANT_CMD_INT_EVENT) 47 48 int supplicant_send_wifi_mgmt_event(const char *ifname, 49 enum net_event_wifi_cmd event, 50 void *status, 51 size_t len); 52 int supplicant_generate_state_event(const char *ifname, 53 enum net_event_supplicant_cmd event, 54 int status); 55 int supplicant_send_wifi_mgmt_conn_event(void *ctx, int status_code); 56 int supplicant_send_wifi_mgmt_disc_event(void *ctx, int reason_code); 57 58 #ifdef CONFIG_AP 59 int supplicant_send_wifi_mgmt_ap_status(void *ctx, 60 enum net_event_wifi_cmd event, 61 enum wifi_ap_status); 62 int supplicant_send_wifi_mgmt_ap_sta_event(void *ctx, 63 enum net_event_wifi_cmd event, 64 void *data); 65 #endif /* CONFIG_AP */ 66 #if defined(CONFIG_WIFI_NM_HOSTAPD_AP) && defined(CONFIG_WIFI_NM_WPA_SUPPLICANT_DPP) 67 void hostapd_handle_dpp_event(void *ctx, char *buf, size_t len); 68 #endif 69 70 #define REASON_CODE_LEN 18 71 #define NM_WIFI_EVENT_STR_LEN 64 72 #define ETH_ALEN 6 73 74 union supplicant_event_data { 75 struct supplicant_event_auth_reject { 76 int auth_type; 77 int auth_transaction; 78 int status_code; 79 uint8_t bssid[ETH_ALEN]; 80 } auth_reject; 81 82 struct supplicant_event_connected { 83 uint8_t bssid[ETH_ALEN]; 84 char ssid[WIFI_SSID_MAX_LEN]; 85 int id; 86 } connected; 87 88 struct supplicant_event_disconnected { 89 uint8_t bssid[ETH_ALEN]; 90 int reason_code; 91 int locally_generated; 92 } disconnected; 93 94 struct supplicant_event_assoc_reject { 95 int status_code; 96 int reason_code; 97 } assoc_reject; 98 99 struct supplicant_event_temp_disabled { 100 int id; 101 char ssid[WIFI_SSID_MAX_LEN]; 102 unsigned int auth_failures; 103 unsigned int duration; 104 char reason_code[REASON_CODE_LEN]; 105 } temp_disabled; 106 107 struct supplicant_event_reenabled { 108 int id; 109 char ssid[WIFI_SSID_MAX_LEN]; 110 } reenabled; 111 112 struct supplicant_event_bss_added { 113 unsigned int id; 114 uint8_t bssid[ETH_ALEN]; 115 } bss_added; 116 117 struct supplicant_event_bss_removed { 118 unsigned int id; 119 uint8_t bssid[ETH_ALEN]; 120 } bss_removed; 121 122 struct supplicant_event_network_added { 123 unsigned int id; 124 } network_added; 125 126 struct supplicant_event_network_removed { 127 unsigned int id; 128 } network_removed; 129 130 char supplicant_event_str[NM_WIFI_EVENT_STR_LEN]; 131 }; 132 133 enum supplicant_event_num { 134 SUPPLICANT_EVENT_CONNECTED, 135 SUPPLICANT_EVENT_DISCONNECTED, 136 SUPPLICANT_EVENT_ASSOC_REJECT, 137 SUPPLICANT_EVENT_AUTH_REJECT, 138 SUPPLICANT_EVENT_TERMINATING, 139 SUPPLICANT_EVENT_SSID_TEMP_DISABLED, 140 SUPPLICANT_EVENT_SSID_REENABLED, 141 SUPPLICANT_EVENT_SCAN_STARTED, 142 SUPPLICANT_EVENT_SCAN_RESULTS, 143 SUPPLICANT_EVENT_SCAN_FAILED, 144 SUPPLICANT_EVENT_BSS_ADDED, 145 SUPPLICANT_EVENT_BSS_REMOVED, 146 SUPPLICANT_EVENT_NETWORK_NOT_FOUND, 147 SUPPLICANT_EVENT_NETWORK_ADDED, 148 SUPPLICANT_EVENT_NETWORK_REMOVED, 149 SUPPLICANT_EVENT_DSCP_POLICY, 150 SUPPLICANT_EVENT_REGDOM_CHANGE, 151 }; 152 153 struct supplicant_int_event_data { 154 enum supplicant_event_num event; 155 void *data; 156 size_t data_len; 157 }; 158 159 #endif /* __SUPP_EVENTS_H__ */ 160