1 /*  RetroArch - A frontend for libretro.
2  *  Copyright (C) 2010-2014 - Hans-Kristian Arntzen
3  *  Copyright (C) 2011-2017 - Daniel De Matteis
4  *  Copyright (C) 2014-2017 - Jean-André Santoni
5  *
6  *  RetroArch is free software: you can redistribute it and/or modify it under the terms
7  *  of the GNU General Public License as published by the Free Software Found-
8  *  ation, either version 3 of the License, or (at your option) any later version.
9  *
10  *  RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
11  *  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  *  PURPOSE.  See the GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along with RetroArch.
15  *  If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef __WIFI_DRIVER__H
19 #define __WIFI_DRIVER__H
20 
21 #include <stdint.h>
22 
23 #include <boolean.h>
24 #include <retro_common_api.h>
25 
26 RETRO_BEGIN_DECLS
27 
28 enum rarch_wifi_ctl_state
29 {
30    RARCH_WIFI_CTL_NONE = 0,
31    RARCH_WIFI_CTL_DESTROY,
32    RARCH_WIFI_CTL_DEINIT,
33    RARCH_WIFI_CTL_SET_ACTIVE,
34    RARCH_WIFI_CTL_UNSET_ACTIVE,
35    RARCH_WIFI_CTL_IS_ACTIVE,
36    RARCH_WIFI_CTL_FIND_DRIVER,
37    RARCH_WIFI_CTL_SET_CB,
38    RARCH_WIFI_CTL_STOP,
39    RARCH_WIFI_CTL_START,
40    RARCH_WIFI_CTL_INIT
41 };
42 
43 typedef struct wifi_network_info
44 {
45    char ssid[33];
46    char passphrase[33];
47    bool connected;
48    bool saved_password;
49    char netid[160];   /* Do not use, internal */
50    /* TODO Add signal strength & other info */
51 } wifi_network_info_t;
52 
53 typedef struct wifi_network_scan
54 {
55    time_t scan_time;
56    wifi_network_info_t *net_list;   /* This is an rbuf array */
57 } wifi_network_scan_t;
58 
59 typedef struct wifi_driver
60 {
61    void *(*init)(void);
62 
63    void (*free)(void *data);
64 
65    bool (*start)(void *data);
66    void (*stop)(void *data);
67 
68    bool (*enable)(void *data, bool enabled);
69    bool (*connection_info)(void *data, wifi_network_info_t *ssid);
70    void (*scan)(void *data);
71    wifi_network_scan_t* (*get_ssids)(void *data);
72    bool (*ssid_is_online)(void *data, unsigned i);
73    bool (*connect_ssid)(void *data, const wifi_network_info_t *netinfo);
74    bool (*disconnect_ssid)(void *data, const wifi_network_info_t *netinfo);
75    void (*tether_start_stop)(void *data, bool start, char* configfile);
76 
77    const char *ident;
78 } wifi_driver_t;
79 
80 extern wifi_driver_t wifi_connmanctl;
81 extern wifi_driver_t wifi_nmcli;
82 
83 /**
84  * config_get_wifi_driver_options:
85  *
86  * Get an enumerated list of all wifi driver names,
87  * separated by '|'.
88  *
89  * Returns: string listing of all wifi driver names,
90  * separated by '|'.
91  **/
92 const char* config_get_wifi_driver_options(void);
93 
94 void driver_wifi_stop(void);
95 
96 bool driver_wifi_start(void);
97 
98 bool driver_wifi_enable(bool);
99 
100 bool driver_wifi_connection_info(wifi_network_info_t *network);
101 
102 void driver_wifi_scan(void);
103 
104 wifi_network_scan_t* driver_wifi_get_ssids(void);
105 
106 bool driver_wifi_ssid_is_online(unsigned i);
107 
108 bool driver_wifi_connect_ssid(const wifi_network_info_t *netinfo);
109 
110 bool driver_wifi_disconnect_ssid(const wifi_network_info_t* netinfo);
111 
112 void driver_wifi_tether_start_stop(bool start, char* configfile);
113 
114 bool wifi_driver_ctl(enum rarch_wifi_ctl_state state, void *data);
115 
116 RETRO_END_DECLS
117 
118 #endif
119