Implement unmanaged mode that will prevent all devices in the
        well_known_udis set from being touched by NetworkManager


=== modified file 'ChangeLog'
--- a/ChangeLog 2008-10-07 20:42:06 +0000
+++ b/ChangeLog 2008-10-07 20:43:19 +0000
@@ -1,9 +1,23 @@
 2008-10-07  Alexander Sack  <[EMAIL PROTECTED]>
+
+       Implement unmanaged mode that will prevent all devices in the
+       well_known_udis set from being touched by NetworkManager
+
+       * system-settings/plugins/ifupdown/plugin.c
+               - (typedef struct SCPluginIfupdownPrivate): add gboolean
+                       unmanage_well_known field used to turn on/off unmanaged
+                       mode
+               - (hal_device_added_cb,hal_device_remove_cb): emit 
|unmanaged-devices-changed|
+                       signal when well_known_udis get added/removed
+               - (SCPluginIfupdown_get_unmanaged_devices): return all 
well_known_udis
+                       if we are in unmanaged mode
+
+2008-10-07  Alexander Sack  <[EMAIL PROTECTED]>
        Add support to track network devices that have a configuration
        with a matching interface.name in /etc/network/interfaces
 
        * system-settings/plugins/ifupdown/plugin.c
                - (typedef struct SCPluginIfupdownPrivate): add hash table
                        to track |well_known_udis|
                - (get_iface_for_udi): helper function to get interface.name
                        for a udi

=== modified file 'system-settings/plugins/ifupdown/plugin.c'
--- a/system-settings/plugins/ifupdown/plugin.c 2008-10-07 20:42:06 +0000
+++ b/system-settings/plugins/ifupdown/plugin.c 2008-10-07 20:43:19 +0000
@@ -47,25 +47,31 @@
 #include <sha1.h>
 
 #include <arpa/inet.h>
 
 #define IFUPDOWN_PLUGIN_NAME "ifupdown"
 #define IFUPDOWN_PLUGIN_INFO "(C) 2008 Canonical Ltd.  To report bugs please 
use the NetworkManager mailing list."
 #define IFUPDOWN_SYSTEM_HOSTNAME_FILE "/etc/hostname"
 
+/* #define ALWAYS_UNMANAGE TRUE */
+#ifndef ALWAYS_UNMANAGE
+#      define ALWAYS_UNMANAGE FALSE
+#endif
+
 typedef struct {
 
        DBusGConnection *g_connection;
        NMSystemConfigHalManager *hal_mgr;
 
        GHashTable *iface_connections;
        gchar* hostname;
 
        GHashTable *well_known_udis;
+       gboolean unmanage_well_known;
 
        gulong inotify_event_id;
        int inotify_system_hostname_wd;
 } SCPluginIfupdownPrivate;
 
 static void
 system_config_interface_init (NMSystemConfigInterface 
*system_config_interface_class);
 
@@ -217,30 +223,37 @@ hal_device_added_cb (NMSystemConfigHalMa
                return;
 
        iface_connection = nm_exported_connection_get_connection 
(exported_iface_connection);
 
        if(!iface_connection)
                return;
 
        g_hash_table_insert (priv->well_known_udis, (gpointer)udi, "nothing");
+
+       if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
+               g_signal_emit_by_name (G_OBJECT(config), 
"unmanaged-devices-changed");
 }
 
 static void
 hal_device_removed_cb (NMSystemConfigHalManager *hal_mgr,
                                   const gchar* udi,
                                   NMDeviceType devtype,
                                   NMSystemConfigInterface *config)
 {
        SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config);
 
        PLUGIN_PRINT("SCPlugin-Ifupdown",
                           "devices removed (udi: %s)", udi);
 
-       g_hash_table_remove (priv->well_known_udis, udi);
+       if(!g_hash_table_remove (priv->well_known_udis, udi))
+               return;
+
+       if (ALWAYS_UNMANAGE || priv->unmanage_well_known)
+               g_signal_emit_by_name (G_OBJECT(config), 
"unmanaged-devices-changed");
 }
 
 static void
 hal_device_added_cb2 (gpointer data,
                                  gpointer user_data)
 {
        NMSystemConfigHalManager *hal_mgr = ((gpointer*)user_data)[0];
        NMSystemConfigInterface *config = ((gpointer*)user_data)[1];
@@ -388,18 +401,30 @@ SCPluginIfupdown_get_connections (NMSyst
 /*
  * Return a list of HAL UDIs of devices which NetworkManager should not
  * manage.  Returned list will be freed by the system settings service, and
  * each element must be allocated using g_malloc() or its variants.
  */
 static GSList*
 SCPluginIfupdown_get_unmanaged_devices (NMSystemConfigInterface *config)
 {
-       // XXX implement this.
-       return NULL;
+       SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config);
+       GList *keys;
+       GSList *udis = NULL;
+
+       if (!ALWAYS_UNMANAGE && !priv->unmanage_well_known)
+               return NULL;
+
+       keys = g_hash_table_get_keys (priv->well_known_udis);
+       PLUGIN_PRINT("Ifupdown", "get unmanaged devices count: %d", 
g_list_length(keys));
+       while(keys) {
+               udis = g_slist_append(udis, g_strdup(keys->data));
+               keys = g_list_next(keys);
+       }
+       return udis;
 }
 
 
 static const char *
 get_hostname (NMSystemConfigInterface *config)
 {
        SCPluginIfupdownPrivate *priv = SC_PLUGIN_IFUPDOWN_GET_PRIVATE (config);
        return priv->hostname;



 - Alexander

_______________________________________________
NetworkManager-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/networkmanager-list

Reply via email to