2014-07-24 08:53:33 -04:00
|
|
|
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
|
* Boston, MA 02110-1301 USA.
|
|
|
|
|
*
|
2017-07-21 17:55:30 +02:00
|
|
|
* Copyright 2011 - 2017 Red Hat, Inc.
|
2014-07-24 08:53:33 -04:00
|
|
|
*/
|
|
|
|
|
|
2016-02-19 14:57:48 +01:00
|
|
|
#include "nm-default.h"
|
2014-11-13 10:07:02 -05:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
#include "nm-setting-bridge.h"
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
2014-10-21 22:30:31 -04:00
|
|
|
#include "nm-connection-private.h"
|
2014-07-24 08:53:33 -04:00
|
|
|
#include "nm-utils.h"
|
|
|
|
|
#include "nm-utils-private.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* SECTION:nm-setting-bridge
|
|
|
|
|
* @short_description: Describes connection properties for bridges
|
|
|
|
|
*
|
|
|
|
|
* The #NMSettingBridge object is a #NMSetting subclass that describes properties
|
|
|
|
|
* necessary for bridging connections.
|
|
|
|
|
**/
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-03-21 16:49:55 +01:00
|
|
|
NM_GOBJECT_PROPERTIES_DEFINE (NMSettingBridge,
|
2019-01-11 08:32:54 +01:00
|
|
|
PROP_MAC_ADDRESS,
|
|
|
|
|
PROP_STP,
|
|
|
|
|
PROP_PRIORITY,
|
|
|
|
|
PROP_FORWARD_DELAY,
|
|
|
|
|
PROP_HELLO_TIME,
|
|
|
|
|
PROP_MAX_AGE,
|
|
|
|
|
PROP_AGEING_TIME,
|
|
|
|
|
PROP_GROUP_FORWARD_MASK,
|
|
|
|
|
PROP_MULTICAST_SNOOPING,
|
2019-03-15 08:53:37 +01:00
|
|
|
PROP_VLAN_FILTERING,
|
|
|
|
|
PROP_VLAN_DEFAULT_PVID,
|
2019-03-21 16:49:55 +01:00
|
|
|
PROP_VLANS,
|
2019-01-11 08:32:54 +01:00
|
|
|
);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
typedef struct {
|
2014-07-30 10:57:45 -04:00
|
|
|
char * mac_address;
|
2014-07-24 08:53:33 -04:00
|
|
|
gboolean stp;
|
|
|
|
|
guint16 priority;
|
|
|
|
|
guint16 forward_delay;
|
|
|
|
|
guint16 hello_time;
|
|
|
|
|
guint16 max_age;
|
|
|
|
|
guint32 ageing_time;
|
2017-07-21 17:55:30 +02:00
|
|
|
guint16 group_forward_mask;
|
2015-02-20 12:32:23 +01:00
|
|
|
gboolean multicast_snooping;
|
2019-03-15 08:53:37 +01:00
|
|
|
gboolean vlan_filtering;
|
|
|
|
|
guint16 vlan_default_pvid;
|
2019-03-21 16:49:55 +01:00
|
|
|
GPtrArray *vlans;
|
2014-07-24 08:53:33 -04:00
|
|
|
} NMSettingBridgePrivate;
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
G_DEFINE_TYPE (NMSettingBridge, nm_setting_bridge, NM_TYPE_SETTING)
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
#define NM_SETTING_BRIDGE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), NM_TYPE_SETTING_BRIDGE, NMSettingBridgePrivate))
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
2019-03-16 17:21:35 +01:00
|
|
|
G_DEFINE_BOXED_TYPE (NMBridgeVlan, nm_bridge_vlan, _nm_bridge_vlan_dup, nm_bridge_vlan_unref)
|
|
|
|
|
|
|
|
|
|
struct _NMBridgeVlan {
|
|
|
|
|
guint refcount;
|
|
|
|
|
guint16 vid;
|
|
|
|
|
bool untagged:1;
|
|
|
|
|
bool pvid:1;
|
|
|
|
|
bool sealed:1;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
NM_IS_BRIDGE_VLAN (const NMBridgeVlan *self, gboolean also_sealed)
|
|
|
|
|
{
|
|
|
|
|
return self
|
|
|
|
|
&& self->refcount > 0
|
|
|
|
|
&& (also_sealed || !self->sealed);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_new:
|
|
|
|
|
* @vid: the VLAN id, must be between 1 and 4094.
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMBridgeVlan object.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new #NMBridgeVlan object.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
nm_bridge_vlan_new (guint16 vid)
|
|
|
|
|
{
|
|
|
|
|
NMBridgeVlan *vlan;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (vid >= NM_BRIDGE_VLAN_VID_MIN, NULL);
|
|
|
|
|
g_return_val_if_fail (vid <= NM_BRIDGE_VLAN_VID_MAX, NULL);
|
|
|
|
|
|
|
|
|
|
vlan = g_slice_new0 (NMBridgeVlan);
|
|
|
|
|
vlan->refcount = 1;
|
|
|
|
|
vlan->vid = vid;
|
|
|
|
|
|
|
|
|
|
return vlan;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_ref:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
*
|
|
|
|
|
* Increases the reference count of the object.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the input argument @vlan object.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
nm_bridge_vlan_ref (NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), NULL);
|
|
|
|
|
|
|
|
|
|
nm_assert (vlan->refcount < G_MAXUINT);
|
|
|
|
|
|
|
|
|
|
vlan->refcount++;
|
|
|
|
|
return vlan;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_unref:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
*
|
|
|
|
|
* Decreases the reference count of the object. If the reference count
|
|
|
|
|
* reaches zero the object will be destroyed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_bridge_vlan_unref (NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE));
|
|
|
|
|
|
|
|
|
|
if (--vlan->refcount == 0)
|
|
|
|
|
g_slice_free (NMBridgeVlan, vlan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_cmp:
|
|
|
|
|
* @a: a #NMBridgeVlan
|
|
|
|
|
* @b: another #NMBridgeVlan
|
|
|
|
|
*
|
|
|
|
|
* Compare two bridge VLAN objects.
|
|
|
|
|
*
|
|
|
|
|
* Returns: zero of the two instances are equivalent or
|
|
|
|
|
* a non-zero integer otherwise. This defines a total ordering
|
|
|
|
|
* over the VLANs. Whether a VLAN is sealed or not does not
|
|
|
|
|
* affect the comparison.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
int
|
|
|
|
|
nm_bridge_vlan_cmp (const NMBridgeVlan *a, const NMBridgeVlan *b)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (a, TRUE), 0);
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (b, TRUE), 0);
|
|
|
|
|
|
|
|
|
|
NM_CMP_SELF (a, b);
|
|
|
|
|
NM_CMP_FIELD (a, b, vid);
|
|
|
|
|
NM_CMP_FIELD_BOOL (a, b, untagged);
|
|
|
|
|
NM_CMP_FIELD_BOOL (a, b, pvid);
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
_nm_bridge_vlan_dup (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), NULL);
|
|
|
|
|
|
|
|
|
|
if (vlan->sealed) {
|
|
|
|
|
nm_bridge_vlan_ref ((NMBridgeVlan *) vlan);
|
|
|
|
|
return (NMBridgeVlan *) vlan;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nm_bridge_vlan_new_clone (vlan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
_nm_bridge_vlan_dup_and_seal (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
NMBridgeVlan *new;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), NULL);
|
|
|
|
|
|
|
|
|
|
new = _nm_bridge_vlan_dup (vlan);
|
|
|
|
|
nm_bridge_vlan_seal (new);
|
|
|
|
|
|
|
|
|
|
return new;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_get_vid:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
*
|
|
|
|
|
* Gets the VLAN id of the object.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the VLAN id
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_bridge_vlan_get_vid (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), 0);
|
|
|
|
|
|
|
|
|
|
return vlan->vid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_is_untagged:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
*
|
|
|
|
|
* Returns whether the VLAN is untagged.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the VLAN is untagged, %FALSE otherwise
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_bridge_vlan_is_untagged (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), FALSE);
|
|
|
|
|
|
|
|
|
|
return vlan->untagged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_is_pvid:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
*
|
|
|
|
|
* Returns whether the VLAN is the PVID for the port.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the VLAN is the PVID
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_bridge_vlan_is_pvid (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), FALSE);
|
|
|
|
|
|
|
|
|
|
return vlan->pvid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_set_untagged:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
* @value: the new value
|
|
|
|
|
*
|
|
|
|
|
* Change the value of the untagged property of the VLAN.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_bridge_vlan_set_untagged (NMBridgeVlan *vlan, gboolean value)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_BRIDGE_VLAN (vlan, FALSE));
|
|
|
|
|
|
|
|
|
|
vlan->untagged = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_set_pvid:
|
|
|
|
|
* @vlan: the #NMBridgeVlan
|
|
|
|
|
* @value: the new value
|
|
|
|
|
*
|
|
|
|
|
* Change the value of the PVID property of the VLAN.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_bridge_vlan_set_pvid (NMBridgeVlan *vlan, gboolean value)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_BRIDGE_VLAN (vlan, FALSE));
|
|
|
|
|
|
|
|
|
|
vlan->pvid = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_is_sealed:
|
|
|
|
|
* @vlan: the #NMBridgeVlan instance
|
|
|
|
|
*
|
|
|
|
|
* Returns: whether @self is sealed or not.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_bridge_vlan_is_sealed (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), FALSE);
|
|
|
|
|
|
|
|
|
|
return vlan->sealed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_seal:
|
|
|
|
|
* @vlan: the #NMBridgeVlan instance
|
|
|
|
|
*
|
|
|
|
|
* Seal the #NMBridgeVlan instance. Afterwards, it is a bug
|
|
|
|
|
* to call all functions that modify the instance (except ref/unref).
|
|
|
|
|
* A sealed instance cannot be unsealed again, but you can create
|
|
|
|
|
* an unsealed copy with nm_bridge_vlan_new_clone().
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
nm_bridge_vlan_seal (NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE));
|
|
|
|
|
|
|
|
|
|
vlan->sealed = TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_new_clone:
|
|
|
|
|
* @vlan: the #NMBridgeVlan instance to copy
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): a clone of @vlan. This instance
|
|
|
|
|
* is always unsealed.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
*/
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
nm_bridge_vlan_new_clone (const NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
NMBridgeVlan *copy;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_BRIDGE_VLAN (vlan, TRUE), NULL);
|
|
|
|
|
|
|
|
|
|
copy = nm_bridge_vlan_new (vlan->vid);
|
|
|
|
|
copy->untagged = vlan->untagged;
|
|
|
|
|
copy->pvid = vlan->pvid;
|
|
|
|
|
|
|
|
|
|
return copy;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-19 15:35:28 +01:00
|
|
|
void
|
|
|
|
|
_nm_bridge_vlan_str_append_rest (const NMBridgeVlan *vlan,
|
|
|
|
|
GString *string,
|
|
|
|
|
gboolean leading_space)
|
|
|
|
|
{
|
|
|
|
|
if (nm_bridge_vlan_is_pvid (vlan)) {
|
|
|
|
|
if (leading_space)
|
|
|
|
|
g_string_append_c (string, ' ');
|
|
|
|
|
g_string_append (string, "pvid");
|
|
|
|
|
leading_space = TRUE;
|
|
|
|
|
}
|
|
|
|
|
if (nm_bridge_vlan_is_untagged (vlan)) {
|
|
|
|
|
if (leading_space)
|
|
|
|
|
g_string_append_c (string, ' ');
|
|
|
|
|
g_string_append (string, "untagged");
|
|
|
|
|
leading_space = TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_to_str:
|
|
|
|
|
* @vlan: the %NMBridgeVlan
|
|
|
|
|
* @error: location of the error
|
|
|
|
|
*
|
|
|
|
|
* Convert a %NMBridgeVlan to a string.
|
|
|
|
|
*
|
|
|
|
|
* Returns: formatted string or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
*/
|
|
|
|
|
char *
|
|
|
|
|
nm_bridge_vlan_to_str (const NMBridgeVlan *vlan, GError **error)
|
|
|
|
|
{
|
|
|
|
|
GString *string;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (vlan, NULL);
|
|
|
|
|
g_return_val_if_fail (!error || !*error, NULL);
|
|
|
|
|
|
|
|
|
|
/* The function never fails at the moment, but it might in the
|
|
|
|
|
* future if more parameters are added to the object that could
|
|
|
|
|
* make it invalid. */
|
|
|
|
|
|
|
|
|
|
string = g_string_sized_new (20);
|
|
|
|
|
|
|
|
|
|
g_string_append_printf (string, "%u", nm_bridge_vlan_get_vid (vlan));
|
|
|
|
|
_nm_bridge_vlan_str_append_rest (vlan, string, TRUE);
|
|
|
|
|
|
|
|
|
|
return g_string_free (string, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_bridge_vlan_from_str:
|
|
|
|
|
* @str: the string representation of a bridge VLAN
|
|
|
|
|
* @error: location of the error
|
|
|
|
|
*
|
|
|
|
|
* Parses the string representation of the queueing
|
|
|
|
|
* discipline to a %NMBridgeVlan instance.
|
|
|
|
|
*
|
|
|
|
|
* Returns: the %NMBridgeVlan or %NULL
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
*/
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
nm_bridge_vlan_from_str (const char *str, GError **error)
|
|
|
|
|
{
|
|
|
|
|
NMBridgeVlan *vlan = NULL;
|
|
|
|
|
gs_free const char **tokens = NULL;
|
|
|
|
|
guint i, vid;
|
|
|
|
|
gboolean pvid = FALSE;
|
|
|
|
|
gboolean untagged = FALSE;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (str, NULL);
|
|
|
|
|
g_return_val_if_fail (!error || !*error, NULL);
|
|
|
|
|
|
2019-04-03 15:44:19 +02:00
|
|
|
tokens = nm_utils_strsplit_set (str, " ");
|
2019-03-19 15:35:28 +01:00
|
|
|
if (!tokens || !tokens[0]) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
"missing VLAN id");
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vid = _nm_utils_ascii_str_to_uint64 (tokens[0],
|
|
|
|
|
10,
|
|
|
|
|
NM_BRIDGE_VLAN_VID_MIN,
|
|
|
|
|
NM_BRIDGE_VLAN_VID_MAX,
|
|
|
|
|
G_MAXUINT);
|
|
|
|
|
if (vid == G_MAXUINT) {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
"invalid VLAN id '%s', must be in [1,4094]", tokens[0]);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 1; tokens[i]; i++) {
|
|
|
|
|
if (nm_streq (tokens[i], "pvid"))
|
|
|
|
|
pvid = TRUE;
|
|
|
|
|
else if (nm_streq (tokens[i], "untagged"))
|
|
|
|
|
untagged = TRUE;
|
|
|
|
|
else {
|
|
|
|
|
g_set_error (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_FAILED,
|
|
|
|
|
"invalid option '%s'", tokens[i]);
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vlan = nm_bridge_vlan_new (vid);
|
|
|
|
|
nm_bridge_vlan_set_pvid (vlan, pvid);
|
|
|
|
|
nm_bridge_vlan_set_untagged (vlan, untagged);
|
|
|
|
|
|
|
|
|
|
return vlan;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-16 17:21:35 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-03-21 16:49:55 +01:00
|
|
|
static int
|
|
|
|
|
vlan_ptr_cmp (gconstpointer a, gconstpointer b)
|
|
|
|
|
{
|
|
|
|
|
const NMBridgeVlan *vlan_a = *(const NMBridgeVlan **) a;
|
|
|
|
|
const NMBridgeVlan *vlan_b = *(const NMBridgeVlan **) b;
|
|
|
|
|
|
|
|
|
|
return nm_bridge_vlan_cmp (vlan_a, vlan_b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gboolean
|
|
|
|
|
_nm_setting_bridge_sort_vlans (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
gboolean need_sort = FALSE;
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
for (i = 1; i < priv->vlans->len; i++) {
|
|
|
|
|
NMBridgeVlan *vlan_prev = priv->vlans->pdata[i - 1];
|
|
|
|
|
NMBridgeVlan *vlan = priv->vlans->pdata[i];
|
|
|
|
|
|
|
|
|
|
if (nm_bridge_vlan_cmp (vlan_prev, vlan) > 0) {
|
|
|
|
|
need_sort = TRUE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (need_sort) {
|
|
|
|
|
g_ptr_array_sort (priv->vlans, vlan_ptr_cmp);
|
|
|
|
|
_notify (setting, PROP_VLANS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return need_sort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2019-03-16 17:21:35 +01:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_mac_address:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:mac-address property of the setting
|
|
|
|
|
**/
|
2014-07-30 10:57:45 -04:00
|
|
|
const char *
|
2014-07-24 08:53:33 -04:00
|
|
|
nm_setting_bridge_get_mac_address (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), NULL);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->mac_address;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_stp:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:stp property of the setting
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bridge_get_stp (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->stp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_priority:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:priority property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_setting_bridge_get_priority (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->priority;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_forward_delay:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:forward-delay property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_setting_bridge_get_forward_delay (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->forward_delay;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_hello_time:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:hello-time property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_setting_bridge_get_hello_time (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->hello_time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_max_age:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:max-age property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_setting_bridge_get_max_age (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->max_age;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_ageing_time:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:ageing-time property of the setting
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_bridge_get_ageing_time (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->ageing_time;
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-21 17:55:30 +02:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_group_forward_mask:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:group-forward-mask property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.10
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_setting_bridge_get_group_forward_mask (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->group_forward_mask;
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-20 12:32:23 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_multicast_snooping:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:multicast-snooping property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bridge_get_multicast_snooping (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->multicast_snooping;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-15 08:53:37 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_vlan_filtering:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:vlan-filtering property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bridge_get_vlan_filtering (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->vlan_filtering;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_vlan_default_pvid:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the #NMSettingBridge:vlan-default-pvid property of the setting
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
guint16
|
|
|
|
|
nm_setting_bridge_get_vlan_default_pvid (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 1);
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_BRIDGE_GET_PRIVATE (setting)->vlan_default_pvid;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 16:49:55 +01:00
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_add_vlan:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
* @vlan: the vlan to add
|
|
|
|
|
*
|
|
|
|
|
* Appends a new vlan and associated information to the setting. The
|
|
|
|
|
* given vlan gets sealed and a reference to it is added.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_bridge_add_vlan (NMSettingBridge *setting,
|
|
|
|
|
NMBridgeVlan *vlan)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_BRIDGE (setting));
|
|
|
|
|
g_return_if_fail (vlan);
|
|
|
|
|
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
nm_bridge_vlan_seal (vlan);
|
|
|
|
|
nm_bridge_vlan_ref (vlan);
|
|
|
|
|
|
|
|
|
|
g_ptr_array_add (priv->vlans, vlan);
|
|
|
|
|
_notify (setting, PROP_VLANS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_num_vlans:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Returns: the number of VLANs
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
guint
|
|
|
|
|
nm_setting_bridge_get_num_vlans (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), 0);
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
return priv->vlans->len;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_get_vlan:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
* @idx: index number of the VLAN to return
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer none): the VLAN at index @idx
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
NMBridgeVlan *
|
|
|
|
|
nm_setting_bridge_get_vlan (NMSettingBridge *setting, guint idx)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), NULL);
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (idx < priv->vlans->len, NULL);
|
|
|
|
|
|
|
|
|
|
return priv->vlans->pdata[idx];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_remove_vlan:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
* @idx: index number of the VLAN.
|
|
|
|
|
*
|
|
|
|
|
* Removes the vlan at index @idx.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_bridge_remove_vlan (NMSettingBridge *setting, guint idx)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_BRIDGE (setting));
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (idx < priv->vlans->len);
|
|
|
|
|
|
|
|
|
|
g_ptr_array_remove_index (priv->vlans, idx);
|
|
|
|
|
_notify (setting, PROP_VLANS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_remove_vlan_by_vid:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
* @vid: the vlan index of the vlan to remove
|
|
|
|
|
*
|
|
|
|
|
* Removes the vlan vith id @vid.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the vlan was found and removed; %FALSE otherwise
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
gboolean
|
|
|
|
|
nm_setting_bridge_remove_vlan_by_vid (NMSettingBridge *setting,
|
|
|
|
|
guint16 vid)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (NM_IS_SETTING_BRIDGE (setting), FALSE);
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < priv->vlans->len; i++) {
|
|
|
|
|
if (nm_bridge_vlan_get_vid (priv->vlans->pdata[i]) == vid) {
|
|
|
|
|
g_ptr_array_remove_index (priv->vlans, i);
|
|
|
|
|
_notify (setting, PROP_VLANS);
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_clear_vlans:
|
|
|
|
|
* @setting: the #NMSettingBridge
|
|
|
|
|
*
|
|
|
|
|
* Removes all configured VLANs.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
void
|
|
|
|
|
nm_setting_bridge_clear_vlans (NMSettingBridge *setting)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv;
|
|
|
|
|
|
|
|
|
|
g_return_if_fail (NM_IS_SETTING_BRIDGE (setting));
|
|
|
|
|
priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
if (priv->vlans->len != 0) {
|
|
|
|
|
g_ptr_array_set_size (priv->vlans, 0);
|
|
|
|
|
_notify (setting, PROP_VLANS);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
2019-02-06 09:04:23 +01:00
|
|
|
static gboolean
|
2014-07-24 08:53:33 -04:00
|
|
|
check_range (guint32 val,
|
|
|
|
|
guint32 min,
|
|
|
|
|
guint32 max,
|
2014-11-10 18:48:37 +01:00
|
|
|
gboolean zero,
|
2014-07-24 08:53:33 -04:00
|
|
|
const char *prop,
|
|
|
|
|
GError **error)
|
|
|
|
|
{
|
2014-11-10 18:48:37 +01:00
|
|
|
if (zero && val == 0)
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
if (val < min || val > max) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("value '%d' is out of range <%d-%d>"),
|
|
|
|
|
val, min, max);
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, prop);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2014-10-21 22:30:31 -04:00
|
|
|
verify (NMSetting *setting, NMConnection *connection, GError **error)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
2014-07-30 10:57:45 -04:00
|
|
|
if (priv->mac_address && !nm_utils_hwaddr_valid (priv->mac_address, ETH_ALEN)) {
|
2014-07-24 08:53:33 -04:00
|
|
|
g_set_error_literal (error,
|
libnm-core: merge NMSetting*Error into NMConnectionError
Each setting type was defining its own error type, but most of them
had exactly the same three errors ("unknown", "missing property", and
"invalid property"), and none of the other values was of much use
programmatically anyway.
So, this commit merges NMSettingError, NMSettingAdslError, etc, all
into NMConnectionError. (The reason for merging into NMConnectionError
rather than NMSettingError is that we also already have
"NMSettingsError", for errors related to the settings service, so
"NMConnectionError" is a less-confusable name for settings/connection
errors than "NMSettingError".)
Also, make sure that all of the affected error messages are localized,
and (where appropriate) prefix them with the relevant property name.
Renamed error codes:
NM_SETTING_ERROR_PROPERTY_NOT_FOUND -> NM_CONNECTION_ERROR_PROPERTY_NOT_FOUND
NM_SETTING_ERROR_PROPERTY_NOT_SECRET -> NM_CONNECTION_ERROR_PROPERTY_NOT_SECRET
Remapped error codes:
NM_SETTING_*_ERROR_MISSING_PROPERTY -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_*_ERROR_INVALID_PROPERTY -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_ERROR_PROPERTY_TYPE_MISMATCH -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BLUETOOTH_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_INVALID_SETTING
NM_SETTING_BOND_ERROR_INVALID_OPTION -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_BOND_ERROR_MISSING_OPTION -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_CONNECTION_ERROR_TYPE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_CONNECTION_ERROR_SLAVE_SETTING_NOT_FOUND -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_IP4_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_IP6_CONFIG_ERROR_NOT_ALLOWED_FOR_METHOD -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_VLAN_ERROR_INVALID_PARENT -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_MISSING_802_1X_SETTING -> NM_CONNECTION_ERROR_MISSING_SETTING
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_802_1X -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_LEAP_REQUIRES_USERNAME -> NM_CONNECTION_ERROR_MISSING_PROPERTY
NM_SETTING_WIRELESS_SECURITY_ERROR_SHARED_KEY_REQUIRES_WEP -> NM_CONNECTION_ERROR_INVALID_PROPERTY
NM_SETTING_WIRELESS_ERROR_CHANNEL_REQUIRES_BAND -> NM_CONNECTION_ERROR_MISSING_PROPERTY
Dropped error codes (were previously defined but unused):
NM_SETTING_CDMA_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_CONNECTION_ERROR_IP_CONFIG_NOT_ALLOWED
NM_SETTING_GSM_ERROR_MISSING_SERIAL_SETTING
NM_SETTING_PPP_ERROR_REQUIRE_MPPE_NOT_ALLOWED
NM_SETTING_PPPOE_ERROR_MISSING_PPP_SETTING
NM_SETTING_SERIAL_ERROR_MISSING_PPP_SETTING
NM_SETTING_WIRELESS_ERROR_MISSING_SECURITY_SETTING
2014-10-20 13:52:23 -04:00
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
2014-07-24 08:53:33 -04:00
|
|
|
_("is not a valid MAC address"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_MAC_ADDRESS);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_range (priv->forward_delay,
|
2017-11-23 15:52:07 +01:00
|
|
|
NM_BR_MIN_FORWARD_DELAY,
|
|
|
|
|
NM_BR_MAX_FORWARD_DELAY,
|
2014-11-10 18:48:37 +01:00
|
|
|
!priv->stp,
|
2014-07-24 08:53:33 -04:00
|
|
|
NM_SETTING_BRIDGE_FORWARD_DELAY,
|
|
|
|
|
error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!check_range (priv->hello_time,
|
2017-11-23 15:52:07 +01:00
|
|
|
NM_BR_MIN_HELLO_TIME,
|
|
|
|
|
NM_BR_MAX_HELLO_TIME,
|
2014-11-10 18:48:37 +01:00
|
|
|
!priv->stp,
|
2014-07-24 08:53:33 -04:00
|
|
|
NM_SETTING_BRIDGE_HELLO_TIME,
|
|
|
|
|
error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!check_range (priv->max_age,
|
2017-11-23 15:52:07 +01:00
|
|
|
NM_BR_MIN_MAX_AGE,
|
|
|
|
|
NM_BR_MAX_MAX_AGE,
|
2014-11-10 18:48:37 +01:00
|
|
|
!priv->stp,
|
2014-07-24 08:53:33 -04:00
|
|
|
NM_SETTING_BRIDGE_MAX_AGE,
|
|
|
|
|
error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!check_range (priv->ageing_time,
|
2017-11-23 15:52:07 +01:00
|
|
|
NM_BR_MIN_AGEING_TIME,
|
|
|
|
|
NM_BR_MAX_AGEING_TIME,
|
2014-11-10 18:48:37 +01:00
|
|
|
!priv->stp,
|
2014-07-24 08:53:33 -04:00
|
|
|
NM_SETTING_BRIDGE_AGEING_TIME,
|
|
|
|
|
error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
2017-07-21 17:55:30 +02:00
|
|
|
if (priv->group_forward_mask & 7) {
|
|
|
|
|
g_set_error_literal (error,
|
|
|
|
|
NM_CONNECTION_ERROR,
|
|
|
|
|
NM_CONNECTION_ERROR_INVALID_PROPERTY,
|
|
|
|
|
_("the mask can't contain bits 0 (STP), 1 (MAC) or 2 (LACP)"));
|
|
|
|
|
g_prefix_error (error, "%s.%s: ", NM_SETTING_BRIDGE_SETTING_NAME, NM_SETTING_BRIDGE_GROUP_FORWARD_MASK);
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-21 16:49:55 +01:00
|
|
|
if (!_nm_connection_verify_required_interface_name (connection, error))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
if (!_nm_utils_bridge_vlan_verify_list (priv->vlans,
|
|
|
|
|
FALSE,
|
|
|
|
|
error,
|
|
|
|
|
NM_SETTING_BRIDGE_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BRIDGE_VLANS))
|
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
|
|
/* Failures from here on are NORMALIZABLE... */
|
|
|
|
|
|
|
|
|
|
if (!_nm_utils_bridge_vlan_verify_list (priv->vlans,
|
|
|
|
|
TRUE,
|
|
|
|
|
error,
|
|
|
|
|
NM_SETTING_BRIDGE_SETTING_NAME,
|
|
|
|
|
NM_SETTING_BRIDGE_VLANS))
|
|
|
|
|
return NM_SETTING_VERIFY_NORMALIZABLE;
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NMTernary
|
|
|
|
|
compare_property (const NMSettInfoSetting *sett_info,
|
|
|
|
|
guint property_idx,
|
|
|
|
|
NMSetting *setting,
|
|
|
|
|
NMSetting *other,
|
|
|
|
|
NMSettingCompareFlags flags)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv_a;
|
|
|
|
|
NMSettingBridgePrivate *priv_b;
|
|
|
|
|
guint i;
|
|
|
|
|
|
|
|
|
|
if (nm_streq (sett_info->property_infos[property_idx].name, NM_SETTING_BRIDGE_VLANS)) {
|
|
|
|
|
if (other) {
|
|
|
|
|
priv_a = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
priv_b = NM_SETTING_BRIDGE_GET_PRIVATE (other);
|
|
|
|
|
|
|
|
|
|
if (priv_a->vlans->len != priv_b->vlans->len)
|
|
|
|
|
return FALSE;
|
|
|
|
|
for (i = 0; i < priv_a->vlans->len; i++) {
|
|
|
|
|
if (nm_bridge_vlan_cmp (priv_a->vlans->pdata[i], priv_b->vlans->pdata[i]))
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NM_SETTING_CLASS (nm_setting_bridge_parent_class)->compare_property (sett_info,
|
|
|
|
|
property_idx,
|
|
|
|
|
setting,
|
|
|
|
|
other,
|
|
|
|
|
flags);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
static void
|
2019-01-11 08:32:54 +01:00
|
|
|
get_property (GObject *object, guint prop_id,
|
|
|
|
|
GValue *value, GParamSpec *pspec)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
2019-01-11 08:32:54 +01:00
|
|
|
NMSettingBridge *setting = NM_SETTING_BRIDGE (object);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_MAC_ADDRESS:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_string (value, nm_setting_bridge_get_mac_address (setting));
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_STP:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_boolean (value, priv->stp);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_PRIORITY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->priority);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_FORWARD_DELAY:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->forward_delay);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_HELLO_TIME:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->hello_time);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_MAX_AGE:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->max_age);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_AGEING_TIME:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->ageing_time);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
2017-07-21 17:55:30 +02:00
|
|
|
case PROP_GROUP_FORWARD_MASK:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_uint (value, priv->group_forward_mask);
|
2017-07-21 17:55:30 +02:00
|
|
|
break;
|
2015-02-20 12:32:23 +01:00
|
|
|
case PROP_MULTICAST_SNOOPING:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_value_set_boolean (value, priv->multicast_snooping);
|
2015-02-20 12:32:23 +01:00
|
|
|
break;
|
2019-03-15 08:53:37 +01:00
|
|
|
case PROP_VLAN_FILTERING:
|
|
|
|
|
g_value_set_boolean (value, priv->vlan_filtering);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_VLAN_DEFAULT_PVID:
|
|
|
|
|
g_value_set_uint (value, priv->vlan_default_pvid);
|
|
|
|
|
break;
|
2019-03-21 16:49:55 +01:00
|
|
|
case PROP_VLANS:
|
|
|
|
|
g_value_take_boxed (value, _nm_utils_copy_array (priv->vlans,
|
|
|
|
|
(NMUtilsCopyFunc) nm_bridge_vlan_ref,
|
|
|
|
|
(GDestroyNotify) nm_bridge_vlan_unref));
|
|
|
|
|
break;
|
2014-07-24 08:53:33 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2019-01-11 08:32:54 +01:00
|
|
|
set_property (GObject *object, guint prop_id,
|
|
|
|
|
const GValue *value, GParamSpec *pspec)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
|
case PROP_MAC_ADDRESS:
|
2019-01-11 08:32:54 +01:00
|
|
|
g_free (priv->mac_address);
|
|
|
|
|
priv->mac_address = _nm_utils_hwaddr_canonical_or_invalid (g_value_get_string (value),
|
|
|
|
|
ETH_ALEN);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_STP:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->stp = g_value_get_boolean (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_PRIORITY:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->priority = (guint16) g_value_get_uint (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_FORWARD_DELAY:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->forward_delay = (guint16) g_value_get_uint (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_HELLO_TIME:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->hello_time = (guint16) g_value_get_uint (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_MAX_AGE:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->max_age = (guint16) g_value_get_uint (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
|
|
|
|
case PROP_AGEING_TIME:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->ageing_time = g_value_get_uint (value);
|
2014-07-24 08:53:33 -04:00
|
|
|
break;
|
2017-07-21 17:55:30 +02:00
|
|
|
case PROP_GROUP_FORWARD_MASK:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->group_forward_mask = (guint16) g_value_get_uint (value);
|
2017-07-21 17:55:30 +02:00
|
|
|
break;
|
2015-02-20 12:32:23 +01:00
|
|
|
case PROP_MULTICAST_SNOOPING:
|
2019-01-11 08:32:54 +01:00
|
|
|
priv->multicast_snooping = g_value_get_boolean (value);
|
2015-02-20 12:32:23 +01:00
|
|
|
break;
|
2019-03-15 08:53:37 +01:00
|
|
|
case PROP_VLAN_FILTERING:
|
|
|
|
|
priv->vlan_filtering = g_value_get_boolean (value);
|
|
|
|
|
break;
|
|
|
|
|
case PROP_VLAN_DEFAULT_PVID:
|
|
|
|
|
priv->vlan_default_pvid = g_value_get_uint (value);
|
|
|
|
|
break;
|
2019-03-21 16:49:55 +01:00
|
|
|
case PROP_VLANS:
|
|
|
|
|
g_ptr_array_unref (priv->vlans);
|
|
|
|
|
priv->vlans = _nm_utils_copy_array (g_value_get_boxed (value),
|
|
|
|
|
(NMUtilsCopyFunc) _nm_bridge_vlan_dup_and_seal,
|
|
|
|
|
(GDestroyNotify) nm_bridge_vlan_unref);
|
|
|
|
|
break;
|
2014-07-24 08:53:33 -04:00
|
|
|
default:
|
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-11 08:32:54 +01:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
nm_setting_bridge_init (NMSettingBridge *setting)
|
|
|
|
|
{
|
2019-03-21 16:49:55 +01:00
|
|
|
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (setting);
|
|
|
|
|
|
|
|
|
|
priv->vlans = g_ptr_array_new_with_free_func ((GDestroyNotify) nm_bridge_vlan_unref);
|
2019-01-11 08:32:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* nm_setting_bridge_new:
|
|
|
|
|
*
|
|
|
|
|
* Creates a new #NMSettingBridge object with default values.
|
|
|
|
|
*
|
|
|
|
|
* Returns: (transfer full): the new empty #NMSettingBridge object
|
|
|
|
|
**/
|
|
|
|
|
NMSetting *
|
|
|
|
|
nm_setting_bridge_new (void)
|
|
|
|
|
{
|
|
|
|
|
return (NMSetting *) g_object_new (NM_TYPE_SETTING_BRIDGE, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
finalize (GObject *object)
|
|
|
|
|
{
|
|
|
|
|
NMSettingBridgePrivate *priv = NM_SETTING_BRIDGE_GET_PRIVATE (object);
|
|
|
|
|
|
|
|
|
|
g_free (priv->mac_address);
|
2019-03-21 16:49:55 +01:00
|
|
|
g_ptr_array_unref (priv->vlans);
|
2019-01-11 08:32:54 +01:00
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (nm_setting_bridge_parent_class)->finalize (object);
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
static void
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
nm_setting_bridge_class_init (NMSettingBridgeClass *klass)
|
2014-07-24 08:53:33 -04:00
|
|
|
{
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
NMSettingClass *setting_class = NM_SETTING_CLASS (klass);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
GArray *properties_override = _nm_sett_info_property_override_create_array ();
|
2014-07-24 08:53:33 -04:00
|
|
|
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
g_type_class_add_private (klass, sizeof (NMSettingBridgePrivate));
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
object_class->get_property = get_property;
|
2019-01-11 08:32:54 +01:00
|
|
|
object_class->set_property = set_property;
|
2014-07-24 08:53:33 -04:00
|
|
|
object_class->finalize = finalize;
|
|
|
|
|
|
2019-03-21 16:49:55 +01:00
|
|
|
setting_class->compare_property = compare_property;
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
setting_class->verify = verify;
|
libnm/trivial: cleanup variable names in settings' class-init functions
- Don't use @parent_class name. This local variable (and @object_class) is
the class instance up-cast to the pointer types of the parents. The point
here is not that it is the direct parent. The point is, that it's the
NMSettingClass type.
Also, it can only be used inconsistently, in face of NMSettingIP4Config,
who's parent type is NMSettingIPConfig. Clearly, inside
nm-setting-ip4-config.c we wouldn't want to use the "parent_class"
name. Consistently rename @parent_class to @setting_class.
- Also rename the pointer to the own class to @klass. "setting_class" is also the
wrong name for that, because the right name would be something like
"setting_6lowpan_class".
However, "klass" is preferred over the latter, because we commonly create new
GObject implementations by copying an existing one. Generic names like "klass"
and "self" inside a type implementation make that simpler.
- drop useless comments like
/* virtual functions */
/* Properties */
It's better to logically and visually structure the code, and avoid trival
remarks about that. They only end up being used inconsistently. If you
even need a stronger visual separator, then an 80 char /****/ line
should be preferred.
2018-07-28 10:43:21 +02:00
|
|
|
|
2014-07-24 08:53:33 -04:00
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:mac-address:
|
|
|
|
|
*
|
|
|
|
|
* If specified, the MAC address of bridge. When creating a new bridge, this
|
2017-07-25 13:15:15 +02:00
|
|
|
* MAC address will be set.
|
|
|
|
|
*
|
|
|
|
|
* If this field is left unspecified, the "ethernet.cloned-mac-address" is
|
|
|
|
|
* referred instead to generate the initial MAC address. Note that setting
|
|
|
|
|
* "ethernet.cloned-mac-address" anyway overwrites the MAC address of
|
|
|
|
|
* the bridge later while activating the bridge. Hence, this property
|
|
|
|
|
* is deprecated.
|
2017-11-22 14:01:43 +01:00
|
|
|
*
|
|
|
|
|
* Deprecated: 1.12: Use the ethernet.cloned-mac-address property instead.
|
2014-07-24 08:53:33 -04:00
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---keyfile---
|
|
|
|
|
* property: mac-address
|
2016-03-30 12:00:54 +02:00
|
|
|
* format: usual hex-digits-and-colons notation
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
* description: MAC address in traditional hex-digits-and-colons notation,
|
|
|
|
|
* or semicolon separated list of 6 decimal bytes (obsolete)
|
|
|
|
|
* example: mac-address=00:22:68:12:79:A2
|
|
|
|
|
* mac-address=0;34;104;18;121;162;
|
|
|
|
|
* ---end---
|
|
|
|
|
* ---ifcfg-rh---
|
|
|
|
|
* property: mac-address
|
2017-11-22 13:55:53 +01:00
|
|
|
* variable: BRIDGE_MACADDR(+)
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
* description: MAC address of the bridge. Note that this requires a recent
|
|
|
|
|
* kernel support, originally introduced in 3.15 upstream kernel)
|
2017-11-22 13:55:53 +01:00
|
|
|
* BRIDGE_MACADDR for bridges is an NM extension.
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MAC_ADDRESS] =
|
|
|
|
|
g_param_spec_string (NM_SETTING_BRIDGE_MAC_ADDRESS, "", "",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
|
|
|
|
|
_properties_override_add_transform (properties_override,
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MAC_ADDRESS],
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
G_VARIANT_TYPE_BYTESTRING,
|
|
|
|
|
_nm_utils_hwaddr_to_dbus,
|
|
|
|
|
_nm_utils_hwaddr_from_dbus);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:stp:
|
|
|
|
|
*
|
|
|
|
|
* Controls whether Spanning Tree Protocol (STP) is enabled for this bridge.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: stp
|
|
|
|
|
* variable: STP
|
|
|
|
|
* default: no
|
|
|
|
|
* description: Span tree protocol participation.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_STP] =
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_BRIDGE_STP, "", "",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:priority:
|
|
|
|
|
*
|
|
|
|
|
* Sets the Spanning Tree Protocol (STP) priority for this bridge. Lower
|
|
|
|
|
* values are "better"; the lowest priority bridge will be elected the root
|
|
|
|
|
* bridge.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: priority
|
|
|
|
|
* variable: BRIDGING_OPTS: priority=
|
|
|
|
|
* values: 0 - 32768
|
|
|
|
|
* default: 32768
|
|
|
|
|
* description: STP priority.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_PRIORITY] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_PRIORITY, "", "",
|
|
|
|
|
0, G_MAXUINT16, 0x8000,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:forward-delay:
|
|
|
|
|
*
|
|
|
|
|
* The Spanning Tree Protocol (STP) forwarding delay, in seconds.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: forward-delay
|
|
|
|
|
* variable: DELAY
|
|
|
|
|
* values: 2 - 30
|
|
|
|
|
* default: 15
|
|
|
|
|
* description: STP forwarding delay.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_FORWARD_DELAY] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_FORWARD_DELAY, "", "",
|
|
|
|
|
0, NM_BR_MAX_FORWARD_DELAY, 15,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:hello-time:
|
|
|
|
|
*
|
|
|
|
|
* The Spanning Tree Protocol (STP) hello time, in seconds.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: hello-time
|
|
|
|
|
* variable: BRIDGING_OPTS: hello_time=
|
|
|
|
|
* values: 1 - 10
|
|
|
|
|
* default: 2
|
|
|
|
|
* description: STP hello time.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_HELLO_TIME] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_HELLO_TIME, "", "",
|
|
|
|
|
0, NM_BR_MAX_HELLO_TIME, 2,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:max-age:
|
|
|
|
|
*
|
|
|
|
|
* The Spanning Tree Protocol (STP) maximum message age, in seconds.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: max-age
|
|
|
|
|
* variable: BRIDGING_OPTS: max_age=
|
|
|
|
|
* values: 6 - 40
|
|
|
|
|
* default: 20
|
|
|
|
|
* description: STP maximum message age.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MAX_AGE] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_MAX_AGE, "", "",
|
|
|
|
|
0, NM_BR_MAX_MAX_AGE, 20,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-07-24 08:53:33 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:ageing-time:
|
|
|
|
|
*
|
|
|
|
|
* The Ethernet MAC address aging time, in seconds.
|
|
|
|
|
**/
|
libnm, libnm-util: move settings doc generation to libnm-core
Move the settings/plugins doc generation from libnm-util to
libnm-core, since libnm-util isn't being updated for all new
properties.
With this commit, the keyfile and ifcfg-rh documentation is basically
unchanged, except that deprecated properties are now gone, and new
properties have been added, and the sections are in a different order.
(generate-plugin-docs.pl just outputs the settings in Makefile order,
and they were unsorted in libnm-util, but are sorted in libnm-core).
The settings documentation used for nm-settings.5, the D-Bus API docs,
and the nmcli help is changed a bit more at this point, and mostly for
the worse, since the libnm-core setting properties don't match up with
the D-Bus API as well as the libnm-util ones do. To be fixed...
(I also removed the "plugins docs" line in each plugin docs comment
block while moving them, since those blocks will be used for more than
just plugins soon, and it's sort of obvious anyway.)
2014-10-28 09:58:25 -04:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: ageing-time
|
|
|
|
|
* variable: BRIDGING_OPTS: ageing_time=
|
|
|
|
|
* values: 0 - 1000000
|
|
|
|
|
* default: 300
|
|
|
|
|
* description: Ethernet MAC ageing time.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_AGEING_TIME] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_AGEING_TIME, "", "",
|
|
|
|
|
NM_BR_MIN_AGEING_TIME, NM_BR_MAX_AGEING_TIME, 300,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2014-08-04 19:57:20 -04:00
|
|
|
|
2017-07-21 17:55:30 +02:00
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:group-forward-mask:
|
|
|
|
|
*
|
|
|
|
|
* A mask of group addresses to forward. Usually, group addresses in
|
|
|
|
|
* the range from 01:80:C2:00:00:00 to 01:80:C2:00:00:0F are not
|
|
|
|
|
* forwarded according to standards. This property is a mask of 16 bits,
|
2017-10-30 21:45:41 +01:00
|
|
|
* each corresponding to a group address in that range that must be
|
2017-07-21 17:55:30 +02:00
|
|
|
* forwarded. The mask can't have bits 0, 1 or 2 set because they are
|
|
|
|
|
* used for STP, MAC pause frames and LACP.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.10
|
|
|
|
|
**/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_GROUP_FORWARD_MASK] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_GROUP_FORWARD_MASK, "", "",
|
|
|
|
|
0, 0xFFFF, 0,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2017-07-21 17:55:30 +02:00
|
|
|
|
2015-02-20 12:32:23 +01:00
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:multicast-snooping:
|
|
|
|
|
*
|
|
|
|
|
* Controls whether IGMP snooping is enabled for this bridge.
|
|
|
|
|
* Note that if snooping was automatically disabled due to hash collisions,
|
|
|
|
|
* the system may refuse to enable the feature until the collisions are
|
|
|
|
|
* resolved.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.2
|
|
|
|
|
**/
|
|
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: multicast-snooping
|
|
|
|
|
* variable: BRIDGING_OPTS: multicast_snooping=
|
|
|
|
|
* values: 0 or 1
|
|
|
|
|
* default: 1
|
|
|
|
|
* description: IGMP snooping support.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-01-11 08:28:26 +01:00
|
|
|
obj_properties[PROP_MULTICAST_SNOOPING] =
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_BRIDGE_MULTICAST_SNOOPING, "", "",
|
|
|
|
|
TRUE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
2015-02-20 12:32:23 +01:00
|
|
|
|
2019-03-15 08:53:37 +01:00
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:vlan-filtering:
|
|
|
|
|
*
|
|
|
|
|
* Control whether VLAN filtering is enabled on the bridge.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: vlan-filtering
|
|
|
|
|
* variable: BRIDGING_OPTS: vlan_filtering=
|
|
|
|
|
* values: 0 or 1
|
|
|
|
|
* default: 0
|
|
|
|
|
* description: VLAN filtering support.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
|
|
|
|
obj_properties[PROP_VLAN_FILTERING] =
|
|
|
|
|
g_param_spec_boolean (NM_SETTING_BRIDGE_VLAN_FILTERING, "", "",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:vlan-default-pvid:
|
|
|
|
|
*
|
|
|
|
|
* The default PVID for the ports of the bridge, that is the VLAN id
|
|
|
|
|
* assigned to incoming untagged frames.
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
|
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: vlan-default-pvid
|
|
|
|
|
* variable: BRIDGING_OPTS: default_pvid=
|
|
|
|
|
* values: 0 - 4094
|
|
|
|
|
* default: 1
|
|
|
|
|
* description: default VLAN PVID.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
|
|
|
|
obj_properties[PROP_VLAN_DEFAULT_PVID] =
|
|
|
|
|
g_param_spec_uint (NM_SETTING_BRIDGE_VLAN_DEFAULT_PVID, "", "",
|
2019-03-16 17:21:35 +01:00
|
|
|
0, NM_BRIDGE_VLAN_VID_MAX, 1,
|
2019-03-15 08:53:37 +01:00
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
G_PARAM_CONSTRUCT |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
2019-03-21 16:49:55 +01:00
|
|
|
/**
|
|
|
|
|
* NMSettingBridge:vlans: (type GPtrArray(NMBridgeVlan))
|
|
|
|
|
*
|
|
|
|
|
* Array of bridge VLAN objects. In addition to the VLANs
|
|
|
|
|
* specified here, the bridge will also have the default-pvid
|
|
|
|
|
* VLAN configured by the bridge.vlan-default-pvid property.
|
|
|
|
|
*
|
|
|
|
|
* In nmcli the VLAN list can be specified with the following
|
|
|
|
|
* syntax:
|
|
|
|
|
*
|
|
|
|
|
* $vid [pvid] [untagged] [, $vid [pvid] [untagged]]...
|
|
|
|
|
*
|
|
|
|
|
* Since: 1.18
|
|
|
|
|
**/
|
2019-03-23 16:58:57 +01:00
|
|
|
/* ---ifcfg-rh---
|
|
|
|
|
* property: vlans
|
|
|
|
|
* variable: BRIDGE_VLANS
|
|
|
|
|
* description: List of VLANs on the bridge
|
|
|
|
|
* example: BRIDGE_VLANS="1 pvid untagged,20,40 untagged"
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
2019-03-21 16:49:55 +01:00
|
|
|
obj_properties[PROP_VLANS] =
|
|
|
|
|
g_param_spec_boxed (NM_SETTING_BRIDGE_VLANS, "", "",
|
|
|
|
|
G_TYPE_PTR_ARRAY,
|
|
|
|
|
G_PARAM_READWRITE |
|
|
|
|
|
NM_SETTING_PARAM_INFERRABLE |
|
|
|
|
|
G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
|
|
_properties_override_add_override (properties_override,
|
|
|
|
|
obj_properties[PROP_VLANS],
|
|
|
|
|
G_VARIANT_TYPE ("aa{sv}"),
|
|
|
|
|
_nm_utils_bridge_vlans_to_dbus,
|
|
|
|
|
_nm_utils_bridge_vlans_from_dbus,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2014-11-16 15:36:18 -05:00
|
|
|
/* ---dbus---
|
|
|
|
|
* property: interface-name
|
|
|
|
|
* format: string
|
|
|
|
|
* description: Deprecated in favor of connection.interface-name, but can
|
|
|
|
|
* be used for backward-compatibility with older daemons, to set the
|
|
|
|
|
* bridge's interface name.
|
|
|
|
|
* ---end---
|
|
|
|
|
*/
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
_properties_override_add_dbus_only (properties_override,
|
|
|
|
|
"interface-name",
|
|
|
|
|
G_VARIANT_TYPE_STRING,
|
|
|
|
|
_nm_setting_get_deprecated_virtual_interface_name,
|
|
|
|
|
NULL);
|
|
|
|
|
|
2019-01-11 08:28:26 +01:00
|
|
|
g_object_class_install_properties (object_class, _PROPERTY_ENUMS_LAST, obj_properties);
|
|
|
|
|
|
libnm: rework setting metadata for property handling
NMSetting internally already tracked a list of all proper GObject properties
and D-Bus-only properties.
Rework the tracking of the list, so that:
- instead of attaching the data to the GType of the setting via
g_type_set_qdata(), it is tracked in a static array indexed by
NMMetaSettingType. This allows to find the setting-data by simple
pointer arithmetic, instead of taking a look and iterating (like
g_type_set_qdata() does).
Note, that this is still thread safe, because the static table entry is
initialized in the class-init function with _nm_setting_class_commit().
And it only accessed by following a NMSettingClass instance, thus
the class constructor already ran (maybe not for all setting classes,
but for the particular one that we look up).
I think this makes initialization of the metadata simpler to
understand.
Previously, in a first phase each class would attach the metadata
to the GType as setting_property_overrides_quark(). Then during
nm_setting_class_ensure_properties() it would merge them and
set as setting_properties_quark(). Now, during the first phase,
we only incrementally build a properties_override GArray, which
we finally hand over during nm_setting_class_commit().
- sort the property infos by name and do binary search.
Also expose this meta data types as internal API in nm-setting-private.h.
While not accessed yet, it can prove beneficial, to have direct (internal)
access to these structures.
Also, rename NMSettingProperty to NMSettInfoProperty to use a distinct
naming scheme. We already have 40+ subclasses of NMSetting that are called
NMSetting*. Likewise, NMMetaSetting* is heavily used already. So, choose a
new, distinct name.
2018-07-28 15:26:03 +02:00
|
|
|
_nm_setting_class_commit_full (setting_class, NM_META_SETTING_TYPE_BRIDGE,
|
|
|
|
|
NULL, properties_override);
|
2014-07-24 08:53:33 -04:00
|
|
|
}
|