> hi there!
> 
> can anybody here tell me how can i send and receive ethernet packets
> directly on layer 2 under linux? 

I'm not an expert on the subject, so i can't say if you are looking at
your problem in a sensible way, but i am using the following to open
a socket for reading packets from an ethernet i/f. So far as i know this
is fairly non-portable! :)

MJW.

> int fd;
> struct ifreq netintreq;
> 
> if ((fd = socket(AF_INET, SOCK_PACKET, htons(ETH_P_ALL))) < 0) {
>   perror("cant get SOCK_PACKET socket");
>   return(-1);
> }
> 
> strcpy(netintreq.ifr_name, ethnetintname);
> if (ioctl(fd, SIOCGIFFLAGS, &netintreq) < 0) {
>   close(fd);
>   perror("cant get flags");
>   return(-1);
> }
> 
> netintreq.ifr_flags |= IFF_PROMISC;
> if (ioctl(fd, SIOCSIFFLAGS, &netintreq) < 0)
>   perror("cant set promiscuous mode");

-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to [EMAIL PROTECTED]

Reply via email to