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 * Common configuration
89 #define TETHERING_TYPE_MAX 4 /**< All, USB, Wi-Fi, BT */
90 #define TETHERING_STR_INFO_LEN 20 /**< length of the ip or mac address */
91 #define TETHERING_STR_HOSTNAME_LEN 32 /**< length of the hostname */
94 * Mobile AP error code
97 MOBILE_AP_ERROR_NONE, /**< No error */
98 MOBILE_AP_ERROR_RESOURCE, /**< Socket creation error, file open error */
99 MOBILE_AP_ERROR_INTERNAL, /**< Driver related error */
100 MOBILE_AP_ERROR_INVALID_PARAM, /**< Invalid parameter */
101 MOBILE_AP_ERROR_ALREADY_ENABLED, /**< Mobile AP is already ON */
102 MOBILE_AP_ERROR_NOT_ENABLED, /**< Mobile AP is not ON, so cannot be disabled */
103 MOBILE_AP_ERROR_NET_OPEN, /**< PDP network open error */
104 MOBILE_AP_ERROR_NET_CLOSE, /**< PDP network close error */
105 MOBILE_AP_ERROR_DHCP, /**< DHCP error */
106 MOBILE_AP_ERROR_IN_PROGRESS, /**< Request is in progress */
107 MOBILE_AP_ERROR_NOT_PERMITTED, /**< Operation is not permitted */
110 } mobile_ap_error_code_e;
113 * Event type on callback
116 MOBILE_AP_ENABLE_CFM,
117 MOBILE_AP_DISABLE_CFM,
119 MOBILE_AP_ENABLE_WIFI_TETHERING_CFM,
120 MOBILE_AP_DISABLE_WIFI_TETHERING_CFM,
121 MOBILE_AP_CHANGE_WIFI_CONFIG_CFM,
123 MOBILE_AP_ENABLE_USB_TETHERING_CFM,
124 MOBILE_AP_DISABLE_USB_TETHERING_CFM,
126 MOBILE_AP_ENABLE_BT_TETHERING_CFM,
127 MOBILE_AP_DISABLE_BT_TETHERING_CFM,
129 MOBILE_AP_GET_STATION_INFO_CFM,
130 MOBILE_AP_GET_DATA_PACKET_USAGE_CFM
142 * from mobileap_internal.h
144 #define DBUS_STRUCT_UINT_STRING (dbus_g_type_get_struct ("GValueArray", \
145 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID))
147 #define DBUS_STRUCT_STATIONS (dbus_g_type_get_struct ("GValueArray", \
148 G_TYPE_UINT, G_TYPE_STRING, G_TYPE_STRING, \
149 G_TYPE_STRING, G_TYPE_INVALID))
151 #define DBUS_STRUCT_STATION (dbus_g_type_get_struct ("GValueArray", \
152 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
155 #define DBUS_STRUCT_INTERFACE (dbus_g_type_get_struct ("GValueArray", \
156 G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \
157 G_TYPE_STRING, G_TYPE_INVALID))
159 #define TETHERING_SERVICE_OBJECT_PATH "/MobileAP"
160 #define TETHERING_SERVICE_NAME "com.samsung.mobileap"
161 #define TETHERING_SERVICE_INTERFACE "com.samsung.mobileap"
163 #define TETHERING_SIGNAL_NAME_LEN 64
165 #define SIGNAL_NAME_NET_CLOSED "net_closed"
166 #define SIGNAL_NAME_STA_CONNECT "sta_connected"
167 #define SIGNAL_NAME_STA_DISCONNECT "sta_disconnected"
168 #define SIGNAL_NAME_WIFI_TETHER_ON "wifi_on"
169 #define SIGNAL_NAME_WIFI_TETHER_OFF "wifi_off"
170 #define SIGNAL_NAME_USB_TETHER_ON "usb_on"
171 #define SIGNAL_NAME_USB_TETHER_OFF "usb_off"
172 #define SIGNAL_NAME_BT_TETHER_ON "bluetooth_on"
173 #define SIGNAL_NAME_BT_TETHER_OFF "bluetooth_off"
174 #define SIGNAL_NAME_NO_DATA_TIMEOUT "no_data_timeout"
175 #define SIGNAL_NAME_LOW_BATTERY_MODE "low_batt_mode"
176 #define SIGNAL_NAME_FLIGHT_MODE "flight_mode"
177 #define SIGNAL_NAME_DHCP_STATUS "dhcp_status"
178 #define SIGNAL_NAME_SECURITY_TYPE_CHANGED "security_type_changed"
179 #define SIGNAL_NAME_SSID_VISIBILITY_CHANGED "ssid_visibility_changed"
180 #define SIGNAL_NAME_PASSPHRASE_CHANGED "passphrase_changed"
182 #define SIGNAL_MSG_NOT_AVAIL_INTERFACE "Interface is not available"
183 #define SIGNAL_MSG_TIMEOUT "There is no connection for a while"
184 #define SIGNAL_MSG_SSID_VISIBLE "ssid_visible"
185 #define SIGNAL_MSG_SSID_HIDE "ssid_hide"
187 /* Network Interface */
188 #define TETHERING_SUBNET_MASK "255.255.255.0"
190 #define TETHERING_USB_IF "usb0"
191 #define TETHERING_USB_GATEWAY "192.168.129.1"
193 #define TETHERING_WIFI_IF "wlan0"
194 #define TETHERING_WIFI_GATEWAY "192.168.61.1"
196 #define TETHERING_BT_IF "bnep0"
197 #define TETHERING_BT_GATEWAY "192.168.130.1"
199 * End of mobileap-agent common values
202 #define TETHERING_DEFAULT_SSID "Redwood"
203 #define TETHERING_DEFAULT_PASSPHRASE "eoiugkl!"
204 #define TETHERING_WIFI_SECURITY_TYPE_OPEN_STR "open"
205 #define TETHERING_WIFI_SECURITY_TYPE_WPA2_PSK_STR "wpa2-psk"
208 typedef void (*__handle_cb_t)(DBusGProxy *proxy, const char *name, gpointer data);
210 char name[TETHERING_SIGNAL_NAME_LEN];
215 DBusGConnection *client_bus;
216 DBusGProxy *client_bus_proxy;
218 tethering_enabled_cb enabled_cb[TETHERING_TYPE_MAX];
219 void *enabled_user_data[TETHERING_TYPE_MAX];
220 tethering_disabled_cb disabled_cb[TETHERING_TYPE_MAX];
221 void *disabled_user_data[TETHERING_TYPE_MAX];
222 tethering_connection_state_changed_cb changed_cb[TETHERING_TYPE_MAX];
223 void *changed_user_data[TETHERING_TYPE_MAX];
224 tethering_data_usage_cb data_usage_cb;
225 void *data_usage_user_data;
226 tethering_wifi_security_type_changed_cb security_type_changed_cb;
227 void *security_type_user_data;
228 tethering_wifi_ssid_visibility_changed_cb ssid_visibility_changed_cb;
229 void *ssid_visibility_user_data;
230 tethering_wifi_passphrase_changed_cb passphrase_changed_cb;
231 void *passphrase_user_data;
235 tethering_type_e interface; /**< interface type */
236 char ip[TETHERING_STR_INFO_LEN]; /**< assigned IP address */
237 char mac[TETHERING_STR_INFO_LEN]; /**< MAC Address */
238 char hostname[TETHERING_STR_HOSTNAME_LEN]; /**< alphanumeric name */
239 } __tethering_client_h;
242 tethering_type_e interface; /**< interface type */
243 char interface_name[TETHERING_STR_INFO_LEN]; /**< interface alphanumeric name */
244 char ip_address[TETHERING_STR_INFO_LEN]; /**< assigned ip addresss to interface */
245 char gateway_address[TETHERING_STR_INFO_LEN]; /**< gateway address of interface */
246 char subnet_mask[TETHERING_STR_INFO_LEN]; /**< subnet mask of interface */
247 } __tethering_interface_t;
253 #endif /* __TETHERING_PRIVATE_H__ */