Hi,
I have modified Erik Quanstrom's raw socket ethernet driver
for 9vx so that it uses the Linux kernel's "tap" device.
It seems to work just fine. I create the tap device first
using "tunctl" which comes with the Usermode Linux toolkit
but I don't think this is necessary.
Tully Gray.
ps: I am shadowdaemon on IRC.
12a13
> #include <linux/if_tun.h>
38d38
< int fd;
40a41
> int fd;
42c43
< if((fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))) < 0)
---
> if((fd = open("/dev/net/tun", O_RDWR)) < 0){
43a45,46
> }
>
45a49
> ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
47,55c51
< if(ioctl(fd, SIOCGIFINDEX, &ifr) < 0){
< close(fd);
< return -1;
< }
< memset(&sa, 0, sizeof sa);
< sa.sll_family = AF_PACKET;
< sa.sll_protocol = htons(ETH_P_ALL);
< sa.sll_ifindex = ifr.ifr_ifindex;
< if(bind(fd, (struct sockaddr*)&sa, sizeof sa) < 0){
---
> if(ioctl(fd, TUNSETIFF, &ifr) < 0){
61,71d56
< memset(&ifr, 0, sizeof ifr);
< strncpy(ifr.ifr_name, dev, sizeof ifr.ifr_name);
< if(ioctl(fd, SIOCGIFFLAGS, &ifr) < 0){
< close(fd);
< return -1;
< }
< ifr.ifr_flags |= IFF_PROMISC;
< if(ioctl(fd, SIOCSIFFLAGS, &ifr) < 0){
< close(fd);
< return -1;
< }
149c134
< 0x00, 0x48, 0x01, 0x23, 0x45, 0x61,
---
> // 0x00, 0x48, 0x01, 0x23, 0x45, 0x61,
158c143
< "eth1", "eth0", "eth2", "eth3", "eth4", "eth5",
---
> "tap0",