modem-helpers: new helper to convert from netmask string to CIDR
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
#include <ModemManager.h>
|
#include <ModemManager.h>
|
||||||
#include <libmm-common.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) */
|
/* +CREG: <stat> (GSM 07.07 CREG=1 unsolicited) */
|
||||||
#define CREG1 "\\+(CREG|CGREG):\\s*0*([0-9])"
|
#define CREG1 "\\+(CREG|CGREG):\\s*0*([0-9])"
|
||||||
|
|
||||||
|
@@ -58,6 +58,8 @@ gchar *mm_create_device_identifier (guint vid,
|
|||||||
const gchar *model,
|
const gchar *model,
|
||||||
const gchar *manf);
|
const gchar *manf);
|
||||||
|
|
||||||
|
guint mm_netmask_to_cidr (const gchar *netmask);
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/* 3GPP specific helpers and utilities */
|
/* 3GPP specific helpers and utilities */
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
Reference in New Issue
Block a user