diff options
| author | michael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2008-12-31 06:26:23 +0000 | 
|---|---|---|
| committer | michael <michael@3ae390bd-cb1e-0410-b409-cd5a39f66f1f> | 2008-12-31 06:26:23 +0000 | 
| commit | 51eb1ecfa9ab1faa133ceed79ace85922a5fb1fe (patch) | |
| tree | 77124c605b5a7f66613090bb7c8ee3689a23bc8e | |
| parent | a40840b2ff5ed97a31c4d8a10b74d492038bfc2c (diff) | |
| download | lcd4linux-51eb1ecfa9ab1faa133ceed79ace85922a5fb1fe.tar.gz | |
ported r835 from volker_dev
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@924 3ae390bd-cb1e-0410-b409-cd5a39f66f1f
| -rw-r--r-- | plugin_netinfo.c | 41 | 
1 files changed, 35 insertions, 6 deletions
| diff --git a/plugin_netinfo.c b/plugin_netinfo.c index 143a5e1..371c9eb 100644 --- a/plugin_netinfo.c +++ b/plugin_netinfo.c @@ -81,8 +81,9 @@ static int open_net(void)  static void my_exists(RESULT * result, RESULT * arg1)  { +    static int errcount = 0;      struct ifreq ifreq; -    double value = 1.0; +    double value = 1.0;		// netdev exists      if (socknr < 0) {  	/* no open socket */ @@ -97,7 +98,11 @@ static void my_exists(RESULT * result, RESULT * arg1)  	    /* device does not exists */  	    value = 0.0;  	} else { -	    error("%s: ioctl(FLAGS) failed: %s", "plugin_netinfo", strerror(errno)); +	    errcount++; +	    if (1 == errcount % 1000) { +		error("%s: ioctl(FLAGS %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); +		error("  (skip next 1000 errors)"); +	    }  	    return;  	}      } @@ -110,6 +115,7 @@ static void my_exists(RESULT * result, RESULT * arg1)  /* get MAC address (hardware address) of network device */  static void my_hwaddr(RESULT * result, RESULT * arg1)  { +    static int errcount = 0;      struct ifreq ifreq;      unsigned char *hw;      char value[18]; @@ -122,7 +128,12 @@ static void my_hwaddr(RESULT * result, RESULT * arg1)      strncpy(ifreq.ifr_name, R2S(arg1), sizeof(ifreq.ifr_name));      if (ioctl(socknr, SIOCGIFHWADDR, &ifreq) < 0) { -	error("%s: ioctl(IFHWADDR) failed: %s", "plugin_netinfo", strerror(errno)); +	errcount++; +	if (1 == errcount % 1000) { +	    error("%s: ioctl(IFHWADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); +	    error("  (skip next 1000 errors)"); +	} +	SetResult(&result, R_STRING, "");  	return;      }      hw = (unsigned char *) ifreq.ifr_hwaddr.sa_data; @@ -136,6 +147,7 @@ static void my_hwaddr(RESULT * result, RESULT * arg1)  /* get ip address of network device */  static void my_ipaddr(RESULT * result, RESULT * arg1)  { +    static int errcount = 0;      struct ifreq ifreq;      struct sockaddr_in *sin;      char value[16]; @@ -148,7 +160,12 @@ static void my_ipaddr(RESULT * result, RESULT * arg1)      strncpy(ifreq.ifr_name, R2S(arg1), sizeof(ifreq.ifr_name));      if (ioctl(socknr, SIOCGIFADDR, &ifreq) < 0) { -	error("%s: ioctl(IFADDR) failed: %s", "plugin_netinfo", strerror(errno)); +	errcount++; +	if (1 == errcount % 1000) { +	    error("%s: ioctl(IFADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); +	    error("  (skip next 1000 errors)"); +	} +	SetResult(&result, R_STRING, "");  	return;      }      sin = (struct sockaddr_in *) &ifreq.ifr_addr; @@ -161,6 +178,7 @@ static void my_ipaddr(RESULT * result, RESULT * arg1)  /* get ip netmask of network device */  static void my_netmask(RESULT * result, RESULT * arg1)  { +    static int errcount = 0;      struct ifreq ifreq;      struct sockaddr_in *sin;      char value[16]; @@ -173,7 +191,12 @@ static void my_netmask(RESULT * result, RESULT * arg1)      strncpy(ifreq.ifr_name, R2S(arg1), sizeof(ifreq.ifr_name));      if (ioctl(socknr, SIOCGIFNETMASK, &ifreq) < 0) { -	error("%s: ioctl(IFNETMASK) failed: %s", "plugin_netinfo", strerror(errno)); +	errcount++; +	if (1 == errcount % 1000) { +	    error("%s: ioctl(IFNETMASK %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); +	    error("  (skip next 1000 errors)"); +	} +	SetResult(&result, R_STRING, "");  	return;      }      sin = (struct sockaddr_in *) &ifreq.ifr_netmask; @@ -186,6 +209,7 @@ static void my_netmask(RESULT * result, RESULT * arg1)  /* get ip broadcast address of network device */  static void my_bcaddr(RESULT * result, RESULT * arg1)  { +    static int errcount = 0;      struct ifreq ifreq;      struct sockaddr_in *sin;      char value[16]; @@ -198,7 +222,12 @@ static void my_bcaddr(RESULT * result, RESULT * arg1)      strncpy(ifreq.ifr_name, R2S(arg1), sizeof(ifreq.ifr_name));      if (ioctl(socknr, SIOCGIFBRDADDR, &ifreq) < 0) { -	error("%s: ioctl(IFBRDADDR) failed: %s", "plugin_netinfo", strerror(errno)); +	errcount++; +	if (1 == errcount % 1000) { +	    error("%s: ioctl(IFBRDADDR %s) failed: %s", "plugin_netinfo", ifreq.ifr_name, strerror(errno)); +	    error("  (skip next 1000 errors)"); +	} +	SetResult(&result, R_STRING, "");  	return;      }      sin = (struct sockaddr_in *) &ifreq.ifr_broadaddr; | 
