Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 12-21-2009, 09:04 AM   #1
LQ Newbie
Registered: Dec 2009
Posts: 1

Rep: Reputation: 0
How to specify ether type with raw socket

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:
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.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*/
What would be the equivalent under Linux ?




Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
raw socket programming bigboss360 Linux - Networking 2 10-17-2009 09:11 AM
Raw Socket Forwarding robtard Programming 1 05-05-2009 06:34 AM
A packet filter using libipq which uses ether type field to capture the packet can26_manish Programming 2 10-16-2007 05:35 AM
Raw Socket Programing djgerbavore Programming 2 08-18-2004 12:58 PM
Socket Raw linuxanswer Programming 1 04-01-2004 09:43 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:51 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration