mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-04 10:40:58 +01:00
2006-05-25 Robert Love <rml@novell.com>
* src/nm-device.h: Introduce nm_ioctl_info(), which defines to nm_info() if IOCTL_DEBUG is set and a no-op if not. We can use this instead of dumping ifdef's throughout the code. * src/NetworkManagerSystem.c, src/nm-device-802-11-wireless.c, src/nm-device-802-3-ethernet.c, src/nm-device.c: Remove ifdef's and use nm_ioctl_info() in lieu. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@1768 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
parent
61dae6e438
commit
33aec50e50
6 changed files with 66 additions and 91 deletions
|
|
@ -1,3 +1,12 @@
|
|||
2006-05-25 Robert Love <rml@novell.com>
|
||||
|
||||
* src/nm-device.h: Introduce nm_ioctl_info(), which defines to
|
||||
nm_info() if IOCTL_DEBUG is set and a no-op if not. We can use this
|
||||
instead of dumping ifdef's throughout the code.
|
||||
* src/NetworkManagerSystem.c, src/nm-device-802-11-wireless.c,
|
||||
src/nm-device-802-3-ethernet.c, src/nm-device.c: Remove ifdef's and
|
||||
use nm_ioctl_info() in lieu.
|
||||
|
||||
2006-05-25 Robert Love <rml@novell.com>
|
||||
|
||||
Patch Valentine Sinitsyn <e_val@inbox.ru> to fix GNOME bug #342400:
|
||||
|
|
|
|||
|
|
@ -99,13 +99,9 @@ static gboolean nm_system_device_set_ip4_route (NMDevice *dev, int ip4_gateway,
|
|||
rtent.rt_mtu = mss;
|
||||
}
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
|
||||
err = ioctl (nm_dev_sock_get_fd (sk), SIOCADDRT, &rtent);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to CADDRT\n", nm_device_get_iface (dev));
|
||||
|
||||
if (err == -1)
|
||||
{
|
||||
|
|
@ -132,23 +128,15 @@ static gboolean nm_system_device_set_ip4_route (NMDevice *dev, int ip4_gateway,
|
|||
rtent2.rt_mtu = mss;
|
||||
}
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
|
||||
err = ioctl (nm_dev_sock_get_fd (sk), SIOCADDRT, &rtent2);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to CADDRT (2)\n", nm_device_get_iface (dev));
|
||||
|
||||
if (!err)
|
||||
{
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to CADDRT (3)\n", nm_device_get_iface (dev));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to CADDRT (3)\n", nm_device_get_iface (dev));
|
||||
err = ioctl (nm_dev_sock_get_fd (sk), SIOCADDRT, &rtent);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to CADDRT (3)\n", nm_device_get_iface (dev));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to CADDRT (3)\n", nm_device_get_iface (dev));
|
||||
|
||||
if (!err)
|
||||
success = TRUE;
|
||||
|
|
|
|||
|
|
@ -235,13 +235,11 @@ nm_device_802_11_wireless_update_signal_strength (NMDevice80211Wireless *self)
|
|||
|
||||
memset (&range, 0, sizeof (iwrange));
|
||||
memset (&stats, 0, sizeof (iwstats));
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'iwrange'.", iface);
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to GET 'iwrange'.", iface);
|
||||
has_range = (iw_get_range_info (nm_dev_sock_get_fd (sk), iface, &range) >= 0);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'iwstats'.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET 'iwstats'.", iface);
|
||||
|
||||
if (iw_get_stats (nm_dev_sock_get_fd (sk), iface, &stats, &range, has_range) == 0)
|
||||
{
|
||||
percent = wireless_qual_to_percent (&stats.qual, (const iwqual *)(&self->priv->max_qual),
|
||||
|
|
@ -1161,9 +1159,9 @@ nm_device_802_11_wireless_get_mode (NMDevice80211Wireless *self)
|
|||
struct iwreq wrq;
|
||||
|
||||
memset (&wrq, 0, sizeof (struct iwreq));
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWMODE.", nm_device_get_iface (NM_DEVICE (self)));
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to GET IWMODE.", nm_device_get_iface (NM_DEVICE (self)));
|
||||
|
||||
if (iw_get_ext (nm_dev_sock_get_fd (sk), nm_device_get_iface (NM_DEVICE (self)), SIOCGIWMODE, &wrq) == 0)
|
||||
{
|
||||
if ((mode == IW_MODE_ADHOC) || (mode == IW_MODE_INFRA))
|
||||
|
|
@ -1206,9 +1204,9 @@ nm_device_802_11_wireless_set_mode (NMDevice80211Wireless *self,
|
|||
const char * iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
struct iwreq wreq;
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to SET IWMODE.", iface);
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to SET IWMODE.", iface);
|
||||
|
||||
wreq.u.mode = mode;
|
||||
if (iw_set_ext (nm_dev_sock_get_fd (sk), iface, SIOCSIWMODE, &wreq) == 0)
|
||||
success = TRUE;
|
||||
|
|
@ -1387,9 +1385,8 @@ nm_device_802_11_wireless_get_essid (NMDevice80211Wireless *self)
|
|||
{
|
||||
wireless_config info;
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET 'basic config' for ESSID.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET 'basic config' for ESSID.", iface);
|
||||
|
||||
err = iw_get_basic_config (nm_dev_sock_get_fd (sk), iface, &info);
|
||||
if (err >= 0)
|
||||
{
|
||||
|
|
@ -1445,9 +1442,8 @@ nm_device_802_11_wireless_set_essid (NMDevice80211Wireless *self,
|
|||
wreq.u.essid.length = len + 1;
|
||||
wreq.u.essid.flags = (len > 0) ? 1 : 0; /* 1=enable ESSID, 0=disable/any */
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to SET IWESSID.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to SET IWESSID.", iface);
|
||||
|
||||
if ((err = iw_set_ext (nm_dev_sock_get_fd (sk), iface, SIOCSIWESSID, &wreq)) == -1)
|
||||
{
|
||||
if (errno != ENODEV)
|
||||
|
|
@ -1492,9 +1488,8 @@ nm_device_802_11_wireless_get_frequency (NMDevice80211Wireless *self)
|
|||
{
|
||||
struct iwreq wrq;
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWFREQ.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET IWFREQ.", iface);
|
||||
|
||||
err = iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWFREQ, &wrq);
|
||||
if (err >= 0)
|
||||
freq = iw_freq2float (&wrq.u.freq);
|
||||
|
|
@ -1565,9 +1560,9 @@ nm_device_802_11_wireless_set_frequency (NMDevice80211Wireless *self,
|
|||
wrq.u.freq.flags = IW_FREQ_FIXED;
|
||||
iw_float2freq (freq, &wrq.u.freq);
|
||||
}
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to SET IWFREQ.", iface);
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to SET IWFREQ.", iface);
|
||||
|
||||
if ((err = iw_set_ext (nm_dev_sock_get_fd (sk), iface, SIOCSIWFREQ, &wrq)) == -1)
|
||||
{
|
||||
gboolean success = FALSE;
|
||||
|
|
@ -1607,9 +1602,7 @@ nm_device_802_11_wireless_get_bitrate (NMDevice80211Wireless *self)
|
|||
iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_WIRELESS, __FUNCTION__, NULL)))
|
||||
{
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWRATE.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET IWRATE.", iface);
|
||||
err = iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWRATE, &wrq);
|
||||
nm_dev_sock_close (sk);
|
||||
}
|
||||
|
|
@ -1654,9 +1647,7 @@ nm_device_802_11_wireless_set_bitrate (NMDevice80211Wireless *self,
|
|||
wrq.u.bitrate.fixed = 0;
|
||||
}
|
||||
/* Silently fail as not all drivers support setting bitrate yet (ipw2x00 for example) */
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to SET IWRATE.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to SET IWRATE.", iface);
|
||||
iw_set_ext (nm_dev_sock_get_fd (sk), iface, SIOCSIWRATE, &wrq);
|
||||
|
||||
nm_dev_sock_close (sk);
|
||||
|
|
@ -1687,9 +1678,7 @@ nm_device_802_11_wireless_get_bssid (NMDevice80211Wireless *self,
|
|||
iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
if ((sk = nm_dev_sock_open (NM_DEVICE (self), DEV_WIRELESS, __FUNCTION__, NULL)))
|
||||
{
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWAP.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET IWAP.", iface);
|
||||
if (iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWAP, &wrq) >= 0)
|
||||
memcpy (bssid, &(wrq.u.ap_addr.sa_data), sizeof (struct ether_addr));
|
||||
nm_dev_sock_close (sk);
|
||||
|
|
@ -1719,9 +1708,7 @@ nm_device_802_11_wireless_disable_encryption (NMDevice80211Wireless *self)
|
|||
.u.data.flags = IW_ENCODE_DISABLED
|
||||
};
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to SET IWENCODE.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to SET IWENCODE.", iface);
|
||||
if (iw_set_ext (nm_dev_sock_get_fd (sk), iface, SIOCSIWENCODE, &wreq) == -1)
|
||||
{
|
||||
if (errno != ENODEV)
|
||||
|
|
@ -2167,9 +2154,7 @@ is_associated (NMDevice80211Wireless *self)
|
|||
*/
|
||||
memset (&wrq, 0, sizeof (struct iwreq));
|
||||
iface = nm_device_get_iface (NM_DEVICE (self));
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWNAME.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET IWNAME.", iface);
|
||||
if (iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWNAME, &wrq) >= 0)
|
||||
{
|
||||
if (!strcmp (wrq.u.name, "unassociated"))
|
||||
|
|
@ -2187,9 +2172,7 @@ is_associated (NMDevice80211Wireless *self)
|
|||
* Is there a better way? Some cards don't work too well with this check, ie
|
||||
* Lucent WaveLAN.
|
||||
*/
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IWAP.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET IWAP.", iface);
|
||||
if (iw_get_ext (nm_dev_sock_get_fd (sk), iface, SIOCGIWAP, &wrq) >= 0)
|
||||
if (nm_ethernet_address_is_valid ((struct ether_addr *)(&(wrq.u.ap_addr.sa_data))))
|
||||
associated = TRUE;
|
||||
|
|
|
|||
|
|
@ -412,18 +412,15 @@ supports_ethtool_carrier_detect (NMDevice8023Ethernet *self)
|
|||
strncpy (ifr.ifr_name, iface, sizeof(ifr.ifr_name) - 1);
|
||||
edata.cmd = ETHTOOL_GLINK;
|
||||
ifr.ifr_data = (char *) &edata;
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to ETHTOOL\n", iface);
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to ETHTOOL\n", iface);
|
||||
if (ioctl (nm_dev_sock_get_fd (sk), SIOCETHTOOL, &ifr) == -1)
|
||||
goto out;
|
||||
|
||||
supports_ethtool = TRUE;
|
||||
|
||||
out:
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: Done with ETHTOOL\n", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: Done with ETHTOOL\n", iface);
|
||||
nm_dev_sock_close (sk);
|
||||
return supports_ethtool;
|
||||
}
|
||||
|
|
@ -481,14 +478,10 @@ mdio_read (NMDevice8023Ethernet *self, NMSock *sk, struct ifreq *ifr, int locati
|
|||
mii = (struct mii_ioctl_data *) &ifr->ifr_ifru;
|
||||
mii->reg_num = location;
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET MIIREG\n", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET MIIREG\n", iface);
|
||||
if (ioctl (nm_dev_sock_get_fd (sk), SIOCGMIIREG, ifr) >= 0)
|
||||
val = mii->val_out;
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: Done with GET MIIREG\n", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: Done with GET MIIREG\n", iface);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
|
@ -514,13 +507,10 @@ supports_mii_carrier_detect (NMDevice8023Ethernet *self)
|
|||
}
|
||||
|
||||
strncpy (ifr.ifr_name, iface, sizeof (ifr.ifr_name) - 1);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET MIIPHY\n", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: About to GET MIIPHY\n", iface);
|
||||
err = ioctl (nm_dev_sock_get_fd (sk), SIOCGMIIPHY, &ifr);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: Done with GET MIIPHY\n", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: Done with GET MIIPHY\n", iface);
|
||||
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
|
|
|
|||
|
|
@ -1684,13 +1684,11 @@ nm_device_update_ip4_address (NMDevice *self)
|
|||
iface = nm_device_get_iface (self);
|
||||
memset (&req, 0, sizeof (struct ifreq));
|
||||
strncpy (req.ifr_name, iface, sizeof (req.ifr_name) - 1);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IFADDR.", iface);
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to GET IFADDR.", iface);
|
||||
err = ioctl (nm_dev_sock_get_fd (sk), SIOCGIFADDR, &req);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: Done with GET IFADDR.", iface);
|
||||
#endif
|
||||
nm_ioctl_info ("%s: Done with GET IFADDR.", iface);
|
||||
|
||||
nm_dev_sock_close (sk);
|
||||
if (err != 0)
|
||||
return;
|
||||
|
|
@ -1744,13 +1742,11 @@ nm_device_is_up (NMDevice *self)
|
|||
|
||||
/* Get device's flags */
|
||||
strncpy (ifr.ifr_name, nm_device_get_iface (self), sizeof (ifr.ifr_name) - 1);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: About to GET IFFLAGS.", nm_device_get_iface (self));
|
||||
#endif
|
||||
|
||||
nm_ioctl_info ("%s: About to GET IFFLAGS.", nm_device_get_iface (self));
|
||||
err = ioctl (nm_dev_sock_get_fd (sk), SIOCGIFFLAGS, &ifr);
|
||||
#ifdef IOCTL_DEBUG
|
||||
nm_info ("%s: Done with GET IFFLAGS.", nm_device_get_iface (self));
|
||||
#endif
|
||||
nm_ioctl_info ("%s: Done with GET IFFLAGS.", nm_device_get_iface (self));
|
||||
|
||||
nm_dev_sock_close (sk);
|
||||
if (!err)
|
||||
return (!((ifr.ifr_flags^IFF_UP) & IFF_UP));
|
||||
|
|
|
|||
|
|
@ -30,7 +30,16 @@
|
|||
#include "nm-ip4-config.h"
|
||||
|
||||
#if 0
|
||||
#define IOCTL_DEBUG
|
||||
# define IOCTL_DEBUG 1
|
||||
#endif
|
||||
|
||||
#ifdef IOCTL_DEBUG
|
||||
# define nm_ioctl_info(fmt, args...) \
|
||||
G_STMT_START { \
|
||||
g_message ("<information>\t" fmt "\n", ##args); \
|
||||
} G_STMT_END
|
||||
#else
|
||||
# define nm_ioctl_info(fmt, args...) do { } while(0)
|
||||
#endif
|
||||
|
||||
typedef enum NMWirelessScanInterval
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue