tizen 2.4 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 #define TETHERING_SERVICE_OBJECT_PATH   "/Tethering"
26 #define TETHERING_SERVICE_NAME          "org.tizen.tethering"
27 #define TETHERING_SERVICE_INTERFACE     "org.tizen.tethering"
28
29 #define SIGNAL_NAME_NET_CLOSED          "net_closed"
30 #define SIGNAL_NAME_STA_CONNECT         "sta_connected"
31 #define SIGNAL_NAME_STA_DISCONNECT      "sta_disconnected"
32 #define SIGNAL_NAME_WIFI_TETHER_ON      "wifi_on"
33 #define SIGNAL_NAME_WIFI_TETHER_OFF     "wifi_off"
34 #define SIGNAL_NAME_USB_TETHER_ON       "usb_on"
35 #define SIGNAL_NAME_USB_TETHER_OFF      "usb_off"
36 #define SIGNAL_NAME_BT_TETHER_ON        "bluetooth_on"
37 #define SIGNAL_NAME_BT_TETHER_OFF       "bluetooth_off"
38 #define SIGNAL_NAME_WIFI_AP_ON          "wifi_ap_on"
39 #define SIGNAL_NAME_WIFI_AP_OFF         "wifi_ap_off"
40 #define SIGNAL_NAME_NO_DATA_TIMEOUT     "no_data_timeout"
41 #define SIGNAL_NAME_LOW_BATTERY_MODE    "low_batt_mode"
42 #define SIGNAL_NAME_FLIGHT_MODE         "flight_mode"
43 #define SIGNAL_NAME_POWER_SAVE_MODE             "power_save_mode"
44 #define SIGNAL_NAME_SECURITY_TYPE_CHANGED       "security_type_changed"
45 #define SIGNAL_NAME_SSID_VISIBILITY_CHANGED     "ssid_visibility_changed"
46 #define SIGNAL_NAME_PASSPHRASE_CHANGED          "passphrase_changed"
47 #define SIGNAL_NAME_DHCP_STATUS         "dhcp_status"
48 #define SIGNAL_MSG_NOT_AVAIL_INTERFACE  "Interface is not available"
49 #define SIGNAL_MSG_TIMEOUT              "There is no connection for a while"
50 #define SIGNAL_MSG_SSID_VISIBLE         "ssid_visible"
51 #define SIGNAL_MSG_SSID_HIDE            "ssid_hide"
52
53 #define DNSMASQ_LEASES_FILE             "/var/lib/misc/dnsmasq.leases"
54 #define IP_USB_SUBNET                   "192.168.129"
55
56 typedef enum {
57         E_SIGNAL_NET_CLOSED,
58         E_SIGNAL_STA_CONNECT,
59         E_SIGNAL_STA_DISCONNECT,
60         E_SIGNAL_WIFI_TETHER_ON,
61         E_SIGNAL_WIFI_TETHER_OFF,
62         E_SIGNAL_USB_TETHER_ON,
63         E_SIGNAL_USB_TETHER_OFF,
64         E_SIGNAL_BT_TETHER_ON,
65         E_SIGNAL_BT_TETHER_OFF,
66         E_SIGNAL_WIFI_AP_ON,
67         E_SIGNAL_WIFI_AP_OFF,
68         E_SIGNAL_NO_DATA_TIMEOUT,
69         E_SIGNAL_LOW_BATTERY_MODE,
70         E_SIGNAL_FLIGHT_MODE,
71         E_SIGNAL_POWER_SAVE_MODE,
72         E_SIGNAL_SECURITY_TYPE_CHANGED,
73         E_SIGNAL_SSID_VISIBILITY_CHANGED,
74         E_SIGNAL_PASSPHRASE_CHANGED,
75         E_SIGNAL_MAX
76 } mobile_ap_sig_e;
77
78 /**
79 * WiFi tethering configuration
80 */
81 #define MOBILE_AP_WIFI_CHANNEL          6       /**< Channel number */
82 #define MOBILE_AP_WIFI_BSSID_LEN        6       /**< BSSID Length */
83 #define MOBILE_AP_WIFI_SSID_MAX_LEN     32      /**< Maximum length of ssid */
84 #define MOBILE_AP_WIFI_KEY_MIN_LEN      8       /**< Minimum length of wifi key */
85 #define MOBILE_AP_WIFI_PLAIN_TEXT_KEY_MAX_LEN   63      /**< Maximum length of wifi plain text key */
86 #define MOBILE_AP_WIFI_KEY_MAX_LEN      64      /**< Maximum length of wifi hash key */
87
88 /**
89 * Common configuration
90 */
91 #define MOBILE_AP_MAX_WIFI_STA          10      /**< Firmware limitation (BCM4339) */
92 #define MOBILE_AP_MAX_BT_STA            4       /**< Bluetooth specification (1 Master and 4 Slaves) */
93 #define MOBILE_AP_MAX_USB_STA           1       /**< Only one usb connection is possible */
94 #define MOBILE_AP_MAX_CONNECTED_STA     15      /**< Maximum connected station. 10(Wi-Fi) + 4(BT) + 1(USB) */
95
96 #define MOBILE_AP_STR_INFO_LEN          20      /**< length of the ip or mac address*/
97 #define MOBILE_AP_STR_HOSTNAME_LEN      33      /**< length of the hostname */
98 #define MOBILE_AP_NAME_UNKNOWN          "UNKNOWN"
99 /**
100 * Mobile AP error code
101 */
102 typedef enum {
103         MOBILE_AP_ERROR_NONE,                   /**< No error */
104         MOBILE_AP_ERROR_RESOURCE,               /**< Socket creation error, file open error */
105         MOBILE_AP_ERROR_INTERNAL,               /**< Driver related error */
106         MOBILE_AP_ERROR_INVALID_PARAM,          /**< Invalid parameter */
107         MOBILE_AP_ERROR_ALREADY_ENABLED,        /**< Mobile AP is already ON */
108         MOBILE_AP_ERROR_NOT_ENABLED,            /**< Mobile AP is not ON, so cannot be disabled */
109         MOBILE_AP_ERROR_NET_OPEN,               /**< PDP network open error */
110         MOBILE_AP_ERROR_NET_CLOSE,              /**< PDP network close error */
111         MOBILE_AP_ERROR_DHCP,                   /**< DHCP error */
112         MOBILE_AP_ERROR_IN_PROGRESS,            /**< Request is in progress */
113         MOBILE_AP_ERROR_NOT_PERMITTED,          /**< Operation is not permitted */
114         MOBILE_AP_ERROR_PERMISSION_DENIED,      /**< Permission Denied */
115
116         MOBILE_AP_ERROR_MAX
117 } mobile_ap_error_code_e;
118
119 /**
120 * Event type on callback
121 */
122 typedef enum {
123         MOBILE_AP_ENABLE_CFM,                   /* mobile_ap_enable() */
124         MOBILE_AP_DISABLE_CFM,                  /* mobile_ap_disable() */
125
126         MOBILE_AP_ENABLE_WIFI_TETHERING_CFM,    /* mobile_ap_enable_wifi_tethering() */
127         MOBILE_AP_DISABLE_WIFI_TETHERING_CFM,   /* mobile_ap_disable_wifi_tethering() */
128         MOBILE_AP_CHANGE_WIFI_CONFIG_CFM,       /* mobile_ap_change_wifi_config() */
129
130         MOBILE_AP_ENABLE_USB_TETHERING_CFM,     /* mobile_ap_enable_usb_tethering() */
131         MOBILE_AP_DISABLE_USB_TETHERING_CFM,    /* mobile_ap_disable_usb_tethering() */
132
133         MOBILE_AP_ENABLE_BT_TETHERING_CFM,      /* mobile_ap_enable_bt_tethering() */
134         MOBILE_AP_DISABLE_BT_TETHERING_CFM,     /* mobile_ap_disable_bt_tethering() */
135
136         MOBILE_AP_ENABLE_WIFI_AP_CFM,           /* mobile_ap_enable_wifi_ap() */
137         MOBILE_AP_DISABLE_WIFI_AP_CFM,          /* mobile_ap_disable_wifi_ap() */
138
139         MOBILE_AP_GET_STATION_INFO_CFM,         /* mobile_ap_get_station_info() */
140         MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,    /* mobile_ap_get_data_packet_usage() */
141
142         MOBILE_AP_DISABLED_IND,                 /* Turning off tethering service indication */
143
144         MOBILE_AP_ENABLED_WIFI_TETHERING_IND,   /* Turning on WiFi tethering indication */
145         MOBILE_AP_DISABLED_WIFI_TETHERING_IND,  /* Turning off WiFi tethering indication */
146
147         MOBILE_AP_ENABLED_USB_TETHERING_IND,    /* Turning on USB tethering indication */
148         MOBILE_AP_DISABLED_USB_TETHERING_IND,   /* Turning off USB tethering indication */
149
150         MOBILE_AP_ENABLED_BT_TETHERING_IND,     /* Turning on BT tethering indication */
151         MOBILE_AP_DISABLED_BT_TETHERING_IND,    /* Turning off BT tethering indication */
152
153         MOBILE_AP_ENABLED_WIFI_AP_IND,          /* Turning on WiFi AP indication */
154         MOBILE_AP_DISABLED_WIFI_AP_IND,         /* Turning off WiFi AP indication */
155
156         MOBILE_AP_STATION_CONNECT_IND,          /* Station connection indication */
157         MOBILE_AP_STATION_DISCONNECT_IND,       /* Station disconnection indication */
158         MOBILE_AP_USB_STATION_CONNECT_IND,
159
160         MOBILE_AP_MAX_EVENT,
161 } mobile_ap_event_e;
162
163 typedef enum {
164         MOBILE_AP_TYPE_WIFI,
165         MOBILE_AP_TYPE_USB,
166         MOBILE_AP_TYPE_BT,
167         MOBILE_AP_TYPE_WIFI_AP,
168         MOBILE_AP_TYPE_MAX,
169 } mobile_ap_type_e;
170
171 typedef struct {
172         unsigned long long pdp_tx_bytes;        /**< packet data transmitted */
173         unsigned long long pdp_rx_bytes;        /**< packet data received */
174 } mobile_ap_data_packet_usage_t;
175
176 typedef struct {
177         mobile_ap_type_e interface;                     /**< interface type */
178         char ip[MOBILE_AP_STR_INFO_LEN];                /**< assigned IP address */
179         char mac[MOBILE_AP_STR_INFO_LEN];               /**< MAC Address */
180         char *hostname;
181         time_t tm;      /**< connection time*/
182 } mobile_ap_station_info_t;
183
184 typedef struct {
185         mobile_ap_type_e interface;                     /**< interface type */
186         char interface_name[MOBILE_AP_STR_INFO_LEN];            /**< interface alphanumeric name */
187         char ip_address[MOBILE_AP_STR_INFO_LEN];                /**< assigned ip addresss to interface */
188         char gateway_address[MOBILE_AP_STR_INFO_LEN];   /**< gateway address of interface */
189         char subnet_mask[MOBILE_AP_STR_INFO_LEN];       /**< subnet mask of interface */
190 } mobile_ap_interface_info_t;
191
192 typedef struct {
193         unsigned short number;                  /**< Number of connected device */
194         mobile_ap_station_info_t sta_info[MOBILE_AP_MAX_CONNECTED_STA];
195 } mobile_ap_device_info_t;
196
197 #ifdef __cplusplus
198 }
199 #endif
200
201 #endif  /* __MOBILEAP_INTERNAL_H__ */