简体   繁体   中英

How to extract source and destination port number from packet in queue of iptables

I am using libnetfilter_queue library. But i couldn't figure out a way to extract port number in the call back function. I am bit new. A detailed help will be highly appreciated!

It can be done in the following manner, in the call back function:

len = nfq_get_payload(nfa, &buffer);
src_port = *((unsigned short*) (buffer + 20));
dst_port = *((unsigned short*) (buffer + 22));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM