/**
 * nm_setting_bridge_port_get_priority:
 * @setting: the #NMSettingBridgePort
 *
 * Returns: the #NMSettingBridgePort:priority property of the setting
 *
 * Since: 0.9.8
 **/
guint16
nm_setting_bridge_port_get_priority (NMSettingBridgePort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), 0);

	return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->priority;
}
/**
 * nm_setting_bridge_port_get_hairpin_mode:
 * @setting: the #NMSettingBridgePort
 *
 * Returns: the #NMSettingBridgePort:hairpin-mode property of the setting
 *
 * Since: 0.9.8
 **/
gboolean
nm_setting_bridge_port_get_hairpin_mode (NMSettingBridgePort *setting)
{
	g_return_val_if_fail (NM_IS_SETTING_BRIDGE_PORT (setting), FALSE);

	return NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting)->hairpin_mode;
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
	NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting);

	if (priv->priority > BR_MAX_PORT_PRIORITY) {
		g_set_error (error,
		             NM_SETTING_BRIDGE_PORT_ERROR,
		             NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
		             _("'%d' is not a valid value for the property (should be <= %d)"),
		             priv->priority, BR_MAX_PORT_PRIORITY);
		g_prefix_error (error, "%s.%s: ",
		                NM_SETTING_BRIDGE_PORT_SETTING_NAME,
		                NM_SETTING_BRIDGE_PORT_PRIORITY);
		return FALSE;
	}

	if (priv->path_cost > BR_MAX_PATH_COST) {
		g_set_error (error,
		             NM_SETTING_BRIDGE_PORT_ERROR,
		             NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
		             _("'%d' is not a valid value for the property (should be <= %d)"),
		             priv->path_cost, BR_MAX_PATH_COST);
		g_prefix_error (error, "%s.%s: ",
		                NM_SETTING_BRIDGE_PORT_SETTING_NAME,
		                NM_SETTING_BRIDGE_PORT_PATH_COST);
		return FALSE;
	}

	return TRUE;
}
static void
get_property (GObject *object, guint prop_id,
              GValue *value, GParamSpec *pspec)
{
	NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (object);

	switch (prop_id) {
	case PROP_PRIORITY:
		g_value_set_uint (value, priv->priority);
		break;
	case PROP_PATH_COST:
		g_value_set_uint (value, priv->path_cost);
		break;
	case PROP_HAIRPIN_MODE:
		g_value_set_boolean (value, priv->hairpin_mode);
		break;
	default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
		break;
	}
}
static gboolean
verify (NMSetting *setting, GSList *all_settings, GError **error)
{
	NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting);

	if (priv->priority > BR_MAX_PORT_PRIORITY) {
		g_set_error (error,
		             NM_SETTING_BRIDGE_PORT_ERROR,
		             NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
		             NM_SETTING_BRIDGE_PORT_PRIORITY);
		return FALSE;
	}

	if (priv->path_cost > BR_MAX_PATH_COST) {
		g_set_error (error,
		             NM_SETTING_BRIDGE_PORT_ERROR,
		             NM_SETTING_BRIDGE_PORT_ERROR_INVALID_PROPERTY,
		             NM_SETTING_BRIDGE_PORT_PATH_COST);
		return FALSE;
	}

	return TRUE;
}
static gboolean
verify (NMSetting *setting, NMConnection *connection, GError **error)
{
	NMSettingBridgePortPrivate *priv = NM_SETTING_BRIDGE_PORT_GET_PRIVATE (setting);

	if (priv->priority > BR_MAX_PORT_PRIORITY) {
		g_set_error (error,
		             NM_CONNECTION_ERROR,
		             NM_CONNECTION_ERROR_INVALID_PROPERTY,
		             _("'%d' is not a valid value for the property (should be <= %d)"),
		             priv->priority, BR_MAX_PORT_PRIORITY);
		g_prefix_error (error, "%s.%s: ",
		                NM_SETTING_BRIDGE_PORT_SETTING_NAME,
		                NM_SETTING_BRIDGE_PORT_PRIORITY);
		return FALSE;
	}

	if (priv->path_cost > BR_MAX_PATH_COST) {
		g_set_error (error,
		             NM_CONNECTION_ERROR,
		             NM_CONNECTION_ERROR_INVALID_PROPERTY,
		             _("'%d' is not a valid value for the property (should be <= %d)"),
		             priv->path_cost, BR_MAX_PATH_COST);
		g_prefix_error (error, "%s.%s: ",
		                NM_SETTING_BRIDGE_PORT_SETTING_NAME,
		                NM_SETTING_BRIDGE_PORT_PATH_COST);
		return FALSE;
	}


	if (connection) {
		NMSettingConnection *s_con;
		const char *slave_type;

		s_con = nm_connection_get_setting_connection (connection);
		if (!s_con) {
			g_set_error (error,
			             NM_CONNECTION_ERROR,
			             NM_CONNECTION_ERROR_MISSING_SETTING,
			             _("missing setting"));
			g_prefix_error (error, "%s: ", NM_SETTING_CONNECTION_SETTING_NAME);
			return FALSE;
		}

		slave_type = nm_setting_connection_get_slave_type (s_con);
		if (   slave_type
		    && strcmp (slave_type, NM_SETTING_BRIDGE_SETTING_NAME)) {
			g_set_error (error,
			             NM_CONNECTION_ERROR,
			             NM_CONNECTION_ERROR_INVALID_PROPERTY,
			             _("A connection with a '%s' setting must have the slave-type set to '%s'. Instead it is '%s'"),
			             NM_SETTING_BRIDGE_PORT_SETTING_NAME,
			             NM_SETTING_BRIDGE_SETTING_NAME,
			             slave_type);
			g_prefix_error (error, "%s.%s: ", NM_SETTING_CONNECTION_SETTING_NAME, NM_SETTING_CONNECTION_SLAVE_TYPE);
			return FALSE;
		}
	}

	return TRUE;
}