summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2019-03-05 10:17:25 +0100
committerAleksander Morgado <aleksander@gnu.org>2019-03-29 10:07:29 +0000
commit0944e592522f932ec72f0e88837252c39bd4df98 (patch)
treeda89013f8f9f11b108d6cb9e955c45a68fb766ab
parent7330f6d5812df26c0518e04eccd3092833c6e4f3 (diff)
downloadModemManager-0944e592522f932ec72f0e88837252c39bd4df98.tar.gz
ublox: parse +UGCNTRD stats as unsigned 64bit values
[1551646332.583651] (ttyACM2): --> 'AT+UGCNTRD<CR>' [1551646332.626567] (ttyACM2): <-- '<CR><LF>+UGCNTRD: 1,0,0,0,0<CR><LF><CR><LF>+UGCNTRD: 2,1397316870,113728263578,1397316870,113728263578<CR><LF><CR><LF>OK<CR><LF>' [1551646332.627120] Reloading stats failed: Couldn't load primary PDP context 2 statistics: Error parsing session RX bytes
-rw-r--r--plugins/ublox/mm-broadband-bearer-ublox.c5
-rw-r--r--plugins/ublox/mm-modem-helpers-ublox.c24
-rw-r--r--plugins/ublox/mm-modem-helpers-ublox.h8
-rw-r--r--plugins/ublox/tests/test-modem-helpers-ublox.c24
4 files changed, 34 insertions, 27 deletions
diff --git a/plugins/ublox/mm-broadband-bearer-ublox.c b/plugins/ublox/mm-broadband-bearer-ublox.c
index 78e9e0534..40dab597e 100644
--- a/plugins/ublox/mm-broadband-bearer-ublox.c
+++ b/plugins/ublox/mm-broadband-bearer-ublox.c
@@ -748,8 +748,8 @@ ugcntrd_ready (MMBaseModem *modem,
MMBroadbandBearerUblox *self;
const gchar *response;
GError *error = NULL;
- guint tx_bytes = 0;
- guint rx_bytes = 0;
+ guint64 tx_bytes = 0;
+ guint64 rx_bytes = 0;
guint cid;
self = MM_BROADBAND_BEARER_UBLOX (g_task_get_source_object (task));
@@ -775,7 +775,6 @@ ugcntrd_ready (MMBaseModem *modem,
result->bytes_tx = tx_bytes;
g_task_return_pointer (task, result, g_free);
}
-
g_object_unref (task);
}
diff --git a/plugins/ublox/mm-modem-helpers-ublox.c b/plugins/ublox/mm-modem-helpers-ublox.c
index f6bd1c773..847a1676f 100644
--- a/plugins/ublox/mm-modem-helpers-ublox.c
+++ b/plugins/ublox/mm-modem-helpers-ublox.c
@@ -1958,19 +1958,19 @@ out:
gboolean
mm_ublox_parse_ugcntrd_response_for_cid (const gchar *response,
guint in_cid,
- guint *out_session_tx_bytes,
- guint *out_session_rx_bytes,
- guint *out_total_tx_bytes,
- guint *out_total_rx_bytes,
+ guint64 *out_session_tx_bytes,
+ guint64 *out_session_rx_bytes,
+ guint64 *out_total_tx_bytes,
+ guint64 *out_total_rx_bytes,
GError **error)
{
GRegex *r;
GMatchInfo *match_info = NULL;
GError *inner_error = NULL;
- guint session_tx_bytes = 0;
- guint session_rx_bytes = 0;
- guint total_tx_bytes = 0;
- guint total_rx_bytes = 0;
+ guint64 session_tx_bytes = 0;
+ guint64 session_rx_bytes = 0;
+ guint64 total_tx_bytes = 0;
+ guint64 total_rx_bytes = 0;
gboolean matched = FALSE;
/* Response may be e.g.:
@@ -1997,22 +1997,22 @@ mm_ublox_parse_ugcntrd_response_for_cid (const gchar *response,
continue;
}
- if (out_session_tx_bytes && !mm_get_uint_from_match_info (match_info, 2, &session_tx_bytes)) {
+ if (out_session_tx_bytes && !mm_get_u64_from_match_info (match_info, 2, &session_tx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing session TX bytes");
goto out;
}
- if (out_session_rx_bytes && !mm_get_uint_from_match_info (match_info, 3, &session_rx_bytes)) {
+ if (out_session_rx_bytes && !mm_get_u64_from_match_info (match_info, 3, &session_rx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing session RX bytes");
goto out;
}
- if (out_total_tx_bytes && !mm_get_uint_from_match_info (match_info, 4, &total_tx_bytes)) {
+ if (out_total_tx_bytes && !mm_get_u64_from_match_info (match_info, 4, &total_tx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing total TX bytes");
goto out;
}
- if (out_total_rx_bytes && !mm_get_uint_from_match_info (match_info, 5, &total_rx_bytes)) {
+ if (out_total_rx_bytes && !mm_get_u64_from_match_info (match_info, 5, &total_rx_bytes)) {
inner_error = g_error_new (MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Error parsing total RX bytes");
goto out;
}
diff --git a/plugins/ublox/mm-modem-helpers-ublox.h b/plugins/ublox/mm-modem-helpers-ublox.h
index cdbddd0ed..121a9839d 100644
--- a/plugins/ublox/mm-modem-helpers-ublox.h
+++ b/plugins/ublox/mm-modem-helpers-ublox.h
@@ -197,10 +197,10 @@ MMUbloxBearerAllowedAuth mm_ublox_parse_uauthreq_test (const char *response,
gboolean mm_ublox_parse_ugcntrd_response_for_cid (const gchar *response,
guint in_cid,
- guint *session_tx_bytes,
- guint *session_rx_bytes,
- guint *total_tx_bytes,
- guint *total_rx_bytes,
+ guint64 *session_tx_bytes,
+ guint64 *session_rx_bytes,
+ guint64 *total_tx_bytes,
+ guint64 *total_rx_bytes,
GError **error);
#endif /* MM_MODEM_HELPERS_UBLOX_H */
diff --git a/plugins/ublox/tests/test-modem-helpers-ublox.c b/plugins/ublox/tests/test-modem-helpers-ublox.c
index 10f718ae3..e0a7d9a86 100644
--- a/plugins/ublox/tests/test-modem-helpers-ublox.c
+++ b/plugins/ublox/tests/test-modem-helpers-ublox.c
@@ -909,10 +909,10 @@ test_uauthreq_less_fields (void)
typedef struct {
const gchar *str;
guint cid;
- guint session_tx_bytes;
- guint session_rx_bytes;
- guint total_tx_bytes;
- guint total_rx_bytes;
+ guint64 session_tx_bytes;
+ guint64 session_rx_bytes;
+ guint64 total_tx_bytes;
+ guint64 total_rx_bytes;
} UgcntrdResponseTest;
static const UgcntrdResponseTest ugcntrd_response_tests[] = {
@@ -949,6 +949,14 @@ static const UgcntrdResponseTest ugcntrd_response_tests[] = {
.session_rx_bytes = 1819,
.total_tx_bytes = 2724,
.total_rx_bytes = 1839
+ },
+ {
+ .str = "+UGCNTRD: 2,1397316870,113728263578,1397316870,113728263578\r\n",
+ .cid = 2,
+ .session_tx_bytes = 1397316870ULL,
+ .session_rx_bytes = 113728263578ULL,
+ .total_tx_bytes = 1397316870ULL,
+ .total_rx_bytes = 113728263578ULL
}
};
@@ -960,10 +968,10 @@ test_ugcntrd_response (void)
for (i = 0; i < G_N_ELEMENTS (ugcntrd_response_tests); i++) {
GError *error = NULL;
gboolean success;
- guint session_tx_bytes = G_MAXUINT;
- guint session_rx_bytes = G_MAXUINT;
- guint total_tx_bytes = G_MAXUINT;
- guint total_rx_bytes = G_MAXUINT;
+ guint64 session_tx_bytes = 0;
+ guint64 session_rx_bytes = 0;
+ guint64 total_tx_bytes = 0;
+ guint64 total_rx_bytes = 0;
success = mm_ublox_parse_ugcntrd_response_for_cid (ugcntrd_response_tests[i].str,
ugcntrd_response_tests[i].cid,