core: use only one struct data instead of thead_data and scan_data

core: do parsing in the main, put all in struct general
fix: code support port > 1024
This commit is contained in:
2025-06-03 16:49:41 +02:00
parent d640c95224
commit 9ae1e29f71
12 changed files with 143 additions and 168 deletions

View File

@ -12,7 +12,7 @@ typedef enum {
FL_IP,
FL_FILE,
FL_SPEEDUP,
FL_SCAN,
FL_TYPE,
FL_MAXRETRIES,
FL_TTL,
// short options
@ -26,8 +26,7 @@ struct option_lst {
};
struct option_lst *parse_options(int ac, char *const *av);
bool option_isset(const struct option_lst *options, e_flag flag);
char *get_option_arg(const struct option_lst *options, e_flag flag);
int parse_ports(const char *arg, uint16_t *start, uint16_t *end);
e_scantype parse_type(const char *arg);
void free_options(struct option_lst *options);
int parsing(struct scan *general, const struct option_lst *options);

View File

@ -3,6 +3,5 @@
#include "parsing.h"
#include "response.h"
void print_host_results(const char *ip_addr, const struct response *responses,
const struct option_lst *options, double scan_time);
void print_host_results(const struct scan *general, double scan_time);
void print_usage(void);

View File

@ -22,7 +22,6 @@ typedef enum {
};
struct response {
uint16_t port;
e_state states[SCAN_ALL];
char *service;
};

View File

@ -19,14 +19,15 @@ typedef enum {
};
struct scan {
const struct host *host;
const char *dest_addr;
struct host host;
char *dest_addr;
uint16_t port_start;
uint16_t port;
uint16_t port_end;
e_scantype type;
uint8_t ttl;
uint8_t max_retries;
struct response *response;
struct response *responses;
uint8_t nb_threads;
};
int scan(struct scan *data);

View File

@ -7,17 +7,4 @@
#include "response.h"
#include "scan.h"
struct thread {
uint16_t port_start;
uint16_t port_end;
char *dest_addr;
e_scantype type;
uint8_t max_retries;
uint8_t ttl;
struct host host;
struct response *responses;
};
void *routine(void *p_data);
int create_threads(const struct option_lst *options, char *ip_addr,
struct response *responses);
int create_threads(struct scan *general);