[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Re: tun/tap OS X for tunneling

From: Mark Kuhr
Subject: Re: [Discuss-gnuradio] Re: tun/tap OS X for tunneling
Date: Sat, 10 Jan 2009 16:40:36 -0600

I've got a small update on this.

To read the tap devices on OS X, just issue the os.open command.

self.tap_fd = os.open("/dev/tap0", os.O_RDWR)

Once this open is completed, you can setup the interface with ifconfig. Spawning this off into a subprocess with popen works well inside the script.

To write to the tap device, just use os.write(self.tap_fd,DATA)

The ioctl command is challenging since it is implemented differently as previously discussed. The request constant (second argument) used by the osxtuntap kernel extensions are different from Linux. Two request constants are used and defined as follows:

#define TUNSIFHEAD _IOW('t', 96, int)
#define TUNGIFHEAD _IOR('t', 97, int)

Translated they become the following:

TUNSIFHEAD = 2147775584
TUNGIFHEAD = 1074033761

So, in tunnel.py, you can modify the ioctl command to be as follows on os x and it should not crash.

ifs = ioctl(tun, TUNSIFHEAD, struct.pack("16sH", "gr%d", mode))

I think it is possible to create a cross-platform abstraction of this functionality that manages the differences between the OSs. Maybe a tun/tap module that is part of gnuradio, however the reliance on external pieces such as the os x tun tap kernel extensions could be problematic. Might want to roll that into the code base as well to maintain some control of the versioning.

On Jan 6, 2009, at 12:00 PM, Eric Blossom wrote:

On Tue, Jan 06, 2009 at 09:52:14AM -0800, Johnathan Corgan wrote:
On Tue, Jan 6, 2009 at 8:59 AM, Ed Criscuolo
<address@hidden> wrote:

There also seems to be a fundamental difference between the
way the TUN/TAP driver works on the two OS's.

Ah, then it's not so easy.  It would be very useful to GNU Radio to
have a cross-platform implementation of this functionality, written in
C++, that abstracts the differences and presents a simple
write/callback API.  I've written a TAP/TUN mblock that has the right
C++ guts that could be extracted and reused, but it would still have
the same problem on OS X.


IIRC there was a discussion about an OS neutral wrapper for tap/tun
several months back.   I don't remember any solution being found,
proposed or built.


Discuss-gnuradio mailing list

reply via email to

[Prev in Thread] Current Thread [Next in Thread]