Networking Forums

Networking Forums > Computer Networking > Linux Networking > Problem using sendto(...) with packet sockets?

Reply
Thread Tools Display Modes

Problem using sendto(...) with packet sockets?

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

 
      05-14-2008, 03:13 PM
I tried the code below and while sendto(...) sends the data contained
in buf, the 'to' address seems to be ignored. As a consequence the
source and destination addresses + the packet type are taken to be the
first 14 bytes of buf, resulting in a gibberish message. What's up?
---jski

struct sockaddr_ll to;
int tolen;
char buf[ 512 ];

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

memset( &to, 0, sizeof( to ) );
for ( i = 0; i < 6; i++ ) to.sll_addr[ i ] = 0xff;
to.sll_family = AF_PACKET;
to.sll_ifindex = ifr.ifr_ifindex;
to.sll_protocol = GEOCAST;
tolen = sizeof( to );

for ( i = 0; i < 512; i++ ) buf[ i ] = (unsigned char) i;

size = sendto( s, buf, 512, 0, (const struct sockaddr *)&to,
tolen );
 
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
how to modify the contents of a TCP/IP packet before it is delivered? Can this be done with ip helper api, can it be done with sockets? I can't seem to find any documentation on how to modify packets before they are delivered. dr Windows Networking 0 07-18-2007 04:36 AM
Why failing sendto/send transmit complete datagram/packet anyway?? maruk2@hotmail.com Linux Networking 0 06-14-2007 06:13 PM
Problem with sockets Andrea Sini Linux Networking 6 02-04-2005 11:14 PM
Problem - Home network using house phone sockets. David Jones Home Networking 9 08-06-2004 10:20 PM
Problem while creating two different sockets. Rajat Linux Networking 0 05-19-2004 12:38 PM



1 2 3 4 5 6 7 8 9 10 11