How to determine packet direction using libpcap?

2019-08-01 13:37发布

问题:

I am working on project using libpcap. Now, I need to know the direction of packet (inbound or outbound) once I got the packet in callback function. I am going to write the methods to compare IP and MAC address between client and these information extract from packet. Am I right?

Could you please help me some comments or advices on this problem?

Thank you for your time.

回答1:

The source or target IP address is sufficient. If the source is local, it's outbound. If the target is local, it's inbound. If neither, it's a promiscuous sniff.