bool __nm_init();
-bool __nm_get_interface_name(char** iface_name);
+bool __nm_get_interface_name(char **iface_name);
connection_type_e __nm_get_connection_type();
void __nm_destroy_profile_iterator();
-bool __nm_get_gateway_address(char* gateway);
+bool __nm_get_gateway_address(char *gateway);
-void __nm_get_linux_arp_table(char* ip_addr, char* mac_addr);
+void __nm_get_linux_arp_table(char *ip_addr, char *mac_addr);
-void __nm_get_ips_mac(char* ip_addr, char* mac_addr);
+void __nm_get_ips_mac(char *ip_addr, char *mac_addr);
void __nm_update_network_type(bool isConnect);
-bool __nm_get_mac_address(char** dest_mac_addr);
+bool __nm_get_mac_address(char **dest_mac_addr);
char* __nm_get_ip_address(void);
-void __nm_get_connected_bssid(char** connect_bssid);
+void __nm_get_connected_bssid(char **connect_bssid);
bool __nm_is_network_connected();
char mobile_id[UAS_DEVICE_ID_MAX_LEN]; /**< MObile ID which is saved in DB */
char mac_addr[MAC_ADDRESS_STRING_SIZE]; /**< MAC address which is saved in DB */
char ip_addr[IP_ADDRESS_STRING_SIZE]; /**< IP address which is saved in DB */
- int absence_count; /**< How many detect ABSENCE of the target dev. */
int mobile_flag; /**< The order of the target dev. */
gboolean new_device; /**< Is newly added device ?*/
unsigned int supported_techs; /**< Operating system type of the target dev. */
/* ARP packet */
uint16_t hw_type;/**< hardware type(ARPHRD_ETHER) */
uint16_t p_type;/**< protocol type(ETH_P_IP) */
- uint8_t p_len; /**< protocol address length */
uint8_t hw_len;/**< hardware address length */
+ uint8_t p_len; /**< protocol address length */
uint16_t operation;/* ARP opcode */
uint8_t s_hwaddr[MAC_ADD_LENGTH]; /**< sender hardware address */
uint8_t s_IPaddr[IP_ADD_LENGTH]; /**< sender IP address */
int __initialize_arp_data(void);
-int __start_wifi_detection(const char* ip, const char* mac);
+int __start_wifi_detection(const char *ip, const char *mac);
-int __start_arp(const char* ip, const char* mac);
+int __start_arp(const char *ip, const char *mac);
int __init_ip_mac_count(void);
-int __start_wifi_add_device(const char* ip, const char* mac);
+int __start_wifi_add_device(const char *ip, const char *mac);
bool __is_device_exists(char *device_id);
#define AUTHOR "Samsung"
#define VERSION "0.1"
-#define DETECTION_CYCLE_DEFAULT 900 /* 15 minutes -> 15 * 60 = 900 seconds */
-#define DETECTION_PERIOD_DEFAULT 60 /* 1 minute -> 1 * 60 = 60 seconds */
+#define DETECTION_WINDOW_DEFAULT 60 /* 1 minute -> 1 * 60 = 60 seconds */
#define ABSENCE_THRESHOLD_DEFAULT 1
-static int wifi_detection_cycle = DETECTION_CYCLE_DEFAULT;
-static int wifi_detection_period = DETECTION_PERIOD_DEFAULT;
-static int wifi_detection_retries = ABSENCE_THRESHOLD_DEFAULT;
-static guint detection_cycle_timer = 0;
+static int wifi_detection_window = DETECTION_WINDOW_DEFAULT;
static bool initial_bursts = true;
static gboolean lpm_enabled = FALSE; /**< Low power mode */
g_strlcpy(wifi_info->mac_addr, sbuf, MAC_ADDRESS_STRING_SIZE);
g_strlcpy(wifi_info->ip_addr, ip_sbuf, IP_ADDRESS_STRING_SIZE);
- wifi_info->absence_count = 0;
-
if (!(UAS_PRESENCE & wifi_detection_type))
break;
continue;
}
- wifi_info->absence_count += 1;
-
- UA_WIFI_INFO("absence_count = %d", wifi_info->absence_count);
-
if ((UAS_ABSENCE & wifi_detection_type) &&
- (wifi_detection_retries <= wifi_info->absence_count) &&
(uas_cbs && uas_cbs->device_detected_cb)) {
dev_info = _wifi_plugin_util_get_dev_info_from_wifi_info(wifi_info);
if (!dev_info) {
if (uas_cbs && uas_cbs->detection_state_cb)
uas_cbs->detection_state_cb(0);
+ /* Reset detection flags */
+ wifi_detection_type = 0;
} else {
if (is_check == true) {
initial_bursts = true;
return UAS_STATUS_SUCCESS;
}
- /* Schedule detection cycle */
- if (0 < detection_cycle_timer)
- g_source_remove(detection_cycle_timer);
-
- detection_cycle_timer = g_timeout_add_seconds(
- wifi_detection_cycle, __start_wifi_scan, NULL);
-
/* Start detection */
__start_wifi_scan(NULL);
if (0 != wifi_detection_type)
goto done;
- /* Remove detection cycle timer */
- if (0 < detection_cycle_timer) {
- g_source_remove(detection_cycle_timer);
- detection_cycle_timer = 0;
- }
-
done:
FUNC_EXIT;
return UAS_STATUS_SUCCESS;
return UAS_STATUS_SUCCESS;
}
-static int set_detection_params(int detection_cycle,
- int detection_period, int detection_retries)
+static int set_detection_window(unsigned int detection_window)
{
FUNC_ENTER;
retv_if(NULL == uas_cbs, UAS_STATUS_NOT_READY);
- retv_if(detection_period > detection_cycle, UAS_STATUS_FAIL);
- retv_if(0 >= detection_retries, UAS_STATUS_FAIL);
- wifi_detection_cycle = detection_cycle;
- wifi_detection_period = detection_period;
- wifi_detection_retries = detection_retries;
+ wifi_detection_window = detection_window;
FUNC_EXIT;
return UAS_STATUS_SUCCESS;
.start_detection = start_detection,
.stop_detection = stop_detection,
.set_low_power_mode = set_low_power_mode,
- .set_detection_params = set_detection_params,
- .set_detection_threshold = set_detection_threshold
+ .set_detection_window = set_detection_window,
+ .set_detection_threshold = set_detection_threshold,
+ .scan_active_devices = NULL,
+ .cancel_active_device_scan = NULL
};
static int module_init(uas_api_t **api)
struct arping_data *arp_data;
-static int __arp_packet_make(const char* mac)
+static int __arp_packet_make(const char *mac)
{
FUNC_ENTER;
bool ret = false;
struct ether_addr* source_mac = NULL;
struct ether_addr* dest_mac = NULL;
- char* source_mac_address = NULL;
+ char *source_mac_address = NULL;
ret = __nm_get_mac_address(&source_mac_address);
/* Closing socket descriptor. */
if (-1 < arp_data->arp_id) {
if (G_IO_STATUS_NORMAL != g_io_channel_shutdown(
- arp_data->arp_sock_io, FALSE, &error)) {
+ arp_data->arp_sock_io, FALSE, &error)) {
UA_WIFI_ERR("Failure received while shutdown io channel[%d]:[%s]",
error->code, error->message);
g_error_free(error);
switch (condition) {
case G_IO_IN:
if (g_io_channel_read_chars(
- source, buffer, ARP_PACKET_SIZE, &bytes_read, NULL) == G_IO_STATUS_NORMAL) {
+ source, buffer, ARP_PACKET_SIZE, &bytes_read, NULL) == G_IO_STATUS_NORMAL) {
uint32_t target_ip = 0;
memset(&arp_recv, 0, sizeof(arp_recv));
return false;
}
-static int __init_arp(const char* mac)
+static int __init_arp(const char *mac)
{
struct ifreq net_ifr;
char error_buf[MAX_SIZE_ERROR_BUFFER];
}
if (G_IO_STATUS_NORMAL != g_io_channel_set_encoding(
- arp_data->arp_sock_io, NULL, NULL)) {
+ arp_data->arp_sock_io, NULL, NULL)) {
UA_WIFI_ERR("Failed to set encoding NULL on io channel");
close(arp_data->arp_id);
arp_data->arp_id = -1;
}
if (G_IO_STATUS_NORMAL != g_io_channel_set_flags(
- arp_data->arp_sock_io, G_IO_FLAG_NONBLOCK, NULL)) {
+ arp_data->arp_sock_io, G_IO_FLAG_NONBLOCK, NULL)) {
UA_WIFI_ERR("Failed to set flags on io channel");
close(arp_data->arp_id);
arp_data->arp_id = -1;
}
arp_data->arp_data_id = g_io_add_watch(
- arp_data->arp_sock_io, G_IO_IN, __arp_packet_receive, NULL);
+ arp_data->arp_sock_io, G_IO_IN, __arp_packet_receive, NULL);
g_io_channel_unref(arp_data->arp_sock_io);
UA_WIFI_INFO("Init arp socket success");
arp_data->arp.s_IPaddr[0], arp_data->arp.s_IPaddr[1],
arp_data->arp.s_IPaddr[2], arp_data->arp_send_ip_addr);
- if (arp_target_ip[0])
- UA_WIFI_INFO("Arp source ip: %s", arp_target_ip);
-
target_ip = inet_addr(ip_buff);
memcpy(arp_target_ip, ip_buff, strlen(ip_buff));
memcpy(arp_data->arp.t_IPaddr, &target_ip, IP_ADD_LENGTH); // target IP address
UA_WIFI_INFO("Send %d UNICAST ARP Packet", arp_data->arp_mac_count);
}
-static int __arp_make_send(const char* ip, const char* mac)
+static int __arp_make_send(const char *ip, const char *mac)
{
FUNC_ENTER;
int ret;
return UAS_STATUS_SUCCESS;
}
-int __start_arp(const char* ip, const char* mac)
+int __start_arp(const char *ip, const char *mac)
{
int ret;
return UAS_STATUS_SUCCESS;
}
-int __start_wifi_detection(const char* ip, const char* mac)
+int __start_wifi_detection(const char *ip, const char *mac)
{
int ret;
return ret;
}
-int __start_wifi_add_device(const char* ip, const char* mac)
+int __start_wifi_add_device(const char *ip, const char *mac)
{
int ret;
wifi_info = g_new0(uas_wifi_info_t, 1);
wifi_info->user_id = dev_info->user_id;
wifi_info->os = dev_info->os;
- wifi_info->absence_count = 0;
wifi_info->supported_techs = dev_info->supported_techs;
g_strlcpy(wifi_info->mobile_id, dev_info->device_id, UAS_DEVICE_ID_MAX_LEN);