fix: add the dest address to conn_addr (bozo)
This commit is contained in:
parent
1ffb554a32
commit
3213a56d1b
10
src/packet.c
10
src/packet.c
@ -95,11 +95,21 @@ static void *create_packet(const struct scan *data, size_t packet_size)
|
||||
int send_packets(const struct scan *data, int sockfd)
|
||||
{
|
||||
struct sockaddr_in conn_addr;
|
||||
conn_addr.sin_family = AF_INET;
|
||||
conn_addr.sin_addr.s_addr = inet_addr(data->dest_addr);
|
||||
|
||||
size_t packet_size = sizeof(struct iphdr) +
|
||||
(data->type == SCAN_UDP ? sizeof(struct udphdr)
|
||||
: sizeof(struct tcphdr));
|
||||
void *packet = create_packet(data, packet_size);
|
||||
|
||||
int one = 1;
|
||||
const int *val = &one;
|
||||
if (setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, val, sizeof(one)) < 0) {
|
||||
perror("Error setting IP_HDRINCL");
|
||||
return -1;
|
||||
}
|
||||
|
||||
sendto(sockfd, packet, packet_size, 0, (struct sockaddr *)&conn_addr,
|
||||
sizeof(struct sockaddr_in));
|
||||
free(packet);
|
||||
|
Loading…
Reference in New Issue
Block a user