tizen 2.3.1 release
[framework/connectivity/mobileap-agent.git] / include / mobileap.h
1 /*
2  * mobileap-agent
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18 #ifndef __MOBILEAP_INTERNAL_H__
19 #define __MOBILEAP_INTERNAL_H__
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 /* Client / Agent common */
26 #define DBUS_STRUCT_UINT_STRING (dbus_g_type_get_struct ("GValueArray", \
27                         G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))
28
29 #define DBUS_STRUCT_STATIONS (dbus_g_type_get_struct ("GValueArray", \
30                         G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, \
31                         G_TYPE_STRING, G_TYPE_UINT, G_TYPE_INVALID))
32
33 #define DBUS_STRUCT_STATION (dbus_g_type_get_struct ("GValueArray", \
34                         G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
35                         G_TYPE_INVALID))
36
37 #define DBUS_STRUCT_INTERFACE (dbus_g_type_get_struct ("GValueArray", \
38                         G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
39                         G_TYPE_STRING, G_TYPE_INVALID))
40
41
42 #define TETHERING_SERVICE_OBJECT_PATH   "/Tethering"
43 #define TETHERING_SERVICE_NAME          "org.tizen.tethering"
44 #define TETHERING_SERVICE_INTERFACE     "org.tizen.tethering"
45
46 #define SIGNAL_NAME_NET_CLOSED          "net_closed"
47 #define SIGNAL_NAME_STA_CONNECT         "sta_connected"
48 #define SIGNAL_NAME_STA_DISCONNECT      "sta_disconnected"
49 #define SIGNAL_NAME_WIFI_TETHER_ON      "wifi_on"
50 #define SIGNAL_NAME_WIFI_TETHER_OFF     "wifi_off"
51 #define SIGNAL_NAME_USB_TETHER_ON       "usb_on"
52 #define SIGNAL_NAME_USB_TETHER_OFF      "usb_off"
53 #define SIGNAL_NAME_BT_TETHER_ON        "bluetooth_on"
54 #define SIGNAL_NAME_BT_TETHER_OFF       "bluetooth_off"
55 #define SIGNAL_NAME_WIFI_AP_ON          "wifi_ap_on"
56 #define SIGNAL_NAME_WIFI_AP_OFF         "wifi_ap_off"
57 #define SIGNAL_NAME_NO_DATA_TIMEOUT     "no_data_timeout"
58 #define SIGNAL_NAME_LOW_BATTERY_MODE    "low_batt_mode"
59 #define SIGNAL_NAME_FLIGHT_MODE         "flight_mode"
60 #define SIGNAL_NAME_POWER_SAVE_MODE             "power_save_mode"
61 #define SIGNAL_NAME_DHCP_STATUS         "dhcp_status"
62 #define SIGNAL_NAME_SECURITY_TYPE_CHANGED       "security_type_changed"
63 #define SIGNAL_NAME_SSID_VISIBILITY_CHANGED     "ssid_visibility_changed"
64 #define SIGNAL_NAME_PASSPHRASE_CHANGED          "passphrase_changed"
65
66 #define SIGNAL_MSG_NOT_AVAIL_INTERFACE  "Interface is not available"
67 #define SIGNAL_MSG_TIMEOUT              "There is no connection for a while"
68 #define SIGNAL_MSG_SSID_VISIBLE         "ssid_visible"
69 #define SIGNAL_MSG_SSID_HIDE            "ssid_hide"
70
71 #define DNSMASQ_LEASES_FILE             "/var/lib/misc/dnsmasq.leases"
72 #define IP_USB_SUBNET                   "192.168.129"
73
74 typedef enum {
75         E_SIGNAL_NET_CLOSED,
76         E_SIGNAL_STA_CONNECT,
77         E_SIGNAL_STA_DISCONNECT,
78         E_SIGNAL_WIFI_TETHER_ON,
79         E_SIGNAL_WIFI_TETHER_OFF,
80         E_SIGNAL_USB_TETHER_ON,
81         E_SIGNAL_USB_TETHER_OFF,
82         E_SIGNAL_BT_TETHER_ON,
83         E_SIGNAL_BT_TETHER_OFF,
84         E_SIGNAL_WIFI_AP_ON,
85         E_SIGNAL_WIFI_AP_OFF,
86         E_SIGNAL_NO_DATA_TIMEOUT,
87         E_SIGNAL_LOW_BATTERY_MODE,
88         E_SIGNAL_FLIGHT_MODE,
89         E_SIGNAL_POWER_SAVE_MODE,
90         E_SIGNAL_SECURITY_TYPE_CHANGED,
91         E_SIGNAL_SSID_VISIBILITY_CHANGED,
92         E_SIGNAL_PASSPHRASE_CHANGED,
93         E_SIGNAL_MAX
94 } mobile_ap_sig_e;
95
96 /**
97 * WiFi tethering configuration
98 */
99 #define MOBILE_AP_WIFI_CHANNEL          6       /**< Channel number */
100 #define MOBILE_AP_WIFI_BSSID_LEN        6       /**< BSSID Length */
101 #define MOBILE_AP_WIFI_SSID_MAX_LEN     32      /**< Maximum length of ssid */
102 #define MOBILE_AP_WIFI_KEY_MIN_LEN      8       /**< Minimum length of wifi key */
103 #define MOBILE_AP_WIFI_PLAIN_TEXT_KEY_MAX_LEN   63      /**< Maximum length of wifi plain text key */
104 #define MOBILE_AP_WIFI_KEY_MAX_LEN      64      /**< Maximum length of wifi hash key */
105
106 /**
107 * Common configuration
108 */
109 #define MOBILE_AP_MAX_WIFI_STA          10      /**< Firmware limitation (BCM4339) */
110 #define MOBILE_AP_MAX_BT_STA            4       /**< Bluetooth specification (1 Master and 4 Slaves) */
111 #define MOBILE_AP_MAX_USB_STA           1       /**< Only one usb connection is possible */
112 #define MOBILE_AP_MAX_CONNECTED_STA     15      /**< Maximum connected station. 10(Wi-Fi) + 4(BT) + 1(USB) */
113
114 #define MOBILE_AP_STR_INFO_LEN          20      /**< length of the ip or mac address*/
115 #define MOBILE_AP_STR_HOSTNAME_LEN      33      /**< length of the hostname */
116 #define MOBILE_AP_NAME_UNKNOWN          "UNKNOWN"
117
118 /**
119 * Mobile AP error code
120 */
121 typedef enum {
122         MOBILE_AP_ERROR_NONE,                   /**< No error */
123         MOBILE_AP_ERROR_RESOURCE,               /**< Socket creation error, file open error */
124         MOBILE_AP_ERROR_INTERNAL,               /**< Driver related error */
125         MOBILE_AP_ERROR_INVALID_PARAM,          /**< Invalid parameter */
126         MOBILE_AP_ERROR_ALREADY_ENABLED,        /**< Mobile AP is already ON */
127         MOBILE_AP_ERROR_NOT_ENABLED,            /**< Mobile AP is not ON, so cannot be disabled */
128         MOBILE_AP_ERROR_NET_OPEN,               /**< PDP network open error */
129         MOBILE_AP_ERROR_NET_CLOSE,              /**< PDP network close error */
130         MOBILE_AP_ERROR_DHCP,                   /**< DHCP error */
131         MOBILE_AP_ERROR_IN_PROGRESS,            /**< Request is in progress */
132         MOBILE_AP_ERROR_NOT_PERMITTED,          /**< Operation is not permitted */
133         MOBILE_AP_ERROR_PERMISSION_DENIED,      /**< Permission Denied */
134
135         MOBILE_AP_ERROR_MAX
136 } mobile_ap_error_code_e;
137
138 /**
139 * Event type on callback
140 */
141 typedef enum {
142         MOBILE_AP_ENABLE_CFM,                   /* mobile_ap_enable() */
143         MOBILE_AP_DISABLE_CFM,                  /* mobile_ap_disable() */
144
145         MOBILE_AP_ENABLE_WIFI_TETHERING_CFM,    /* mobile_ap_enable_wifi_tethering() */
146         MOBILE_AP_DISABLE_WIFI_TETHERING_CFM,   /* mobile_ap_disable_wifi_tethering() */
147         MOBILE_AP_CHANGE_WIFI_CONFIG_CFM,       /* mobile_ap_change_wifi_config() */
148
149         MOBILE_AP_ENABLE_USB_TETHERING_CFM,     /* mobile_ap_enable_usb_tethering() */
150         MOBILE_AP_DISABLE_USB_TETHERING_CFM,    /* mobile_ap_disable_usb_tethering() */
151
152         MOBILE_AP_ENABLE_BT_TETHERING_CFM,      /* mobile_ap_enable_bt_tethering() */
153         MOBILE_AP_DISABLE_BT_TETHERING_CFM,     /* mobile_ap_disable_bt_tethering() */
154
155         MOBILE_AP_ENABLE_WIFI_AP_CFM,           /* mobile_ap_enable_wifi_ap() */
156         MOBILE_AP_DISABLE_WIFI_AP_CFM,          /* mobile_ap_disable_wifi_ap() */
157
158         MOBILE_AP_GET_STATION_INFO_CFM,         /* mobile_ap_get_station_info() */
159         MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,    /* mobile_ap_get_data_packet_usage() */
160
161         MOBILE_AP_DISABLED_IND,                 /* Turning off tethering service indication */
162
163         MOBILE_AP_ENABLED_WIFI_TETHERING_IND,   /* Turning on WiFi tethering indication */
164         MOBILE_AP_DISABLED_WIFI_TETHERING_IND,  /* Turning off WiFi tethering indication */
165
166         MOBILE_AP_ENABLED_USB_TETHERING_IND,    /* Turning on USB tethering indication */
167         MOBILE_AP_DISABLED_USB_TETHERING_IND,   /* Turning off USB tethering indication */
168
169         MOBILE_AP_ENABLED_BT_TETHERING_IND,     /* Turning on BT tethering indication */
170         MOBILE_AP_DISABLED_BT_TETHERING_IND,    /* Turning off BT tethering indication */
171
172         MOBILE_AP_ENABLED_WIFI_AP_IND,          /* Turning on WiFi AP indication */
173         MOBILE_AP_DISABLED_WIFI_AP_IND,         /* Turning off WiFi AP indication */
174
175         MOBILE_AP_STATION_CONNECT_IND,          /* Station connection indication */
176         MOBILE_AP_STATION_DISCONNECT_IND,       /* Station disconnection indication */
177         MOBILE_AP_USB_STATION_CONNECT_IND,
178
179         MOBILE_AP_MAX_EVENT,
180 } mobile_ap_event_e;
181
182 typedef enum {
183         MOBILE_AP_TYPE_WIFI,
184         MOBILE_AP_TYPE_USB,
185         MOBILE_AP_TYPE_BT,
186         MOBILE_AP_TYPE_WIFI_AP,
187         MOBILE_AP_TYPE_MAX,
188 } mobile_ap_type_e;
189
190 typedef struct {
191         unsigned long long pdp_tx_bytes;        /**< packet data transmitted */
192         unsigned long long pdp_rx_bytes;        /**< packet data received */
193 } mobile_ap_data_packet_usage_t;
194
195 typedef struct {
196         mobile_ap_type_e interface;                     /**< interface type */
197         char ip[MOBILE_AP_STR_INFO_LEN];                /**< assigned IP address */
198         char mac[MOBILE_AP_STR_INFO_LEN];               /**< MAC Address */
199         char *hostname;
200         time_t tm;      /**< connection time*/
201 } mobile_ap_station_info_t;
202
203 typedef struct {
204         mobile_ap_type_e interface;                     /**< interface type */
205         char interface_name[MOBILE_AP_STR_INFO_LEN];            /**< interface alphanumeric name */
206         char ip_address[MOBILE_AP_STR_INFO_LEN];                /**< assigned ip addresss to interface */
207         char gateway_address[MOBILE_AP_STR_INFO_LEN];   /**< gateway address of interface */
208         char subnet_mask[MOBILE_AP_STR_INFO_LEN];       /**< subnet mask of interface */
209 } mobile_ap_interface_info_t;
210
211 typedef struct {
212         unsigned short number;                  /**< Number of connected device */
213         mobile_ap_station_info_t sta_info[MOBILE_AP_MAX_CONNECTED_STA];
214 } mobile_ap_device_info_t;
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif  /* __MOBILEAP_INTERNAL_H__ */