Skip to content
Snippets Groups Projects
Commit c2c4b1de authored by Sukru Senli's avatar Sukru Senli
Browse files

adapt loop-detector to new uci config and options

parent 021d27c6
Branches
No related tags found
No related merge requests found
config loop-detect_config
option send_loop_discovery_period '10'
option send_discovery_numbertimes '6'
...@@ -39,7 +39,7 @@ uint8_t numberDetectedLoops = 0; ...@@ -39,7 +39,7 @@ uint8_t numberDetectedLoops = 0;
char **portsLoop; 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){ void init_portsLoop(void){
uint8_t i; uint8_t i;
...@@ -143,7 +143,7 @@ void ethernetCaptureLoopHandler( u_char *args, const struct pcap_pkthdr *packet_ ...@@ -143,7 +143,7 @@ void ethernetCaptureLoopHandler( u_char *args, const struct pcap_pkthdr *packet_
if(test && senddiscoverycheck==1 && numberDetectedLoops == 0) { if(test && senddiscoverycheck==1 && numberDetectedLoops == 0) {
senddiscoverycheck = 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"); ethernetDeviceUpDown(args, "down");
sent_after_loop_counter = 1; sent_after_loop_counter = 1;
addPortsLoop(args); addPortsLoop(args);
......
...@@ -56,7 +56,7 @@ void getAppUciParams(void){ ...@@ -56,7 +56,7 @@ void getAppUciParams(void){
if (!uci_ctx) fprintf(stdout, "uci_ctx alloc failed\n"); 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_free_context(uci_ctx);
uci_ctx = NULL; uci_ctx = NULL;
return; return;
...@@ -68,10 +68,10 @@ void getAppUciParams(void){ ...@@ -68,10 +68,10 @@ void getAppUciParams(void){
s = uci_to_section(e2); s = uci_to_section(e2);
uci_foreach_element(&s->options, e3) { uci_foreach_element(&s->options, e3) {
opt = uci_to_option(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); 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); send_discovery_numbertimes = atoi(opt->v.string);
} }
} }
...@@ -164,8 +164,10 @@ int main(int argc, char *argv[]) { ...@@ -164,8 +164,10 @@ int main(int argc, char *argv[]) {
findPortsNumberNames(); findPortsNumberNames();
buildL2LoopDiscoveryFrame(); buildL2LoopDiscoveryFrame();
init_l2loop_send_discovery_thread(); 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_ethernet_thread_pool();
join_ports_threads(); init_l2loop_send_discovery_thread();
init_ethernet_thread_pool();
join_ports_threads();
return 0; return 0;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment