Skip to content

Commit

Permalink
tools/nut-scanner/nut-scanner.c: use run*() methods for most of the n…
Browse files Browse the repository at this point in the history
…on-threaded scans too [networkupstools#2244]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jul 4, 2024
1 parent 286909f commit 70338b6
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions tools/nut-scanner/nut-scanner.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ static void * run_usb(void *arg)
dev[TYPE_USB] = nutscan_scan_usb(scanopts_ptr);
return NULL;
}
#endif /* HAVE_PTHREAD */

static void * run_snmp(void * arg)
{
Expand Down Expand Up @@ -387,12 +388,11 @@ static void * run_ipmi(void * arg)

static void * run_eaton_serial(void *arg)
{
NUT_UNUSED_VARIABLE(arg);
char * arg_serial_ports = (char *)arg;

dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial(serial_ports);
dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial(arg_serial_ports);
return NULL;
}
#endif /* HAVE_PTHREAD */

static void show_usage(void)
{
Expand Down Expand Up @@ -1047,6 +1047,7 @@ int main(int argc, char *argv[])
}
#else
upsdebugx(1, "USB SCAN: no pthread support, starting nutscan_scan_usb...");
/* Not calling run_usb() here, as it re-processes the arg */
dev[TYPE_USB] = nutscan_scan_usb(&cli_link_detail_level);
#endif /* HAVE_PTHREAD */
} else {
Expand All @@ -1068,7 +1069,8 @@ int main(int argc, char *argv[])
}
#else
upsdebugx(1, "SNMP SCAN: no pthread support, starting nutscan_scan_snmp...");
dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip, end_ip, timeout, &snmp_sec);
/* dev[TYPE_SNMP] = nutscan_scan_snmp(start_ip, end_ip, timeout, &snmp_sec); */
run_snmp(&snmp_sec);
#endif /* HAVE_PTHREAD */
}
} else {
Expand All @@ -1091,11 +1093,8 @@ int main(int argc, char *argv[])
}
#else
upsdebugx(1, "XML/HTTP SCAN: no pthread support, starting nutscan_scan_xml_http_range()...");
if (ip_ranges_count) {
dev[TYPE_XML] = nutscan_scan_xml_http_range(start_ip, end_ip, timeout, &xml_sec);
} else {
/* Probe broadcast */
dev[TYPE_XML] = nutscan_scan_xml_http_range(NULL, NULL, timeout, &xml_sec);
/* dev[TYPE_XML] = nutscan_scan_xml_http_range(start_ip, end_ip, timeout, &xml_sec); */
run_xml(&xml_sec);
}
#endif /* HAVE_PTHREAD */
} else {
Expand All @@ -1117,7 +1116,8 @@ int main(int argc, char *argv[])
}
#else
upsdebugx(1, "NUT bus (old) SCAN: no pthread support, starting nutscan_scan_nut...");
dev[TYPE_NUT] = nutscan_scan_nut(start_ip, end_ip, port, timeout);
/*dev[TYPE_NUT] = nutscan_scan_nut(start_ip, end_ip, port, timeout);*/
run_nut_old(NULL);
#endif /* HAVE_PTHREAD */
}
} else {
Expand All @@ -1133,8 +1133,9 @@ int main(int argc, char *argv[])
nutscan_avail_nut_simulation = 0;
}
#else
upsdebugx(1, "NUT simulation devices SCAN: no pthread support, starting nutscan_scan_nut_simulation...");
dev[TYPE_NUT_SIMULATION] = nutscan_scan_nut_simulation(timeout);
upsdebugx(1, "NUT simulation devices SCAN: no pthread support, starting nutscan_scan_nut_simulation...");
/* dev[TYPE_NUT_SIMULATION] = nutscan_scan_nut_simulation(); */
run_nut_simulation(NULL);
#endif /* HAVE_PTHREAD */
} else {
upsdebugx(1, "NUT simulation devices SCAN: not requested or supported, SKIPPED");
Expand All @@ -1150,7 +1151,8 @@ int main(int argc, char *argv[])
}
#else
upsdebugx(1, "NUT bus (avahi) SCAN: no pthread support, starting nutscan_scan_avahi...");
dev[TYPE_AVAHI] = nutscan_scan_avahi(timeout);
/* dev[TYPE_AVAHI] = nutscan_scan_avahi(timeout); */
run_avahi(NULL);
#endif /* HAVE_PTHREAD */
} else {
upsdebugx(1, "NUT bus (avahi) SCAN: not requested or supported, SKIPPED");
Expand All @@ -1171,12 +1173,8 @@ int main(int argc, char *argv[])
}
#else
upsdebugx(1, "IPMI SCAN: no pthread support, starting nutscan_scan_ipmi...");
if (ip_ranges_count) {
dev[TYPE_IPMI] = nutscan_scan_ipmi(start_ip, end_ip, &ipmi_sec);
} else {
/* Probe local device */
dev[TYPE_IPMI] = nutscan_scan_ipmi(NULL, NULL, &ipmi_sec);
}
/* dev[TYPE_IPMI] = nutscan_scan_ipmi(start_ip, end_ip, &ipmi_sec); */
run_ipmi(&ipmi_sec);
#endif /* HAVE_PTHREAD */
} else {
upsdebugx(1, "IPMI SCAN: not requested or supported, SKIPPED");
Expand All @@ -1193,7 +1191,8 @@ int main(int argc, char *argv[])
/* nutscan_avail_eaton_serial(?) = 0; */
#else
upsdebugx(1, "SERIAL SCAN: no pthread support, starting nutscan_scan_eaton_serial...");
dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial (serial_ports);
/* dev[TYPE_EATON_SERIAL] = nutscan_scan_eaton_serial (serial_ports); */
run_eaton_serial(serial_ports);
#endif /* HAVE_PTHREAD */
} else {
upsdebugx(1, "SERIAL SCAN: not requested or supported, SKIPPED");
Expand Down

0 comments on commit 70338b6

Please sign in to comment.