<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.1.2" -->
<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/"
	>

<channel>
	<title>Chip Miller's Log</title>
	<link>http://chip-miller.net</link>
	<description>Milling Chips Since 1996</description>
	<pubDate>Sat, 15 Mar 2008 06:57:53 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.1.2</generator>
	<language>en</language>
			<item>
		<title>Solving a DNS Mystery on OS X</title>
		<link>http://chip-miller.net/2008/03/14/solving-a-dns-mystery-on-os-x/</link>
		<comments>http://chip-miller.net/2008/03/14/solving-a-dns-mystery-on-os-x/#comments</comments>
		<pubDate>Fri, 14 Mar 2008 11:00:00 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[networking]]></category>

		<category><![CDATA[mac]]></category>

		<category><![CDATA[osx]]></category>

		<category><![CDATA[os x]]></category>

		<category><![CDATA[dns]]></category>

		<guid isPermaLink="false">http://chip-miller.net/2008/03/14/solving-a-dns-mystery-on-os-x/</guid>
		<description><![CDATA[Someone on a forum I frequent noticed that telnet on Mac OS X 10.5 (Leopard) sometimes acts strangely when connecting to TCP port 25. Specifically, if the destination host is a DNS name then and that name has an MX record, telnet connects to the MX host instead of the named host.
For example:

$ host example.com
example.com [...]]]></description>
			<content:encoded><![CDATA[<p>Someone on a forum I frequent noticed that <code>telnet</code> on Mac OS X 10.5 (Leopard) sometimes acts strangely when connecting to TCP port 25. Specifically, if the destination host is a DNS name then and that name has an MX record, telnet connects to the MX host instead of the named host.</p>
<p>For example:</p>
<p><code><br />
$ host example.com<br />
example.com has address 10.0.0.1<br />
example.com mail is handled by 10 mail.example.com.<br />
$ host mail.example.com<br />
mail.example.com has address 192.168.1.1<br />
$ telnet example.com 25<br />
Trying 192.168.1.1...<br />
Connected to example.com.<br />
Escape character is '^]'.<br />
</code></p>
<p>Needless to say, this is a little weird. When the average person fires up <code>telnet</code> they want it to connect directly to the named host and port, not randomly start looking up MX records and connecting to that host instead. This isn&#8217;t the end of the world for interactive use (since you can look up the desired IP address manually and pass that to <code>telnet</code>), but it could be a problem for mail clients if it directed outgoing messages to the wrong host.</p>
<p>Since most of Darwin (the core of OS X, including most of the networking libraries and utilities), is open source, I decided to start investigating and see what I could find. The Darwin source for 10.5.2 is available here: <a href="http://www.opensource.apple.com/darwinsource/10.5.2/">Apple Mac OS X 10.5.2 Darwin sources</a> (Index page with all releases here: <a href="http://www.opensource.apple.com/darwinsource/">Darwin sources</a>)</p>
<p>First, I downloaded the <a href="http://www.opensource.apple.com/darwinsource/tarballs/other/remote_cmds-13.tar.gz">telnet source</a> to see if this was specific to telnet.</p>
<p>The relevant code in <code>telnet</code> (connecting to a specified port on a named host) is essentially:</p>
<p><code><br />
commands.c:</p>
<p>struct addrinfo hints, *res, ...;</p>
<p>...</p>
<p>memset(&#038;hints, 0, sizeof(hints));<br />
hints.ai_family = family;<br />
hints.ai_socktype = SOCK_STREAM;<br />
hints.ai_flags = AI_CANONNAME;<br />
error = getaddrinfo(hostname, portp, &#038;hints, &#038;res);</p>
<p>...</p>
<p>do {<br />
        printf("Trying %s...\n", sockaddr_ntop(res->ai_addr));<br />
        net = socket(res->ai_family, res->ai_socktype, res->ai_protocol);</p>
<p>        if (connect(net, res->ai_addr, res->ai_addrlen) < 0)<br />
        {<br />
            struct addrinfo *next;</p>
<p>            next = res->ai_next;</p>
<p>            &#8230;</p>
<p>            res = next;<br />
        }</p>
<p>        connected++;</p>
<p>        &#8230;</p>
<p>} while (connected == 0);<br />
</code></p>
<p>In short, it simply passes the specified host and port to <code>getaddrinfo(3)</code> and tries each resulting host address in order. So the MX address is coming from <code>getaddrinfo(3)</code>, not <code>telnet</code>.</p>
<p><code>getaddrinfo</code> is in <a href="http://www.opensource.apple.com/darwinsource/tarballs/apsl/Libinfo-278.tar.gz">Libinfo</a>.</p>
<p>There, <code>getaddrinfo</code> hands off the query to its helper <code>ds_getaddrinfo</code>, which hands off the query to another helper <code>LI_DSLookupQuery</code>.</p>
<p><code><br />
getaddrinfo.c:</p>
<p>static int<br />
ds_getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)<br />
{<br />
    ...<br />
    status = LI_DSLookupGetProcedureNumber("getaddrinfo", &#038;gai_proc);<br />
    ...<br />
    request = gai_make_query(nodename, servname, hints);<br />
    ...<br />
    status = LI_DSLookupQuery(gai_proc, request, &#038;reply);<br />
    ...<br />
}<br />
</code></p>
<p><code><br />
lu_utils.c:</p>
<p>LI_DSLookupQuery(int32_t procno, kvbuf_t *request, kvarray_t **reply)<br />
{<br />
...<br />
status = libinfoDSmig_Query(_ds_port, procno, request->databuf, request->datalen, ilbuf, &#038;illen, &#038;oobuf, &#038;oolen, &#038;token);<br />
...<br />
}<br />
</code></p>
<p>This was something of a dead end. It looked like <code>libinfoDSmig_Query</code> was probably doing some RPC or IPC (looking up a function number by name at runtime and invoking the function indirectly) and the &#8220;DS&#8221; suggested it was related to DirectoryServices. However <code>libinfoDSmig_Query</code> wasn&#8217;t found as a name defined in any of the code I had so far, or the system headers. But it was a function, so it had to be defined somewhere. I jumped back to the top of <code>lu_utils.c</code> and found a reference to <code>DSlibinfoMIG.defs</code>.</p>
<p>Here we go. Definitely looks like an RPC/IPC API definition! The prefixes and function names must get concatenated by a preprocessor, explaining why <code>grep</code> wasn&#8217;t finding <code>libinfoDSmig_Query</code> anywhere.</p>
<p><code><br />
DSlibinfoMIG.defs:</p>
<p>userprefix libinfoDSmig_;<br />
serverprefix libinfoDSmig_do_;</p>
<p>...</p>
<p>routine GetProcedureNumber<br />
(<br />
    server : mach_port_t;<br />
    name : proc_name_t;<br />
    out procno : int32_t;<br />
    ServerAuditToken bsmtoken : audit_token_t;<br />
    UserSecToken usertoken : security_token_t<br />
);</p>
<p>routine Query<br />
(<br />
    server : mach_port_t;<br />
    proc : int32_t;<br />
    request : inline_data_t;<br />
    out reply : inline_data_t;<br />
    out ooreply : pointer_t, Dealloc;<br />
    ServerAuditToken bsmtoken : audit_token_t;<br />
    UserSecToken usertoken : security_token_t<br />
);<br />
</code></p>
<p>This still didn&#8217;t tell me where <code>libinfoDSmig_Query</code> was implemented. Assuming the &#8220;DS&#8221; meant DirectoryServices, I got the <a href="http://www.opensource.apple.com/darwinsource/tarballs/apsl/DirectoryService-514.4.tar.gz">DirectoryServices</a> source.</p>
<p>A search for <code>libinfoDSmig_do_Query</code> (concatenating the &#8220;routine&#8221; name onto the &#8220;serverprefix&#8221;) found:</p>
<p><code><br />
ServerControl.cpp:</p>
<p>extern CCachePlugin    *gCacheNode;</p>
<p>kern_return_t libinfoDSmig_do_Query(...)<br />
{<br />
    ...<br />
    returnedBuf = gCacheNode->ProcessLookupRequest(procnumber, request, requestCnt, aPID);<br />
    ...<br />
}<br />
</code></p>
<p><code>CCachePlugin::ProcessLookupRequest()</code> was in <code>CCachePlugin.cpp</code>:</p>
<p><code><br />
CCachePlugin.cpp:</p>
<p>kvbuf_t* CCachePlugin::ProcessLookupRequest ( int inProcNumber, char* inData, int inCount, pid_t inPID )<br />
{<br />
...<br />
    switch ( inProcNumber )<br />
    {<br />
...<br />
        case kDSLUgetaddrinfo:<br />
            outData = DSgetaddrinfo( buffer, inPID );<br />
            break;<br />
...<br />
    }<br />
}<br />
</code></p>
<p>Getting warmer?</p>
<p><code><br />
kvbuf_t* CCachePlugin::DSgetaddrinfo( kvbuf_t *inBuffer, pid_t inPID )<br />
{<br />
    ...</p>
<p>    // we special case smtp and TCP combo and insert a specialized query<br />
    if( bHaveServiceName == true &#038;&#038; bResolveName &#038;&#038; (IPPROTO_TCP == protocol || 0 == protocol)<br />
        &#038;&#038; (SOCK_STREAM == socktype || 0 == socktype) &#038;&#038; (strcmp(pService, "smtp") == 0 || strcmp(pService, "25") == 0) )<br />
    {<br />
        protocolListStr[serviceCount] = NULL;<br />
        protocolList[serviceCount] = "6";<br />
        socktypeList[serviceCount] = "1";<br />
        serviceNameList[serviceCount] = strdup( "MX" );<br />
        serviceCount++;<br />
    }</p>
<p>    ...<br />
}<br />
</code></p>
<p>Boom! There you have it. Somebody hard-coded an exception into DirectoryServices to also look up the MX records of a host (in addition to IPv4 A and IPv6 AAAA records) when the destination port is TCP/25. As far as I can tell, there&#8217;s no way to turn that feature off (short of perhaps modifying the source and recompiling DirectoryServices).</p>
<p>Note: A quick Google search showed that &#8220;MIG&#8221; does indeed relate to IPC and RPC - it stands for &#8220;Mach Interface Generator&#8221;. See<br />
<a href="http://developer.apple.com/documentation/Darwin/Conceptual/KernelProgramming/boundaries/chapter_14_section_4.html">Kernel Programming Guide - Mach Messaging and Mach Interprocess Communication</a>.</p>
<p>ASPL for quoted ASPL code:<br />
<small>Portions Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.</p>
<p>This file contains Original Code and/or Modifications of Original Code as defined in and that are subject to the Apple Public Source License Version 2.0 (the &#8216;License&#8217;). You may not use this file except in compliance with the License. Please obtain a copy of the License at http://www.opensource.apple.com/apsl/ and read it before using this file.</p>
<p>The Original Code and all software distributed under the License are distributed on an &#8216;AS IS&#8217; basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the specific language governing rights and limitations under the License.</small></p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2008/03/14/solving-a-dns-mystery-on-os-x/feed/</wfw:commentRss>
		</item>
		<item>
		<title>What&#8217;s Wrong With This Picture?</title>
		<link>http://chip-miller.net/2008/02/24/whats-wrong-with-this-picture/</link>
		<comments>http://chip-miller.net/2008/02/24/whats-wrong-with-this-picture/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 16:00:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[networking]]></category>

		<category><![CDATA[slow]]></category>

		<category><![CDATA[comcast]]></category>

		<category><![CDATA[ping]]></category>

		<guid isPermaLink="false">http://chip-miller.net/2008/02/25/whats-wrong-with-this-picture/</guid>
		<description><![CDATA[
Try the 1400 millisecond ping time to my shell server. Yes, that&#8217;s fourteen hundred milliseconds, or 1.4 seconds. This is over my cable Internet connection (Comcast) to a machine less than a mile away that has a Gigabit link to the Internet and Internet2. Normally the round-trip time is less than 10ms. I can&#8217;t remember [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://andrew-medico.com/images/insane-ping.png" alt="What's wrong with this picture?" /></p>
<p>Try the <b>1400 millisecond</b> ping time to my shell server. Yes, that&#8217;s <i>fourteen hundred</i> milliseconds, or 1.4 <b>seconds</b>. This is over my cable Internet connection (Comcast) to a machine less than a mile away that has a Gigabit link to the Internet and Internet2. Normally the round-trip time is less than 10ms. I can&#8217;t remember ever seeing ping times this bad, even on dialup. Trying to use vim over ssh is a joke, since the result of a keypress doesn&#8217;t show up until more than a second later.</p>
<p>I don&#8217;t know what is causing this ridiculous slowdown. Most likely one of my roommates is downloading m4d w4r3z with BitTorrent, or maybe Comcast is just screwing around.</p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2008/02/24/whats-wrong-with-this-picture/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Gallery Moved</title>
		<link>http://chip-miller.net/2008/02/02/gallery-moved/</link>
		<comments>http://chip-miller.net/2008/02/02/gallery-moved/#comments</comments>
		<pubDate>Sat, 02 Feb 2008 16:00:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[pictures]]></category>

		<category><![CDATA[photos]]></category>

		<category><![CDATA[gallery]]></category>

		<guid isPermaLink="false">http://chip-miller.net/2008/02/02/gallery-moved/</guid>
		<description><![CDATA[The gallery has been moved! Instead of being hosted at home on a cable modem with a terribly slow upload rate limit, everything has been migrated to real hosting.
The new gallery is now here: http://gallery.chip-miller.net/
]]></description>
			<content:encoded><![CDATA[<p>The gallery has been moved! Instead of being hosted at home on a cable modem with a terribly slow upload rate limit, everything has been migrated to real hosting.</p>
<p>The new gallery is now here: <a href="http://gallery.chip-miller.net/">http://gallery.chip-miller.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2008/02/02/gallery-moved/feed/</wfw:commentRss>
		</item>
		<item>
		<title>AFC Championship Photos</title>
		<link>http://chip-miller.net/2008/01/20/afc-championship-photos/</link>
		<comments>http://chip-miller.net/2008/01/20/afc-championship-photos/#comments</comments>
		<pubDate>Mon, 21 Jan 2008 03:00:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[pictures]]></category>

		<category><![CDATA[photos]]></category>

		<category><![CDATA[football]]></category>

		<category><![CDATA[patriots]]></category>

		<category><![CDATA[chargers]]></category>

		<category><![CDATA[afc]]></category>

		<guid isPermaLink="false">http://chip-miller.net/2008/02/08/afc-championship-photos/</guid>
		<description><![CDATA[I took some photos at the Patriots/Chargers AFC Championship game today with my shiny new D40. On to the Superbowl!
Album is here: http://gallery.chip-miller.net/main.php?g2_itemId=25
]]></description>
			<content:encoded><![CDATA[<p>I took some photos at the Patriots/Chargers AFC Championship game today with my shiny new D40. On to the Superbowl!</p>
<p>Album is here: <a href="http://gallery.chip-miller.net/main.php?g2_itemId=25">http://gallery.chip-miller.net/main.php?g2_itemId=25</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2008/01/20/afc-championship-photos/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Camp Time-Lapse</title>
		<link>http://chip-miller.net/2007/11/25/camp-time-lapse/</link>
		<comments>http://chip-miller.net/2007/11/25/camp-time-lapse/#comments</comments>
		<pubDate>Sun, 25 Nov 2007 20:00:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[camp]]></category>

		<category><![CDATA[norway]]></category>

		<category><![CDATA[maine]]></category>

		<category><![CDATA[time lapse]]></category>

		<guid isPermaLink="false">http://chip-miller.net/2007/11/25/camp-time-lapse/</guid>
		<description><![CDATA[I put together a sort of time-lapse of camp lake photos. It&#8217;s only two images (summer 2003 and fall 2007) so far, but it&#8217;s still interesting to see the changes over time (i.e. more houses).
View time-lapse
]]></description>
			<content:encoded><![CDATA[<p>I put together a sort of time-lapse of camp lake photos. It&#8217;s only two images (summer 2003 and fall 2007) so far, but it&#8217;s still interesting to see the changes over time (i.e. more houses).</p>
<p><a href="http://andrew-medico.com/misc/camp/index.html">View time-lapse</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2007/11/25/camp-time-lapse/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Father Goat Tonsils Returns!</title>
		<link>http://chip-miller.net/2007/04/16/father-goat-tonsils-returns/</link>
		<comments>http://chip-miller.net/2007/04/16/father-goat-tonsils-returns/#comments</comments>
		<pubDate>Mon, 16 Apr 2007 17:11:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[goat]]></category>

		<category><![CDATA[tonsils]]></category>

		<category><![CDATA[bob]]></category>

		<category><![CDATA[website]]></category>

		<category><![CDATA[father]]></category>

		<guid isPermaLink="false">http://chip-miller.net/2007/04/16/father-goat-tonsils-returns/</guid>
		<description><![CDATA[Father Goat Tonsils is back, thanks to the magic of archive.org! I should have the old photos and flipbooks on an old hard drive somewhere, so with any luck I&#8217;ll have those back up soon as well.  
http://goattonsils.com
]]></description>
			<content:encoded><![CDATA[<p>Father Goat Tonsils is back, thanks to the magic of archive.org! I should have the old photos and flipbooks on an old hard drive somewhere, so with any luck I&#8217;ll have those back up soon as well.  </p>
<p><a href="http://goattonsils.com/">http://goattonsils.com</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2007/04/16/father-goat-tonsils-returns/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Kittens!</title>
		<link>http://chip-miller.net/2007/03/25/kittens/</link>
		<comments>http://chip-miller.net/2007/03/25/kittens/#comments</comments>
		<pubDate>Mon, 26 Mar 2007 01:00:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[kittens]]></category>

		<category><![CDATA[cats]]></category>

		<category><![CDATA[cute]]></category>

		<category><![CDATA[pictures]]></category>

		<guid isPermaLink="false">http://chip-miller.net/?p=3</guid>
		<description><![CDATA[Finally took some pictures of the new kittens. Until I get a gallery set up here, you can see the post on James&#8217; forum.
Take me to the kittens!
]]></description>
			<content:encoded><![CDATA[<p>Finally took some pictures of the new kittens. Until I get a gallery set up here, you can see the post on James&#8217; forum.</p>
<p><a href="http://www.jnote.org/forum/index.php?t=msg&#038;th=82&#038;start=0&#038;S=749b31a3f7763297e24cc14ccf4aa6af">Take me to the kittens!</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chip-miller.net/2007/03/25/kittens/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>

