Hi..
I think you're saying "SOCK_PACKET" not "SOCKET_PACKET".
In my understanding, SOCK_PACKET is not a new one.
Linux has supported SOCK_PACKET socket type which you states.
This is a part of "linux/include/asm-i386/socket.h" file.
#define SOCK_PACKET 10 /* linux specific way of */
/* getting packets at the dev */
/* level. For writing rarp and */
/* other similar things on the */
/* user level. */
You can use this socket just like any other socket.
Here is an example which send "Gratuitous ARP" directly data link layer.
This is a part of implementation of Mobile IP(Binghamton University)
Hope this helpful :-)
void
send_gratarp (char *device, u_long ipaddr, char *hwaddr, u_long destipaddr)
{
char frame[60];
struct ethhdr *ehdr;
Arphdr *ahdr;
int sockid;
struct sockaddr sa;
if ((sockid = socket (AF_INET, SOCK_PACKET, htons (ETH_P_802_3))) < 0)
{
perror ("Socket call failed in send_gratarp():");
return;
}
bzero ((void *) frame, sizeof (frame));
/* Ethernet header */
ehdr = (struct ethhdr *) frame;
hwaddread (ehdr->h_dest, "ff:ff:ff:ff:ff:ff");
bcopy (hwaddr, ehdr->h_source, 6);
ehdr->h_proto = htons (ETH_P_ARP);
ahdr = (Arphdr *) (frame + sizeof (struct ethhdr));
/* Arp header */
ahdr->ar_hrd = htons (ARPHRD_ETHER);
ahdr->ar_pro = htons (ETH_P_IP);
ahdr->ar_hln = 6;
ahdr->ar_pln = 4;
ahdr->ar_op = htons (ARPOP_REQUEST);
bcopy (hwaddr, ahdr->ar_sha, 6);
bcopy (&ipaddr, ahdr->ar_sip, 4);
bzero (ahdr->ar_tha, 6);
bcopy (&ipaddr, ahdr->ar_tip, 4);
sa.sa_family = AF_INET;
strcpy (sa.sa_data, device);
if (sendto (sockid, frame, sizeof (frame), 0, &sa, sizeof (sa)) < 0)
{
perror ("Sendto failed:");
exit (-1);
}
}
Regards
Chae-yong
----- Original Message -----
From: Anurag
To: [EMAIL PROTECTED]
Sent: Tuesday, August 21, 2001 10:54 PM
Subject: query
hi alex
I have one query .
"The Linux support new socket type ,SOCKET_PACKET ,That provides access to data link
,similar to DLPI.
I want to know how application communicates directly with the data link layer ,Is
there any special functions and data structures?
thanks.
RESPECT OTHER'S ,U'LL GET RESPECT
Anurag Uxa
IWave Embedded Systems
Bangalore India
PH:6786243/5 Extn:206
--------------------------------------------------------------------
IETF IPng Working Group Mailing List
IPng Home Page: http://playground.sun.com/ipng
FTP archive: ftp://playground.sun.com/pub/ipng
Direct all administrative requests to [EMAIL PROTECTED]
--------------------------------------------------------------------