about summary refs log tree commit diff
path: root/src/libnm-base
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnm-base')
-rw-r--r--src/libnm-base/nm-base.c30
-rw-r--r--src/libnm-base/nm-base.h22
-rw-r--r--src/libnm-base/nm-ethtool-base.c12
-rw-r--r--src/libnm-base/nm-ethtool-utils-base.h2
4 files changed, 59 insertions, 7 deletions
diff --git a/src/libnm-base/nm-base.c b/src/libnm-base/nm-base.c
index f81b285c..fa64372f 100644
--- a/src/libnm-base/nm-base.c
+++ b/src/libnm-base/nm-base.c
@@ -9,3 +9,33 @@
 NM_CACHED_QUARK_FCN("nm-crypto-error-quark", _nm_crypto_error_quark);
 
 /*****************************************************************************/
+
+char *
+nm_dhcp_iaid_to_hexstr(guint32 iaid, char buf[static NM_DHCP_IAID_TO_HEXSTR_BUF_LEN])
+{
+    iaid = htobe32(iaid);
+    return nm_utils_bin2hexstr_full(&iaid, sizeof(iaid), ':', FALSE, buf);
+}
+
+gboolean
+nm_dhcp_iaid_from_hexstr(const char *str, guint32 *out_value)
+{
+    union {
+        guint32 num;
+        guint8  bin[sizeof(guint32)];
+    } iaid;
+
+    if (!nm_utils_hexstr2bin_full(str,
+                                  TRUE,
+                                  FALSE,
+                                  FALSE,
+                                  ":",
+                                  sizeof(iaid),
+                                  iaid.bin,
+                                  sizeof(iaid),
+                                  NULL))
+        return FALSE;
+
+    NM_SET_OUT(out_value, be32toh(iaid.num));
+    return TRUE;
+}
diff --git a/src/libnm-base/nm-base.h b/src/libnm-base/nm-base.h
index ff062a18..77d2ef0a 100644
--- a/src/libnm-base/nm-base.h
+++ b/src/libnm-base/nm-base.h
@@ -393,6 +393,12 @@ typedef struct {
 
 #define NM_BOND_PORT_QUEUE_ID_DEF 0
 
+/****************************************************************************/
+
+/* ifindex generation is per-net namespace, and loopback is always the first
+ * device in the network namespace, thus any loopback device should get ifindex 1. */
+#define NM_LOOPBACK_IFINDEX 1
+
 /*****************************************************************************/
 
 /* NM_CRYPTO_ERROR is part of public API in libnm (implemented in libnm-core).
@@ -409,4 +415,20 @@ typedef struct {
 #define _NM_CRYPTO_ERROR _nm_crypto_error_quark()
 GQuark _nm_crypto_error_quark(void);
 
+typedef enum {
+    NM_DNS_IP_CONFIG_TYPE_REMOVED = -1,
+
+    NM_DNS_IP_CONFIG_TYPE_DEFAULT = 0,
+    NM_DNS_IP_CONFIG_TYPE_BEST_DEVICE,
+    NM_DNS_IP_CONFIG_TYPE_VPN,
+} NMDnsIPConfigType;
+
+/*****************************************************************************/
+
+#define NM_DHCP_IAID_TO_HEXSTR_BUF_LEN (3 * sizeof(guint32))
+
+char *nm_dhcp_iaid_to_hexstr(guint32 iaid, char buf[static NM_DHCP_IAID_TO_HEXSTR_BUF_LEN]);
+
+gboolean nm_dhcp_iaid_from_hexstr(const char *str, guint32 *out_value);
+
 #endif /* __NM_LIBNM_BASE_H__ */
diff --git a/src/libnm-base/nm-ethtool-base.c b/src/libnm-base/nm-ethtool-base.c
index a75df8a0..c31cff6f 100644
--- a/src/libnm-base/nm-ethtool-base.c
+++ b/src/libnm-base/nm-ethtool-base.c
@@ -271,12 +271,12 @@ nm_ethtool_data_get_by_optname(const char *optname)
 
     _ASSERT_data();
 
-    idx = nm_utils_array_find_binary_search(_by_name,
-                                            sizeof(_by_name[0]),
-                                            _NM_ETHTOOL_ID_NUM,
-                                            optname,
-                                            _by_name_cmp,
-                                            NULL);
+    idx = nm_array_find_bsearch(_by_name,
+                                _NM_ETHTOOL_ID_NUM,
+                                sizeof(_by_name[0]),
+                                optname,
+                                _by_name_cmp,
+                                NULL);
     return (idx < 0) ? NULL : nm_ethtool_data[_by_name[idx]];
 }
 
diff --git a/src/libnm-base/nm-ethtool-utils-base.h b/src/libnm-base/nm-ethtool-utils-base.h
index 3656ed3f..fa9c3071 100644
--- a/src/libnm-base/nm-ethtool-utils-base.h
+++ b/src/libnm-base/nm-ethtool-utils-base.h
@@ -3,7 +3,7 @@
  * Copyright (C) 2018 Red Hat, Inc.
  */
 
-#ifndef __NM_ETHTOOL_UTILS_H__ /* lgtm[cpp/duplicate-include-guard] */
+#ifndef __NM_ETHTOOL_UTILS_H__
 #define __NM_ETHTOOL_UTILS_H__
 
 G_BEGIN_DECLS