fix: struct were not passed correctly as the argument of *_response
This commit is contained in:
parent
675248cbff
commit
ad367d6792
14
src/scan.c
14
src/scan.c
@ -20,27 +20,31 @@ static void dispatch_callback(u_char *user, const struct pcap_pkthdr *h,
|
||||
const struct iphdr *iphdr =
|
||||
(struct iphdr *)(bytes + sizeof(struct ether_header));
|
||||
|
||||
printf("uwu\n");
|
||||
|
||||
if (iphdr->protocol == IPPROTO_TCP &&
|
||||
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
||||
sizeof(struct tcphdr)) {
|
||||
tcp_response(
|
||||
(const struct tcphdr *)(iphdr + sizeof(struct iphdr)),
|
||||
(const struct tcphdr *)(bytes +
|
||||
sizeof(struct ether_header) +
|
||||
sizeof(struct iphdr)),
|
||||
data);
|
||||
}
|
||||
if (iphdr->protocol == IPPROTO_UDP &&
|
||||
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
||||
sizeof(struct udphdr)) {
|
||||
udp_response(
|
||||
(const struct udphdr *)(iphdr + sizeof(struct iphdr)),
|
||||
(const struct udphdr *)(bytes +
|
||||
sizeof(struct ether_header) +
|
||||
sizeof(struct iphdr)),
|
||||
data);
|
||||
}
|
||||
if (iphdr->protocol == IPPROTO_ICMP &&
|
||||
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
||||
sizeof(struct icmphdr)) {
|
||||
icmp_response(
|
||||
(const struct icmphdr *)(iphdr + sizeof(struct iphdr)),
|
||||
(const struct icmphdr *)(bytes +
|
||||
sizeof(struct ether_header) +
|
||||
sizeof(struct iphdr)),
|
||||
data);
|
||||
}
|
||||
}
|
||||
|
@ -19,11 +19,11 @@ void *routine(void *p_data)
|
||||
port <= thread_data->port_end; port++) {
|
||||
scan_data.port = port;
|
||||
scan_data.response =
|
||||
&thread_data->responses[thread_data->port_start - port];
|
||||
&thread_data->responses[port - thread_data->port_start];
|
||||
if (scan(&scan_data))
|
||||
return NULL;
|
||||
printf("state of port %d: %d\n", port,
|
||||
scan_data.response->state);
|
||||
printf("%d: %s\n", port,
|
||||
scan_data.response->state == 1 ? "OPEN" : "CLOSED");
|
||||
}
|
||||
|
||||
return p_data;
|
||||
|
Loading…
Reference in New Issue
Block a user