diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-modem-helpers.c | 12 | ||||
-rw-r--r-- | src/mm-modem-helpers.h | 2 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/mm-modem-helpers.c b/src/mm-modem-helpers.c index 4c93045b..e595c45b 100644 --- a/src/mm-modem-helpers.c +++ b/src/mm-modem-helpers.c @@ -22,6 +22,7 @@ #include <string.h> #include <ctype.h> #include <stdlib.h> +#include <arpa/inet.h> #include <ModemManager.h> #include <libmm-common.h> @@ -135,6 +136,17 @@ mm_create_device_identifier (guint vid, /*****************************************************************************/ +guint +mm_netmask_to_cidr (const gchar *netmask) +{ + guint32 num = 0; + + inet_pton (AF_INET, netmask, &num); + return mm_count_bits_set (num); +} + +/*****************************************************************************/ + /* +CREG: <stat> (GSM 07.07 CREG=1 unsolicited) */ #define CREG1 "\\+(CREG|CGREG):\\s*0*([0-9])" diff --git a/src/mm-modem-helpers.h b/src/mm-modem-helpers.h index 4754e7f9..26169e97 100644 --- a/src/mm-modem-helpers.h +++ b/src/mm-modem-helpers.h @@ -58,6 +58,8 @@ gchar *mm_create_device_identifier (guint vid, const gchar *model, const gchar *manf); +guint mm_netmask_to_cidr (const gchar *netmask); + /*****************************************************************************/ /* 3GPP specific helpers and utilities */ /*****************************************************************************/ |