简体   繁体   English

如何从C中的数据包头数据中获取参与ARP的计算机的MAC和IP地址?

[英]How can I obtain the MAC and IP addresses of a machine participating in ARP from the packet header data in C?

Thanks for reading, 谢谢阅读,

I'm in the midst of a homework assignment in which I need to, among other things, determine the MAC and IP addresses of a remote machine based on the captured packets I have. 我正在进行一项家庭作业,除其他事项外,我需要根据捕获的数据包确定远程计算机的MAC和IP地址。 Using the pcap_loop function, I need to find the location of the proper struct (an ARP header which gives this information) relative to the pointer to the start of the packet (which is given as a u_char* in my callback function). 使用pcap_loop函数,我需要找到相对于数据包开头的指针(在我的回调函数中以u_char *形式给出)的正确结构(提供此信息的ARP头)的位置。

I haven't been able to find information online on how to obtain a struct, such as ether_arp, which has the addresses, in relation to the packet. 我还无法在线找到有关如何获取结构的信息,例如具有与数据包相关的地址的ether_arp。 It would be incredibly helpful if you could point me in the right direction - as I mentioned, this is homework, so I'm not looking for a complete answer. 如果您能为我指明正确的方向,那将非常有用-正如我所提到的,这是家庭作业,因此我不需要完整的答案。

Thanks again for your help! 再次感谢你的帮助!

This article "http://en.wikipedia.org/wiki/Address_Resolution_Protocol" tells the layout of an ARP message. 本文“ http://zh.wikipedia.org/wiki/Address_Resolution_Protocol”介绍了ARP消息的布局。 You don't need a structure, just use offsets. 您不需要结构,只需使用偏移量即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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