2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef __TETHERING_PRIVATE_H__
18 #define __TETHERING_PRIVATE_H__
20 #define LOG_TAG "tethering"
23 #include <dbus/dbus-glib.h>
26 #include "tethering.h"
33 #define API __attribute__ ((visibility("default")))
36 #ifndef DEPRECATED_API
37 # define DEPRECATED_API __attribute__ ((deprecated))
40 #define DBG(fmt, args...) LOGD("[%s()][Ln:%d] "fmt, __func__, __LINE__, ##args)
41 #define WARN(fmt, args...) LOGW("[%s()][Ln:%d] "fmt, __func__, __LINE__, ##args)
42 #define ERR(fmt, args...) LOGE("[%s()][Ln:%d] "fmt, __func__, __LINE__, ##args)
44 #define _warn_if(expr, fmt, arg...) do { \
50 #define _ret_if(expr) do { \
56 #define _retv_if(expr, val) do { \
62 #define _retm_if(expr, fmt, arg...) do { \
69 #define _retvm_if(expr, val, fmt, arg...) do { \
77 * Start of mobileap-agent common values
78 * When these values are changed, mobileap-agent should be also changed.
79 * But some of those will be removed.
87 * WiFi tethering configuration
89 #define TETHERING_WIFI_CHANNEL 7 /**< Channel number */
90 #define TETHERING_WIFI_BSSID_LEN 6 /**< BSSID Length */
91 #define TETHERING_WIFI_PASSPHRASE_MIN_LEN 8 /**< Minimum length of wifi key */
92 #define TETHERING_WIFI_PASSPHRASE_MAX_LEN 63 /**< Maximum length of wifi key */
95 * Common configuration
97 #define TETHERING_MAX_WIFI_STA 8
98 #define TETHERING_MAX_BT_STA 7
99 #define TETHERING_MAX_USB_STA 1
100 #define TETHERING_MAX_CONNECTED_STA 16 /**< Maximum connected station. 8(Wi-Fi) + 7(BT) + 1(USB) */
102 #define TETHERING_NAME_UNKNOWN "UNKNOWN"
104 #define TETHERING_TYPE_MAX 4 /**< All, USB, Wi-Fi, BT */
105 #define TETHERING_STR_INFO_LEN 20 /**< length of the ip or mac address */
106 #define TETHERING_STR_HOSTNAME_LEN 32 /**< length of the hostname */
109 * Mobile AP error code
112 MOBILE_AP_ERROR_NONE, /**< No error */
113 MOBILE_AP_ERROR_RESOURCE, /**< Socket creation error, file open error */
114 MOBILE_AP_ERROR_INTERNAL, /**< Driver related error */
115 MOBILE_AP_ERROR_INVALID_PARAM, /**< Invalid parameter */
116 MOBILE_AP_ERROR_ALREADY_ENABLED, /**< Mobile AP is already ON */
117 MOBILE_AP_ERROR_NOT_ENABLED, /**< Mobile AP is not ON, so cannot be disabled */
118 MOBILE_AP_ERROR_NET_OPEN, /**< PDP network open error */
119 MOBILE_AP_ERROR_NET_CLOSE, /**< PDP network close error */
120 MOBILE_AP_ERROR_DHCP, /**< DHCP error */
121 MOBILE_AP_ERROR_IN_PROGRESS, /**< Request is in progress */
122 MOBILE_AP_ERROR_NOT_PERMITTED, /**< Operation is not permitted */
125 } mobile_ap_error_code_e;
128 * Event type on callback
131 MOBILE_AP_ENABLE_CFM,
132 MOBILE_AP_DISABLE_CFM,
134 MOBILE_AP_ENABLE_WIFI_TETHERING_CFM,
135 MOBILE_AP_DISABLE_WIFI_TETHERING_CFM,
136 MOBILE_AP_CHANGE_WIFI_CONFIG_CFM,
138 MOBILE_AP_ENABLE_USB_TETHERING_CFM,
139 MOBILE_AP_DISABLE_USB_TETHERING_CFM,
141 MOBILE_AP_ENABLE_BT_TETHERING_CFM,
142 MOBILE_AP_DISABLE_BT_TETHERING_CFM,
144 MOBILE_AP_GET_STATION_INFO_CFM,
145 MOBILE_AP_GET_DATA_PACKET_USAGE_CFM
157 * from mobileap_internal.h
159 #define DBUS_STRUCT_UINT_STRING (dbus_g_type_get_struct ("GValueArray", \
160 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))
162 #define DBUS_STRUCT_STATIONS (dbus_g_type_get_struct ("GValueArray", \
163 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, \
164 G_TYPE_STRING, G_TYPE_INVALID))
166 #define DBUS_STRUCT_STATION (dbus_g_type_get_struct ("GValueArray", \
167 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
170 #define DBUS_STRUCT_INTERFACE (dbus_g_type_get_struct ("GValueArray", \
171 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
172 G_TYPE_STRING, G_TYPE_INVALID))
174 #define TETHERING_SERVICE_OBJECT_PATH "/MobileAP"
175 #define TETHERING_SERVICE_NAME "com.samsung.mobileap"
176 #define TETHERING_SERVICE_INTERFACE "com.samsung.mobileap"
178 #define TETHERING_SIGNAL_NAME_LEN 64
180 #define SIGNAL_NAME_NET_CLOSED "net_closed"
181 #define SIGNAL_NAME_STA_CONNECT "sta_connected"
182 #define SIGNAL_NAME_STA_DISCONNECT "sta_disconnected"
183 #define SIGNAL_NAME_WIFI_TETHER_ON "wifi_on"
184 #define SIGNAL_NAME_WIFI_TETHER_OFF "wifi_off"
185 #define SIGNAL_NAME_USB_TETHER_ON "usb_on"
186 #define SIGNAL_NAME_USB_TETHER_OFF "usb_off"
187 #define SIGNAL_NAME_BT_TETHER_ON "bluetooth_on"
188 #define SIGNAL_NAME_BT_TETHER_OFF "bluetooth_off"
189 #define SIGNAL_NAME_NO_DATA_TIMEOUT "no_data_timeout"
190 #define SIGNAL_NAME_LOW_BATTERY_MODE "low_batt_mode"
191 #define SIGNAL_NAME_FLIGHT_MODE "flight_mode"
192 #define SIGNAL_NAME_DHCP_STATUS "dhcp_status"
194 #define SIGNAL_MSG_NOT_AVAIL_INTERFACE "Interface is not available"
196 /* Network Interface */
197 #define TETHERING_SUBNET_MASK "255.255.255.0"
199 #define TETHERING_USB_IF "usb0"
200 #define TETHERING_USB_GATEWAY "192.168.129.1"
202 #define TETHERING_WIFI_IF "wlan0"
203 #define TETHERING_WIFI_GATEWAY "192.168.61.1"
205 #define TETHERING_BT_IF "bnep0"
206 #define TETHERING_BT_GATEWAY "192.168.130.1"
208 * End of mobileap-agent common values
211 #define TETHERING_DEFAULT_SSID "Redwood"
212 #define TETHERING_DEFAULT_PASSPHRASE "eoiugkl!"
213 #define TETHERING_WIFI_SECURITY_TYPE_OPEN_STR "open"
214 #define TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR "wpa2-psk"
217 typedef void (*__handle_cb_t)(DBusGProxy *proxy, const char *name, gpointer data);
219 char name[TETHERING_SIGNAL_NAME_LEN];
224 DBusGConnection *client_bus;
225 DBusGProxy *client_bus_proxy;
227 tethering_enabled_cb enabled_cb[TETHERING_TYPE_MAX];
228 void *enabled_user_data[TETHERING_TYPE_MAX];
229 tethering_disabled_cb disabled_cb[TETHERING_TYPE_MAX];
230 void *disabled_user_data[TETHERING_TYPE_MAX];
231 tethering_connection_state_changed_cb changed_cb[TETHERING_TYPE_MAX];
232 void *changed_user_data[TETHERING_TYPE_MAX];
233 tethering_data_usage_cb data_usage_cb;
234 void *data_usage_user_data;
238 tethering_type_e interface; /**< interface type */
239 char ip[TETHERING_STR_INFO_LEN]; /**< assigned IP address */
240 char mac[TETHERING_STR_INFO_LEN]; /**< MAC Address */
241 char hostname[TETHERING_STR_HOSTNAME_LEN]; /**< alphanumeric name */
242 } __tethering_client_h;
245 tethering_type_e interface; /**< interface type */
246 char interface_name[TETHERING_STR_INFO_LEN]; /**< interface alphanumeric name */
247 char ip_address[TETHERING_STR_INFO_LEN]; /**< assigned ip addresss to interface */
248 char gateway_address[TETHERING_STR_INFO_LEN]; /**< gateway address of interface */
249 char subnet_mask[TETHERING_STR_INFO_LEN]; /**< subnet mask of interface */
250 } __tethering_interface_t;
256 #endif /* __TETHERING_PRIVATE_H__ */