wip: file of hosts as an argument
This commit is contained in:
12
src/thread.c
12
src/thread.c
@ -103,6 +103,7 @@ int create_threads(const struct option_lst *options, char *ip_addr,
|
||||
init_threads_data(options, ip_addr, &host, responses, 1);
|
||||
thread_data->port_start = port_start;
|
||||
thread_data->port_end = port_end;
|
||||
g_start = true;
|
||||
routine(thread_data);
|
||||
return 0;
|
||||
}
|
||||
@ -126,10 +127,13 @@ int create_threads(const struct option_lst *options, char *ip_addr,
|
||||
uint16_t remaining_ports = (port_end - port_start) % g_nb_threads;
|
||||
for (uint8_t i = 0; i < g_nb_threads; i++) {
|
||||
threads_data[i].port_start = port_start + i * ports_per_thread;
|
||||
threads_data[i].port_end =
|
||||
port_start + (i + 1) * ports_per_thread;
|
||||
// TODO implement remaining_ports
|
||||
(void)remaining_ports;
|
||||
threads_data[i].port_end = port_start +
|
||||
(i + 1) * ports_per_thread +
|
||||
(remaining_ports ? 1 : 0);
|
||||
if (remaining_ports) {
|
||||
remaining_ports--;
|
||||
port_start++;
|
||||
}
|
||||
if (pthread_create(&threads[i], NULL, routine,
|
||||
&threads_data[i])) {
|
||||
dprintf(2, "ft_nmap: error during pthread_create()\n");
|
||||
|
||||
Reference in New Issue
Block a user