summaryrefslogtreecommitdiff
path: root/src/backends/NetworkManagerRedHat.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/NetworkManagerRedHat.c')
-rw-r--r--src/backends/NetworkManagerRedHat.c232
1 files changed, 0 insertions, 232 deletions
diff --git a/src/backends/NetworkManagerRedHat.c b/src/backends/NetworkManagerRedHat.c
index f29ee25c9b..a9cec5b4bb 100644
--- a/src/backends/NetworkManagerRedHat.c
+++ b/src/backends/NetworkManagerRedHat.c
@@ -252,238 +252,6 @@ void nm_system_device_add_ip6_link_address (NMDevice *dev)
nm_generic_device_add_ip6_link_address (dev);
}
-
-typedef struct RHSystemConfigData
-{
- NMIP4Config * config;
- gboolean use_dhcp;
- gboolean system_disabled;
-} RHSystemConfigData;
-
-
-/*
- * get_current_profile_name
- *
- * Retrieve the current network profile, if any
- *
- */
-static char *get_current_profile_name (void)
-{
- shvarFile * file;
- char * buf;
-
- if (!(file = svNewFile (SYSCONFDIR"/sysconfig/network")))
- return NULL;
-
- buf = svGetValue (file, "CURRENT_PROFILE");
- if (!buf)
- buf = strdup ("default");
- svCloseFile (file);
-
- return buf;
-}
-
-
-/*
- * nm_system_device_get_system_config
- *
- * Read in the config file for a device.
- *
- */
-void *nm_system_device_get_system_config (NMDevice *dev)
-{
- char * cfg_file_path = NULL;
- shvarFile * file;
- char * buf = NULL;
- RHSystemConfigData * sys_data = NULL;
- gboolean error = FALSE;
-
- g_return_val_if_fail (dev != NULL, NULL);
-
- /* Red Hat/Fedora Core systems store this information in
- * /etc/sysconfig/network-scripts/ifcfg-* where * is the interface
- * name.
- */
-
- sys_data = g_malloc0 (sizeof (RHSystemConfigData));
- sys_data->use_dhcp = TRUE;
-
- cfg_file_path = g_strdup_printf (SYSCONFDIR"/sysconfig/network-scripts/ifcfg-%s", nm_device_get_iface (dev));
- if (!cfg_file_path)
- return sys_data;
-
- if (!(file = svNewFile (cfg_file_path)))
- {
- g_free (cfg_file_path);
- return sys_data;
- }
- g_free (cfg_file_path);
-
- /* Make sure this config file is for this device */
- buf = svGetValue (file, "DEVICE");
- if (!buf || strcmp (buf, nm_device_get_iface (dev)))
- {
- free (buf);
- goto out;
- }
-
- if ((buf = svGetValue (file, "BOOTPROTO")))
- {
- if (strcasecmp (buf, "dhcp"))
- sys_data->use_dhcp = FALSE;
- free (buf);
- }
-
- if ((buf = svGetValue (file, "NM_CONTROLLED")))
- {
- nm_debug ("NM_CONTROLLED=%s", buf);
- if (!strcasecmp (buf, "no"))
- {
- nm_info ("System configuration disables device %s", nm_device_get_iface (dev));
- sys_data->system_disabled = TRUE;
- }
- free (buf);
- }
-
- sys_data->config = nm_ip4_config_new ();
-
- if (!(sys_data->use_dhcp))
- {
- if ((buf = svGetValue (file, "IPADDR")))
- {
- nm_ip4_config_set_address (sys_data->config, inet_addr (buf));
- free (buf);
- }
- else
- {
- nm_warning ("Network configuration for device '%s' was invalid (non-DHCP configuration, "
- "but no IP address specified. Will use DHCP instead.", nm_device_get_iface (dev));
- error = TRUE;
- goto out;
- }
-
- if ((buf = svGetValue (file, "GATEWAY")))
- {
- nm_ip4_config_set_gateway (sys_data->config, inet_addr (buf));
- free (buf);
- }
- else
- {
- nm_warning ("Network configuration for device '%s' was invalid (non-DHCP configuration, "
- "but no gateway specified. Will use DHCP instead.", nm_device_get_iface (dev));
- error = TRUE;
- goto out;
- }
-
- if ((buf = svGetValue (file, "NETMASK")))
- {
- nm_ip4_config_set_netmask (sys_data->config, inet_addr (buf));
- free (buf);
- }
- else
- {
- guint32 addr = nm_ip4_config_get_address (sys_data->config);
-
- /* Make a default netmask if we have an IP address */
- if (((ntohl (addr) & 0xFF000000) >> 24) <= 127)
- nm_ip4_config_set_netmask (sys_data->config, htonl (0xFF000000));
- else if (((ntohl (addr) & 0xFF000000) >> 24) <= 191)
- nm_ip4_config_set_netmask (sys_data->config, htonl (0xFFFF0000));
- else
- nm_ip4_config_set_netmask (sys_data->config, htonl (0xFFFFFF00));
- }
-
- if ((buf = svGetValue (file, "BROADCAST")))
- {
- nm_ip4_config_set_broadcast (sys_data->config, inet_addr (buf));
- free (buf);
- }
- else
- {
- guint32 broadcast = ((nm_ip4_config_get_address (sys_data->config) & nm_ip4_config_get_netmask (sys_data->config))
- | ~nm_ip4_config_get_netmask (sys_data->config));
- nm_ip4_config_set_broadcast (sys_data->config, broadcast);
- }
- }
-
- /* If we're using Static IP, grab DNS servers from the profile's config file */
- if (!sys_data->use_dhcp)
- {
- char * cur_profile_name = get_current_profile_name ();
-
- if (cur_profile_name)
- {
- char *filename = g_strdup_printf (SYSCONFDIR"/sysconfig/networking/profiles/%s/resolv.conf", cur_profile_name);
-
- nm_generic_set_ip4_config_from_resolv_conf (filename, sys_data->config);
- g_free (filename);
- g_free (cur_profile_name);
- }
- }
-
-#if 0
- nm_debug ("------ Config (%s)", nm_device_get_iface (dev));
- nm_debug (" DHCP=%d\n", sys_data->use_dhcp);
- nm_debug (" ADDR=%d\n", nm_ip4_config_get_address (sys_data->config));
- nm_debug (" GW=%d\n", nm_ip4_config_get_gateway (sys_data->config));
- nm_debug (" NM=%d\n", nm_ip4_config_get_netmask (sys_data->config));
- nm_debug ("---------------------\n");
-#endif
-
-out:
- svCloseFile (file);
-
- if (error)
- {
- sys_data->use_dhcp = TRUE;
- /* Clear out the config */
- g_object_unref (sys_data->config);
- sys_data->config = NULL;
- }
-
- return (void *)sys_data;
-}
-
-
-/*
- * nm_system_device_free_system_config
- *
- * Free stored system config data
- *
- */
-void nm_system_device_free_system_config (NMDevice *dev, void *system_config_data)
-{
- RHSystemConfigData *sys_data = (RHSystemConfigData *)system_config_data;
-
- g_return_if_fail (dev != NULL);
-
- if (!sys_data)
- return;
-
- if (sys_data->config)
- g_object_unref (sys_data->config);
-}
-
-
-/*
- * nm_system_device_get_disabled
- *
- * Return whether the distro-specific system config tells us to use
- * dhcp for this device.
- *
- */
-gboolean nm_system_device_get_disabled (NMDevice *dev)
-{
- RHSystemConfigData *sys_data;
-
- g_return_val_if_fail (dev != NULL, FALSE);
-
- if ((sys_data = nm_device_get_system_config_data (dev)))
- return sys_data->system_disabled;
-
- return FALSE;
-}
-
/*
* nm_system_activate_nis
*