![]() |
| | #1 |
| Registered User Join Date: Dec 2009
Posts: 1
| Specific ether type with raw socket under linux 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: 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 |
| sinacbe is offline | |
| | #2 |
| Registered User Join Date: Dec 2009 Location: Henderson, NV
Posts: 887
| ndrv.h? Mate this looks like something that is Apple-specific; I (and probably anybody) can get you there using BSD sockets (which AFAIK OS/X supports) and is more portable than the Apple-specific API it seems like you are using...Google for Beej's Networking how-to and you will find a method that will/should work on both platforms but probably not Windows w/o a lot of #ifdefs to block out the platform-specific code...but now we are talking about a whole other discipline in code, cross-platform development which could fill volumes... Peace and Happy Holidays... J. |
| jeffcobb is offline | |
![]() |
| Thread Tools | |
| Display Modes | |
|
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to pass a matrix/array from main to a function | Inukami | C Programming | 7 | 12-09-2009 09:03 PM |
| LDAP Query | Travoiz | C++ Programming | 0 | 08-13-2009 02:58 PM |
| Question on l-values. | Hulag | C++ Programming | 6 | 10-13-2005 04:33 PM |
| Dynamic array of pointers | csisz3r | C Programming | 8 | 09-25-2005 02:06 PM |
| Problem with Visual C++ Object-Oriented Programming Book. | GameGenie | C++ Programming | 9 | 08-29-2005 11:21 PM |