<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>shapeshifter.se &#187; FreeBSD</title>
	<atom:link href="http://www.shapeshifter.se/category/freebsd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shapeshifter.se</link>
	<description>Mostly miscellaneous technical mumbo-jumbo.</description>
	<lastBuildDate>Mon, 11 Jul 2011 14:19:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>uhso(4): Option HSDPA driver for FreeBSD 8</title>
		<link>http://www.shapeshifter.se/2009/07/20/uhso4-option-hsdpa-driver-for-freebsd-8/</link>
		<comments>http://www.shapeshifter.se/2009/07/20/uhso4-option-hsdpa-driver-for-freebsd-8/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 14:52:54 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[hsdpa]]></category>
		<category><![CDATA[hso]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=633</guid>
		<description><![CDATA[
A bit late, but here is the first beta of the Option HSDPA driver for FreeBSD 8. It&#8217;s more or less completely rewritten and there are some visible changes to the interface.
Because ucom(4) has matured it can now be utilized instead of mucking around directly with the TTY layer. This results in that the device [...]]]></description>
			<content:encoded><![CDATA[<p><!-- WSA: rules for context 'adsense-post-top' did not apply --></p>
<p>A bit late, but here is the first <strong>beta</strong> of the Option HSDPA driver for FreeBSD 8. It&#8217;s more or less completely rewritten and there are some visible changes to the interface.</p>
<p>Because ucom(4) has matured it can now be utilized instead of mucking around directly with the TTY layer. This results in that the device names in /dev has changed and are now longer called /dev/HSO*, instead they follow the standard ucom names of cuaU*.</p>
<p>The new USB stack attach USB devices per USB interface instead of per USB device, so it&#8217;s possible to get both a cuaU0 and cuaU1 device (instead of just cuaU0.0 and cuaU0.1). The number of found serial ports can be read through sysctl.</p>
<p>The packet interface is now exposed as a raw interface instead of emulating an Ethernet device (I seriously wonder why I did that&#8230;).</p>
<p>The driver switches automatically from install-cd mode to modem mode, there is no longer any need for manual switching through devd. Please remove the option-icon.conf file from your /usr/local/etc/devd directory.<br />
This can be disabled by setting hw.usb.uhso.auto_switch to 0</p>
<p>And last, I&#8217;ve renamed the driver to uhso to reflect its USB nature.</p>
<p>Download: <a href="/pub/hso/uhso-20091122.tar.gz">uhso-20091122.tar.gz</a> &#8211; Add support for iCON 505, fix probing of devices with dynamic number of interfaces, add new custom attach messages based on the port type.</p>
<p>Download: <a href="/pub/hso/uhsoctl-beta-20090820.tar.gz">uhsoctl-beta-20090820.tar.gz</a> &#8211; uhsoctl connection utility, similar to old hsoctl</p>
<p><span style="text-decoration: line-through;">Download: <a href="/pub/hso/uhso-beta-20090812.tar.gz">uhso-beta-20090812.tar.gz</a></span> &#8211; Minor bug fix and reworked sysctl nodes.</p>
<p><span style="text-decoration: line-through;">Download: <a href="/pub/hso/uhso-beta-20090723.tar.gz">uhso-beta-20090723.tar.gz</a></span> &#8211; No longer PTP interface (completely useless), fixed (hopefully) CDC notification on modem port, added several new device IDs. Thanks to Iain Hibbert for this!</p>
<p><span style="text-decoration: line-through;">Download: <a href="/pub/hso/uhso-beta-20090722.tar.gz">uhso-beta-20090722.tar.gz</a></span> &#8211; Bug fixes that should improve RX speed.</p>
<p><span style="text-decoration: line-through;">Download: <a href="/pub/hso/uhso-beta-20090720.tar.gz">uhso-beta-20090720.tar.gz</a></span></p>
<p><strong>If you own an Option device, please leave a comment (or send a mail) with its full name and USB device ID.</strong></p>
<p><strong>I&#8217;m particularly interested in the following devices iCON 031, iCON 210, iCON 315, iCON 322, iCON 401, iCON 431, iCON 451, iCON 452, iCON 505.</strong></p>
<p><strong>If you&#8217;re running FreeBSD 8 and own an Option device, please mail me the output of<br />
</strong></p>
<blockquote>
<pre>usbconfig -u X -a Y dump_device_desc
usbconfig -u X -a Y dump_all_config_desc</pre>
</blockquote>
<p>where X and Y (5 and 2 below) can be obtained through usbconfig</p>
<blockquote>
<pre># usbconfig
...
ugen5.2: &lt;Globetrotter HSDPA Modem Option N.V.&gt; at usbus5, cfg=0 md=HOST spd=FULL (12Mbps) pwr=ON</pre>
</blockquote>
<p><strong>This driver has been tested with a Globesurfer iCON 7.2, iCON 255, iCON 505<br />
</strong></p>
<p><strong>Quick setup for manual connection</strong><br />
<em>uhsoctl works as before!</em></p>
<p>Look up the serial ports</p>
<blockquote>
<pre># sysctl dev.uhso
dev.uhso.0.netif: uhso0
dev.uhso.0.type: Network/Serial
dev.uhso.0.ports: 2
dev.uhso.0.port.control.tty: cuaU0.0
dev.uhso.0.port.control.desc: Control
dev.uhso.0.port.application.tty: cuaU0.1
dev.uhso.0.port.application.desc: Application
...
dev.uhso.1.type: Serial
dev.uhso.1.ports: 1
dev.uhso.1.port.diagnostic.tty: cuaU1
dev.uhso.1.port.diagnostic.desc: Diagnostic</pre>
</blockquote>
<p>Open /dev/cuaU0.0 in a terminal application, for example minicom. Issue the following commands to establish a connection.</p>
<blockquote>
<pre>AT+CPIN="1234" # Your PIN
OK

AT_OWANCALL=1,1,1
OK

AT_OWANDATA=1
_OWANDATA: 1, 95.209.79.126, 0.0.0.0, 80.251.201.177, 80.251.201.178, 0.0.0.0, 0.0.0.0, 72000</pre>
</blockquote>
<p>If you haven&#8217;t configured a PDP context with your providers APN, please see the <a href="http://www.shapeshifter.se/code/hso/">hso page.</a></p>
<p>Configure the interface and set a default route</p>
<blockquote>
<pre># ifconfig uhso0 95.209.79.126
# route add default -interface uhso0</pre>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2009/07/20/uhso4-option-hsdpa-driver-for-freebsd-8/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>PPTP from FreeBSD</title>
		<link>http://www.shapeshifter.se/2009/03/10/pptp-from-freebsd/</link>
		<comments>http://www.shapeshifter.se/2009/03/10/pptp-from-freebsd/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:40:05 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Mpd]]></category>
		<category><![CDATA[PPTP]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=438</guid>
		<description><![CDATA[
Getting FreeBSD to connect to a Windows VPN using PPTP (who designed that protocol anyway?) is not the most pleasant experience, but at least it&#8217;s doable.
The most competent console tool for this in FreeBSD is probably Mpd5. It&#8217;s quite easy to work with but you&#8217;ll need to get all the details right otherwise it just [...]]]></description>
			<content:encoded><![CDATA[<p><!-- WSA: rules for context 'adsense-post-top' did not apply --><br />
Getting FreeBSD to connect to a Windows VPN using <a href="http://en.wikipedia.org/wiki/Pptp">PPTP</a> (who designed that protocol anyway?) is not the most pleasant experience, but at least it&#8217;s doable.</p>
<p>The most competent console tool for this in FreeBSD is probably <a href="http://mpd.sourceforge.net">Mpd5.</a> It&#8217;s quite easy to work with but you&#8217;ll need to get all the details right otherwise it just won&#8217;t work.</p>
<p>The following mpd.conf configuration file worked for me and allowed me to successfully connect to a Windows VPN. One of the keys were to disable EAP, this particular VPN server just plain refused to work with it enabled</p>
<blockquote>
<pre>default:
    load vpn
vpn:
    create bundle static B1
    # Create a default route (use a net/mask to create specific routes)
    set iface route default
    # Script to execute on connect (custom routes etc)
    # set iface up-script /usr/local/etc/route-up.sh
    # Accept any IP-address
    set ipcp ranges 0.0.0.0/0 0.0.0.0/0
    # Microsoft Point-to-Point Compression, only enable if you have a really fast machine
    # set bundle enable compression
    set ccp yes mppc
    set mppc yes e40
    set mppc yes e56
    set mppc yes e128
    create link static L1 pptp
    set link action bundle B1
    # Replace with you credentials or use the mpd.secret file
    set auth authname USERNAME
    set auth password SECRET
    set link max-redial 0
    set link mtu 1460
    set link keep-alive 20 75
    # Hostname/IP of the VPN server
    set pptp peer vpn.example.com
    set pptp disable windowing
    set link no eap</pre>
</blockquote>
<p>Save it to a file, say mpd.conf in /usr/local/etc/mpd.conf and simply run mpd5 mpd.conf and with some luck you&#8217;ll be connected the the VPN.</p>
<p><strong>The order of the statements are important</strong>. As they only apply to the current selected link (create link) or bundle (create bundle). Keep this in mind when editing.</p>
<h4>Windows logon name</h4>
<p>If you&#8217;re connecting to a Windows network you&#8217;ll probably need to use &#8220;DOMAIN\\username&#8221; as the authname (with the quotes and double backslash).</p>
<h4>Firewall and NAT issues</h4>
<p>The PPTP protocol is far from ideal. If you&#8217;re behind NAT chances are you won&#8217;t be able to do multiple PPTP connections to the <em>same</em> VPN server from within your LAN.</p>
<p>You&#8217;ll also need to allow the GRE protocol through, with Free/OpenBSD pf (packet filter) the following line is enough (you still won&#8217;t be able to do simultaneous connections to the same server though)</p>
<blockquote>
<pre>pass out on $ext_if proto gre from ($ext_if) to any keep state</pre>
</blockquote>
<p>Replace $ext_if with your external network interface.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2009/03/10/pptp-from-freebsd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>First release of FreeBSD driver for Option HSDPA devices</title>
		<link>http://www.shapeshifter.se/2008/04/22/first-release-of-freebsd-driver-for-option-hsdpa-devices/</link>
		<comments>http://www.shapeshifter.se/2008/04/22/first-release-of-freebsd-driver-for-option-hsdpa-devices/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 21:12:00 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[hsdpa]]></category>
		<category><![CDATA[hso]]></category>
		<category><![CDATA[option]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=48</guid>
		<description><![CDATA[I&#8217;ve published the first public beta of my FreeBSD driver for Option HSDPA modems. The driver is still beta but have been successfully tested (and used) with a Option GlobeSurfer iCON 7.2 S device (using a Turbo 3G account from Tre/Hi3G Access Sweden).
The driver is available for download together with instructions at the hso page. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve published the first public beta of my FreeBSD driver for Option HSDPA modems. The driver is still beta but have been successfully tested (and used) with a Option GlobeSurfer iCON 7.2 S device (using a Turbo 3G account from Tre/Hi3G Access Sweden).</p>
<p>The driver is available for download together with instructions at the <a href="http://www.shapeshifter.se/code/hso">hso</a> page. Please report successes and failures.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2008/04/22/first-release-of-freebsd-driver-for-option-hsdpa-devices/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Update on UPEK fingerprint drivers for FreeBSD</title>
		<link>http://www.shapeshifter.se/2008/04/09/update-on-upek-fingerprint-drivers-for-freebsd/</link>
		<comments>http://www.shapeshifter.se/2008/04/09/update-on-upek-fingerprint-drivers-for-freebsd/#comments</comments>
		<pubDate>Wed, 09 Apr 2008 19:40:20 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[biometric]]></category>
		<category><![CDATA[fingerprint]]></category>
		<category><![CDATA[upek]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=42</guid>
		<description><![CDATA[The current binary does not work with FreeBSD 7&#8230;not even with 6 anymore because of a gettext library bump.  I contacted UPEK a while ago, had an conversation with one of the guys there.  I was even given a beta driver that worked, but then our communication seemed to halt.
I was just about [...]]]></description>
			<content:encoded><![CDATA[<p>The current binary does not work with FreeBSD 7&#8230;not even with 6 anymore because of a gettext library bump.  I contacted UPEK a while ago, had an conversation with one of the guys there.  I was even given a beta driver that worked, but then our communication seemed to halt.</p>
<p>I was just about to send them another mail when I stumbled on <a href="http://www.reactivated.net/fprint/wiki/Main_Page">fprint</a>, a GPL based fingerprint abstraction layer that includes <strong>reversed engineered drivers for the UPEK devices</strong>.  The drivers live in user land and the USB bus is accessed through libusb which already is ported to FreeBSD.  So, getting a more stable support for fingerprint devices than the binary-only UPEK drivers should only be a matter of porting this library to FreeBSD.</p>
<p>Woho&#8230;no more BioAPI-hell (worst. library. ever.). I&#8217;m not yet motivated enough to do a port myself, maybe if I get some more free time.</p>
<p>Update: Apparently they did a release, but two people have reported problems with Undefined symbol &#8220;GuiCallback&#8221;.  I&#8217;ll take a look and see if I&#8217;m able to use it. At least the beta driver I was given worked, but I never tested it together with the PAM module.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2008/04/09/update-on-upek-fingerprint-drivers-for-freebsd/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>FreeBSD driver for Option HSDPA cards</title>
		<link>http://www.shapeshifter.se/2008/04/08/freebsd-driver-for-option-hsdpa-cards/</link>
		<comments>http://www.shapeshifter.se/2008/04/08/freebsd-driver-for-option-hsdpa-cards/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 21:00:45 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[3g]]></category>
		<category><![CDATA[hsdpa]]></category>
		<category><![CDATA[hso]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/?p=40</guid>
		<description><![CDATA[I&#8217;ve been hacking on a driver for Option GlobeSurfer iCON 7.2 S HSDPA/3G USB cards (and more or less all newer Option cards) for a few days now and I just reached a major milestone. A successful connection!
The driver is called hso for now (same name as the linux driver).  The card is not [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been hacking on a driver for Option GlobeSurfer iCON 7.2 S HSDPA/3G USB cards (and more or less all newer Option cards) for a few days now and I just reached a major milestone. <strong>A successful connection!</strong></p>
<p>The driver is called hso for now (same name as the linux driver).  The card is not a &#8220;normal&#8221; 3G-modem in the sense that it&#8217;s not simply a serial-over-USB card.  Instead it has several serial channels that accept the normal AT interface (signal strength, SMS, etc) and in addition to that a IP packet interface to which one reads and writes raw IP packets.  The card is exposed through a simulated Ethernet device.<span id="more-40"></span></p>
<pre>hso0: flags=1088c3&lt;UP,BROADCAST,RUNNING,NOARP,SIMPLEX,MULTICAST,NEEDSGIANT&gt;
   metric 0 mtu 1500
        ether 40:0c:e3:69:11:00
        inet 83.178.12.92 netmask 0xffffffff broadcast 83.178.12.92
        inet6 fe80::420c:e3ff:fe69:1100%hso0 prefixlen 64 scopeid 0x5</pre>
<p>Currently it&#8217;s a bit annoying to setup a connection as it requires that one first opens a serial channels and issue  AT_OWANCALL to create a connection and AT_OWANDATA to get the ip-address and nameservers and then manually configure the interface.  It would be nice if this could be automated by the driver with the interface is brought up, however that would require the driver (and thus kernel) itself to read from its own serial channel&#8230;bit hackish but maybe it works</p>
<p>Finally, the output from the very first connections. This is a ping from my workstation to the computer connected through the card.</p>
<pre>fli@nexus&gt; ping 83.178.12.92
PING 83.178.12.92 (83.178.12.92): 56 data bytes
64 bytes from 83.178.12.92: icmp_seq=0 ttl=56 time=446.203 ms
64 bytes from 83.178.12.92: icmp_seq=1 ttl=56 time=332.321 ms</pre>
<p>And this is from the computer connected with the card</p>
<pre>fli@genesis&gt; ping ping.sunet.se
PING ping.sunet.se (192.36.125.18): 56 data bytes
64 bytes from 192.36.125.18: icmp_seq=0 ttl=248 time=287.708 ms</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2008/04/08/freebsd-driver-for-option-hsdpa-cards/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Look who&#039;s talking</title>
		<link>http://www.shapeshifter.se/2007/07/16/look-whos-talking/</link>
		<comments>http://www.shapeshifter.se/2007/07/16/look-whos-talking/#comments</comments>
		<pubDate>Mon, 16 Jul 2007 10:36:32 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Summer of Code 2007]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/2007/07/16/look-whos-talking/</guid>
		<description><![CDATA[Yep, mdnsd speaks now, actually it has been able to do that for a couple of weeks but I just got probing and announcing working as I wanted it to.

I ended up rewriting most of the record database and I think I&#8217;ve ironed out most bugs now, and it now follows the variable system (which [...]]]></description>
			<content:encoded><![CDATA[<p>Yep, mdnsd speaks now, actually it has been able to do that for a couple of weeks but I just got probing and announcing working as I wanted it to.<br />
<span id="more-31"></span></p>
<p>I ended up rewriting most of the record database and I think I&#8217;ve ironed out most bugs now, and it now follows the variable system (which in turn follows the system state).  Here is a sample <a href="http://perforce.freebsd.org/fileViewer.cgi?FSPC=//depot/projects/soc2007/fli%2dmdns%5fsd/mdnsd/mdnsd.conf.sample">mdnsd.conf</a> that creates a resource with the name &#8220;hostname&#8221;.local (where hostname is the actual hostname of the machine), in case this name is already in use, it fall backs to &#8220;hostname-ifname&#8221;.local. To this rrset it will claim/announce A records for all IPv4 addresses configured on this interface, it also claims/announces AAAA records for all configured IPv6 addresses. It also announces matching PTR records for each A/AAAA record, this introduced a new feature that allows the resource data of a record to be a &#8220;pointer&#8221; to an existing rrset name. This allows the PTR records to follow whatever name that&#8217;s configured on the A/AAAA records.</p>
<p>I also rewrote most of the packet construction. Previously I wrote the raw packets directly when a rrset/qset was added, this however led to problems with the DNS name compression code when records where added &#8220;out-of-order&#8221;. Therefore, instead of writing the raw packets directly, I introduced an abstract type struct mdns_{rrset,qset} {} which holds the resource data for a record. Basically one acquires a rrset/qset object, fills it with the resource data and adds it to the packet, but instead of  writing it to the packet buffer it&#8217;s simply added to a list. The raw packets is created from this list first when mdns_pkgchain_finalize() is called, this also has the neat side effect that packet construction becomes quite light weight (and thus, should speed up parsing of received packets as response construction becomes lighter) and the last heavy weight finalize step is moved into the output queue (which will run in a separate thread).</p>
<p>To avoid large malloc()/free() overhead when acquiring rrset/qset objects I also added an &#8220;object allocator&#8221; which allocates various types of fixed sized objects that the daemon requires, when an used object is released back to the allocator it does not immediately free the used memory, instead it simply puts it on a free list for further use, memory is reclaimed when an object hasn&#8217;t been used for a certain amount of time.</p>
<p>There is even more technical mumbo-jumbo  (an multicast output aggregation queue, probing/announcing restarts on affected records when system state changes, etc) but let&#8217;s see mdnsd in action instead. The daemon is running with the sample configuration file, my FreeBSD machine hostname is &#8220;nexus&#8221;, let&#8217;s demonstrate it with a ping from a Mac OS X machine.</p>
<pre>Welcome to Darwin!shiva:~ fli$ ping nexus.local.PING nexus.local (192.168.1.100): 56 data bytes64 bytes from 192.168.1.100: icmp_seq=0 ttl=64 time=0.285 ms</pre>
<p>And, what did mdnsd say</p>
<pre>mdnsd: pkgprocess: Packet received peer=192.168.1.98, port=51909, if=em0mdnsd: pkgprocess: type=query, questions=1, answers=0, authority=0mdnsd: process_query: question for nexus.local., type=1, unicast=0, legacy=1mdnsd: process_query: Found nexus.local. in database, responding</pre>
<p>and the tcpdump output</p>
<pre>12:23:44.049848 IP (tos 0x0, ttl   1, id 16358, offset 0, flags [none],  proto: UDP (17), length: 57)  192.168.1.98.50636 &gt; 224.0.0.251.5353:  38575+ A? nexus.local. (29)12:23:44.050858 IP (tos 0x0, ttl 255, id 59663, offset 0, flags [none],   proto: UDP (17), length: 73) 192.168.1.100.5353 &gt; 192.168.1.98.50636:   38575*- 1/0/0 nexus.local. A 192.168.1.100 (45)12:23:44.051052  IP (tos 0x0, ttl 255, id 59664, offset 0, flags [none],  proto: UDP (17), length: 67) 192.168.1.100.5353 &gt; 224.0.0.251.5353:  0*- [0q] 1/0/0 nexus.local. A 192.168.1.100 (39)</pre>
<p>There is two responses, one unicast and one multicast, the unicast response was sent because the client needed it and the multicast response was sent because it was &#8220;long&#8221; time since we last multicasted this record.</p>
<p>What&#8217;s very funny is that Mac OS X doesn&#8217;t seem to have integrated their resolver library with their responder, and thus does not benefit from opportunistic caching when simply resolving names, they even do legacy type queries (the term used in the specs). The machine runs Mac OS X 10.4.9.</p>
<pre>Darwin shiva.int.shapeshifter.se 8.9.0 Darwin Kernel Version 8.9.0:Thu Feb 22 20:54:07 PST 2007;root:xnu-792.17.14~1/RELEASE_PPC Power Macintosh powerpc</pre>
<p>I could continue and show some neat tcpdumps from the probe/announce steps, but that would probably only get boring, so let&#8217;s call it a post shall we. Now I&#8217;m going to continue with the last large piece of the puzzle which is the local client side that actually enables applications to use the daemon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2007/07/16/look-whos-talking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>mdnsd progress</title>
		<link>http://www.shapeshifter.se/2007/06/20/mdnsd-progress/</link>
		<comments>http://www.shapeshifter.se/2007/06/20/mdnsd-progress/#comments</comments>
		<pubDate>Wed, 20 Jun 2007 16:20:39 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Summer of Code 2007]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/2007/06/20/mdnsd-progress/</guid>
		<description><![CDATA[It&#8217;s been way too long since I wrote something here, but no writing does not equal no coding  
I&#8217;ve finished of several quite large subsystems in mdnsd, including the cache and the record database (which is used for self-claimed records).  This means that it&#8217;s able to receive and cache records, and able to [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been way too long since I wrote something here, but no writing does not equal no coding <img src='http://www.shapeshifter.se/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>I&#8217;ve finished of several quite large subsystems in mdnsd, including the cache and the record database (which is used for self-claimed records).  This means that it&#8217;s able to receive and cache records, and able to read self-claimed records off a configuration file and add them to its database.<span id="more-30"></span></p>
<p>The configuration file is quite simple, while still being flexible enough to allow more advanced configurations, it&#8217;s however a bit different from a regular DNS configuration as the namespace in mDNS is quite flat.<br />
This is a sample that claims a A record, AAAA record and PTR records for each address;</p>
<pre>
# A zone is only a way to avoid duplicate typing,
# one could have skipped it and simply
# used $(hostname).local. as the rrset.
zone "local." {
# A rrset holds a name and one or more resources, a
# resource type can hold multiple data sets
rrset "$(hostname)" {
alt = "$(hostname)-$(ifname)";
# This is a resource for the IN type A with the data set to $(ifaddrs4)
res A { data = "$(ifaddrs4)"; }
res AAAA { data = "$(ifaddrs6)"; }
}
}
rrset "$(ifaddrs4)" {
res PTR { data = "$(hostname).local."; }
}
rrset "$(ifaddrs6)" {
res PTR { data = "$(hostname).local."; }
}</pre>
<p>(It&#8217;s supposed to be white spaces in there but they seem to disappear)</p>
<p>This also demonstrates the quite nifty variable systems that is in place. A variable will be expanded to one or more lines of data, this data is context aware, which means that putting $(ifaddr4) as a rrset name will result in a in-addr.arpa-domain while setting $(ifaddr4) as a resource data on a IN resource will encode it into a regular (binary) ip-address.<br />
On our imaginary host foobar with the interface foo0, which has two ipv4 addresses (10.0.0.1, 10.0.0.2) and one ipv6 address (fe80::20a:5eff:fe5c:f5d7), the above configuration would result in the following;</p>
<pre>
foobar.local. IN A 10.0.0.1
foobar.local. IN A 10.0.0.2
foobar.local. IN AAAA fe80::20a:5eff:fe5c:f5d7
1.0.0.10.in-addr.arpa. IN PTR foobar.local.
2.0.0.10.in-addr.arpa. IN PTR foobar.local.
7.d.5.f.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.a.5.e.f.f.f.e.5.c.f.5.d.7.ip6.arpa. IN PTR foobar.local.</pre>
<p>The records will automatically adjust to any changes to the interface configuration.</p>
<p>Any settings that should only be set on a specific interface can be wrapped inside a interface &#8220;foo0&#8243; {} statement.<br />
Note how one configuration line expands into several real records.</p>
<p>Next up will be some sort of output queue and routines to send responses (packet construction routines are already in place in the low-level stack).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2007/06/20/mdnsd-progress/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Never let a tree do a hash table&#8217;s job</title>
		<link>http://www.shapeshifter.se/2007/05/25/never-let-a-tree-do-a-hash-tables-job/</link>
		<comments>http://www.shapeshifter.se/2007/05/25/never-let-a-tree-do-a-hash-tables-job/#comments</comments>
		<pubDate>Fri, 25 May 2007 15:58:41 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Summer of Code 2007]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/2007/05/25/never-let-a-tree-do-a-hash-tables-job/</guid>
		<description><![CDATA[&#8230;or something like that.
I&#8217;ve been toying and experimenting with different data structures to represent the domain name cache in mdnsd.
These are the structures I&#8217;ve seriously considered

Radix tree/trie &#8211; It&#8217;s attractive to do lookup in O(k), but with a key length of 255 bytes (utf8) the tree would be huge, 2040 bits. Not sure it would [...]]]></description>
			<content:encoded><![CDATA[<p>&#8230;or something like that.</p>
<p>I&#8217;ve been toying and experimenting with different data structures to represent the domain name cache in mdnsd.</p>
<p>These are the structures I&#8217;ve seriously considered</p>
<ul>
<li>Radix tree/trie &#8211; It&#8217;s attractive to do lookup in O(k), but with a key length of 255 bytes (utf8) the tree would be huge, 2040 bits. Not sure it would be effective even with all the compression techniques in the book.</li>
<li>Splay tree (self-balancing binary tree), scales well but key comparisons must be strcmp().</li>
<li>Hash table, well obviously fast but there could be scaling problems as collisions become lager.</li>
<li>&#8220;Chained&#8221; hash table &#8211; Use the fact that domain names are separated in labels (label1.label2.tld) and use one hash table on each level.</li>
</ul>
<p><span id="more-29"></span>Very early on I also considered skip lists, but a test showed that it didn&#8217;t beat the splay tree, so it got ditched.  Radix tree were also ditched as I believe it will be quite hard to make it effective for such large keys.</p>
<p>I measured the performance of the three remaining structures using 1000000 random domain names, the numbers are an average of 10 runs.  Code compiled with -O2, tests performed on a Pentium M 1.7Ghz. &#8220;add&#8221; refers to the time it took to insert 1000000 entries, and &#8220;find&#8221; refers to the time it took to find those 1000000 entries.</p>
<ul>
<li>Splay tree (sys/tree.h),  add 4.90300 seconds,  find   3.3907 seconds</li>
<li>&#8220;Chained&#8221; hash table, add 7.62640 seconds, find 1.38780 seconds</li>
<li>Hash table, add 2.19680 seconds, find 1.04970 seconds</li>
</ul>
<p>The reason the chained hash table has such a bad add time is mainly because of malloc() call overhead in the hash table initiation for each level, there is code to reduce malloc overhead (pre-allocating a large chunk and splitting it) but it&#8217;s not enough.  The hash table is  self-growing and will double in size when any bucket hits a threshold number of collisions, experiments showed that up to about 10 collisions per bucket was reasonable. The tests above that included a hash table had a maximum hash table size of 131072 buckets,  obviously by increasing the max size (trading memory for speed) you get better performance.</p>
<p>My initial doubts that a hash table would scale bad were not true, 1000000 entries is A LOT more than what the mdnsd responder will ever cache in practice, and because it&#8217;s self-growing it won&#8217;t waste a lot of memory. I guess I&#8217;ll use a hash table then.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2007/05/25/never-let-a-tree-do-a-hash-tables-job/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>mDNS stack to the responder daemon</title>
		<link>http://www.shapeshifter.se/2007/05/09/mdns-stack-to-the-responder-daemon/</link>
		<comments>http://www.shapeshifter.se/2007/05/09/mdns-stack-to-the-responder-daemon/#comments</comments>
		<pubDate>Wed, 09 May 2007 07:32:30 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Summer of Code 2007]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/2007/05/09/mdns-stack-to-the-responder-daemon/</guid>
		<description><![CDATA[Last night (local time) I submitted my initial mDNS stack to p4, it forms the foundation of the responder daemon (mdnsd).  The stack is more or less complete, but I&#8217;ll see how it works out once I integrate it with the rest of the application, there will probably be some more code re-factoring (and [...]]]></description>
			<content:encoded><![CDATA[<p>Last night (local time) I submitted my initial mDNS stack to p4, it forms the foundation of the responder daemon (mdnsd).  The stack is more or less complete, but I&#8217;ll see how it works out once I integrate it with the rest of the application, there will probably be some more code re-factoring (and bug fixing).<span id="more-27"></span></p>
<p>The stack provides an abstract interface to the underlying sockets, it takes care of multicast group memberships,  buffer management, packet creation and parsing. The interface is the same both for IPv4 and IPv6 which was one of the main requirements. As for DNS names the interface uses wide characters (wchar_t) only and properly encodes/decodes to UTF-8 (just as the specification says), this means that one should be able to use exotic characters natively (such as smörgåsbord.local) without punny-encoding. Oh, and it also does optimal dns name compression in the packets.</p>
<p>All my initial tests shows that the stack itself works well and it&#8217;s able to parse all packets my Mac OS X client is sending.  I&#8217;ve also been running it together with network fuzzer (<a href="http://sam.zoy.org/zzuf/">zzuf</a>) while spewing packets on it, haven&#8217;t crashed this far (famous last words) <img src='http://www.shapeshifter.se/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  In addition to this I have a few static test cases I&#8217;m going to put it through, which it should support, at least in theory that is. I also plan to run it through gprof to see if there are any dead-obvious sections that could be optimized.</p>
<p>But, all in good time. Now I&#8217;m gonna disappear for a while and take care of some school stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2007/05/09/mdns-stack-to-the-responder-daemon/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Multicast DNS, Service Discovery, etc</title>
		<link>http://www.shapeshifter.se/2007/04/17/multicast-dns-service-discovery-etc/</link>
		<comments>http://www.shapeshifter.se/2007/04/17/multicast-dns-service-discovery-etc/#comments</comments>
		<pubDate>Tue, 17 Apr 2007 12:54:02 +0000</pubDate>
		<dc:creator>fli</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Summer of Code 2007]]></category>

		<guid isPermaLink="false">http://www.shapeshifter.se/2007/04/17/multicast-dns-service-discovery-etc/</guid>
		<description><![CDATA[I&#8217;ll be hacking on Multicast DNS and Service Discovery as a part of this years Summer of Code, my mentor is Bruce M. Simpson.
There are some initial information about the project on the FreeBSD wiki, I&#8217;ll try to keep it updated as time goes.  The main priority is to get the responder running and [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll be hacking on Multicast DNS and Service Discovery as a part of this years Summer of Code, my mentor is <a href="http://wiki.freebsd.org/BruceSimpson">Bruce M. Simpson</a>.</p>
<p>There are some initial information about the project on the <a href="http://wiki.freebsd.org/MulticastDNS">FreeBSD wiki</a>, I&#8217;ll try to keep it updated as time goes.  The main priority is to get the responder running and to create a clean client API.</p>
<p>I already have some code, I just need to get the hang of perforce so I can submit it <img src='http://www.shapeshifter.se/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.shapeshifter.se/2007/04/17/multicast-dns-service-discovery-etc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

