summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarie Rannou2009-10-16 15:41:30 +0200
committerMarie Rannou2009-10-16 15:41:30 +0200
commite377c9520e40ac133f8c1a0cd394efbd0611644c (patch)
tree0d78cc47a52bf2b12a543405a1152c6d09573ff7
parent37c5dd9c51f4f70d0d5a0ec20f5a9bb38c7ac59d (diff)
[devkit] Ticket#209 : add a sysctl to manage delays for logging events for whitelist
-rw-r--r--devkit/plc-polux/core/linux_tx.c4
-rw-r--r--devkit/plc-polux/core/plc_drv.h3
-rw-r--r--devkit/plc-polux/core/plc_nd.c5
-rw-r--r--devkit/plc-polux/core/plc_sysctl.c56
-rw-r--r--devkit/plc-polux/core/plc_sysctl.h10
5 files changed, 65 insertions, 13 deletions
diff --git a/devkit/plc-polux/core/linux_tx.c b/devkit/plc-polux/core/linux_tx.c
index 0f5f80dfe7..c0dc21fb5e 100644
--- a/devkit/plc-polux/core/linux_tx.c
+++ b/devkit/plc-polux/core/linux_tx.c
@@ -199,8 +199,10 @@ DevErr linux_drv__init__step1 (struct plc_drv_unit * unit)
unit->scan.samples = 20;
unit->scan.period = 36;
- // whitelist : default = whitelist disable
+ // whitelist : default = whitelist disable:
unit->sysctl.nd.enable = 1;
+ // whitelist log delay : default = 5 sec:
+ unit->sysctl.wl.logdelay = 5000;
if (unit->scan.samples > MAX_SCAN_SAMPLES)
{
diff --git a/devkit/plc-polux/core/plc_drv.h b/devkit/plc-polux/core/plc_drv.h
index a1a58e7793..5813bec553 100644
--- a/devkit/plc-polux/core/plc_drv.h
+++ b/devkit/plc-polux/core/plc_drv.h
@@ -122,6 +122,9 @@ struct plc_drv_sysctl {
struct{
bool enable;
} nd;
+ struct{
+ int logdelay;
+ } wl;
};
/* PLC driver unit */
diff --git a/devkit/plc-polux/core/plc_nd.c b/devkit/plc-polux/core/plc_nd.c
index 1b60c6855a..cbb5d2414c 100644
--- a/devkit/plc-polux/core/plc_nd.c
+++ b/devkit/plc-polux/core/plc_nd.c
@@ -38,7 +38,6 @@
extern struct list_head whitelist_list;
extern rwlock_t whitelist_lock;
extern struct white_list_info whiteinfo[1];
-#define WHITELIST_LOG_INTERVAL 5000000
/* all frames begins with this header */
struct nd_header {
@@ -566,7 +565,7 @@ static void assoc_request (struct plc_drv_unit *unit, struct assoc_request *requ
{
is_authorized =2;
uint32_t current_time = get_time();
- if ( (current_time - whitelist->last_log_date) >= 5000000)
+ if ( (current_time - whitelist->last_log_date) >= ((unit->sysctl.wl.logdelay)*1000))
{
sprintf(mac_address_string, "%02x:%02x:%02x:%02x:%02x:%02x",whitelist-> mac_addr[0],whitelist-> mac_addr[1],whitelist-> mac_addr[2],whitelist-> mac_addr[3],whitelist-> mac_addr[4],whitelist-> mac_addr[5] );
printk("WHITELIST slave %s, connection refused (no authorization)\n",mac_address_string);
@@ -580,7 +579,7 @@ static void assoc_request (struct plc_drv_unit *unit, struct assoc_request *requ
if (is_authorized == 0)
{
uint32_t current_time = get_time();
- if ( (current_time - whitelist->last_log_date) >= 5000000)
+ if ( (current_time - whitelist->last_log_date) >= ((unit->sysctl.wl.logdelay)*1000))
{
sprintf(mac_address_string, "%02x:%02x:%02x:%02x:%02x:%02x",request->head.srcEthAddr.addr[0],request->head.srcEthAddr.addr[1],request->head.srcEthAddr.addr[2],request->head.srcEthAddr.addr[3],request->head.srcEthAddr.addr[4],request->head.srcEthAddr.addr[5] );
printk("WHITELIST slave %s, connection refused (not in whitelist)\n",mac_address_string);
diff --git a/devkit/plc-polux/core/plc_sysctl.c b/devkit/plc-polux/core/plc_sysctl.c
index 8fd1c61b65..1796e9e0d2 100644
--- a/devkit/plc-polux/core/plc_sysctl.c
+++ b/devkit/plc-polux/core/plc_sysctl.c
@@ -2139,6 +2139,28 @@ SYSCTL_function (sysctl_nd_mode)
return 0;
}
+SYSCTL_function (sysctl_wl_logdelay)
+{
+ struct plc_drv_unit *unit = plc_drv_get_unit (0);
+
+ if (oldval) // read
+ {
+ *oldlenp = sprintf (oldval, "%hd", unit->sysctl.wl.logdelay);
+ }
+
+ if (newval) // write
+ {
+ unsigned int val = strtoul (newval, NULL, 0);
+
+ if (val != 0)
+ {
+ unit->sysctl.wl.logdelay = val;
+ }
+ }
+
+ return 0;
+}
+
// ########################################################################
// # tree declaration
// ########################################################################
@@ -2451,6 +2473,19 @@ static ctl_table nd_mode_table[] = {
{0}
};
+/* for whitelist*/
+static ctl_table wl_logdelay_table[] = {
+ {
+ .ctl_name = WL_LOGDELAY,
+ .procname = "logdelay",
+ .data = NULL,
+ .maxlen = 0,
+ .mode = 0666,
+ .proc_handler = &std_proc_handler,
+ .strategy = &sysctl_wl_logdelay},
+ {0}
+};
+
static ctl_table plccfp_table[] = {
{
.ctl_name = PLCCFP_AUTO_BALANCE_RESSOURCE,
@@ -2836,13 +2871,20 @@ static ctl_table plc_table[] = {
.mode = 0555,
.child = melissa_table},
#endif
- {
- .ctl_name = PLC_ND_MODE,
- .procname = "nd",
- .data = NULL,
- .maxlen = 0,
- .mode = 0555,
- .child = nd_mode_table},
+ {
+ .ctl_name = PLC_ND_MODE,
+ .procname = "nd",
+ .data = NULL,
+ .maxlen = 0,
+ .mode = 0555,
+ .child = nd_mode_table},
+ {
+ .ctl_name = PLC_WL_LOGDELAY,
+ .procname = "wl",
+ .data = NULL,
+ .maxlen = 0,
+ .mode = 0555,
+ .child = wl_logdelay_table},
{0}
};
diff --git a/devkit/plc-polux/core/plc_sysctl.h b/devkit/plc-polux/core/plc_sysctl.h
index b840c88866..123852e3a4 100644
--- a/devkit/plc-polux/core/plc_sysctl.h
+++ b/devkit/plc-polux/core/plc_sysctl.h
@@ -119,9 +119,10 @@ enum {
PLC_EVENTS,
PLC_DATARATE,
#ifdef CONFIG_PLC_MELISSA
- PLC_MELISSA
+ PLC_MELISSA,
#endif
- PLC_ND_MODE
+ PLC_ND_MODE,
+ PLC_WL_LOGDELAY
// Always insert on the end list.
};
@@ -362,6 +363,11 @@ enum {
ND_MODE = 1,
};
+/* items in wl directory */
+enum {
+ WL_LOGDELAY = 1,
+};
+
#ifdef __KERNEL__
extern ctl_table plc_root_table[];
#endif