int __connman_counter_unregister(const char *owner, const char *path);
void __connman_counter_notify(struct connman_ipconfig *config,
- unsigned int rx_bytes, unsigned int tx_bytes);
+ unsigned int rx_packets, unsigned int tx_packets,
+ unsigned int rx_bytes, unsigned int tx_bytes,
+ unsigned int rx_error, unsigned int tx_error,
+ unsigned int rx_dropped, unsigned int tx_dropped);
int __connman_counter_add_service(struct connman_service *service);
void __connman_counter_remove_service(struct connman_service *service);
void __connman_service_remove_nameserver(struct connman_service *service,
const char *nameserver);
-unsigned long __connman_service_stats_get_tx_bytes(struct connman_service *service);
+unsigned long __connman_service_stats_get_rx_packets(struct connman_service *service);
+unsigned long __connman_service_stats_get_tx_packets(struct connman_service *service);
unsigned long __connman_service_stats_get_rx_bytes(struct connman_service *service);
+unsigned long __connman_service_stats_get_tx_bytes(struct connman_service *service);
+unsigned long __connman_service_stats_get_rx_errors(struct connman_service *service);
+unsigned long __connman_service_stats_get_tx_errors(struct connman_service *service);
+unsigned long __connman_service_stats_get_rx_dropped(struct connman_service *service);
+unsigned long __connman_service_stats_get_tx_dropped(struct connman_service *service);
unsigned long __connman_service_stats_get_time(struct connman_service *service);
void __connman_service_stats_update(struct connman_service *service,
- unsigned long rx_bytes,
- unsigned long tx_bytes);
+ unsigned int rx_packets, unsigned int tx_packets,
+ unsigned int rx_bytes, unsigned int tx_bytes,
+ unsigned int rx_error, unsigned int tx_error,
+ unsigned int rx_dropped, unsigned int tx_dropped);
#include <connman/location.h>
DBusMessage *message;
DBusMessageIter array, dict;
const char *service_path;
+ unsigned long rx_packets;
+ unsigned long tx_packets;
unsigned long rx_bytes;
unsigned long tx_bytes;
+ unsigned long rx_errors;
+ unsigned long tx_errors;
+ unsigned long rx_dropped;
+ unsigned long tx_dropped;
unsigned long time;
message = dbus_message_new_method_call(counter->owner, counter->path,
connman_dbus_dict_open(&array, &dict);
+ rx_packets = __connman_service_stats_get_rx_packets(service);
+ tx_packets = __connman_service_stats_get_tx_packets(service);
rx_bytes = __connman_service_stats_get_rx_bytes(service);
tx_bytes = __connman_service_stats_get_tx_bytes(service);
+ rx_errors = __connman_service_stats_get_rx_errors(service);
+ tx_errors = __connman_service_stats_get_tx_errors(service);
+ rx_dropped = __connman_service_stats_get_rx_dropped(service);
+ tx_dropped = __connman_service_stats_get_tx_dropped(service);
time = __connman_service_stats_get_time(service);
+ connman_dbus_dict_append_basic(&dict, "RX.Packets", DBUS_TYPE_UINT32,
+ &rx_packets);
+ connman_dbus_dict_append_basic(&dict, "TX.Packets", DBUS_TYPE_UINT32,
+ &tx_packets);
connman_dbus_dict_append_basic(&dict, "RX.Bytes", DBUS_TYPE_UINT32,
&rx_bytes);
connman_dbus_dict_append_basic(&dict, "TX.Bytes", DBUS_TYPE_UINT32,
&tx_bytes);
+ connman_dbus_dict_append_basic(&dict, "RX.Errors", DBUS_TYPE_UINT32,
+ &rx_errors);
+ connman_dbus_dict_append_basic(&dict, "TX.Errors", DBUS_TYPE_UINT32,
+ &tx_errors);
+ connman_dbus_dict_append_basic(&dict, "RX.Dropped", DBUS_TYPE_UINT32,
+ &rx_dropped);
+ connman_dbus_dict_append_basic(&dict, "TX.Dropped", DBUS_TYPE_UINT32,
+ &tx_dropped);
connman_dbus_dict_append_basic(&dict, "Time", DBUS_TYPE_UINT32,
&time);
}
void __connman_counter_notify(struct connman_ipconfig *config,
- unsigned int rx_bytes, unsigned int tx_bytes)
+ unsigned int rx_packets, unsigned int tx_packets,
+ unsigned int rx_bytes, unsigned int tx_bytes,
+ unsigned int rx_errors, unsigned int tx_errors,
+ unsigned int rx_dropped, unsigned int tx_dropped)
{
struct counter_data *data;
GHashTableIter iter;
if (data == NULL)
return;
- __connman_service_stats_update(data->service, rx_bytes, tx_bytes);
+ __connman_service_stats_update(data->service,
+ rx_packets, tx_packets,
+ rx_bytes, tx_bytes,
+ rx_errors, tx_errors,
+ rx_dropped, tx_dropped);
if (data->first_update == TRUE) {
data->first_update = FALSE;
struct connman_stats {
connman_bool_t valid;
+ unsigned int rx_packets_last;
+ unsigned int tx_packets_last;
+ unsigned int rx_packets;
+ unsigned int tx_packets;
unsigned int rx_bytes_last;
unsigned int tx_bytes_last;
unsigned int rx_bytes;
unsigned int tx_bytes;
+ unsigned int rx_errors_last;
+ unsigned int tx_errors_last;
+ unsigned int rx_errors;
+ unsigned int tx_errors;
+ unsigned int rx_dropped_last;
+ unsigned int tx_dropped_last;
+ unsigned int rx_dropped;
+ unsigned int tx_dropped;
unsigned int time_start;
unsigned int time;
GTimer *timer;
static int __connman_service_stats_load(struct connman_service *service,
GKeyFile *keyfile, const char *identifier)
{
+ service->stats.rx_packets = g_key_file_get_integer(keyfile,
+ identifier, "rx_packets", NULL);
+ service->stats.tx_packets = g_key_file_get_integer(keyfile,
+ identifier, "tx_packets", NULL);
service->stats.rx_bytes = g_key_file_get_integer(keyfile,
identifier, "rx_bytes", NULL);
service->stats.tx_bytes = g_key_file_get_integer(keyfile,
identifier, "tx_bytes", NULL);
+ service->stats.rx_errors = g_key_file_get_integer(keyfile,
+ identifier, "rx_errors", NULL);
+ service->stats.tx_errors = g_key_file_get_integer(keyfile,
+ identifier, "tx_errors", NULL);
+ service->stats.rx_dropped = g_key_file_get_integer(keyfile,
+ identifier, "rx_dropped", NULL);
+ service->stats.tx_dropped = g_key_file_get_integer(keyfile,
+ identifier, "tx_dropped", NULL);
service->stats.time = g_key_file_get_integer(keyfile,
identifier, "time", NULL);
static int __connman_service_stats_save(struct connman_service *service,
GKeyFile *keyfile, const char *identifier)
{
+ g_key_file_set_integer(keyfile, identifier, "rx_packets",
+ service->stats.rx_packets);
+ g_key_file_set_integer(keyfile, identifier, "tx_packets",
+ service->stats.tx_packets);
g_key_file_set_integer(keyfile, identifier, "rx_bytes",
service->stats.rx_bytes);
g_key_file_set_integer(keyfile, identifier, "tx_bytes",
service->stats.tx_bytes);
+ g_key_file_set_integer(keyfile, identifier, "rx_errors",
+ service->stats.rx_errors);
+ g_key_file_set_integer(keyfile, identifier, "tx_errors",
+ service->stats.tx_errors);
+ g_key_file_set_integer(keyfile, identifier, "rx_dropped",
+ service->stats.rx_dropped);
+ g_key_file_set_integer(keyfile, identifier, "tx_dropped",
+ service->stats.tx_dropped);
g_key_file_set_integer(keyfile, identifier, "time",
service->stats.time);
DBG("service %p", service);
service->stats.valid = FALSE;
+ service->stats.rx_packets = 0;
+ service->stats.tx_packets = 0;
service->stats.rx_bytes = 0;
service->stats.tx_bytes = 0;
+ service->stats.rx_errors = 0;
+ service->stats.tx_errors = 0;
+ service->stats.rx_dropped = 0;
+ service->stats.tx_dropped = 0;
service->stats.time = 0;
service->stats.time_start = 0;
g_timer_reset(service->stats.timer);
}
-unsigned long __connman_service_stats_get_tx_bytes(struct connman_service *service)
+unsigned long __connman_service_stats_get_rx_packets(struct connman_service *service)
{
- return service->stats.tx_bytes;
+ return service->stats.rx_packets;
+}
+
+unsigned long __connman_service_stats_get_tx_packets(struct connman_service *service)
+{
+ return service->stats.tx_packets;
}
unsigned long __connman_service_stats_get_rx_bytes(struct connman_service *service)
return service->stats.rx_bytes;
}
+unsigned long __connman_service_stats_get_tx_bytes(struct connman_service *service)
+{
+ return service->stats.tx_bytes;
+}
+
+unsigned long __connman_service_stats_get_rx_errors(struct connman_service *service)
+{
+ return service->stats.rx_errors;
+}
+
+unsigned long __connman_service_stats_get_tx_errors(struct connman_service *service)
+{
+ return service->stats.tx_errors;
+}
+
+unsigned long __connman_service_stats_get_rx_dropped(struct connman_service *service)
+{
+ return service->stats.rx_dropped;
+}
+
+unsigned long __connman_service_stats_get_tx_dropped(struct connman_service *service)
+{
+ return service->stats.tx_dropped;
+}
+
unsigned long __connman_service_stats_get_time(struct connman_service *service)
{
return service->stats.time;
}
void __connman_service_stats_update(struct connman_service *service,
- unsigned long rx_bytes,
- unsigned long tx_bytes)
+ unsigned int rx_packets, unsigned int tx_packets,
+ unsigned int rx_bytes, unsigned int tx_bytes,
+ unsigned int rx_errors, unsigned int tx_errors,
+ unsigned int rx_dropped, unsigned int tx_dropped)
{
unsigned int seconds;
struct connman_stats *stats = &service->stats;
return;
if (stats->valid == TRUE) {
+ stats->rx_packets +=
+ rx_packets - stats->rx_packets_last;
+ stats->tx_packets +=
+ tx_packets - stats->tx_packets_last;
stats->rx_bytes +=
rx_bytes - stats->rx_bytes_last;
stats->tx_bytes +=
tx_bytes - stats->tx_bytes_last;
+ stats->rx_errors +=
+ rx_errors - stats->rx_errors_last;
+ stats->tx_errors +=
+ tx_errors - stats->tx_errors_last;
+ stats->rx_dropped +=
+ rx_dropped - stats->rx_dropped_last;
+ stats->tx_dropped +=
+ tx_dropped - stats->tx_dropped_last;
} else {
stats->valid = TRUE;
}
+ stats->rx_packets_last = rx_packets;
+ stats->tx_packets_last = tx_packets;
stats->rx_bytes_last = rx_bytes;
stats->tx_bytes_last = tx_bytes;
+ stats->rx_errors_last = rx_errors;
+ stats->tx_errors_last = tx_errors;
+ stats->rx_dropped_last = rx_dropped;
+ stats->tx_dropped_last = tx_dropped;
seconds = g_timer_elapsed(stats->timer, NULL);
stats->time = stats->time_start + seconds;