fix: struct were not passed correctly as the argument of *_response

This commit is contained in:
0x35c 2025-05-26 16:01:49 +02:00
parent 675248cbff
commit ad367d6792
2 changed files with 12 additions and 8 deletions

View File

@ -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);
}
}

View File

@ -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;