Hello,
I'm trying to specify ether type when opening a raw socket. I've already done it under Windows and MacOSX but dunno how to do it under Linux.
Under MacOSX, I'm using:
What would be the equivalent under Linux ?Code:struct ndrv_protocol_desc desc; struct ndrv_demux_desc demux_desc[1]; /*... some code to create the socket and bind the socket to the selected network interface ...*/ bzero(&desc, sizeof(desc)); bzero(&demux_desc, sizeof(demux_desc)); desc.version = NDRV_PROTOCOL_DESC_VERS; desc.protocol_family = NDRV_DEMUXTYPE_ETHERTYPE; desc.demux_count = (u_int32_t)1; desc.demux_list = (struct ndrv_demux_desc*)&demux_desc; demux_desc[0].type = NDRV_DEMUXTYPE_ETHERTYPE; demux_desc[0].length = sizeof(demux_desc[0].data.ether_type); demux_desc[0].data.ether_type = MY_ETHER_TYPE; if (setsockopt( fd, SOL_NDRVPROTO, NDRV_SETDMXSPEC, (caddr_t)&desc, sizeof(desc))) { /*failed, perform some cleanup and leave function*/ } /*succeed, get mac address and other stuff then leave function*/
Thanks,
SinaC



LinkBack URL
About LinkBacks


