<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Advogato blog for fraggle</title>
    <link>http://www.advogato.org/person/fraggle/</link>
    <description>Advogato blog for fraggle</description>
    <language>en-us</language>
    <generator>mod_virgule</generator>
    <pubDate>Sun, 21 Mar 2010 22:07:09 GMT</pubDate>
    <item>
      <pubDate>Fri, 5 Feb 2010 14:03:36 GMT</pubDate>
      <title>Chocolate Doom on OS X, and GNUstep</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=61</link>
      <guid>http://fragglet.livejournal.com/18339.html</guid>
      <description>&lt;a href="http://www.chocolate-doom.org/" &gt;Chocolate Doom&lt;/a&gt; runs on Mac OS X and has done for several years; however, until now, getting it running has been overly complicated and required compiling the source code from scratch.  Obviously this isn't really appropriate for a Mac; it certainly doesn't fit in with the Apple way of doing things.  I recently set about trying to improve the situation.&lt;br /&gt;&lt;br /&gt;I first investigated how things are installed on OS X.  Generally speaking there are two ways that things are installed; the &lt;a href="http://en.wikipedia.org/wiki/Installer_(Mac_OS_X)" &gt;installer&lt;/a&gt; (.pkg files), and &lt;a href="http://en.wikipedia.org/wiki/Application_Bundle" &gt;Application Bundles&lt;/a&gt;, typically contained inside a .dmg archive.  The installer simply installs a bunch of files to your machine, while Application Bundles are a lot more fluid; to install, you simply drag an icon into the Applications folder.&lt;br /&gt;&lt;br /&gt;Application Bundles seem obviously preferable, but there's the problem of how one should be structured.  Chocolate Doom needs a Doom IWAD file that contains the data used by the game, so it's not sufficient to simply package the normal binary as a bundle. Then there's the setup tool as well - should that be in a separate bundle?  Finally, people often like to load PWAD files containing extra levels and mods.  How do you do that with a bundle?&lt;br /&gt;&lt;br /&gt;In the end, I decided to write a minimalist launcher program.  Everything is in a single bundle file which, when launched opens a launcher window.  The launcher allows the locations of the IWAD files to be configured and extra command line parameters entered.  There's also a button to open the setup tool.&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.chocolate-doom.org/wiki/images/5/5b/OS_X_Launcher.png"&gt;&lt;br /&gt;&lt;br /&gt;The launcher also sets up file associations when installed, so that it is possible to double-click a WAD file in the Finder, and an appropriate command line is constructed to load it.  The interface is not as fully-featured as other "launcher" programs are, but it's simple and I think fits with the philosophy of the project.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt; Developing with GNUstep &lt;/h3&gt;&lt;br /&gt;The interesting part is how I developed the launcher.  I only have occasional use of a Mac, so I developed it on &lt;a href="http://www.gnustep.org/" &gt;GNUstep&lt;/a&gt;.  This is an earlier version of the launcher interface while it was under development:&lt;br /&gt;&lt;img src="http://www.soulsphere.org/img/screenshots/gnustep-launcher.png"&gt;&lt;br /&gt;GNUstep provides an implementation of the same Objective C API that OS X's Cocoa provides, albeit with a rather crufty-looking &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/NeXTStep" &gt;NeXTStep&lt;/a&gt; appearance.  It also has &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/Gorm_(computing)" &gt;Gorm&lt;/a&gt;, which works in a very similar way to OS X's Interface Builder application.  Using GNUstep, I was able to mock up a working program relatively easy.  Constructing interfaces is very straightforward: the controls are simply dragged-and-dropped onto a window.  I was able to get the underlying code into a working state before porting to OS X.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt; Porting to OS X &lt;/h3&gt;&lt;br /&gt;Porting to OS X had some hassles.  Firstly, Gorm/GNUstep uses its own native format for interface files, which are different to the .nibs used on OS X.  Recent versions of Gorm can save .nibs, but I found that the program crashed when I tried to do this.  I eventually just reconstructed the whole interface from scratch in Interface Builder.  GNUstep can use .nibs, so I just threw the older Gorm interface away.&lt;br /&gt;&lt;a href="http://www.chocolate-doom.org/wiki/index.php/Image:OS_X_Launcher_GNUstep.png" &gt;&lt;img src="http://www.chocolate-doom.org/wiki/images/thumb/c/c7/180px-OS_X_Launcher_GNUstep.png"&gt;&lt;/a&gt;&lt;br /&gt;The other main annoyance was that the format for &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/Property_list" &gt;property lists&lt;/a&gt; is different on OS X.  It seems that GNUstep uses the older NeXT format, which Apple have since replaced with a newer XML-based format. Finally, icon files on OS X are in a proprietary .icns format, while GNUstep simply uses PNGs.&lt;br /&gt;&lt;br /&gt;Both OS X and GNUstep try to force you to use their build tools (Xcode, ProjectCenter) which seem to generate a whole load of junk.  I wrote a &lt;a href="http://chocolate-doom.svn.sourceforge.net/viewvc/chocolate-doom/trunk/chocolate-doom/pkg/osx/GNUmakefile" &gt;Makefile&lt;/a&gt; instead. There are some conditional parts to handle the two systems - OS X and GNUstep application bundles have different internal structures, for example.  On OS X, the Makefile will do the complete process of compiler code, constructing the application bundle and generating a .dmg archive.&lt;br /&gt;&lt;br /&gt;One thing I did find interesting is how OS X handles libraries.  The full paths to any .dylib libraries (which are like Linux .so files or Windows DLLs) are stored inside a program when it is compiled.  In my case, my application bundle needs to include the SDL libraries that Chocolate Doom depends upon.  There's a convenient program called &lt;a href="http://developer.apple.com/Mac/library/documentation/Darwin/Reference/ManPages/man1/install_name_tool.1.html" &gt;install_name_tool&lt;/a&gt; that can be used to change these paths after the program has been compiled.  A special macro called @executable_path can be used to mean "the path where this binary is".  I wrote a &lt;a href="http://chocolate-doom.svn.sourceforge.net/viewvc/chocolate-doom/trunk/chocolate-doom/pkg/osx/cp-with-libs" &gt;script&lt;/a&gt; to copy a program along with any libraries it depends on, changing its library search paths appropriately.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt; Thoughts on GNUstep &lt;/h3&gt;&lt;br /&gt;GNUstep was certainly incredibly useful in this activity; the ability to develop the program on my usual (Linux) laptop was very convenient.  From a technical perspective, GNUstep seems to be a very impressive project.  There is great usefulness in having a Linux implementation of the OPENSTEP (ie. Cocoa) API, which is what GNUstep is. However, the NeXT-style interface clashes horribly with almost any desktop environment that you might want to run under Linux (Gnome/KDE/etc), which is a huge turn-off.&lt;br /&gt;&lt;br /&gt;The main problems are (1) the mini-window icons (which represent the running application) and (2) the menus, which appear in a separate window to the other application windows.  I expect these are things that I could get used to if I was running a full GNUstep desktop where everything was like this; however, I'm not and it wouldn't really be practical for me to do so.  It is possible to theme GNUstep to look nicer than its default "ugly grey square" appearance, but these problem remain.&lt;br /&gt;&lt;br /&gt;GNUstep is a frustrating project in this respect. I can't help wonder if the full potential of the project is limited by the short-sightedness of its developers. It seems like they're too hung up on their goal of recreating NeXTstep, when I doubt there are many people who would even want to use such a system nowadays. &lt;a href="http://wiki.gnustep.org/index.php/Developer_FAQ#How_about_implementing_parts_of_the_Application_Kit_with_GTK.3F" &gt;This&lt;/a&gt; entry from the developer FAQ gives a good example of what I'm talking about:&lt;br /&gt;&lt;blockquote&gt;&lt;b&gt;How about implementing parts of the Application Kit with GTK?&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Yes and No - The GNUstep architecture provides a single, platform-independent, API for handling all aspects of GUI interaction (implemented in the gstep-gui library), with a backend architecture that permits you to have different display models (display postscript, X-windows, win32, berlin ...) while letting you use the same code for printing as for displaying. Use of GTK in the frontend gui library would remove some of those advantages &lt;b&gt;without adding any&lt;/b&gt;.&lt;/i&gt;&lt;/blockquote&gt;&lt;br /&gt;"Without adding any [advantages]" - except, of course, the ability to give GNUstep applications an appearance that is consistent with 99% of Linux desktops!  If it &lt;i&gt;was&lt;/i&gt; possible to use GNUstep to make applications that looked like Gtk+ apps, I bet it would be a lot more attractive to developers. The practical advantages of such a decision are dismissed completely in the face of architectural/technical advantages that probably have little practical use.</description>
    </item>
    <item>
      <pubDate>Thu, 10 Dec 2009 13:09:08 GMT</pubDate>
      <title>How to make a program just run</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=60</link>
      <guid>http://fragglet.livejournal.com/18071.html</guid>
      <description>Starting with Windows Vista, Windows limits the privileges that are given to normal users, running programs as the Administrator user only when necessary.  To smooth over the fact that  install programs for most software need to run as Administrator, it uses heuristics to detect whether a program is an installer.  One of these is to look at the file name - if it contains &amp;quot;setup&amp;quot; in the name (among others), it is treated as an installer.&lt;br /&gt;&lt;br /&gt;This is a problem if you develop &lt;a href="http://www.chocolate-doom.org/wiki/index.php/Textscreen" &gt;a program&lt;/a&gt; that is not an installer but has &amp;quot;&lt;a href="http://doom.wikia.com/wiki/Setup_program" &gt;setup&lt;/a&gt;&amp;quot; in the name, because Windows treats it as though it is an installer and prompts you for administrator privileges. &lt;br /&gt;&lt;br /&gt;&lt;h2&gt;User Account Control&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;The first problem is that it prompts the user for administrator privileges.  This is part of the &lt;a href="http://en.wikipedia.org/wiki/User_Account_Control" &gt;User Account Control&lt;/a&gt; system.  Fortunately, there's a way around this - it's possible to embed a special &amp;quot;manifest&amp;quot; XML file inside the EXE that tells Windows that Administrator privileges aren't necessary.&lt;br /&gt;&lt;br /&gt;Here's the magic manifest file to do this:&lt;blockquote&gt;&lt;pre&gt;

&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot;?&amp;gt;

&amp;lt;assembly xmlns=&amp;quot;urn:schemas-microsoft-com:asm.v1&amp;quot; manifestVersion=&amp;quot;1.0&amp;quot;&amp;gt;
  &amp;lt;!-- The &amp;quot;name&amp;quot; field in this tag should be the same as the executable's
       name --&amp;gt;
  &amp;lt;assemblyIdentity version=&amp;quot;0.0.0.0&amp;quot; processorArchitecture=&amp;quot;X86&amp;quot;
                    name=&amp;quot;chocolate-setup.exe&amp;quot; type=&amp;quot;win32&amp;quot;/&amp;gt;
  &amp;lt;trustInfo xmlns=&amp;quot;urn:schemas-microsoft-com:asm.v3&amp;quot;&amp;gt;
    &amp;lt;security&amp;gt;
      &amp;lt;requestedPrivileges&amp;gt;
        &amp;lt;requestedExecutionLevel level=&amp;quot;asInvoker&amp;quot; uiAccess=&amp;quot;false&amp;quot; /&amp;gt;
      &amp;lt;/requestedPrivileges&amp;gt;
    &amp;lt;/security&amp;gt;
  &amp;lt;/trustInfo&amp;gt;
&amp;lt;/assembly&amp;gt;
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;The important part here is the &amp;quot;requestedExecutionLevel&amp;quot; statement, that specifies to run the program as the invoker.  I think the &amp;quot;uiAccess&amp;quot; element is necessary as well.  I'm not entirely sure what this control does, and there are some people who say &lt;a href="http://blogs.msdn.com/cjacks/archive/2009/10/15/using-the-uiaccess-attribute-of-requestedexecutionlevel-to-improve-applications-providing-remote-control-of-the-desktop.aspx" &gt;it should be set to true&lt;/a&gt;.  However, it seems that if set to true, the executable has to be digitally signed with a certificate, which all looks like a massive hassle, so I've just left it turned off.&lt;br /&gt;&lt;br /&gt;The "assemblyIdentity" tag here matches the executable name, but I'm not sure it's actually necessary.  The version number is a dummy value.&lt;br /&gt;&lt;br /&gt;Embedding it inside an executable is a matter of writing a resource file containing a statement to include the manifest file.  Here's the magic statement for that:&lt;br /&gt;&lt;blockquote&gt;&lt;code&gt;1 24 MOVEABLE PURE &amp;quot;setup-manifest.xml&amp;quot;&lt;/code&gt;&lt;/blockquote&gt;&lt;br /&gt;The resource file is then compiled to a .o (using windres) and incorporated into the build.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Compatibility Assistant&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;So far, so good.  If the above is done properly, Windows won't prompt to run the program with administrator privileges any more.  However, that's not the end of the story.  Windows still thinks the program is an installer, just an installer that &lt;i&gt;doesn't need administrator privileges&lt;/i&gt;.  The next problem is the &amp;quot;Program Compatibility Assistant&amp;quot;.&lt;br /&gt;&lt;br /&gt;If your program exits without writing any files to disk (in Chocolate Setup, it's possible to quit without saving configuration file changes, for example), the compatibility assistant appears.  Because Windows thinks the program is an installer, and it hasn't written any files to disk, it assumes that something must have gone wrong with installation, and it might be a compatibility problem with a program designed for an older version of Windows.  The assistant is supposed to help you resolve the problems you've encountered.&lt;br /&gt;&lt;br /&gt;To work around this requires an addition to the manifest file to state that Vista (and Windows 7) are supported OSes; therefore, if no files are written, it's no problem.  Here's the new version of the manifest:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;yes&amp;quot;?&amp;gt;

&amp;lt;assembly xmlns=&amp;quot;urn:schemas-microsoft-com:asm.v1&amp;quot; manifestVersion=&amp;quot;1.0&amp;quot;&amp;gt;
  &amp;lt;!-- The &amp;quot;name&amp;quot; field in this tag should be the same as the executable's
       name --&amp;gt;
  &amp;lt;assemblyIdentity version=&amp;quot;0.0.0.0&amp;quot; processorArchitecture=&amp;quot;X86&amp;quot;
                    name=&amp;quot;chocolate-setup.exe&amp;quot; type=&amp;quot;win32&amp;quot;/&amp;gt;
  &amp;lt;trustInfo xmlns=&amp;quot;urn:schemas-microsoft-com:asm.v3&amp;quot;&amp;gt;
    &amp;lt;security&amp;gt;
      &amp;lt;requestedPrivileges&amp;gt;
        &amp;lt;requestedExecutionLevel level=&amp;quot;asInvoker&amp;quot; uiAccess=&amp;quot;false&amp;quot; /&amp;gt;
      &amp;lt;/requestedPrivileges&amp;gt;
    &amp;lt;/security&amp;gt;
  &amp;lt;/trustInfo&amp;gt;

&lt;b&gt;  &amp;lt;!-- Stop the Program Compatibility Assistant appearing: --&amp;gt;

  &amp;lt;compatibility xmlns=&amp;quot;urn:schemas-microsoft-com:compatibility.v1&amp;quot;&amp;gt;
    &amp;lt;application&amp;gt;
      &amp;lt;supportedOS Id=&amp;quot;{35138b9a-5d96-4fbd-8e2d-a2440225f93a}&amp;quot;/&amp;gt; &amp;lt;!-- 7 --&amp;gt;
      &amp;lt;supportedOS Id=&amp;quot;{e2011457-1546-43c5-a5fe-008deee3d3f0}&amp;quot;/&amp;gt; &amp;lt;!-- Vista --&amp;gt;
    &amp;lt;/application&amp;gt;
  &amp;lt;/compatibility&amp;gt; &lt;/b&gt;
&amp;lt;/assembly&amp;gt;
&lt;/pre&gt;&lt;/blockquote&gt;</description>
    </item>
    <item>
      <pubDate>Thu, 7 May 2009 12:08:38 GMT</pubDate>
      <title>Python's braindamaged scoping rules</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=59</link>
      <guid>http://fragglet.livejournal.com/17838.html</guid>
      <description>Python distinguishes between local and global variables from assignment statements.  If a variable is assigned within a function, that variable is treated as a local variable.  This means that you cannot do this:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
my_var = None

def set_my_var():
    my_var = "hello world"

set_my_var()
print my_var
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;As &lt;i&gt;my_var&lt;/i&gt; is assigned within the function, it is treated as a local variable that is separate to the global variable with the same name.  Instead, you have to explicitly tell the compiler that you want to assign the global variable, like this:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
my_var = None

def set_my_var():
    &lt;b&gt;global my_var&lt;/b&gt;
    my_var = "hello world"

set_my_var()
print my_var
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;This all strikes me as rather brain-damaged.  If assignments are used to detect the declaration of a variable, is it really so difficult to just examine the surrounding context to see if there is already a variable with the same name?</description>
    </item>
    <item>
      <pubDate>Thu, 30 Apr 2009 23:06:12 GMT</pubDate>
      <title>Creative defacement</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=58</link>
      <guid>http://fragglet.livejournal.com/17509.html</guid>
      <description>Something funny I saw attached to a sign on the car park down the road from my flat:&lt;br /&gt;&lt;br /&gt;&lt;a href="http://www.soulsphere.org/img/cctv-eyes.jpg" &gt;&lt;img src="http://www.soulsphere.org/img/cctv-eyes-small.jpg"&gt;&lt;/a&gt;</description>
    </item>
    <item>
      <pubDate>Fri, 20 Mar 2009 22:07:46 GMT</pubDate>
      <title>IPv6</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=57</link>
      <guid>http://fragglet.livejournal.com/17181.html</guid>
      <description>&lt;a href="" &gt;IPv6&lt;/a&gt; is something that I've been interested in for a while; I was even &lt;a href="http://www.soulsphere.org/hacks/ipv6/" &gt;employed&lt;/a&gt; to do some v6 porting work a few years ago.  Unfortunately, even though it's been several years and &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/IPv4_address_exhaustion" &gt;address exhaustion is rapidly approaching&lt;/a&gt;, uptake remains slow.&lt;br /&gt;&lt;br /&gt;As I see it there are several problems with IPv6 adoption:&lt;br /&gt;&lt;ol&gt;&lt;li&gt; Software doesn't support it&lt;br /&gt;&lt;li&gt; Hardware doesn't support it&lt;br /&gt;&lt;li&gt; ISPs don't provide it&lt;/ol&gt;&lt;br /&gt;As these go, (1) isn't actually that big a problem now.  A lot of the most important software already supports v6.  Ubuntu/Debian seems to just work with IPv6 (and presumably other Linux distributions as well), and even Windows supports it &lt;a href="http://www.microsoft.com/technet/network/ipv6/ipv6faq.mspx" &gt;as of Vista&lt;/a&gt;.  Software packages like Firefox work out of the box.&lt;br /&gt;&lt;br /&gt;(2) is still a big issue for a lot of hardware but I suspect that there's a lot of hardware now that supports it, but has it turned off (routers, etc).  (3) is simply a fact; I haven't heard of any ISPs supporting v6, and I suspect a lot of that is dependent on (2).&lt;br /&gt;&lt;h3&gt; 6to4 &lt;/h3&gt;&lt;br /&gt;&lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/6to4" &gt;6to4&lt;/a&gt; (not to be confused with&lt;br /&gt;&lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/6in4" &gt;6in4&lt;/a&gt; or&lt;br /&gt;&lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/6over4" &gt;6over4&lt;/a&gt;, thanks for the clear naming, guys), is in my opinion an excellent piece of engineering and exactly what is needed to fuel IPv6 adoption.  It solves the hardware/ISP problems by tunneling v6 traffic over v4; however, the clever part about it is that it does this without the need to register an account with a tunnel provider or explicitly configure it.  I first became aware of 6to4 when I heard that the Apple Extreme base station has it enabled by default, which I think demonstrates its potential; it's possible to circumvent the remaining hardware/ISP problems with IPv6 just by getting manufacturers of broadband routers to adopt 6to4.&lt;br /&gt;&lt;br /&gt;With 6to4, tunnels are made &lt;i&gt;opportunistically&lt;/i&gt; between v4 addresses, which means that if you have two machines using 6to4, they can communicate directly, without the overhead that routing through a third party would cause (If this sounds a bit pointless, consider that it means two machines both behind NAT gateways in the v4 world can have end-to-end connectivity&lt;br /&gt;in the v6 world). Any other v6 data is sent to a magic &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/Anycast" &gt;anycast&lt;/a&gt; address that automatically routes v6 data to the closest v6 gateway.&lt;br /&gt;&lt;br /&gt;With 6to4, a machine has an IPv6 address range that is derived from its public IPv4 address.  For example, if your IPv4 address is 1.2.3.4, your IPv6 subnet range is 2002:0102:0304::/48.  IPv6 traffic for that range automatically gets sent to that IPv4 address. What really happens&lt;br /&gt;is that your 6to4-enabled broadband router assigns addresses from this range to machines on your home LAN.&lt;br /&gt;&lt;h3&gt; Setting up 6to4 &lt;/h3&gt;&lt;br /&gt;My DSL router doesn't support 6to4; however, I managed to work around this. My router &lt;i&gt;does&lt;/i&gt; support port forwarding (actually, protocol forwarding in this case), and I have a Linux machine in my lounge that I use as a media centre/server.&lt;br /&gt;&lt;br /&gt;The first step was to set up a rule on the router to forward 6to4 data to the server machine.	I have a &lt;a href="http://corz.org/comms/hardware/router/bt.voyager.205_router.how-to.php" &gt;BT&lt;br /&gt;Voyager&lt;/a&gt; router which is helpfully quite flexible in this respect. 6to4 data is IP traffic with a protocol number of 41. From the router's command line interface, this did the job:&lt;br /&gt;&lt;blockquote&gt;&lt;tt&gt;&lt;br /&gt;create nat rule entry ruleid 41416 rdr prot num 41 lcladdrfrom 192.168.1.6 lcladdrto 192.168.1.6 &lt;br /&gt;&lt;/tt&gt;&lt;/blockquote&gt;&lt;br /&gt;It was then a case of configuring the server to do 6to4.  As it is running Ubuntu, I added this to &lt;tt&gt;/etc/network/interfaces&lt;/tt&gt;:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
iface tun6to4 inet6 v4tunnel
	address 2002:0102:0304::1
	netmask 16
	endpoint any
	local 192.168.1.6
	ttl 255
	remote 192.88.99.1
	post-up ip -6 route add 2000::/3 via ::192.88.99.1 dev tun6to4
	post-down ip -6 route flush dev tun6to4

auto tun6to4
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;A simple "&lt;tt&gt;sudo ifup tun6to4&lt;/tt&gt;" and the tunnel device should come up.  It should then be possible to ping IPv6 addresses:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
$ ping6 ipv6.google.com
PING ipv6.google.com(2001:4860:a003::68) 56 data bytes
64 bytes from 2001:4860:a003::68: icmp_seq=1 ttl=61 time=53.8 ms
64 bytes from 2001:4860:a003::68: icmp_seq=2 ttl=61 time=52.5 ms
64 bytes from 2001:4860:a003::68: icmp_seq=3 ttl=61 time=45.5 ms
64 bytes from 2001:4860:a003::68: icmp_seq=4 ttl=61 time=51.5 ms
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt; Routing &lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;At this point, the server has IPv6 connectivity, but what I really want is every machine on the network to have it.  So the next step is to set up the server as an IPv6 router.&lt;br /&gt;&lt;br /&gt;To do this, other machines need to know that the server is a router and acquire IPv6 addresses.  In IPv4, this is usually done with a &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/DHCP" &gt;DHCP server&lt;/a&gt; handing out addresses from a pool.  Instead, with IPv6, routers &lt;i&gt;advertise&lt;/i&gt; their address ranges, and the clients automatically construct an address.  This is possible because of the vast address range in IPv6.&lt;br /&gt;&lt;br /&gt;A package called &lt;tt&gt;radvd&lt;/tt&gt; (router advertisement daemon) sends router advertisements.  It's in the Debian package repository and very easy to configure.  This is my &lt;tt&gt;/etc/radvd.conf&lt;/tt&gt; file:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
interface eth0
{
	AdvSendAdvert on;
	prefix 2002:0102:0304:face::/64
	{
		AdvOnLink on;
		AdvAutonomous on;
		AdvRouterAddr on;
	};
};
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Notice that I've defined a subnet range for clients.  The address range given by 6to4 is 2002:0102:0304::/48, while radvd assigns addresses in the 2002:0102:0304:face::/64 range.  Next, I statically assign an address in this range in &lt;tt&gt;/etc/network/interfaces&lt;/tt&gt; by adding this:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
iface eth0 inet6 static
        address 2002:0102:0304:face::1
	netmask 64
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Now the router advertisements are handing out v6 addresses to other machines on the network, and the server has an address within the subnet range to communicate with them.  It's then just a matter of turning on routing.  Add this to &lt;tt&gt;/etc/sysctl.conf&lt;/tt&gt;:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
net.ipv6.conf.all.forwarding=1
net.ipv6.conf.default.forwarding=1
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;Or to make it take effect immediately:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
sudo sysctl net.ipv6.conf.all.forwarding=1
sudo sysctl net.ipv6.conf.default.forwarding=1
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;That's it!  Here's the output from &lt;tt&gt;ifconfig&lt;/tt&gt; on another machine on my network:&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;
wlan0     Link encap:Ethernet  HWaddr 00:1c:10:63:63:d0
          inet addr:192.168.1.25  Bcast:192.168.1.255  Mask:255.255.255.0
          &lt;b&gt;inet6 addr: 2002:0102:0304:face:21c:10ff:fe63:63d0/64 Scope:Global&lt;/b&gt;
          inet6 addr: fe80::21c:10ff:fe63:63d0/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7658 errors:0 dropped:0 overruns:0 frame:0
          TX packets:7228 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:4073660 (4.0 MB)  TX bytes:903010 (903.0 KB)
&lt;/pre&gt;&lt;/blockquote&gt;&lt;br /&gt;And here's Google IPv6:&lt;br /&gt;&lt;blockquote&gt;&lt;a href="http://www.soulsphere.org/img/screenshots/ipv6-google.png" &gt;&lt;br /&gt;&lt;img src="http://www.soulsphere.org/img/screenshots/ipv6-google-thumb.png"&gt;&lt;br /&gt;&lt;/a&gt;&lt;/blockquote&gt;&lt;br /&gt;Note that in the examples above, I've obscured my 6to4 address range to 2002:0102:0304::, to hide my IPv4 address, for privacy.  If you want to follow my instructions, this needs to be replaced with your own public IPv4 address.</description>
    </item>
    <item>
      <pubDate>Fri, 13 Feb 2009 13:08:15 GMT</pubDate>
      <title>Stock photos</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=56</link>
      <guid>http://fragglet.livejournal.com/16955.html</guid>
      <description>BBC News' obsession with filling their articles with stock photos that contain no relevant information is &lt;a href="http://news.bbc.co.uk/1/hi/technology/7887577.stm?lss" &gt;reaching absurd extremes&lt;/a&gt;.</description>
    </item>
    <item>
      <pubDate>Mon, 9 Feb 2009 02:09:25 GMT</pubDate>
      <title>"The Scene"</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=55</link>
      <guid>http://fragglet.livejournal.com/16701.html</guid>
      <description>&lt;a href="http://torrentfreak.com/someone-is-leaking-our-torrents-burn-him-090208/" &gt;An interesting article&lt;/a&gt; about "The Scene", describing the hypocritical stupidity of the pirate subculture.  I already experienced this nonsense first hand a while back when I &lt;a href="http://fragglet.livejournal.com/5067.html" &gt;dared to provide a well-reasoned criticism&lt;/a&gt; of the unnecessary use of spanning RAR files in BitTorrent downloads.  The irrational and angry flames that I received in response were a convincing demonstration of the absurd elitist mentality of these people.&lt;br /&gt;&lt;br /&gt;The ridiculous things that people can convince themselves of when they form into groups really are incredible.</description>
    </item>
    <item>
      <pubDate>Tue, 20 Jan 2009 02:05:00 GMT</pubDate>
      <title>ebay</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=54</link>
      <guid>http://fragglet.livejournal.com/16486.html</guid>
      <description>Buying things on eBay became more fun once I started &lt;a href="http://feedback.ebay.co.uk/ws/eBayISAPI.dll?ViewFeedback2&amp;amp;userid=fraggle_uk_uk&amp;amp;ftab=FeedbackLeftForOthers" &gt;getting creative&lt;/a&gt; with the feedback that I leave for people.</description>
    </item>
    <item>
      <pubDate>Mon, 19 Jan 2009 21:06:07 GMT</pubDate>
      <title>12 inch pianist</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=53</link>
      <guid>http://fragglet.livejournal.com/16374.html</guid>
      <description>&lt;a href="http://www.aarons-jokes.com/joke-168.shtml" &gt;For anyone who doesn't get&lt;/a&gt; &lt;a href="http://xkcd.com/532/" &gt;today's xkcd&lt;/a&gt; (I did, but there seem to be quite a few people who haven't heard that joke before).</description>
    </item>
    <item>
      <pubDate>Tue, 23 Dec 2008 01:04:22 GMT</pubDate>
      <title>The Buddha Lounge</title>
      <link>http://www.advogato.org/person/fraggle/diary.html?start=52</link>
      <guid>http://fragglet.livejournal.com/15872.html</guid>
      <description>The Indian restaurant opposite my house, which was called &lt;a href="http://www.natrajbalti.co.uk/Main/home/index.php" &gt;The Natraj&lt;/a&gt;, has reinvented itself as a trendy bar, called "The Buddha Lounge".  This is ironic on multiple levels.&lt;br /&gt;&lt;br /&gt;Firstly, the &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/Five_Precepts" &gt;Five precepts&lt;/a&gt; of Buddhism forbid the consumption of alcohol or intoxicating substances. Secondly, the more strict &lt;a href="https://secure.wikimedia.org/wikipedia/en/wiki/Eight_precepts#Eight_Precepts" &gt;Eight precepts&lt;/a&gt; encourage followers to abstain from music and dancing, and also from all sexual activity (and the main purpose of these types of bar is basically to find willing sexual partners).  Finally, followers also refrain from "luxurious places for sitting or sleeping", so even the "lounge" part is out.&lt;br /&gt;&lt;br /&gt;What's next, the Jesus Casino?</description>
    </item>
  </channel>
</rss>
