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 =
|
const struct iphdr *iphdr =
|
||||||
(struct iphdr *)(bytes + sizeof(struct ether_header));
|
(struct iphdr *)(bytes + sizeof(struct ether_header));
|
||||||
|
|
||||||
printf("uwu\n");
|
|
||||||
|
|
||||||
if (iphdr->protocol == IPPROTO_TCP &&
|
if (iphdr->protocol == IPPROTO_TCP &&
|
||||||
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
||||||
sizeof(struct tcphdr)) {
|
sizeof(struct tcphdr)) {
|
||||||
tcp_response(
|
tcp_response(
|
||||||
(const struct tcphdr *)(iphdr + sizeof(struct iphdr)),
|
(const struct tcphdr *)(bytes +
|
||||||
|
sizeof(struct ether_header) +
|
||||||
|
sizeof(struct iphdr)),
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
if (iphdr->protocol == IPPROTO_UDP &&
|
if (iphdr->protocol == IPPROTO_UDP &&
|
||||||
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
||||||
sizeof(struct udphdr)) {
|
sizeof(struct udphdr)) {
|
||||||
udp_response(
|
udp_response(
|
||||||
(const struct udphdr *)(iphdr + sizeof(struct iphdr)),
|
(const struct udphdr *)(bytes +
|
||||||
|
sizeof(struct ether_header) +
|
||||||
|
sizeof(struct iphdr)),
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
if (iphdr->protocol == IPPROTO_ICMP &&
|
if (iphdr->protocol == IPPROTO_ICMP &&
|
||||||
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
h->caplen >= sizeof(struct ether_header) + sizeof(struct iphdr) +
|
||||||
sizeof(struct icmphdr)) {
|
sizeof(struct icmphdr)) {
|
||||||
icmp_response(
|
icmp_response(
|
||||||
(const struct icmphdr *)(iphdr + sizeof(struct iphdr)),
|
(const struct icmphdr *)(bytes +
|
||||||
|
sizeof(struct ether_header) +
|
||||||
|
sizeof(struct iphdr)),
|
||||||
data);
|
data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,11 +19,11 @@ void *routine(void *p_data)
|
|||||||
port <= thread_data->port_end; port++) {
|
port <= thread_data->port_end; port++) {
|
||||||
scan_data.port = port;
|
scan_data.port = port;
|
||||||
scan_data.response =
|
scan_data.response =
|
||||||
&thread_data->responses[thread_data->port_start - port];
|
&thread_data->responses[port - thread_data->port_start];
|
||||||
if (scan(&scan_data))
|
if (scan(&scan_data))
|
||||||
return NULL;
|
return NULL;
|
||||||
printf("state of port %d: %d\n", port,
|
printf("%d: %s\n", port,
|
||||||
scan_data.response->state);
|
scan_data.response->state == 1 ? "OPEN" : "CLOSED");
|
||||||
}
|
}
|
||||||
|
|
||||||
return p_data;
|
return p_data;
|
||||||
|
Loading…
Reference in New Issue
Block a user