Can anyone help me decypher the following code :<br><br><pre>int tun_alloc(char *dev)<br> {<br> struct ifreq ifr;<br> int fd, err;<br><br> if( (fd = open("/dev/net/tun", O_RDWR)) < 0 )<br> return tun_alloc_old(dev);<br>
<br> memset(&ifr, 0, sizeof(ifr));<br><br> /* Flags: IFF_TUN - TUN device (no Ethernet headers) <br> * IFF_TAP - TAP device <br> *<br> * IFF_NO_PI - Do not provide packet information <br>
*/ <br> ifr.ifr_flags = IFF_TUN; <br> if( *dev )<br> strncpy(ifr.ifr_name, dev, IFNAMSIZ);<br><br> if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){<br> close(fd);<br> return err;<br>
}<br> strcpy(dev, ifr.ifr_name);<br> return fd;<br> } <br></pre>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.<br>
<br>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...<br><br>Thanks in advance and sorry for any inconvenience...<br>