summary refs log tree commit diff
path: root/libnm-core/nm-libnm-core-intern
diff options
context:
space:
mode:
Diffstat (limited to 'libnm-core/nm-libnm-core-intern')
-rw-r--r--libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c49
-rw-r--r--libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h24
2 files changed, 73 insertions, 0 deletions
diff --git a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
index 8d2ea09c..f2c85cc6 100644
--- a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
+++ b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.c
@@ -10,6 +10,54 @@
 
 /*****************************************************************************/
 
+const char **
+nm_utils_bond_option_arp_ip_targets_split (const char *arp_ip_target)
+{
+	return nm_utils_strsplit_set_full (arp_ip_target, ",", NM_UTILS_STRSPLIT_SET_FLAGS_STRSTRIP);
+}
+
+void
+_nm_setting_bond_remove_options_miimon (NMSettingBond *s_bond)
+{
+	g_return_if_fail (NM_IS_SETTING_BOND (s_bond));
+
+	nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_MIIMON);
+	nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_UPDELAY);
+	nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_DOWNDELAY);
+}
+
+void
+_nm_setting_bond_remove_options_arp_interval (NMSettingBond *s_bond)
+{
+	g_return_if_fail (NM_IS_SETTING_BOND (s_bond));
+
+	nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_ARP_INTERVAL);
+	nm_setting_bond_remove_option (s_bond, NM_SETTING_BOND_OPTION_ARP_IP_TARGET);
+}
+
+NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
+	_nm_setting_bond_mode_from_string,
+	NMBondMode,
+	{ g_return_val_if_fail (name, NM_BOND_MODE_UNKNOWN); },
+	{ return NM_BOND_MODE_UNKNOWN; },
+	{ "0",             NM_BOND_MODE_ROUNDROBIN   },
+	{ "1",             NM_BOND_MODE_ACTIVEBACKUP },
+	{ "2",             NM_BOND_MODE_XOR          },
+	{ "3",             NM_BOND_MODE_BROADCAST    },
+	{ "4",             NM_BOND_MODE_8023AD       },
+	{ "5",             NM_BOND_MODE_TLB          },
+	{ "6",             NM_BOND_MODE_ALB          },
+	{ "802.3ad",       NM_BOND_MODE_8023AD       },
+	{ "active-backup", NM_BOND_MODE_ACTIVEBACKUP },
+	{ "balance-alb",   NM_BOND_MODE_ALB          },
+	{ "balance-rr",    NM_BOND_MODE_ROUNDROBIN   },
+	{ "balance-tlb",   NM_BOND_MODE_TLB          },
+	{ "balance-xor",   NM_BOND_MODE_XOR          },
+	{ "broadcast",     NM_BOND_MODE_BROADCAST    },
+);
+
+/*****************************************************************************/
+
 gboolean
 nm_utils_vlan_priority_map_parse_str (NMVlanPriorityMap map_type,
                                       const char *str,
@@ -207,4 +255,5 @@ NM_UTILS_ENUM2STR_DEFINE (nm_utils_route_type2str, guint8,
 	NM_UTILS_ENUM2STR (RTN_THROW, "throw"),
 	NM_UTILS_ENUM2STR (RTN_UNICAST, "unicast"),
 	NM_UTILS_ENUM2STR (RTN_UNREACHABLE, "unreachable"),
+	NM_UTILS_ENUM2STR (RTN_UNSPEC, "unspecified"),
 );
diff --git a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h
index afc214d4..bb3fa5fc 100644
--- a/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h
+++ b/libnm-core/nm-libnm-core-intern/nm-libnm-core-utils.h
@@ -5,6 +5,7 @@
 
 /****************************************************************************/
 
+#include "nm-setting-bond.h"
 #include "nm-setting-bridge.h"
 #include "nm-setting-connection.h"
 #include "nm-setting-ip-config.h"
@@ -46,6 +47,29 @@ NM_AUTO_DEFINE_FCN0 (NMWireGuardPeer *, _nm_auto_unref_wgpeer, nm_wireguard_peer
 
 /****************************************************************************/
 
+const char **nm_utils_bond_option_arp_ip_targets_split (const char *arp_ip_target);
+
+void _nm_setting_bond_remove_options_miimon (NMSettingBond *s_bond);
+void _nm_setting_bond_remove_options_arp_interval (NMSettingBond *s_bond);
+
+typedef enum {
+	NM_BOND_MODE_UNKNOWN      = -1,
+
+	/* The numeric values correspond to kernel's numbering of the modes. */
+	NM_BOND_MODE_ROUNDROBIN   = 0,
+	NM_BOND_MODE_ACTIVEBACKUP = 1,
+	NM_BOND_MODE_XOR          = 2,
+	NM_BOND_MODE_BROADCAST    = 3,
+	NM_BOND_MODE_8023AD       = 4,
+	NM_BOND_MODE_TLB          = 5,
+	NM_BOND_MODE_ALB          = 6,
+	_NM_BOND_MODE_NUM,
+} NMBondMode;
+
+NMBondMode _nm_setting_bond_mode_from_string (const char *str);
+
+/*****************************************************************************/
+
 static inline guint32
 nm_utils_vlan_priority_map_get_max_prio (NMVlanPriorityMap map, gboolean from)
 {