static gboolean connection_compatible (NMDevice *device, NMConnection *connection, GError **error) { NMSettingConnection *s_con; NMSettingOlpcMesh *s_olpc_mesh; const char *ctype; 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_OLPC_MESH_SETTING_NAME) != 0) { g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_NOT_OLPC_MESH_CONNECTION, "The connection was not a Olpc Mesh connection."); return FALSE; } s_olpc_mesh = nm_connection_get_setting_olpc_mesh (connection); if (!s_olpc_mesh) { g_set_error (error, NM_DEVICE_OLPC_MESH_ERROR, NM_DEVICE_OLPC_MESH_ERROR_INVALID_OLPC_MESH_CONNECTION, "The connection was not a valid Olpc Mesh connection."); return FALSE; } return NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->connection_compatible (device, connection, error); }
static NMActStageReturn act_stage2_config (NMDevice *device, NMDeviceStateReason *reason) { NMDeviceOlpcMesh *self = NM_DEVICE_OLPC_MESH (device); NMConnection *connection; NMSettingOlpcMesh *s_mesh; guint32 channel; GBytes *ssid; const char *anycast_addr; connection = nm_device_get_connection (device); g_assert (connection); s_mesh = nm_connection_get_setting_olpc_mesh (connection); g_assert (s_mesh); channel = nm_setting_olpc_mesh_get_channel (s_mesh); if (channel != 0) _mesh_set_channel (self, channel); ssid = nm_setting_olpc_mesh_get_ssid (s_mesh); nm_platform_mesh_set_ssid (nm_device_get_ifindex (device), g_bytes_get_data (ssid, NULL), g_bytes_get_size (ssid)); anycast_addr = nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh); nm_device_set_dhcp_anycast_address (device, anycast_addr); return NM_ACT_STAGE_RETURN_SUCCESS; }
static gboolean check_connection_compatible (NMDevice *device, NMConnection *connection) { NMSettingConnection *s_con; NMSettingOlpcMesh *s_mesh; if (!NM_DEVICE_CLASS (nm_device_olpc_mesh_parent_class)->check_connection_compatible (device, connection)) return FALSE; s_con = nm_connection_get_setting_connection (connection); g_assert (s_con); if (strcmp (nm_setting_connection_get_connection_type (s_con), NM_SETTING_OLPC_MESH_SETTING_NAME)) return FALSE; s_mesh = nm_connection_get_setting_olpc_mesh (connection); if (!s_mesh) return FALSE; return TRUE; }
static gboolean complete_connection (NMDevice *device, NMConnection *connection, const char *specific_object, const GSList *existing_connections, GError **error) { NMSettingOlpcMesh *s_mesh; GByteArray *tmp; s_mesh = nm_connection_get_setting_olpc_mesh (connection); if (!s_mesh) { s_mesh = (NMSettingOlpcMesh *) nm_setting_olpc_mesh_new (); nm_connection_add_setting (connection, NM_SETTING (s_mesh)); } if (!nm_setting_olpc_mesh_get_ssid (s_mesh)) { tmp = g_byte_array_sized_new (strlen (DEFAULT_SSID)); g_byte_array_append (tmp, (const guint8 *) DEFAULT_SSID, strlen (DEFAULT_SSID)); g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_SSID, tmp, NULL); g_byte_array_free (tmp, TRUE); } if (!nm_setting_olpc_mesh_get_dhcp_anycast_address (s_mesh)) { const char *anycast = "c0:27:c0:27:c0:27"; g_object_set (G_OBJECT (s_mesh), NM_SETTING_OLPC_MESH_DHCP_ANYCAST_ADDRESS, anycast, NULL); } nm_utils_complete_generic (connection, NM_SETTING_OLPC_MESH_SETTING_NAME, existing_connections, NULL, _("Mesh"), NULL, FALSE); /* No IPv6 by default */ return TRUE; }