使用Winsock的原始以太网帧 [英] Raw Ethernet Frames Using Winsock

查看:78
本文介绍了使用Winsock的原始以太网帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将通信库从Linux移植到Windows.我知道我的方法大部分是什么.该库将所有原始以太网级别的帧用于所有通信.

I am porting a communications library from Linux to Windows. I know what my approach is for the most part. The library uses all raw ethernet level frames for all the communications.

我要从中移植的库使用PF_PACKET系列和struct sockaddr_ll.浏览 MSDN winsock 站点后,我还没有找到等效的 family/struct.我的方法应该在这里?

The library I am porting from makes use of the PF_PACKET family and the struct sockaddr_ll. After browsing through the MSDN winsock site, I haven't found an equivalent family/struct. What should my approach be here?

我有一些主意,但我不确定它们是否是好主意我可以使用PF_UNSPEC来进行指定.我可以传递PF_PACKET代表的数字(这是一个无符号的缩写)我也可以在Windows中创建自己的sockadddr_ll结构.

I have a few ideas, but I am not sure if they are good ideas I could use PF_UNSPEC, for unspecified. I could just pass the number PF_PACKET represents (it's an unsigned short) I could also just make my own sockadddr_ll struct in Windows.

这些想法对我来说似乎都不是好主意,它们只是看起来似乎不太可能奏效的骇客.

None of those ideas seem good to me, they just seem like hacks that aren't really likely to work.

如果有人有任何建议,我将不胜感激.

If anyone has any suggestions, I would appreciate it.

推荐答案

我假设您是指Raw Sockets(必须在其中编写网络层,传输层和应用程序层信息).Windows新版本(XP SP2及更高版本)对原始套接字的支持非常有限,但有很多限制.

I assume you're referring to Raw Sockets (where you have to write the network layer, transport layer, and application layer information). New Windows versions (XP SP2 and up) have very limited support for raw sockets with many restrictions.

更多信息(向下滚动至原始套接字限制")

More info (scroll down to "Limitations on Raw Sockets")

我认为,解决方案是使用 WinPcap ,它使您可以发送原始数据包.

The solution, I believe, is to use WinPcap, which allows you to send raw packets on those systems.

这篇关于使用Winsock的原始以太网帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆