Networking Forums

Networking Forums > Computer Networking > Linux Networking > ioctl() call with a raw socket???

Reply
Thread Tools Display Modes

ioctl() call with a raw socket???

 
 
john.chludzinski@gmail.com
Guest
Posts: n/a

 
      03-28-2006, 11:11 PM
I'm trying to use the code fragment below in a simple experiment to
attach a raw socket to a network device (card) and read the incoming
MAC packets (frames). But all I get is: Line: 41, Error: Invalid
argument, on the call to ioctl(...). I assume this is in reference to
the request argument: SIOCSIFNAME. Having looked thru
/usr/include/bits/ioctls.h there doesn't appear to be a valid
alternative (even though I've tried quite a few with the same result).

Suggestions?

Thanks, John

----------------------------------------------------------------------------------------------------------------------------------------------

struct ifreq ifrequest;

if ( sock = socket( PF_PACKET, SOCK_RAW, htons( ETH_P_IP ) ) == -1)
{
fprintf( stderr, "Line: %i, Error: %s\n", __LINE__, strerror( errno));
return -1;
}

/* binding device to raw socket */
strncpy( ifrequest.ifr_name, "eth0", sizeof( ifrequest.ifr_name ));

if ( ioctl( sock, SIOCSIFNAME, &ifrequest ) == -1)
{
fprintf( stderr, "Line: %i, Error: %s\n", __LINE__, strerror( errno));
return -1;
}

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
socket call does not read full content jainarunk@gmail.com Linux Networking 6 07-22-2006 10:53 PM
socket read modifies third parameter after the call: Very strange jainarunk@gmail.com Linux Networking 1 07-20-2006 09:15 PM
Call abroad for the price of a national call bbp Broadband 2 10-23-2003 11:02 PM
ioctl(SIOCGIFCONF) AW Linux Networking 1 09-23-2003 10:04 AM
Obtaining interface information via an ioctl call Will Linux Networking 0 06-25-2003 04:26 PM



1 2 3 4 5 6 7 8 9 10 11