<?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>BarryODonovan.com &#187; asterisk</title>
	<atom:link href="http://www.barryodonovan.com/index.php/tag/asterisk/feed" rel="self" type="application/rss+xml" />
	<link>http://www.barryodonovan.com</link>
	<description>The thoughts, ramblings and rants of Barry O&#039;Donovan</description>
	<lastBuildDate>Wed, 09 Dec 2009 14:30:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>chan_ss7, pcap files and 64bit machines</title>
		<link>http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines</link>
		<comments>http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines#comments</comments>
		<pubDate>Mon, 28 Apr 2008 19:01:32 +0000</pubDate>
		<dc:creator>Barry O'Donovan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[VoIP]]></category>
		<category><![CDATA[asterisk]]></category>
		<category><![CDATA[chan_ss7]]></category>
		<category><![CDATA[ss7]]></category>

		<guid isPermaLink="false">http://www.barryodonovan.com/?p=75</guid>
		<description><![CDATA[UPDATE: April 29th 2008 Anders Baekgaard of Dicea ApS (current chan_ss7 maintainers) recommends the following alternative patch. Please note that mtp3d.c will also need to be patched in the same way: --- chan_ss7.c~ 2008-04-03 09:23:56.000000000 +0200 +++ chan_ss7.c 2008-04-29 08:29:20.000000000 +0200 @@ -249,11 +249,12 @@ static void dump_pcap(FILE *f, struct mtp_event *event) { + unsigned [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: April 29th 2008</strong></p>
<p>Anders Baekgaard of <a href="dicea.dk">Dicea ApS</a> (current chan_ss7 maintainers) recommends the following alternative patch. Please note that <code>mtp3d.c</code> will also need to be patched in the same way:</p>
<pre>
--- chan_ss7.c~ 2008-04-03 09:23:56.000000000 +0200
+++ chan_ss7.c  2008-04-29 08:29:20.000000000 +0200
@@ -249,11 +249,12 @@

 static void dump_pcap(FILE *f, struct mtp_event *event)
 {
+  unsigned int sec  = event->dump.stamp.tv_sec;
   unsigned int usec  = event->dump.stamp.tv_usec -
     (event->dump.stamp.tv_usec % 1000) +
     event->dump.slinkno*2 + /* encode link number in usecs */
     event->dump.out /* encode direction in/out */;

-  fwrite(&#038;event->dump.stamp.tv_sec, sizeof(event->dump.stamp.tv_sec), 1, f);
+  fwrite(&#038;sec, sizeof(sec), 1, f);
   fwrite(&#038;usec, sizeof(usec), 1, f);
   fwrite(&#038;event->len, sizeof(event->len), 1, f); /* number of bytes of packet in file */
   fwrite(&#038;event->len, sizeof(event->len), 1, f); /* actual length of packet */
</pre>
<p><strong>END UPDATE: April 29th 2008</strong></p>
<p>A quickie for the Google trolls:</p>
<p>While trying to debug some SS7 Nature of Address (NAI) indication issues, I needed to use chan_ss7&#8242;s &#8216;dump&#8217; feature from the Asterisk CLI. It worked fine but the resultant pcap files always failed with messages like:</p>
<pre>
# tshark -r /tmp/now
tshark: "/tmp/now" appears to be damaged or corrupt.
(pcap: File has 409000-byte packet, bigger than maximum of 65535)
</pre>
<p>After much digging about and head-against-wall banging, I discovered the issue<br />
is with the packet header in the pcap file. It&#8217;s defined by its spec to be:</p>
<pre>
typedef struct pcaprec_hdr_s {
        guint32 ts_sec;         /* timestamp seconds */
        guint32 ts_usec;        /* timestamp microseconds */
        guint32 incl_len;       /* number of octets of packet saved in file */
        guint32 orig_len;       /* actual length of packet */
} pcaprec_hdr_t;
</pre>
<p>chan_ss7 uses the <code>timeval</code> struct defined by system headers to represent ts_sec and ts_usec. But, on 64bit machines (certainly mine), these values are defined as <code>unsigned long</code> rather than <code>unsigned int</code> (presumably as a step to get over the &#8216;year 2038 bug&#8217;). Hence the packet header is all wrong.</p>
<p>An easy solution is the following patch in <code>mtp.h</code>:</p>
<pre>
77a78,90
> /*
>  * The packet header in the pcap file (used for the CLI command 'dump') is
defined so has to
>  * have the two time components as unsigned ints. However, on 64bit
machines, the system
>  * timeval struct may use unsigned long. As such, we use a custom version
here:
>  */
> struct _32bit_timeval
> {
>   unsigned int tv_sec;            /* Seconds.  */
>   unsigned int tv_usec;      /* Microseconds.  */
> };
>
>
>
125c138
<       struct timeval stamp;        /* Timestamp */
---
>       struct _32bit_timeval stamp;        /* Timestamp */
</pre>
<p>There may be a better way &#8211; but this works.</p>
<p>This relates to chan_ss7-1.0.0 from <a href="http://www.dicea.dk/company/downloads">http://www.dicea.dk/company/downloads</a> and I have let them know also. It&#8217;s also a known issue for the Wireshark developers (although I did not investigate in detail to see what their resolution was for the future). See the following thread from 1999:</p>
<ul>
<li> <a href="http://www.ethereal.com/lists/ethereal-dev/199908/msg00065.html">http://www.ethereal.com/lists/ethereal-dev/199908/msg00065.html</a> </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.barryodonovan.com/index.php/2008/04/28/chan_ss7-pcap-files-and-64bit-machines/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
