#include "common.h"
#include "plugin.h"
-#if defined(KERNEL_LINUX)
-# define WIRELESS_HAVE_READ 1
-#else
-# define WIRELESS_HAVE_READ 0
+#if !KERNEL_LINUX
+# error "No applicable input method."
#endif
#define WIRELESS_PROC_FILE "/proc/net/wireless"
-#if WIRELESS_HAVE_READ
#if 0
static double wireless_dbm_to_watt (double dbm)
{
vl.values = values;
vl.values_len = 1;
- vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "wireless");
- strncpy (vl.plugin_instance, plugin_instance,
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "wireless", sizeof (vl.plugin));
+ sstrncpy (vl.plugin_instance, plugin_instance,
sizeof (vl.plugin_instance));
+ sstrncpy (vl.type, type, sizeof (vl.type));
- plugin_dispatch_values (type, &vl);
+ plugin_dispatch_values (&vl);
} /* void wireless_submit */
#define POWER_MIN -90.0
power = 1.0; /* invalid */
else if ((power >= 0.0) && (power <= 100.0))
power = wireless_percent_to_power (power);
- else if (power > 100.0)
+ else if ((power > 100.0) && (power <= 256.0))
+ power = power - 256.0;
+ else if (power > 0.0)
power = 1.0; /* invalid */
/* noise [dBm] < 0.0 */
- noise = strtod (fields[3], &endptr);
- if (fields[3] == endptr)
+ noise = strtod (fields[4], &endptr);
+ if (fields[4] == endptr)
noise = 1.0; /* invalid */
else if ((noise >= 0.0) && (noise <= 100.0))
noise = wireless_percent_to_power (noise);
- else if (noise > 100.0)
+ else if ((noise > 100.0) && (noise <= 256.0))
+ noise = noise - 256.0;
+ else if (noise > 0.0)
noise = 1.0; /* invalid */
wireless_submit (device, "signal_quality", quality);
return (0);
} /* int wireless_read */
-#endif /* WIRELESS_HAVE_READ */
void module_register (void)
{
-#if WIRELESS_HAVE_READ
plugin_register_read ("wireless", wireless_read);
-#endif /* WIRELESS_HAVE_READ */
} /* void module_register */