1e5b75505Sopenharmony_ci/* 2e5b75505Sopenharmony_ci * WPA Supplicant / UNIX domain socket -based control interface 3e5b75505Sopenharmony_ci * Copyright (c) 2004-2005, Jouni Malinen <j@w1.fi> 4e5b75505Sopenharmony_ci * 5e5b75505Sopenharmony_ci * This software may be distributed under the terms of the BSD license. 6e5b75505Sopenharmony_ci * See README for more details. 7e5b75505Sopenharmony_ci */ 8e5b75505Sopenharmony_ci 9e5b75505Sopenharmony_ci#ifndef CTRL_IFACE_H 10e5b75505Sopenharmony_ci#define CTRL_IFACE_H 11e5b75505Sopenharmony_ci 12e5b75505Sopenharmony_ci#ifdef CONFIG_CTRL_IFACE 13e5b75505Sopenharmony_ci 14e5b75505Sopenharmony_ci/* Shared functions from ctrl_iface.c; to be called by ctrl_iface backends */ 15e5b75505Sopenharmony_ci 16e5b75505Sopenharmony_ci/** 17e5b75505Sopenharmony_ci * wpa_supplicant_ctrl_iface_process - Process ctrl_iface command 18e5b75505Sopenharmony_ci * @wpa_s: Pointer to wpa_supplicant data 19e5b75505Sopenharmony_ci * @buf: Received command buffer (nul terminated string) 20e5b75505Sopenharmony_ci * @resp_len: Variable to be set to the response length 21e5b75505Sopenharmony_ci * Returns: Response (*resp_len bytes) or %NULL on failure 22e5b75505Sopenharmony_ci * 23e5b75505Sopenharmony_ci * Control interface backends call this function when receiving a message that 24e5b75505Sopenharmony_ci * they do not process internally, i.e., anything else than ATTACH, DETACH, 25e5b75505Sopenharmony_ci * and LEVEL. The return response value is then sent to the external program 26e5b75505Sopenharmony_ci * that sent the command. Caller is responsible for freeing the buffer after 27e5b75505Sopenharmony_ci * this. If %NULL is returned, *resp_len can be set to two special values: 28e5b75505Sopenharmony_ci * 1 = send "FAIL\n" response, 2 = send "OK\n" response. If *resp_len has any 29e5b75505Sopenharmony_ci * other value, no response is sent. 30e5b75505Sopenharmony_ci */ 31e5b75505Sopenharmony_cichar * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, 32e5b75505Sopenharmony_ci char *buf, size_t *resp_len); 33e5b75505Sopenharmony_ci 34e5b75505Sopenharmony_ci/** 35e5b75505Sopenharmony_ci * wpa_supplicant_global_ctrl_iface_process - Process global ctrl_iface command 36e5b75505Sopenharmony_ci * @global: Pointer to global data from wpa_supplicant_init() 37e5b75505Sopenharmony_ci * @buf: Received command buffer (nul terminated string) 38e5b75505Sopenharmony_ci * @resp_len: Variable to be set to the response length 39e5b75505Sopenharmony_ci * Returns: Response (*resp_len bytes) or %NULL on failure 40e5b75505Sopenharmony_ci * 41e5b75505Sopenharmony_ci * Control interface backends call this function when receiving a message from 42e5b75505Sopenharmony_ci * the global ctrl_iface connection. The return response value is then sent to 43e5b75505Sopenharmony_ci * the external program that sent the command. Caller is responsible for 44e5b75505Sopenharmony_ci * freeing the buffer after this. If %NULL is returned, *resp_len can be set to 45e5b75505Sopenharmony_ci * two special values: 1 = send "FAIL\n" response, 2 = send "OK\n" response. If 46e5b75505Sopenharmony_ci * *resp_len has any other value, no response is sent. 47e5b75505Sopenharmony_ci */ 48e5b75505Sopenharmony_cichar * wpa_supplicant_global_ctrl_iface_process(struct wpa_global *global, 49e5b75505Sopenharmony_ci char *buf, size_t *resp_len); 50e5b75505Sopenharmony_ci 51e5b75505Sopenharmony_ci 52e5b75505Sopenharmony_ci/* Functions that each ctrl_iface backend must implement */ 53e5b75505Sopenharmony_ci 54e5b75505Sopenharmony_ci/** 55e5b75505Sopenharmony_ci * wpa_supplicant_ctrl_iface_init - Initialize control interface 56e5b75505Sopenharmony_ci * @wpa_s: Pointer to wpa_supplicant data 57e5b75505Sopenharmony_ci * Returns: Pointer to private data on success, %NULL on failure 58e5b75505Sopenharmony_ci * 59e5b75505Sopenharmony_ci * Initialize the control interface and start receiving commands from external 60e5b75505Sopenharmony_ci * programs. 61e5b75505Sopenharmony_ci * 62e5b75505Sopenharmony_ci * Required to be implemented in each control interface backend. 63e5b75505Sopenharmony_ci */ 64e5b75505Sopenharmony_cistruct ctrl_iface_priv * 65e5b75505Sopenharmony_ciwpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s); 66e5b75505Sopenharmony_ci 67e5b75505Sopenharmony_ci/** 68e5b75505Sopenharmony_ci * wpa_supplicant_ctrl_iface_deinit - Deinitialize control interface 69e5b75505Sopenharmony_ci * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init() 70e5b75505Sopenharmony_ci * 71e5b75505Sopenharmony_ci * Deinitialize the control interface that was initialized with 72e5b75505Sopenharmony_ci * wpa_supplicant_ctrl_iface_init(). 73e5b75505Sopenharmony_ci * 74e5b75505Sopenharmony_ci * Required to be implemented in each control interface backend. 75e5b75505Sopenharmony_ci */ 76e5b75505Sopenharmony_civoid wpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv); 77e5b75505Sopenharmony_ci 78e5b75505Sopenharmony_ci/** 79e5b75505Sopenharmony_ci * wpa_supplicant_ctrl_iface_wait - Wait for ctrl_iface monitor 80e5b75505Sopenharmony_ci * @priv: Pointer to private data from wpa_supplicant_ctrl_iface_init() 81e5b75505Sopenharmony_ci * 82e5b75505Sopenharmony_ci * Wait until the first message from an external program using the control 83e5b75505Sopenharmony_ci * interface is received. This function can be used to delay normal startup 84e5b75505Sopenharmony_ci * processing to allow control interface programs to attach with 85e5b75505Sopenharmony_ci * %wpa_supplicant before normal operations are started. 86e5b75505Sopenharmony_ci * 87e5b75505Sopenharmony_ci * Required to be implemented in each control interface backend. 88e5b75505Sopenharmony_ci */ 89e5b75505Sopenharmony_civoid wpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv); 90e5b75505Sopenharmony_ci 91e5b75505Sopenharmony_ci/** 92e5b75505Sopenharmony_ci * wpa_supplicant_global_ctrl_iface_init - Initialize global control interface 93e5b75505Sopenharmony_ci * @global: Pointer to global data from wpa_supplicant_init() 94e5b75505Sopenharmony_ci * Returns: Pointer to private data on success, %NULL on failure 95e5b75505Sopenharmony_ci * 96e5b75505Sopenharmony_ci * Initialize the global control interface and start receiving commands from 97e5b75505Sopenharmony_ci * external programs. 98e5b75505Sopenharmony_ci * 99e5b75505Sopenharmony_ci * Required to be implemented in each control interface backend. 100e5b75505Sopenharmony_ci */ 101e5b75505Sopenharmony_cistruct ctrl_iface_global_priv * 102e5b75505Sopenharmony_ciwpa_supplicant_global_ctrl_iface_init(struct wpa_global *global); 103e5b75505Sopenharmony_ci 104e5b75505Sopenharmony_ci/** 105e5b75505Sopenharmony_ci * wpa_supplicant_global_ctrl_iface_deinit - Deinitialize global ctrl interface 106e5b75505Sopenharmony_ci * @priv: Pointer to private data from wpa_supplicant_global_ctrl_iface_init() 107e5b75505Sopenharmony_ci * 108e5b75505Sopenharmony_ci * Deinitialize the global control interface that was initialized with 109e5b75505Sopenharmony_ci * wpa_supplicant_global_ctrl_iface_init(). 110e5b75505Sopenharmony_ci * 111e5b75505Sopenharmony_ci * Required to be implemented in each control interface backend. 112e5b75505Sopenharmony_ci */ 113e5b75505Sopenharmony_civoid wpa_supplicant_global_ctrl_iface_deinit( 114e5b75505Sopenharmony_ci struct ctrl_iface_global_priv *priv); 115e5b75505Sopenharmony_ci 116e5b75505Sopenharmony_civoid wpas_ctrl_radio_work_flush(struct wpa_supplicant *wpa_s); 117e5b75505Sopenharmony_ci#ifdef CONFIG_MAGICLINK 118e5b75505Sopenharmony_ciint hw_magiclink_ctrl_iface_update_network( 119e5b75505Sopenharmony_ci struct wpa_supplicant *wpa_s, struct wpa_ssid *ssid, 120e5b75505Sopenharmony_ci char *name, char *value); 121e5b75505Sopenharmony_ci#endif /* CONFIG_MAGICLINK */ 122e5b75505Sopenharmony_ci 123e5b75505Sopenharmony_ci#else /* CONFIG_CTRL_IFACE */ 124e5b75505Sopenharmony_ci 125e5b75505Sopenharmony_cistatic inline struct ctrl_iface_priv * 126e5b75505Sopenharmony_ciwpa_supplicant_ctrl_iface_init(struct wpa_supplicant *wpa_s) 127e5b75505Sopenharmony_ci{ 128e5b75505Sopenharmony_ci return (void *) -1; 129e5b75505Sopenharmony_ci} 130e5b75505Sopenharmony_ci 131e5b75505Sopenharmony_cistatic inline void 132e5b75505Sopenharmony_ciwpa_supplicant_ctrl_iface_deinit(struct ctrl_iface_priv *priv) 133e5b75505Sopenharmony_ci{ 134e5b75505Sopenharmony_ci} 135e5b75505Sopenharmony_ci 136e5b75505Sopenharmony_cistatic inline void 137e5b75505Sopenharmony_ciwpa_supplicant_ctrl_iface_send(struct ctrl_iface_priv *priv, int level, 138e5b75505Sopenharmony_ci char *buf, size_t len) 139e5b75505Sopenharmony_ci{ 140e5b75505Sopenharmony_ci} 141e5b75505Sopenharmony_ci 142e5b75505Sopenharmony_cistatic inline void 143e5b75505Sopenharmony_ciwpa_supplicant_ctrl_iface_wait(struct ctrl_iface_priv *priv) 144e5b75505Sopenharmony_ci{ 145e5b75505Sopenharmony_ci} 146e5b75505Sopenharmony_ci 147e5b75505Sopenharmony_cistatic inline struct ctrl_iface_global_priv * 148e5b75505Sopenharmony_ciwpa_supplicant_global_ctrl_iface_init(struct wpa_global *global) 149e5b75505Sopenharmony_ci{ 150e5b75505Sopenharmony_ci return (void *) 1; 151e5b75505Sopenharmony_ci} 152e5b75505Sopenharmony_ci 153e5b75505Sopenharmony_cistatic inline void 154e5b75505Sopenharmony_ciwpa_supplicant_global_ctrl_iface_deinit(struct ctrl_iface_global_priv *priv) 155e5b75505Sopenharmony_ci{ 156e5b75505Sopenharmony_ci} 157e5b75505Sopenharmony_ci 158e5b75505Sopenharmony_cistatic inline void wpas_ctrl_radio_work_flush(struct wpa_supplicant *wpa_s) 159e5b75505Sopenharmony_ci{ 160e5b75505Sopenharmony_ci} 161e5b75505Sopenharmony_ci 162e5b75505Sopenharmony_ci#endif /* CONFIG_CTRL_IFACE */ 163e5b75505Sopenharmony_ci 164e5b75505Sopenharmony_ci#endif /* CTRL_IFACE_H */ 165