From 2f94dba7385fd0e0ef19a06eb4a2fcf6c43d7946 Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Mon, 14 Feb 2022 19:23:28 +0100 Subject: New upstream version 1.35.91 --- src/libnm-core-impl/nm-setting-ip4-config.c | 160 +++++++++++++++++----------- 1 file changed, 97 insertions(+), 63 deletions(-) (limited to 'src/libnm-core-impl/nm-setting-ip4-config.c') diff --git a/src/libnm-core-impl/nm-setting-ip4-config.c b/src/libnm-core-impl/nm-setting-ip4-config.c index a7b3d68b..5b06739c 100644 --- a/src/libnm-core-impl/nm-setting-ip4-config.c +++ b/src/libnm-core-impl/nm-setting-ip4-config.c @@ -131,9 +131,9 @@ static gboolean verify(NMSetting *setting, NMConnection *connection, GError **error) { NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(setting); - NMSettingIPConfig * s_ip = NM_SETTING_IP_CONFIG(setting); + NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); NMSettingVerifyResult ret; - const char * method; + const char *method; ret = NM_SETTING_CLASS(nm_setting_ip4_config_parent_class)->verify(setting, connection, error); if (ret != NM_SETTING_VERIFY_SUCCESS) @@ -344,7 +344,7 @@ static GVariant * ip4_addresses_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { gs_unref_ptrarray GPtrArray *addrs = NULL; - const char * gateway; + const char *gateway; g_object_get(setting, NM_SETTING_IP_CONFIG_ADDRESSES, &addrs, NULL); gateway = nm_setting_ip_config_get_gateway(NM_SETTING_IP_CONFIG(setting)); @@ -355,8 +355,8 @@ static gboolean ip4_addresses_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) { GPtrArray *addrs; - GVariant * s_ip4; - char ** labels, *gateway = NULL; + GVariant *s_ip4; + char **labels, *gateway = NULL; int i; /* FIXME: properly handle errors */ @@ -397,8 +397,8 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) { NMSettingIPConfig *s_ip = NM_SETTING_IP_CONFIG(setting); gboolean have_labels = FALSE; - GPtrArray * labels; - GVariant * ret; + GPtrArray *labels; + GVariant *ret; int num_addrs, i; if (!_nm_connection_serialize_non_secret(flags)) @@ -407,7 +407,7 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) num_addrs = nm_setting_ip_config_get_num_addresses(s_ip); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, i); - GVariant * label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); + GVariant *label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); if (label) { have_labels = TRUE; @@ -420,7 +420,7 @@ ip4_address_labels_get(_NM_SETT_INFO_PROP_TO_DBUS_FCN_ARGS _nm_nil) labels = g_ptr_array_sized_new(num_addrs); for (i = 0; i < num_addrs; i++) { NMIPAddress *addr = nm_setting_ip_config_get_address(s_ip, i); - GVariant * label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); + GVariant *label = nm_ip_address_get_attribute(addr, NM_IP_ADDRESS_ATTRIBUTE_LABEL); g_ptr_array_add(labels, (char *) (label ? g_variant_get_string(label, NULL) : "")); } @@ -522,53 +522,6 @@ ip4_route_data_set(_NM_SETT_INFO_PROP_FROM_DBUS_FCN_ARGS _nm_nil) /*****************************************************************************/ -static void -get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) -{ - NMSettingIP4Config *s_ip4 = NM_SETTING_IP4_CONFIG(object); - - switch (prop_id) { - case PROP_DHCP_CLIENT_ID: - g_value_set_string(value, nm_setting_ip4_config_get_dhcp_client_id(s_ip4)); - break; - case PROP_DHCP_FQDN: - g_value_set_string(value, nm_setting_ip4_config_get_dhcp_fqdn(s_ip4)); - break; - case PROP_DHCP_VENDOR_CLASS_IDENTIFIER: - g_value_set_string(value, nm_setting_ip4_config_get_dhcp_vendor_class_identifier(s_ip4)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -static void -set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) -{ - NMSettingIP4ConfigPrivate *priv = NM_SETTING_IP4_CONFIG_GET_PRIVATE(object); - - switch (prop_id) { - case PROP_DHCP_CLIENT_ID: - g_free(priv->dhcp_client_id); - priv->dhcp_client_id = g_value_dup_string(value); - break; - case PROP_DHCP_FQDN: - g_free(priv->dhcp_fqdn); - priv->dhcp_fqdn = g_value_dup_string(value); - break; - case PROP_DHCP_VENDOR_CLASS_IDENTIFIER: - g_free(priv->dhcp_vendor_class_identifier); - priv->dhcp_vendor_class_identifier = g_value_dup_string(value); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec); - break; - } -} - -/*****************************************************************************/ - static void nm_setting_ip4_config_init(NMSettingIP4Config *setting) { @@ -593,15 +546,15 @@ nm_setting_ip4_config_new(void) static void nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) { - GObjectClass * object_class = G_OBJECT_CLASS(klass); - NMSettingClass * setting_class = NM_SETTING_CLASS(klass); + GObjectClass *object_class = G_OBJECT_CLASS(klass); + NMSettingClass *setting_class = NM_SETTING_CLASS(klass); NMSettingIPConfigClass *setting_ip_config_class = NM_SETTING_IP_CONFIG_CLASS(klass); GArray *properties_override = _nm_sett_info_property_override_create_array_ip_config(AF_INET); g_type_class_add_private(klass, sizeof(NMSettingIP4ConfigPrivate)); - object_class->get_property = get_property; - object_class->set_property = set_property; + object_class->get_property = _nm_setting_property_get_property_direct; + object_class->set_property = _nm_setting_property_set_property_direct; setting_class->verify = verify; @@ -996,9 +949,73 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) * property: routes * format: a comma separated list of routes * description: A list of IPv4 destination addresses, prefix length, optional IPv4 - * next hop addresses, optional route metric, optional attribute. The valid syntax is: - * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". For example - * "192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24". + * next hop addresses, optional route metric, optional attribute. The valid syntax is: + * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". For example + * "192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24". + * description-docbook: + * + * A list of IPv4 destination addresses, prefix length, optional IPv4 + * next hop addresses, optional route metric, optional attribute. The valid syntax is: + * "ip[/prefix] [next-hop] [metric] [attribute=val]...[,ip[/prefix]...]". + * For example "192.0.2.0/24 10.1.1.1 77, 198.51.100.0/24". + * + * + * Various attributes are supported: + * + * + * "cwnd" - an unsigned 32 bit integer. + * + * + * "initcwnd" - an unsigned 32 bit integer. + * + * + * "initrwnd" - an unsigned 32 bit integer. + * + * + * "lock-cwnd" - a boolean value. + * + * + * "lock-initcwnd" - a boolean value. + * + * + * "lock-initrwnd" - a boolean value. + * + * + * "lock-mtu" - a boolean value. + * + * + * "lock-window" - a boolean value. + * + * + * "mtu" - an unsigned 32 bit integer. + * + * + * "onlink" - a boolean value. + * + * + * "scope" - an unsigned 8 bit integer. IPv4 only. + * + * + * "src" - an IPv4 address. + * + * + * "table" - an unsigned 32 bit integer. The default depends on ipv4.route-table. + * + * + * "tos" - an unsigned 8 bit integer. IPv4 only. + * + * + * "type" - one of unicast, local, blackhole, + * unavailable, prohibit. The default is unicast. + * + * + * "window" - an unsigned 32 bit integer. + * + * + * + * + * For details see also `man ip-route`. + * * ---end--- */ _nm_properties_override_gobj( @@ -1030,6 +1047,23 @@ nm_setting_ip4_config_class_init(NMSettingIP4ConfigClass *klass) .compare_fcn = _nm_setting_property_compare_fcn_ignore, .from_dbus_fcn = ip4_route_data_set, )); + /* ---nmcli--- + * property: routing-rules + * format: a comma separated list of routing rules + * description: A comma separated list of routing rules for policy routing. + * description-docbook: + * + * A comma separated list of routing rules for policy routing. The format + * is based on ip rule add syntax and mostly compatible. + * One difference is that routing rules in NetworkManager always need a + * fixed priority. + * + * + * Example: priority 5 from 192.167.4.0/24 table 45 + * + * ---end--- + */ + g_object_class_install_properties(object_class, _PROPERTY_ENUMS_LAST, obj_properties); _nm_setting_class_commit(setting_class, -- cgit 1.3.0-6-gf8a5