From c2c4b1de3315fe7b04460b57351b9ee9d3163bd7 Mon Sep 17 00:00:00 2001 From: Sukru Senli <sukru.senli@inteno.se> Date: Thu, 2 Nov 2017 11:26:50 +0100 Subject: [PATCH] adapt loop-detector to new uci config and options --- config/loopDetect | 4 ---- ethernetThreadPool.c | 4 ++-- loop-detector.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 12 deletions(-) delete mode 100644 config/loopDetect diff --git a/config/loopDetect b/config/loopDetect deleted file mode 100644 index 9800785..0000000 --- a/config/loopDetect +++ /dev/null @@ -1,4 +0,0 @@ -config loop-detect_config - option send_loop_discovery_period '10' - option send_discovery_numbertimes '6' - diff --git a/ethernetThreadPool.c b/ethernetThreadPool.c index 3d4d227..6dbc8da 100644 --- a/ethernetThreadPool.c +++ b/ethernetThreadPool.c @@ -39,7 +39,7 @@ uint8_t numberDetectedLoops = 0; char **portsLoop; /* - * functions that allows to control ethernet ports that corresponds to L2Loops + * functions that allows to control ethernet ports that corresponds to L2 loops */ void init_portsLoop(void){ uint8_t i; @@ -143,7 +143,7 @@ void ethernetCaptureLoopHandler( u_char *args, const struct pcap_pkthdr *packet_ if(test && senddiscoverycheck==1 && numberDetectedLoops == 0) { senddiscoverycheck = 0; - fprintf(stdout,"L2Loop detected in the port: %s\n", args); + fprintf(stdout,"L2 loop is detected on port: %s\n", args); ethernetDeviceUpDown(args, "down"); sent_after_loop_counter = 1; addPortsLoop(args); diff --git a/loop-detector.c b/loop-detector.c index d3bb7fc..899d42b 100644 --- a/loop-detector.c +++ b/loop-detector.c @@ -56,7 +56,7 @@ void getAppUciParams(void){ if (!uci_ctx) fprintf(stdout, "uci_ctx alloc failed\n"); } - if (uci_load(uci_ctx, "loopDetect", &uci_config_package)) { + if (uci_load(uci_ctx, "loop_detection", &uci_config_package)) { uci_free_context(uci_ctx); uci_ctx = NULL; return; @@ -68,10 +68,10 @@ void getAppUciParams(void){ s = uci_to_section(e2); uci_foreach_element(&s->options, e3) { opt = uci_to_option(e3); - if(!strcmp(opt->e.name, "send_loop_discovery_period")) { + if(!strcmp(opt->e.name, "discovery_interval")) { send_loop_discovery_period = atoi(opt->v.string); } - if(!strcmp(opt->e.name, "send_discovery_numbertimes")) { + if(!strcmp(opt->e.name, "recovery_check_tries")) { send_discovery_numbertimes = atoi(opt->v.string); } } @@ -164,8 +164,10 @@ int main(int argc, char *argv[]) { findPortsNumberNames(); buildL2LoopDiscoveryFrame(); - init_l2loop_send_discovery_thread(); - init_ethernet_thread_pool(); - join_ports_threads(); + fprintf(stdout, "L2 loop detection started with discovery interval set to %d seconds and recovery check tries set to %d\n", send_loop_discovery_period, send_discovery_numbertimes); + + init_l2loop_send_discovery_thread(); + init_ethernet_thread_pool(); + join_ports_threads(); return 0; } -- GitLab