return MOBILE_AP_ERROR_INVALID_PARAM;
}
- int fd = -1;
- char cmd[MAX_BUF_SIZE] = {0, };
-
- fd = open(IP_FORWARD, O_WRONLY);
- if (fd < 0) {
- ERR("open failed\n");
- return MOBILE_AP_ERROR_RESOURCE;
- }
-
- if (write(fd, "1", 1) != 1) {
- ERR("write failed\n");
- close(fd);
- return MOBILE_AP_ERROR_INTERNAL;
- }
- close(fd);
-
- snprintf(cmd, sizeof(cmd), "%s -t nat -A POSTROUTING "MASQUERADE_RULE,
- IPTABLES, ext_if);
- if (_execute_command(cmd)) {
- ERR("iptables failed : %s\n", cmd);
- return MOBILE_AP_ERROR_INTERNAL;
- }
-
- _add_data_usage_rule(WIFI_IF, ext_if);
- _add_data_usage_rule(BT_IF_ALL, ext_if);
- _add_data_usage_rule(USB_IF, ext_if);
+ _add_data_usage_rule(TETHER_IF, ext_if);
return MOBILE_AP_ERROR_NONE;
}
return MOBILE_AP_ERROR_INVALID_PARAM;
}
- int fd = -1;
- char cmd[MAX_BUF_SIZE] = {0, };
-
- fd = open(IP_FORWARD, O_WRONLY);
- if (fd < 0) {
- ERR("open failed\n");
- return MOBILE_AP_ERROR_RESOURCE;
- }
-
- if (write(fd, "0", 1) != 1) {
- ERR("write failed\n");
- close(fd);
- return MOBILE_AP_ERROR_INTERNAL;
- }
- close(fd);
-
- snprintf(cmd, sizeof(cmd), "%s -t nat -D POSTROUTING "MASQUERADE_RULE,
- IPTABLES, ext_if);
- if (_execute_command(cmd)) {
- ERR("iptables failed : %s\n", cmd);
- return MOBILE_AP_ERROR_INTERNAL;
- }
-
- _del_data_usage_rule(WIFI_IF, ext_if);
- _del_data_usage_rule(BT_IF_ALL, ext_if);
- _del_data_usage_rule(USB_IF, ext_if);
+ _del_data_usage_rule(TETHER_IF, ext_if);
return MOBILE_AP_ERROR_NONE;
}
DBusGMethodInvocation *context)
{
char *if_name = NULL;
- unsigned long long wifi_tx_bytes = 0;
- unsigned long long wifi_rx_bytes = 0;
- unsigned long long bt_tx_bytes = 0;
- unsigned long long bt_rx_bytes = 0;
- unsigned long long usb_tx_bytes = 0;
- unsigned long long usb_rx_bytes = 0;
unsigned long long tx_bytes = 0;
unsigned long long rx_bytes = 0;
return FALSE;
}
- if (_mobileap_is_enabled(MOBILE_AP_STATE_WIFI))
- _get_data_usage(WIFI_IF, if_name,
- &wifi_tx_bytes, &wifi_rx_bytes);
-
- if (_mobileap_is_enabled(MOBILE_AP_STATE_BT))
- _get_data_usage(BT_IF_ALL, if_name,
- &bt_tx_bytes, &bt_rx_bytes);
-
- if (_mobileap_is_enabled(MOBILE_AP_STATE_USB))
- _get_data_usage(USB_IF, if_name,
- &usb_tx_bytes, &usb_rx_bytes);
+ if (!_mobileap_is_disabled())
+ _get_data_usage(TETHER_IF, if_name,
+ &tx_bytes, &rx_bytes);
free(if_name);
- tx_bytes = wifi_tx_bytes + bt_tx_bytes + usb_tx_bytes;
- rx_bytes = wifi_rx_bytes + bt_rx_bytes + usb_rx_bytes;
-
dbus_g_method_return(context, MOBILE_AP_GET_DATA_PACKET_USAGE_CFM,
tx_bytes, rx_bytes);