IOReturn AgereET131x::setMulticastMode(bool active) { if( active ) { adapter.PacketFilter |= ET131X_PACKET_TYPE_MULTICAST; } else { adapter.PacketFilter &= ~(ET131X_PACKET_TYPE_MULTICAST|ET131X_PACKET_TYPE_ALL_MULTICAST); } set_packet_filter(); return kIOReturnSuccess; }
IOReturn AgereET131x::setPromiscuousMode(bool active) { if( active ) { adapter.PacketFilter |= ET131X_PACKET_TYPE_PROMISCUOUS; } else { adapter.PacketFilter &= ~ET131X_PACKET_TYPE_PROMISCUOUS; } set_packet_filter(); return kIOReturnSuccess; }
int setup_packet_capture(struct producer_config *pc, const char* device, const char* filter){ if(init_pcap_interface(&pc->pcap, device) != 0){ fprintf(stderr, "error initializing packet capture interface!\n"); return -1; } if(open_pcap_interface(&pc->pcap) != 0){ fprintf(stderr, "error opening packet capture interface!\n"); return -1; } (void)setgid(getgid()); (void)setuid(getuid()); if(set_packet_filter(&pc->pcap, filter) != 0){ fprintf(stderr, "error setting packet filter!\n"); return -1; } return 0; }
IOReturn AgereET131x::setMulticastList(IOEthernetAddress * addrs, UInt32 count) { UINT32 PacketFilter = 0; IOSimpleLockLock( adapter.Lock ); /************************************************************************** Before we modify the platform-independent filter flags, store them locally. This allows us to determine if anything's changed and if we even need to bother the hardware *************************************************************************/ PacketFilter = adapter.PacketFilter; /************************************************************************** Clear the 'multicast' flag locally; becuase we only have a single flag to check multicast, and multiple multicast addresses can be set, this is the easiest way to determine if more than one multicast address is being set. *************************************************************************/ PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST; /************************************************************************** Check the net_device flags and set the device independent flags accordingly *************************************************************************/ if( count > NIC_MAX_MCAST_LIST ) { adapter.PacketFilter |= ET131X_PACKET_TYPE_ALL_MULTICAST; } else if( count < 1 ) { adapter.PacketFilter &= ~ET131X_PACKET_TYPE_ALL_MULTICAST; adapter.PacketFilter &= ~ET131X_PACKET_TYPE_MULTICAST; } else { /************************************************************************** Set values in the private adapter struct *************************************************************************/ adapter.MCAddressCount = count; for( UInt32 k = 0; k < count; k++ ) { bcopy( addrs[k].bytes, adapter.MCList[k], ETH_ALEN ); } } /************************************************************************** Are the new flags different from the previous ones? If not, then no action is required NOTE - This block will always update the MCList with the hardware, even if the addresses aren't the same. *************************************************************************/ if( PacketFilter != adapter.PacketFilter ) { /********************************************************************** Call the device's filter function *********************************************************************/ set_packet_filter(); } IOSimpleLockUnlock( adapter.Lock ); return kIOReturnSuccess; }