Archive for December, 2004

Dynamic languages and C

Tuesday, December 21st, 2004

I’ve been tinkering about an idea for a while. It’s fairly easy given an API specification to write glue code so that you can call from your favourite dynamic language into C. Swig is a program that given an API will generate all the glue code you need to make that library available in a variety of langauges (python, perl, java, ruby, tcl, guile and heaps of others). The problem is you have to sit down and write this glue yourself. But do you? When compiled with debugging information C libraries all contain information about the types of all the symbols in the file. C++ is even easier, the name mangling standards provide all the type information you could ever want.

So, every so often I tinker around with writing a python library that will use pythons import hooks to let you import arbitary C libraries and call through transparently into the functions contained within. There are however several stumbling blocks.

First is that calling an arbitary C function is difficult. Oh sure dlsym(3) can return a pointer to whatever symbol you can care to name, but you still need a way of passing it arbitary parameters. gcc has __builtin_apply() but that seems uh quirky at best, and isn’t really designed with this in mind. Then, after that I’ve got to write something to parse .so files and read the stabs debugging information. Now I’m planning on doing this in python calling through to libbfd (which I can manually provide the symbol table and type information for).

Anyway, just my thoughts. Thought I should document them somewhere as I don’t think I’ve mentioned them here anywhere.

IPv6 and in Internet (again!)

Sunday, December 12th, 2004

This seems to be a regular topic for me, oh well. Anyway, I’ve not mentioned Teredo here before so I thought I really should mention it. Teredo is a nifty protocol that lets you get a realworld IPv6 address on a machine that is behind most common forms of NAT. Teredo means that even if you are behind a NAT box that doesn’t easily support uPNP or manual configuration is too hard, or too dynamic to be easily done, you can get a real world address (even if it is IPv6 only) and use that.

So why would you want a realworld IP address? Well, the major reasons are VoIP and P2P. If you have a realworld IP address then people can call you or you can more actively participate in a modern P2P network (where more active participation in usually rewarded with faster download speeds).

Teredo is trival to setup for the gazillions of Microsoft clients out there, all you need to do is type two commands at the command line (documented on the wlug wiki). From a programmer point of view it’s easy to use, all you need is to support IPv6. No platform specific API’s or anything, practically every machine worth mentioning supports IPv6 these days and the code isn’t hard to modify from IPv4 only to IPv6 capable.

So why aren’t people flocking all over Teredo and 6to4? Coz the clients don’t support it. I can’t fathom why they don’t support it, it should be a trivial thing for them to do and would bring huge advantages to them. If even Bittorrent supported IPv6 fully then there would be a way forward for people who are stuck behind NAT, and theres a possibility that >30% of the Internet traffic would be IPv6 today. Thats enough traffic for people to sit up and take notice and start getting serious about their IPv6 deployments. No more horrible tunnel brokers with uptime that makes a mole look positively high flying. No more routes crisscrossing the pacific (and sometimes the atlantic too).

Bittorrent seems to support IPv6 reasonably easily in the protocol, and the support is in some of the clients, but the trackers don’t support IPv6. And without the trackers to tell the other clients about IPv6 clients there is no IPv6 swarm. Sigh.

So one of my goals this summer is to get at least one tracker up and going with IPv6 support so we can experiment with Teredo and discover what the problems are, and so we can shine a torch out of the maze of limited IPv4 addresses and into the wide open expanse of IPv6 with no naive NAT gatekeepers.