diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-31 13:54:48 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-31 15:11:29 +0200 |
commit | 529eecdb9771cbb9140af015e4a8a5fdb3df59a7 (patch) | |
tree | 9ac5c6409d2db50cdf4685dba842d1eaab707401 /src/mm-modem-helpers.c | |
parent | ab7f558a2c6376396c021d57175c6faaba57554c (diff) |
modem-helpers: new helper to convert from netmask string to CIDR
Diffstat (limited to 'src/mm-modem-helpers.c')
-rw-r--r-- | src/mm-modem-helpers.c | 12 |
1 files changed, 12 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])" |