int delay_time;
int verbosity;
+int scan_interval;
+int scan_wait;
+
+struct in_addr scanrange[NUM_RANGES];
+int scanrangesize[NUM_RANGES];
+int ranges;
+
int use_mysql;
char mysql_host[64];
char mysql_username[32];
char mysql_password[32];
-void parse_configfile(int do_scan)
+void parse_configfile()
{
FILE *configfile = fopen("nbtscanner.conf", "r");
int lineno = 0;
delay_time = 100;
verbosity = 2;
+ ranges = 0;
+
use_mysql = 0;
strcpy(mysql_host, "no_host_given");
strcpy(mysql_username, "no_username_given");
continue;
}
- parse_line(buf, lineno, do_scan);
+ parse_line(buf, lineno);
}
fclose(configfile);
}
-void parse_line(char *buf, int lineno, int do_scan)
+void parse_line(char *buf, int lineno)
{
char *ptr = strchr(buf, '=');
}
/* finally pass it on to the keyword checker */
- parse_keyword(buf, ptr, lineno, do_scan);
+ parse_keyword(buf, ptr, lineno);
}
-void parse_keyword(char *keyword, char *value, int lineno, int do_scan)
+void parse_keyword(char *keyword, char *value, int lineno)
{
if (strcasecmp(keyword, "num_retries") == 0) {
parse_int(value, &num_retries, lineno);
parse_int(value, &delay_time, lineno);
} else if (strcasecmp(keyword, "verbosity") == 0) {
parse_int(value, &verbosity, lineno);
+ } else if (strcasecmp(keyword, "scan_interval") == 0) {
+ parse_int(value, &scan_interval, lineno);
+ } else if (strcasecmp(keyword, "scan_wait") == 0) {
+ parse_int(value, &scan_wait, lineno);
} else if (strcasecmp(keyword, "use_mysql") == 0) {
parse_int(value, &use_mysql, lineno);
} else if (strcasecmp(keyword, "mysql_host") == 0) {
} else if (strcasecmp(keyword, "mysql_password") == 0) {
strcpy(mysql_password, value);
} else if (strcasecmp(keyword, "range") == 0) {
- /* really ugly to have here */
- if (use_mysql) {
- init_mysql(mysql_host, mysql_username, mysql_password);
- }
- if (do_scan) parse_range(value, lineno);
+ parse_range(value, lineno);
} else {
char buf[1024];
sprintf(buf, "Unknown keyword `%s'", keyword);
}
}
- scan_range(in, rangesize);
+ memcpy((char *)(&(scanrange[ranges])), (char *)(&in), sizeof(in));
+ scanrangesize[ranges++] = rangesize;
}
void line_error(int lineno, char *err_str)