What is the difference between sending IP packets (from user-space) to a tun device and using a raw socket?
For the purpose of tunneling IP packets through user-space. Why would I use one method over the other?
raw socket:
s = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
send(s, ip_pkt, len, 0);
tun device:
struct ifreq ifr;
fd = open("/dev/net/tun", O_RDWR);
ifr.ifr_flags = IFF_TUN;
ioctl(fd, TUNSETIFF, (void *) &ifr)
send(s, ip_pkt, len, 0);