I have this code in this website :
// Retrieve packet payload
size = nfq_get_payload(nfa, &full_packet);
// Get IP addresses in char form
ip = (struct iphdr *) full_packet;
strcpy (src_ip_str, inet_ntoa(ipa));
strcpy (dst_ip_str, inet_ntoa(ipa));
fprintf(stdout, "Source IP: %s Destination IP: %s\n", src_ip_str, dst_ip_str);
We can retrive the ip address and print them to terminal.
This code uses libnetfilter_queue library to work with packets.
By the nfq_get_payload(nfa, &full_packet) we have the IP header with TCP header alonge with data(application data) in "full_packet" struct
and now i don't know how can i get or retrive TCP ports ????