Set pointer to TCP header in callback function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am stuck trying to access the TCP header from the callback function
of my nfq_q_handle.  I have packets coming in, and can access the IP
header without any problem, but I am not getting the correct TCP
destination port.  Here is the section of code I am having problems
with.  I am guessing I am setting the pointer tchp wrong.  I have done
this before in the kernel with sk_buffs, but the method for accessing
the TCP header was a little different.

struct iphdr *iph = NULL;
struct tcphdr *tcph = NULL;
int ret;
char *payload;

ret = nfq_get_payload(nfa, &payload);
if (ret >= 0)
	printf("payload_len=%d ", ret);

iph = (struct iphdr *) payload;
if ((iph->protocol == IPPROTO_TCP) ){
	printf("packet is a TCP packet\n ");
}

tcph = (struct tcphdr *) (((u_int32_t *)payload) + (iph->ihl * 4));
//this must initialize to the wrong byte
printf("iph length is %u\n",iph->ihl);  //this works
printf("dest port is %u\n",tcph->dest); //this displays the wrong ports
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux