hi,
here are a few problems about writing my own
SOCK_DGRAM packet on the link layer level.
(redhat 6.0)
the packet(7) page says..
"Packets sent through a SOCK_DGRAM packet socket get
a suitable physical layer header based on the
information
in the sockaddr_ll destination address before they
are
queued."
if i write a piece of code thus...
#include <stdio.h>
#include <sys/socket.h>
#include <errno.h>
#include <netinet/if_ether.h>
#include <linux/if_packet.h>
int main(void)
{
int s;
struct sockaddr_ll dstaddr;
char buff[10]="jamboree";
s = socket(PF_PACKET,SOCK_DGRAM,ETH_P_IP);
if (s < 0)
{
perror("socket");
return 1;
}
/* now fill up the sockaddr_ll to send */
memset(&dstaddr,0,sizeof(struct
sockaddr_ll));
dstaddr.sll_protocol=htons(ETH_P_IP);
dstaddr.sll_ifindex=0;
dstaddr.sll_hatype=ARPHRD_ETHER;
dstaddr.sll_pkttype=PACKET_OUTGOING;
dstaddr.sll_halen=ETH_ALEN; /* defined as 6 */
dstaddr.sll_addr[0]=0x00;
dstaddr.sll_addr[1]=0x10; /* the hw addr of the */
dstaddr.sll_addr[2]=0x4B; / * machine i want to
*/
dstaddr.sll_addr[3]=0x0E; / * send it to
*/
dstaddr.sll_addr[4]=0xEA;
dstaddr.sll_addr[5]=0x63;
if ( sendto(s,buff,sizeof(buff),0,(struct sockaddr
*)&dstaddr,sizeof(struct sockaddr_ll))<0)
{ perror("sendto");
return 1;
}
}
-----------------------------
on running it i get a 'device not configured' as the
sendto error.
i have an eth0 up.
i am specifying ETH_P_IP as my protocol in the socket
call, is it right?
what is ETH_P_802_3 used for?
the linux/if_ether.h file defines it as 'dummy type
for 802.3 frames'...
why the 'dummy'?
do i need to bind the socket to eth0 first?
even if the sendto is successful will the transmitted
packet show
in the TX packets on doing ifconfig?
how is PACKET_OTHERHOST different from the above?
thanks in advance,
sid
__________________________________________________
Do You Yahoo!?
Send online invitations with Yahoo! Invites.
http://invites.yahoo.com
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]