2
0
mirror of https://github.com/lm-sensors/lm-sensors synced 2025-09-04 00:05:10 +00:00

libsensors: Add support for intrusion detection.

git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5879 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Jean Delvare
2010-11-03 13:00:59 +00:00
parent 2a0c688cb8
commit 05a24e5bb2
5 changed files with 25 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ lm-sensors CHANGES file
SVN HEAD SVN HEAD
Makefile: Check for bison and flex Makefile: Check for bison and flex
libsensors: Add support for intrusion detection
sensors: Display 3 decimal places in raw output sensors: Display 3 decimal places in raw output
sensors-detect: Improve LM90 and W83L771 detection sensors-detect: Improve LM90 and W83L771 detection
Fix error seen if I2C bus numbers are not sequential Fix error seen if I2C bus numbers are not sequential

View File

@@ -6,6 +6,12 @@ over time. This document summarizes these evolutions so that application
authors can quickly figure out how to test for the availability of a authors can quickly figure out how to test for the availability of a
given new feature. given new feature.
0x431 lm-sensors SVN
* Added support for intrusion detection
enum sensors_feature_type SENSORS_FEATURE_INTRUSION
enum sensors_subfeature_type SENSORS_SUBFEATURE_INTRUSION_ALARM
enum sensors_subfeature_type SENSORS_SUBFEATURE_INTRUSION_BEEP
0x430 lm-sensors 3.2.0 0x430 lm-sensors 3.2.0
* License changed from GPL to LGPL * License changed from GPL to LGPL

View File

@@ -33,7 +33,7 @@ LIBMAN5FILES := $(MODULE_DIR)/sensors.conf.5
# changed in a backward incompatible way. The interface is defined by # changed in a backward incompatible way. The interface is defined by
# the public header files - in this case they are error.h and sensors.h. # the public header files - in this case they are error.h and sensors.h.
LIBMAINVER := 4 LIBMAINVER := 4
LIBMINORVER := 3.0 LIBMINORVER := 3.1
LIBVER := $(LIBMAINVER).$(LIBMINORVER) LIBVER := $(LIBMAINVER).$(LIBMINORVER)
# The static lib name, the shared lib name, and the internal ('so') name of # The static lib name, the shared lib name, and the internal ('so') name of

View File

@@ -1,7 +1,7 @@
/* /*
sensors.h - Part of libsensors, a Linux library for reading sensor data. sensors.h - Part of libsensors, a Linux library for reading sensor data.
Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl> Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
Copyright (C) 2007 Jean Delvare <khali@linux-fr.org> Copyright (C) 2007, 2010 Jean Delvare <khali@linux-fr.org>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@@ -141,6 +141,7 @@ typedef enum sensors_feature_type {
SENSORS_FEATURE_ENERGY = 0x04, SENSORS_FEATURE_ENERGY = 0x04,
SENSORS_FEATURE_CURR = 0x05, SENSORS_FEATURE_CURR = 0x05,
SENSORS_FEATURE_VID = 0x10, SENSORS_FEATURE_VID = 0x10,
SENSORS_FEATURE_INTRUSION = 0x11,
SENSORS_FEATURE_BEEP_ENABLE = 0x18, SENSORS_FEATURE_BEEP_ENABLE = 0x18,
SENSORS_FEATURE_UNKNOWN = INT_MAX, SENSORS_FEATURE_UNKNOWN = INT_MAX,
} sensors_feature_type; } sensors_feature_type;
@@ -198,6 +199,9 @@ typedef enum sensors_subfeature_type {
SENSORS_SUBFEATURE_VID = SENSORS_FEATURE_VID << 8, SENSORS_SUBFEATURE_VID = SENSORS_FEATURE_VID << 8,
SENSORS_SUBFEATURE_INTRUSION_ALARM = SENSORS_FEATURE_INTRUSION << 8,
SENSORS_SUBFEATURE_INTRUSION_BEEP,
SENSORS_SUBFEATURE_BEEP_ENABLE = SENSORS_FEATURE_BEEP_ENABLE << 8, SENSORS_SUBFEATURE_BEEP_ENABLE = SENSORS_FEATURE_BEEP_ENABLE << 8,
SENSORS_SUBFEATURE_UNKNOWN = INT_MAX, SENSORS_SUBFEATURE_UNKNOWN = INT_MAX,

View File

@@ -1,7 +1,7 @@
/* /*
sysfs.c - Part of libsensors, a library for reading Linux sensor data sysfs.c - Part of libsensors, a library for reading Linux sensor data
Copyright (c) 2005 Mark M. Hoffman <mhoffman@lightlink.com> Copyright (c) 2005 Mark M. Hoffman <mhoffman@lightlink.com>
Copyright (C) 2007-2008 Jean Delvare <khali@linux-fr.org> Copyright (C) 2007-2010 Jean Delvare <khali@linux-fr.org>
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
@@ -137,14 +137,14 @@ static int sysfs_foreach_busdev(const char *bus_type,
char sensors_sysfs_mount[NAME_MAX]; char sensors_sysfs_mount[NAME_MAX];
#define MAX_MAIN_SENSOR_TYPES 6 #define MAX_MAIN_SENSOR_TYPES 6
#define MAX_OTHER_SENSOR_TYPES 1 #define MAX_OTHER_SENSOR_TYPES 2
#define MAX_SENSORS_PER_TYPE 24 #define MAX_SENSORS_PER_TYPE 24
#define MAX_SUBFEATURES 8 #define MAX_SUBFEATURES 8
#define FEATURE_SIZE (MAX_SUBFEATURES * 2) #define FEATURE_SIZE (MAX_SUBFEATURES * 2)
#define FEATURE_TYPE_SIZE (MAX_SENSORS_PER_TYPE * FEATURE_SIZE) #define FEATURE_TYPE_SIZE (MAX_SENSORS_PER_TYPE * FEATURE_SIZE)
/* Room for all 6 main types (in, fan, temp, power, energy, current) and 1 /* Room for all 6 main types (in, fan, temp, power, energy, current) and 2
other type (VID) with all their subfeatures + misc features */ other types (VID, intrusion) with all their subfeatures + misc features */
#define SUB_OFFSET_OTHER (MAX_MAIN_SENSOR_TYPES * FEATURE_TYPE_SIZE) #define SUB_OFFSET_OTHER (MAX_MAIN_SENSOR_TYPES * FEATURE_TYPE_SIZE)
#define SUB_OFFSET_MISC (SUB_OFFSET_OTHER + \ #define SUB_OFFSET_MISC (SUB_OFFSET_OTHER + \
MAX_OTHER_SENSOR_TYPES * FEATURE_TYPE_SIZE) MAX_OTHER_SENSOR_TYPES * FEATURE_TYPE_SIZE)
@@ -190,6 +190,7 @@ char *get_feature_name(sensors_feature_type ftype, char *sfname)
case SENSORS_FEATURE_POWER: case SENSORS_FEATURE_POWER:
case SENSORS_FEATURE_ENERGY: case SENSORS_FEATURE_ENERGY:
case SENSORS_FEATURE_CURR: case SENSORS_FEATURE_CURR:
case SENSORS_FEATURE_INTRUSION:
underscore = strchr(sfname, '_'); underscore = strchr(sfname, '_');
name = strndup(sfname, underscore - sfname); name = strndup(sfname, underscore - sfname);
if (!name) if (!name)
@@ -289,6 +290,11 @@ static const struct subfeature_type_match cpu_matches[] = {
{ NULL, 0 } { NULL, 0 }
}; };
static const struct subfeature_type_match intrusion_matches[] = {
{ "alarm", SENSORS_SUBFEATURE_INTRUSION_ALARM },
{ "beep", SENSORS_SUBFEATURE_INTRUSION_BEEP },
{ NULL, 0 }
};
static struct feature_type_match matches[] = { static struct feature_type_match matches[] = {
{ "temp%d%c", temp_matches }, { "temp%d%c", temp_matches },
{ "in%d%c", in_matches }, { "in%d%c", in_matches },
@@ -297,6 +303,7 @@ static struct feature_type_match matches[] = {
{ "power%d%c", power_matches }, { "power%d%c", power_matches },
{ "curr%d%c", curr_matches }, { "curr%d%c", curr_matches },
{ "energy%d%c", energy_matches }, { "energy%d%c", energy_matches },
{ "intrusion%d%c", intrusion_matches },
}; };
/* Return the subfeature type and channel number based on the subfeature /* Return the subfeature type and channel number based on the subfeature
@@ -411,6 +418,7 @@ static int sensors_read_dynamic_chip(sensors_chip_features *chip,
sorted table */ sorted table */
switch (ftype) { switch (ftype) {
case SENSORS_FEATURE_VID: case SENSORS_FEATURE_VID:
case SENSORS_FEATURE_INTRUSION:
i = SUB_OFFSET_OTHER + i = SUB_OFFSET_OTHER +
(ftype - SENSORS_FEATURE_VID) * FEATURE_TYPE_SIZE + (ftype - SENSORS_FEATURE_VID) * FEATURE_TYPE_SIZE +
nr * FEATURE_SIZE + (sftype & 0xFF); nr * FEATURE_SIZE + (sftype & 0xFF);