📄 driver.h
字号:
/** * init - Initialize driver interface * @ctx: context to be used when calling wpa_supplicant functions, * e.g., wpa_supplicant_event() * @ifname: interface name, e.g., wlan0 * * Returns: Pointer to private data, %NULL on failure * * Initialize driver interface, including event processing for kernel * driver events (e.g., associated, scan results, Michael MIC failure). * This function can allocate a private configuration data area for * @ctx, file descriptor, interface name, etc. information that may be * needed in future driver operations. If this is not used, non-NULL * value will need to be returned because %NULL is used to indicate * failure. The returned value will be used as 'void *priv' data for * all other driver_ops functions. * * The main event loop (eloop.c) of wpa_supplicant can be used to * register callback for read sockets (eloop_register_read_sock()). * * See wpa_supplicant.h for more information about events and * wpa_supplicant_event() function. */ void * (*init)(void *ctx, const char *ifname); /** * deinit - Deinitialize driver interface * @priv: private driver interface data from init() * * Shut down driver interface and processing of driver events. Free * private data buffer if one was allocated in init() handler. */ void (*deinit)(void *priv); /** * set_param - Set driver configuration parameters * @priv: private driver interface data from init() * @param: driver specific configuration parameters * * Returns: 0 on success, -1 on failure * * Optional handler for notifying driver interface about configuration * parameters (driver_param). */ int (*set_param)(void *priv, const char *param); /** * set_countermeasures - Enable/disable TKIP countermeasures * @priv: private driver interface data * @enabled: 1 = countermeasures enabled, 0 = disabled * * Returns: 0 on success, -1 on failure * * Configure TKIP countermeasures. When these are enabled, the driver * should drop all received and queued frames that are using TKIP. */ int (*set_countermeasures)(void *priv, int enabled); /** * set_drop_unencrypted - Enable/disable unencrypted frame filtering * @priv: private driver interface data * @enabled: 1 = unencrypted Tx/Rx frames will be dropped, 0 = disabled * * Returns: 0 on success, -1 on failure * * Configure the driver to drop all non-EAPOL frames (both receive and * transmit paths). Unencrypted EAPOL frames (ethertype 0x888e) must * still be allowed for key negotiation. */ int (*set_drop_unencrypted)(void *priv, int enabled); /** * scan - Request the driver to initiate scan * @priv: private driver interface data * @ssid: specific SSID to scan for (ProbeReq) or %NULL to scan for * all SSIDs (either active scan with broadcast SSID or passive * scan * @ssid_len: length of the SSID * * Returns: 0 on success, -1 on failure * * Once the scan results are ready, the driver should report scan * results event for wpa_supplicant which will eventually request the * results with wpa_driver_get_scan_results(). */ int (*scan)(void *priv, const u8 *ssid, size_t ssid_len); /** * get_scan_results - Fetch the latest scan results * @priv: private driver interface data * @results: pointer to buffer for scan results * @max_size: maximum number of entries (buffer size) * * Returns: Number of scan result entries used on success, -1 on * failure * * If scan results include more than max_size BSSes, max_size will be * returned and the remaining entries will not be included in the * buffer. */ int (*get_scan_results)(void *priv, struct wpa_scan_result *results, size_t max_size); /** * deauthenticate - Request driver to deauthenticate * @priv: private driver interface data * @addr: peer address (BSSID of the AP) * @reason_code: 16-bit reason code to be sent in the deauthentication * frame * * Returns: 0 on success, -1 on failure */ int (*deauthenticate)(void *priv, const u8 *addr, int reason_code); /** * disassociate - Request driver to disassociate * @priv: private driver interface data * @addr: peer address (BSSID of the AP) * @reason_code: 16-bit reason code to be sent in the disassociation * frame * * Returns: 0 on success, -1 on failure */ int (*disassociate)(void *priv, const u8 *addr, int reason_code); /** * associate - Request driver to associate * @priv: private driver interface data * @params: association parameters * * Returns: 0 on success, -1 on failure */ int (*associate)(void *priv, struct wpa_driver_associate_params *params); /** * set_auth_alg - Set IEEE 802.11 authentication algorithm * @priv: private driver interface data * @auth_alg: bit field of AUTH_ALG_* * * If the driver supports more than one authentication algorithm at the * same time, it should configure all supported algorithms. If not, one * algorithm needs to be selected arbitrarily. Open System * authentication should be ok for most cases and it is recommended to * be used if other options are not supported. Static WEP configuration * may also use Shared Key authentication and LEAP requires its own * algorithm number. For LEAP, user can make sure that only one * algorithm is used at a time by configuring LEAP as the only * supported EAP method. This information is also available in * associate() params, so set_auth_alg may not be needed in case of * most drivers. * * Returns: 0 on success, -1 on failure */ int (*set_auth_alg)(void *priv, int auth_alg); /** * add_pmkid - Add PMKSA cache entry to the driver * @priv: private driver interface data * @bssid: BSSID for the PMKSA cache entry * @pmkid: PMKID for the PMKSA cache entry * * Returns: 0 on success, -1 on failure * * This function is called when a new PMK is received, as a result of * either normal authentication or RSN pre-authentication. * * If the driver generates RSN IE, i.e., it does not use wpa_ie in * associate(), add_pmkid() can be used to add new PMKSA cache entries * in the driver. If the driver uses wpa_ie from wpa_supplicant, this * driver_ops function does not need to be implemented. Likewise, if * the driver does not support WPA, this function is not needed. */ int (*add_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid); /** * remove_pmkid - Remove PMKSA cache entry to the driver * @priv: private driver interface data * @bssid: BSSID for the PMKSA cache entry * @pmkid: PMKID for the PMKSA cache entry * * Returns: 0 on success, -1 on failure * * This function is called when the supplicant drops a PMKSA cache * entry for any reason. * * If the driver generates RSN IE, i.e., it does not use wpa_ie in * associate(), remove_pmkid() can be used to synchronize PMKSA caches * between the driver and wpa_supplicant. If the driver uses wpa_ie * from wpa_supplicant, this driver_ops function does not need to be * implemented. Likewise, if the driver does not support WPA, this * function is not needed. */ int (*remove_pmkid)(void *priv, const u8 *bssid, const u8 *pmkid); /** * flush_pmkid - Flush PMKSA cache * @priv: private driver interface data * * Returns: 0 on success, -1 on failure * * This function is called when the supplicant drops all PMKSA cache * entries for any reason. * * If the driver generates RSN IE, i.e., it does not use wpa_ie in * associate(), remove_pmkid() can be used to synchronize PMKSA caches * between the driver and wpa_supplicant. If the driver uses wpa_ie * from wpa_supplicant, this driver_ops function does not need to be * implemented. Likewise, if the driver does not support WPA, this * function is not needed. */ int (*flush_pmkid)(void *priv); /** * flush_pmkid - Flush PMKSA cache * @priv: private driver interface data * * Returns: 0 on success, -1 on failure * * Get driver/firmware/hardware capabilities. */ int (*get_capa)(void *priv, struct wpa_driver_capa *capa); /** * poll - Poll driver for association information * @priv: private driver interface data * * This is an option callback that can be used when the driver does not * provide event mechanism for association events. This is called when * receiving WPA EAPOL-Key messages that require association * information. The driver interface is supposed to generate associnfo * event before returning from this callback function. In addition, the * driver interface should generate an association event after having * sent out associnfo. */ void (*poll)(void *priv); /** * get_ifname - Get interface name * @priv: private driver interface data * * Returns: Pointer to the interface name. This can differ from the * interface name used in init() call. * * This optional function can be used to allow the driver interface to * replace the interface name with something else, e.g., based on an * interface mapping from a more descriptive name. */ const char * (*get_ifname)(void *priv); /** * get_mac_addr - Get own MAC address * @priv: private driver interface data * * Returns: Pointer to own MAC address or %NULL on failure * * This optional function can be used to get the own MAC address of the * device from the driver interface code. This is only needed if the * l2_packet implementation for the OS does not provide easy access to * a MAC address. */ const u8 * (*get_mac_addr)(void *priv); /** * send_eapol - Optional function for sending EAPOL packets * @priv: private driver interface data * @dest: Destination MAC address * @proto: Ethertype * @data: EAPOL packet starting with IEEE 802.1X header * @data_len: Size of the EAPOL packet * * Returns: 0 on success, -1 on failure * * This optional function can be used to override l2_packet operations * with driver specific functionality. If this function pointer is set, * l2_packet module is not used at all and the driver interface code is * responsible for receiving and sending all EAPOL packets. The * received EAPOL packets are sent to core code by calling * wpa_supplicant_rx_eapol(). The driver interface is required to * implement get_mac_addr() handler if send_eapol() is used. */ int (*send_eapol)(void *priv, const u8 *dest, u16 proto, const u8 *data, size_t data_len);};#endif /* DRIVER_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -