I am trying to change the IP header to include more IP parameters with libnetfiletr_queue. So far, I have managed to get to the point where I receive the package, as shown below.
if (nfq_set_mode(qh, NFQNL_COPY_PACKET, 0xffff) < 0) {
fprintf(stderr, "Unable to set nfq_set_mode\n");
exit(1);
}
Then I managed to go far, as shown below,
static int my_callBack(struct nfq_q_handle *qh, struct nfgenmsg *nfmsg,struct nfq_data *tb)
{
int id = 0;
int packet_len;
unsigned char *data;
struct nfqnl_msg_packet_hdr *packet_hdr;
unsigned char *data;
packet_hdr = nfq_get_msg_packet_hdr(tb);
if (packet_hdr) {
id = ntohl(packet_hdr->packet_id);
}
packet_len = nfq_get_payload(tb, &data);
if (packet_len >= 0) {
printf("payload_length = %d ", packet_len);
}
return nfq_set_verdict(qh, id, NF_ACCEPT, 0, NULL);
}
But from here I got a little confused about how to continue modifying the IP headercaptured packet in //modify packet ip headercomment.Example about modifying the IP header (e.g. traffic class (IPV6) / IP options / version / flags / destination address) is normal, since I only need to understand how modification works :).
I tried a lot of resources and could not achieve further success. You will be very grateful for the expert advice and help on this. :)
Many thanks:)