如何在 SOCK_PACKET 套接字上发送数据而不指定它绑定到哪个主机?我已经构建了 IP 标头以显示它应该去哪里,但是 write() 不起作用。
问问题
5155 次
1 回答
2
Don't. use write(), use sendto().
If you use PF_PACKET,SOCK_DGRAM, then it builds the link-layer headers for you, which is normally what you want. You still need to build whatever higher protocol you are using on top though.
You specify a sockaddr_ll in the destination parameter. You can specify a link-layer unicast address, multicast address or broadcast address.
于 2009-08-23T20:05:25.190 回答