[fpc-pascal] TUN/TAP
Jorge Aldo G. de F. Junior
jagfj80 at gmail.com
Sat Oct 3 06:59:58 CEST 2009
Can anyone help me decypher the following code :
int tun_alloc(char *dev)
{
struct ifreq ifr;
int fd, err;
if( (fd = open("/dev/net/tun", O_RDWR)) < 0 )
return tun_alloc_old(dev);
memset(&ifr, 0, sizeof(ifr));
/* Flags: IFF_TUN - TUN device (no Ethernet headers)
* IFF_TAP - TAP device
*
* IFF_NO_PI - Do not provide packet information
*/
ifr.ifr_flags = IFF_TUN;
if( *dev )
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){
close(fd);
return err;
}
strcpy(dev, ifr.ifr_name);
return fd;
}
This is an example code found in TUN/TAP documentation. I need to do some
network diagnosing programs and i plan to use Freepascal to do the job.
Opening the TUN/TAP (/dev/net/tun) without the ioctl call is not doing the
job, but i dont know how to do this with pascal equivalent code...
Thanks in advance and sorry for any inconvenience...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20091003/6d72ad92/attachment.html>
More information about the fpc-pascal
mailing list