- 论坛徽章:
- 0
|
关于mac层的socket!
其实我觉得你只要不设置混杂模式就行了啊。你肯定要用RAWsocket,肯定要用arp,这样不就没问题了。除了这个,其他的在你找到的资料里面肯定都说了。
建议你找个libnet的源码看看,人家里面处理的很好,给你贴一点:
#ifdef HAVE_SOLARIS
if (isatm) {
/*
** Have to turn on some special ATM promiscuous mode
** for SunATM.
** Do *NOT* turn regular promiscuous mode on; it doesn't
** help, and may break things.
*/
if (strioctl(p->;fd, A_PROMISCON_REQ, 0, NULL) < 0) {
snprintf(ebuf, PCAP_ERRBUF_SIZE, "A_PROMISCON_REQ: %s",
pcap_strerror(errno));
goto bad;
}
} else
#endif
if (promisc) {
/*
** Enable promiscuous
*/
if (dlpromisconreq(p->;fd, DL_PROMISC_PHYS, ebuf) < 0 ||
dlokack(p->;fd, "promisc_phys", (char *)buf, ebuf) < 0)
goto bad;
/*
** Try to enable multicast (you would have thought
** promiscuous would be sufficient). (Skip if using
** HP-UX or SINIX)
*/
#if !defined(__hpux) && !defined(sinix)
if (dlpromisconreq(p->;fd, DL_PROMISC_MULTI, ebuf) < 0 ||
dlokack(p->;fd, "promisc_multi", (char *)buf, ebuf) < 0)
fprintf(stderr,
"WARNING: DL_PROMISC_MULTI failed (%s)\n", ebuf);
#endif |
|