static gboolean complete_connection (NMDevice *device, NMConnection *connection, const char *specific_object, const GSList *existing_connections, GError **error) { NMSettingTeam *s_team, *tmp; guint32 i = 0; char *name; const GSList *iter; gboolean found; nm_utils_complete_generic (connection, NM_SETTING_TEAM_SETTING_NAME, existing_connections, _("Team connection %d"), NULL, TRUE); s_team = nm_connection_get_setting_team (connection); if (!s_team) { s_team = (NMSettingTeam *) nm_setting_team_new (); nm_connection_add_setting (connection, NM_SETTING (s_team)); } /* Grab the first name that doesn't exist in either our connections * or a device on the system. */ while (i < 500 && !nm_setting_team_get_interface_name (s_team)) { name = g_strdup_printf ("team%u", i); /* check interface names */ if (!nm_platform_link_exists (name)) { /* check existing team connections */ for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) { NMConnection *candidate = iter->data; tmp = nm_connection_get_setting_team (candidate); if (tmp && nm_connection_is_type (candidate, NM_SETTING_TEAM_SETTING_NAME)) { if (g_strcmp0 (nm_setting_team_get_interface_name (tmp), name) == 0) { found = TRUE; break; } } } if (!found) g_object_set (G_OBJECT (s_team), NM_SETTING_TEAM_INTERFACE_NAME, name, NULL); } g_free (name); i++; } return TRUE; }
static const char * get_virtual_iface_name (NMSetting *setting) { NMSettingTeam *self = NM_SETTING_TEAM (setting); return nm_setting_team_get_interface_name (self); }
static void get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) { NMSettingTeam *setting = NM_SETTING_TEAM (object); switch (prop_id) { case PROP_INTERFACE_NAME: g_value_set_string (value, nm_setting_team_get_interface_name (setting)); break; case PROP_CONFIG: g_value_set_string (value, nm_setting_team_get_config (setting)); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { NMSettingConnection *s_con; NMSettingTeam *s_team; const char *ctype, *dev_iface_name, *team_iface_name; s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); ctype = nm_setting_connection_get_connection_type (s_con); if (strcmp (ctype, NM_SETTING_TEAM_SETTING_NAME) != 0) { g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_NOT_TEAM_CONNECTION, "The connection was not a team connection."); return FALSE; } s_team = nm_connection_get_setting_team (connection); if (!s_team) { g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INVALID_TEAM_CONNECTION, "The connection was not a valid team connection."); return FALSE; } dev_iface_name = nm_device_get_iface (device); team_iface_name = nm_setting_team_get_interface_name (s_team); if (g_strcmp0 (dev_iface_name, team_iface_name) != 0) { g_set_error (error, NM_DEVICE_TEAM_ERROR, NM_DEVICE_TEAM_ERROR_INTERFACE_MISMATCH, "The interfaces of the device and the connection didn't match."); return FALSE; } /* FIXME: check slaves? */ return NM_DEVICE_CLASS (nm_device_team_parent_class)->connection_compatible (device, connection, error); }