LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


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

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


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

Thanks,

SinaC
 
  


Reply


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

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

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

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