<?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>logIt &#187; General Linux</title>
	<atom:link href="https://lakm.us/logit/category/general-linux/feed/" rel="self" type="application/rss+xml" />
	<link>https://lakm.us/logit</link>
	<description>Log Around The Clock</description>
	<lastBuildDate>Sat, 06 Jun 2015 14:17:37 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Mobile WiFi NAS on Raspberry Pi with TrueCrypt</title>
		<link>https://lakm.us/logit/2014/06/mobile-wifi-nas-raspberry-pi-truecrypt/</link>
		<comments>https://lakm.us/logit/2014/06/mobile-wifi-nas-raspberry-pi-truecrypt/#comments</comments>
		<pubDate>Sun, 01 Jun 2014 04:23:18 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[General Linux]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[ARMv6]]></category>
		<category><![CDATA[file system]]></category>
		<category><![CDATA[fuse]]></category>
		<category><![CDATA[Raspberry Pi]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=778</guid>
		<description><![CDATA[Mobile NAS sounds like an idea worth waiting for to run on my mini Raspberry Pi Model A. Unfortunately, it only took me a while, before abandoning it. I&#8217;ve waited since writing about Raspberry Pi USB problem, that is to finally cut the backfeeding power line from the el cheapo powered USB hub. There comes [...]]]></description>
				<content:encoded><![CDATA[<p>Mobile <a href="http://en.wikipedia.org/wiki/Network-attached_storage" target="_blank">NAS</a> sounds like an idea worth waiting for to run on my mini <a href="http://www.raspberrypi.org/tag/model-a/" target="_blank">Raspberry Pi Model A</a>. Unfortunately, it only took me a while, before abandoning it. I&#8217;ve waited since <a href="../../../2013/03/raspberry-pi-common-usb-problems/" title="Raspberry Pi Common USB Problems" target="_blank">writing about Raspberry Pi USB problem</a>, that is to <a href="https://flic.kr/p/kqopvk" title="Cutting backfeed from el cheapo USB hub to make friend with dual rating power bank &#038; Raspberry Pi" target="_blank">finally cut the backfeeding power line from the <em>el cheapo</em> powered USB hub</a>. There comes new problem afterward, my &#8220;big storage&#8221; ―a <a href="http://www.seagate.com/external-hard-drives/portable-hard-drives/standard/backup-plus/" title="Backup Plus Slim Portable Drive" target="_blank">Seagate® Backup Plus Slim Portable Drive</a>, shipped with no bulky power supply line― can&#8217;t be mounted. Silence soon follows rotating motor sound a while after plugging-in. I&#8217;ve tried both <a href="http://en.wikipedia.org/wiki/Ext3" target="_blank">ext3</a> and <a href="http://en.wikipedia.org/wiki/NTFS-3G" target="_blank">NTFS (using ntfs-3g)</a> without luck. Later, as benchmark whether it is USB power in question, I try to connect the same set of <em>el cheapo</em> USB hub plus external power to laptop, and it works, leaving me stranded with other issue (is it USB 3.0? 256MB of the Model A? Anything?). I must say that it isn&#8217;t completely not-working as the USB hub set can mount with <a href="http://www.ebay.co.uk/itm/Ritmo-R-Driver-III-USB-2-0-to-sata-Ide-cable-/221221820375" title="R-Driver III USB 2.0 to sata / Ide cable" target="_blank">USB to IDE converter</a> and my old internal hard disk (noting that there shouldn&#8217;t be similar power issue this way). If only it weren&#8217;t for the AC power adapter and large size, this is Mobile NAS; beats me.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Mobile NAS [Raspberry Pi hack] by aqila_rifti, on Flickr" src="https://farm6.staticflickr.com/5193/14317107955_73226c6432_n.jpg" title="Mobile NAS [Raspberry Pi hack] by aqila_rifti, on Flickr" width="320" height="320" /><p class="wp-caption-text">Battery power bank, WiFi USB stick, and thumb drive</p></div>
<p>I then turn away to motor-less small storage, a <a href="http://www.sandisk.com/products/usb/drives/cruzer-switch/" title="Sandisk Cruzer CZ52 " target="_blank">32 Gigs USB thumb drive</a> so I can move on to other concern: on-the-fly encryption. Hence, I follow <a href="http://kenfallon.com/truecrypt-on-a-respberry-pi-no-gui/" target="_blank">instructions to install True Crypt on Raspberry Pi</a>. After unpacking of <code>wxWidgets-2.8.12.tar.gz</code> and <code>TrueCrypt 7.1a Source.tar.gz</code> in place, putting header files from <code>pkcs-11-cryptoki2.20</code>, and then install <code>libfuse-dev</code>, the following <code>make</code> will require long time:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PKCS11_INC</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>truecrypt<span style="color: #000000; font-weight: bold;">/</span>pkcs<span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">NOGUI</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">WX_ROOT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>wxWidgets wxbuild
Configuring wxWidgets library...
Building wxWidgets library...
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>wxWidgets<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>common<span style="color: #000000; font-weight: bold;">/</span>string.cpp:<span style="color: #000000;">84</span>:<span style="color: #000000;">39</span>: warning: ‘wxEmptyString’ initialized and declared ‘extern’ <span style="color: #7a0874; font-weight: bold;">&#91;</span>enabled by default<span style="color: #7a0874; font-weight: bold;">&#93;</span></pre></div></div>

<p><span id="more-778"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #007800;">NOGUI</span>=<span style="color: #000000;">1</span> <span style="color: #007800;">WX_ROOT</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>wxWidgets wxbuild
Compiling Buffer.cpp
Compiling Exception.cpp
Compiling Event.cpp
...
..<span style="color: #000000; font-weight: bold;">/</span>Crypto<span style="color: #000000; font-weight: bold;">/</span>Aeskey.c:<span style="color: #000000;">527</span>:<span style="color: #000000;">25</span>: warning: operation on ‘ss<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>’ may be undefined <span style="color: #7a0874; font-weight: bold;">&#91;</span>-Wsequence-point<span style="color: #7a0874; font-weight: bold;">&#93;</span>
..<span style="color: #000000; font-weight: bold;">/</span>Crypto<span style="color: #000000; font-weight: bold;">/</span>Aeskey.c:<span style="color: #000000;">527</span>:<span style="color: #000000;">25</span>: warning: operation on ‘ss<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>’ may be undefined <span style="color: #7a0874; font-weight: bold;">&#91;</span>-Wsequence-point<span style="color: #7a0874; font-weight: bold;">&#93;</span>
..<span style="color: #000000; font-weight: bold;">/</span>Crypto<span style="color: #000000; font-weight: bold;">/</span>Aeskey.c:<span style="color: #000000;">527</span>:<span style="color: #000000;">25</span>: warning: operation on ‘ss<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">7</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>’ may be undefined <span style="color: #7a0874; font-weight: bold;">&#91;</span>-Wsequence-point<span style="color: #7a0874; font-weight: bold;">&#93;</span>
...
Converting Language.xml
Compiling Resources.cpp
Linking truecrypt</pre></div></div>

<p>I created the TrueCrypt volume separately via its desktop GUI with <code>ext3</code> file system to then mount it in Pi to a configured <a href="http://en.wikipedia.org/wiki/Samba_(software)" target="_blank">Samba share</a>. As pointed out in <a href="http://raspberrywebserver.com/serveradmin/share-your-raspberry-pis-files-and-folders-across-a-network.html" target="_blank">a post</a>, the following changes are added to <code>smb.conf</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
wins support = <span style="color: #c20cb9; font-weight: bold;">yes</span>
...
<span style="color: #7a0874; font-weight: bold;">&#91;</span>pitruecrypt<span style="color: #7a0874; font-weight: bold;">&#93;</span>
   <span style="color: #007800;">comment</span>= Pi Truecrypt Volume
   <span style="color: #007800;">path</span>=<span style="color: #000000; font-weight: bold;">&lt;</span>the <span style="color: #c20cb9; font-weight: bold;">mount</span> path of the USB thumb drive TrueCrypt volume<span style="color: #000000; font-weight: bold;">&gt;</span>
   <span style="color: #007800;">browseable</span>=Yes
   <span style="color: #007800;">writeable</span>=Yes
   only <span style="color: #007800;">guest</span>=no
   create <span style="color: #007800;">mask</span>=0777
   directory <span style="color: #007800;">mask</span>=0777
   <span style="color: #007800;">public</span>=no</pre></div></div>

<p>and then user-password are entered via interactive command.</p>
<p>For mobility, I already had the Pi as WiFi access point using <code><a href="hostap.epitest.fi/hostapd/" target="_blank">hostapd</a></code> (check <a href="http://sirlagz.net/2012/08/09/how-to-use-the-raspberry-pi-as-a-wireless-access-pointrouter-part-1/" target="_blank">these steps</a>) and <a href="http://www.amazon.com/HAME-10400mAh-Double-Indicators-Capacity/dp/B00B5OFC5I" target="_blank">power bank</a>, so it&#8217;s now matter of performance. In the case of <code><a href="http://www.samba.org/rsync/" target="_blank">rsync</a></code>, initial sync of some 1,500 items totaling in 1 Gig size elapses in approximately the same 12 minutes of time compared to one bulk file of the same size. Of course, over the next incremental sync, it only takes less than a minute for the thousand items to just update slight differences.</p>
<h3>Security</h3>
<p>Back to security, there surely risk by opening Samba share to mounted TrueCrypt volume. But, for me it would be practically manageable (cross my finger). There is more concern to the fate of <a href="http://truecrypt.sourceforge.net/" target="_blank">TrueCrypt</a> after it is being closed in such a weird way, given that <a href="https://opencryptoaudit.org/reports/iSec_Final_Open_Crypto_Audit_Project_TrueCrypt_Security_Assessment.pdf" target="_blank">last audit</a> finds nothing severe. Anyway, I found brute force tool, but no critical attack exists currently, unless e.g. it stays powered on and mounted, the person gain physical access. Beats me again.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2014/06/mobile-wifi-nas-raspberry-pi-truecrypt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How DHCP/DNS Server Works in Web Proxy Autodiscovery Protocol (WPAD) for Today&#8217;s Browsers</title>
		<link>https://lakm.us/logit/2013/05/how-dhcp-dns-server-works-web-proxy-autodiscovery-protocol-wpad-today-major-browsers/</link>
		<comments>https://lakm.us/logit/2013/05/how-dhcp-dns-server-works-web-proxy-autodiscovery-protocol-wpad-today-major-browsers/#comments</comments>
		<pubDate>Wed, 15 May 2013 07:22:42 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[autodiscovery]]></category>
		<category><![CDATA[DHCP]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[MikroTik]]></category>
		<category><![CDATA[proxy]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=665</guid>
		<description><![CDATA[Web Proxy Autodiscovery Protocol (WPAD) protocol draft expired in 1999, but today&#8217;s major browsers are still supporting it as will be shown later. Two types of DHCP server are tested to describe how WPAD behaves prior to/after starting up the internet browser. To be clear, uploaded packet captures are shared in CloudShark. DNS and domain [...]]]></description>
				<content:encoded><![CDATA[<p>Web Proxy Autodiscovery Protocol <a href="http://tools.ietf.org/html/draft-ietf-wrec-wpad-01" title="Web Proxy Auto-Discovery Protocol" target="_blank">(WPAD) protocol draft</a> expired in 1999, but today&#8217;s major browsers are still supporting it as will be shown later. Two types of DHCP server are tested to describe how WPAD behaves prior to/after starting up the internet browser. To be clear, uploaded packet captures are shared in <a href="http://www.cloudshark.org/" title="CloudShark" target="_blank">CloudShark</a>. DNS and domain resolution is a must for the WPAD to work when MS Windows Internet Options configured to &#8220;<a href="http://https://github.com/bandono/proxyConf/blob/v1.1/www/images/winxp-internet-properties-02-lan-settings.png" title="proxyConf Github: screenshot of Windows Internet Options proxy setting" target="_blank">Automatically detect settings</a>&#8221; (for <a href="http://en.wikipedia.org/wiki/Internet_Explorer_6">IE 6 in Windows XP desktop</a>, <a href="http://en.wikipedia.org/wiki/Internet_Explorer_8" target="_blank">IE 8 in Windows 7 desktop</a>, and <a href="https://www.google.com/intl/en/chrome/browser/" title="Chrome Browser - Google" target="_blank">Google Chrome</a>) or Firefox to &#8220;<a href="https://github.com/bandono/proxyConf/blob/v1.1/www/images/firefox-03-auto-proxy-config-url.png" title="proxyConf Github: screenshot of Firefox proxy setting" target="_blank">Auto-detect proxy settings for this network</a>&#8220;. As simplest DNS setting should work, this post will not cover its configuration. </p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Low level view of WPAD interactions involving DHCP, DNS, and HTTP servers in packet capture (shared in CloudShark)" src="../../../../images/proxy-wpad-dhcp-dns-packet-capture-cloudshark.png" title="Low level view of WPAD interactions involving DHCP, DNS, and HTTP servers in packet capture (shared in CloudShark)" width="390" height="328" /><p class="wp-caption-text">Low level view of WPAD interactions involving DHCP, DNS, and HTTP servers in packet capture (shared in CloudShark)</p></div>
<p>In DHCP discovery-offer-request-acknowledgement cycle, WPAD information is given in option 252 (check <a href="http://tools.ietf.org/html/draft-ietf-wrec-wpad-01#section-4.4.1" target="_blank">section 4.4.1 of the draft</a>). I used <a href="http://packages.ubuntu.com/precise/dhcp3-server" target="_blank"><code>dhcpd3-server</code> package</a> in Ubuntu and setup <code>/ip dhcp-server option add code=252 ...</code> in <a href="http://www.mikrotik.com/download/CHANGELOG_5" target="_blank">Mikrotik 5.20</a> for example variations. For both, trailing &#8220;<code>\n</code>&#8221; are added to <code>wpad.dat</code> URL value as most howtos recommend.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #ff0000;">&quot;http://wpad.some-company.net/wpad.dat<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span></pre></div></div>

<p>In the above example value, <code>wpad.dat</code> is hosted in <a href="http://packages.ubuntu.com/precise/apache2" target="_blank">Apache2 HTTP server</a> resolvable by the DNS to the actual host IP of <code>wpad.some-company.net</code>. When the client use all DHCP offered items, it gets domain name (option 15) <code>some-company.net</code> besides other things e.g.  router (option 3), DNS (option 6), etc. In a case where the client use its own DNS (only use IP from DHCP), <strong>WPAD likely won&#8217;t work</strong> unless it is able to resolve the example <code>some-company.net</code> or <code>wpad.some-company.net</code>. Following the tail of <code>/var/log/apache2/access.log</code>, successful <code>wpad.dat</code> request will appear as</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.75 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span>01<span style="color: #000000; font-weight: bold;">/</span>May<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">21</span>:<span style="color: #000000;">51</span>:<span style="color: #000000;">15</span> +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat HTTP/1.1&quot;</span> <span style="color: #000000;">200</span> <span style="color: #000000;">1070</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;-&quot;</span></pre></div></div>

<p><span id="more-665"></span><br />
In the above tail, I enabled a Windows 7&#8242;s network adapter (from previously disabled) and it would soon try to HTTP <code>GET</code> the <code>wpad.dat</code> even when no browser opened yet.</p>
<p>From testing with Windows XP, Windows 7, and Ubuntu (with different browsers mostly), <code>DHCP Inform</code>&#8216;s WPAD behavior can be seen with Windows 7 test by analyzing the packet going out after some time since the initial DHCP stream (check <a href="http://www.cloudshark.org/captures/1dc9e4cb8ca1" title="WPAD packet capture: Windows 7 client with ISC DHCP server running in Ubuntu 12.04" target="_blank">the packet capture</a> for 7 seconds after <code>DHCP Discover</code>). It asked for WPAD in one of the <code>Parameter Request List Item</code> (apply the filter <code>bootp.option.request_list_item == 252</code> for a closer look), but received no answer.</p>
<p>I failed to reproduce other samples of <code>DHCP Inform</code> packet asking for WPAD. Hence, for the rest, it&#8217;s the browser who is doing the <code>GET</code> to <code>http://wpad.some-company.net/wpad.dat</code> with DHCP only supplied domain name instead of complete WPAD (check <a href="http://www.cloudshark.org/captures/5d73416a18d5" target="_blank">another packet capture</a>, this time for <a href="http://packages.ubuntu.com/precise/firefox" target="_blank">Ubuntu with Firefox 20</a>). The <code>GET</code> attempt isn&#8217;t actually one shot attempt. When it fails to find the <code>wpad.dat</code> in <code>http://wpad.some-company.net/wpad.dat</code>, it should iteratively try to find within the higher domain e.g. <code>http://some-company.net/wpad.dat</code>.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Getting proxy setting (WPAD) from DHCP or directly by browser iterative decision" src="../../../../images/proxy-wpad-dhcp-browser-iteration-decision-illustration.png" title="Getting proxy setting (WPAD) from DHCP or directly by browser iterative decision" width="292" height="193" /><p class="wp-caption-text">Getting proxy setting (WPAD) from DHCP or directly by browser iterative decision</p></div>
<p>DHCP server configuration used, <code>wpad.dat</code> file example (I simply use symbolic link to <code>proxy.pac</code>), and Apache2 <code>VirtualHost</code> config are available in <a href="https://github.com/bandono/proxyConf/tree/v1.1" target="_blank">my github, an attempt to integrate Squid3 cache with WPAD, PAC, and DHCP</a>.</p>
<p><a id="History" href="#History" rel="bookmark" title="History"><br />
<h4>History</h4>
<p></a></p>
<p>For trailing character in WPAD value mentioned earlier, I once configured option 252 value with &#8220;<code>wpad.dat\?</code>&#8220;, &#8220;<code>proxy.pa</code>&#8220;, and some other likely wrong variations. I also configured the browser in Windows XP and 7 with these variations of wrong values before getting the browser to use proxy auto-discovery again. Somehow it kept the wrong <code>GET</code> with trailing character resulting in 404 (page not found):</p>
<ol>
<li>Firefox</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.78 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">30</span><span style="color: #000000; font-weight: bold;">/</span>Apr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">20</span>:<span style="color: #000000;">39</span> +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat/ HTTP/1.1&quot;</span> <span style="color: #000000;">404</span> <span style="color: #000000;">478</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Mozilla/4.0 (compatible; MSIE 6.0; Win32)&quot;</span></pre></div></div>

<li>IE 6</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.78 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">30</span><span style="color: #000000; font-weight: bold;">/</span>Apr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">16</span>:<span style="color: #000000;">28</span>:07 +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat/ HTTP/1.1&quot;</span> <span style="color: #000000;">404</span> <span style="color: #000000;">478</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;Mozilla/4.0 (compatible; MSIE 6.0; Win32)&quot;</span></pre></div></div>

<li>IE 8</li>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">192.168.40.77 - - <span style="color: #7a0874; font-weight: bold;">&#91;</span>01<span style="color: #000000; font-weight: bold;">/</span>May<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2013</span>:<span style="color: #000000;">20</span>:07:<span style="color: #000000;">24</span> +0700<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #ff0000;">&quot;GET /wpad.dat/? HTTP/1.1&quot;</span> <span style="color: #000000;">404</span> <span style="color: #000000;">534</span> <span style="color: #ff0000;">&quot;-&quot;</span> <span style="color: #ff0000;">&quot;-&quot;</span></pre></div></div>

</ol>
<p>I was able to force it to <code>GET</code> the correct WPAD value by adding new network adapter which received different IP lease from DHCP server. Afterwards, connecting with the old adapter will also keep correct behavior.</p>
<p>I still don&#8217;t know how they keep the previously incorrect behavior. <strong>In short we can&#8217;t rely on WPAD alone</strong>, but there is probability that some portions of the network clients will find the proxy this way, automatically without technical assistance.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/05/how-dhcp-dns-server-works-web-proxy-autodiscovery-protocol-wpad-today-major-browsers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Running Two Squid Instances in Upstart Init</title>
		<link>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/</link>
		<comments>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/#comments</comments>
		<pubDate>Fri, 10 May 2013 08:55:16 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[daemon]]></category>
		<category><![CDATA[proxy]]></category>
		<category><![CDATA[squid]]></category>
		<category><![CDATA[startup]]></category>
		<category><![CDATA[workaround]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=644</guid>
		<description><![CDATA[After installing squid3 from repository, Ubuntu will place the init in upstart style (instead of /etc/rc*.d/ or /etc/init.d/ style used to maintain backward compatibility to legacy System-V init). The upstart job is placed in /etc/init/squid3.conf with default runlevel (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using service: $ sudo [...]]]></description>
				<content:encoded><![CDATA[<p>After installing <a href="http://www.squid-cache.org/" target="_blank">squid3</a> from <a href="http://packages.ubuntu.com/precise/squid3" target="_blank">repository</a>, Ubuntu will place the <code>init</code> in <a href="http://upstart.ubuntu.com/" target="_blank">upstart</a> style (instead of <code>/etc/rc*.d/</code> or <code>/etc/init.d/</code> style used to maintain backward compatibility to legacy <a href="http://en.wikipedia.org/wiki/Init" target="_blank">System-V init</a>). The upstart job is placed in <code>/etc/init/squid3.conf</code> with default <code>runlevel</code> (2,3,4 or 5) to start the instance during reboot and relevant start/stop command using <code>service</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> service squid3 <span style="color: #7a0874; font-weight: bold;">&#123;</span>start<span style="color: #000000; font-weight: bold;">|</span>stop<span style="color: #000000; font-weight: bold;">|</span>restart<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>To specify what to run, an <code>upstart</code> <a href="http://upstart.ubuntu.com/getting-started.html" target="_blank">must have</a> <code>exec</code> or <code>script</code> stanza. When the goal is to start two or more (multiple) instances of <code>squid3</code>, <code>exec</code> is meant <a href="http://manpages.ubuntu.com/manpages/precise/man3/exec.3.html" target="_blank">to replace existing process image</a> of <code>/usr/sbin/squid3</code> executable, therefore will not start two instances.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Eltek Smartpack Controller type with SNMP Support" src="../../../../images/squid3-two-instances-illustration.png" title="Multiple squid3 instances started via upstart exec" width="385" height="188" /><p class="wp-caption-text">Multiple squid3 instances started via upstart exec</p></div>
<p>As workaround we can have symbolic link to <code>squid3</code> executable instead and add new <code>upstart</code> job configuration with <code>exec</code> call to the link. I need two instances running in the same machine due to the implementation design where the fist instance is HTTP proxy cache while the second one is accelerator/interceptor (reverse proxy) that serves default landing page telling user to use proxy (and how to do that). Hence, for the second instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">lrwxrwxrwx <span style="color: #000000;">1</span> root root <span style="color: #000000;">6</span> May  <span style="color: #000000;">3</span> 09:<span style="color: #000000;">25</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>squid3ins2 -<span style="color: #000000; font-weight: bold;">&gt;</span> squid3
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">1156</span> May  <span style="color: #000000;">6</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">30</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3ins2.conf</pre></div></div>

<p>and for the first instance I add:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> root root <span style="color: #000000;">298</span> May  <span style="color: #000000;">3</span> <span style="color: #000000;">10</span>:<span style="color: #000000;">13</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init<span style="color: #000000; font-weight: bold;">/</span>squid3.override</pre></div></div>

<p><code>squid3ins2</code> is our link and <code>/etc/init/squid3ins2.conf</code> contains <code>exec</code> call to it to run second <code>squid3</code>. For the first instance I choose to write an override (<code>/etc/init/squid3.override</code>) so that the original job configuration file is left intact. For the complete content of all files check <a href="https://github.com/bandono/proxyConf/tree/v1.1/init" target="_blank">my github v1.1</a> of the Squid integration. There, in details you&#8217;ll also find how both instances PID, log, etc. are differentiated by each instance config via the following directives:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">http_port
cache_dir
pid_filename
cache_access_log
cache_log</pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/05/running-two-multiple-squid-instances-upstart-init-job/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HTTPS Using Server-Client Certificate Pair (1): Generate &amp; Sign by OpenSSL</title>
		<link>https://lakm.us/logit/2013/01/https-server-client-certificate-pair-1-generate-openssl/</link>
		<comments>https://lakm.us/logit/2013/01/https-server-client-certificate-pair-1-generate-openssl/#comments</comments>
		<pubDate>Wed, 23 Jan 2013 04:41:30 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[certificate]]></category>
		<category><![CDATA[https]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[SSL]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=451</guid>
		<description><![CDATA[Multiple command lines in the process of generating certificates using openssl can be quite confusing and easily mixed up over which-do-what. Most of them are repetitions of almost the same syntax (where the confusion comes). Background: I need to setup an HTTPS site with not just server certificate to secure it, but requiring also client [...]]]></description>
				<content:encoded><![CDATA[<p>Multiple command lines in the process of generating certificates using <code><a title="OpenSSL" href="http://www.openssl.org/" target="_blank">openssl</a></code> can be quite confusing and easily mixed up over which-do-what. Most of them are repetitions of almost the same syntax (where the confusion comes).</p>
<p>Background:<br />
I need to setup an <a title="HTTP Secure" href="http://en.wikipedia.org/wiki/HTTP_Secure" target="_blank">HTTPS</a> site with not just server certificate to secure it, but requiring also client side certificate. The site will only show the content to authorized users with the correct pair of server-client certificate. It will also expire after a certain date. The certificates are self-signed as they&#8217;re for closed environment usage.</p>
<p>This post covers two general processes: <em><strong>generating</strong></em> and <em><strong>signing</strong></em>.</p>
<p>How to <em><strong>generate</strong></em> SSL certificate using <code>openssl</code> is a straightforward process of:</p>
<ol>
<li>generate its key</li>
<li>create certificate request with that key</li>
<li>generate certificate from request and key</li>
</ol>
<p>Hence, in any type of the certificate I have a general <code>&lt;some-cert-key&gt;.key</code>, <code>&lt;some-cert-request&gt;.csr</code>, and <code>&lt;some-cert&gt;.crt</code>. When I mean &#8220;type&#8221;, they are <a href="http://en.wikipedia.org/wiki/Certificate_authority" title="Certificate Authority" target="_blank">CA (Certificate Authority)</a>, one/more server certificate, and one/more client certificate.</p>
<div class="wp-caption aligncenter" style="width: 460px"><img title="Generating Pair of Key-Certificate with openSSL" src="../../../../images/ssl-certificate-ca-server-client-illustration-1.png" alt="ssl-certificate-ca-server-client-illustration-1.png" width="286" height="226" /><p class="wp-caption-text">Generating Pairs of Key-Certificate with openSSL: CA, server, &amp; client</p></div>
<p>In terms of <strong>signing</strong> the certificates, all of them are signed using the CA. Which files to be used in the server will become the subject of the next post.</p>
<p><span id="more-451"></span><code>openssl</code> will run interactively. To go through all the recurring questions using prepared default answers, we need to create a config file first. I created <code>caconfig.cnf</code> (find it on the bottom of the post) and use <code>-config caconfig.cnf</code> option in some commands.</p>
<p>First, prepare set of directories to clearly separate what we&#8217;re working on (keys, requests, and resulting certificates in different places for server and user):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> certs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> private
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> server
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> server<span style="color: #000000; font-weight: bold;">/</span>certs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> server<span style="color: #000000; font-weight: bold;">/</span>creqs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> server<span style="color: #000000; font-weight: bold;">/</span>ckeys
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> user
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> user<span style="color: #000000; font-weight: bold;">/</span>certs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> user<span style="color: #000000; font-weight: bold;">/</span>creqs
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> user<span style="color: #000000; font-weight: bold;">/</span>ckeys</pre></div></div>

<p>Prepare &#8220;database&#8221; and index number to keep track of certificates issued:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> 01 <span style="color: #000000; font-weight: bold;">&gt;</span> serial
<span style="color: #c20cb9; font-weight: bold;">touch</span> index.txt</pre></div></div>

<p>Generate the CA: (again) generate key, create request (the interactive part), and create certificate:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-out</span> private<span style="color: #000000; font-weight: bold;">/</span>myCA.key <span style="color: #000000;">2048</span>
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> private<span style="color: #000000; font-weight: bold;">/</span>myCA.key <span style="color: #660033;">-out</span> certs<span style="color: #000000; font-weight: bold;">/</span>myCA.csr <span style="color: #660033;">-config</span> caconfig.cnf 
openssl req <span style="color: #660033;">-x509</span> <span style="color: #660033;">-days</span> <span style="color: #000000;">365</span> <span style="color: #660033;">-in</span> certs<span style="color: #000000; font-weight: bold;">/</span>myCA.csr <span style="color: #660033;">-out</span> certs<span style="color: #000000; font-weight: bold;">/</span>myCA.crt <span style="color: #660033;">-key</span> private<span style="color: #000000; font-weight: bold;">/</span>myCA.key</pre></div></div>

<p>We can always check:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl x509 <span style="color: #660033;">-in</span> certs<span style="color: #000000; font-weight: bold;">/</span>myCA.crt <span style="color: #660033;">-text</span></pre></div></div>

<p>Now, <em><strong>generating</strong></em> for the <strong>server</strong>, I use the name <code>lakmus</code> as an example. First the key:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> server<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>lakmus.key <span style="color: #000000;">2048</span></pre></div></div>

<p>(<a href="http://en.wikipedia.org/wiki/Triple_DES" title="Triple DES" target="_blank">Triple-DES</a> cipher will ask for pass phrase of 4 characters minimum)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Enter pass phrase <span style="color: #000000; font-weight: bold;">for</span> server<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>lakmus.key:
Verifying - Enter pass phrase <span style="color: #000000; font-weight: bold;">for</span> server<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>lakmus.key:</pre></div></div>

<p>Then, the request (which will ask for the above key pass phrase):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> server<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>lakmus.key <span style="color: #660033;">-out</span> server<span style="color: #000000; font-weight: bold;">/</span>creqs<span style="color: #000000; font-weight: bold;">/</span>lakmus.csr <span style="color: #660033;">-config</span> caconfig.cnf</pre></div></div>

<p>Note that <code>organizationName</code> field needs to be the same with the CA certificate.</p>
<p>Then, <em><strong>signing</strong></em> it with the CA (and again check as text):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl ca <span style="color: #660033;">-days</span> <span style="color: #000000;">365</span> <span style="color: #660033;">-in</span> server<span style="color: #000000; font-weight: bold;">/</span>creqs<span style="color: #000000; font-weight: bold;">/</span>lakmus.csr <span style="color: #660033;">-cert</span> certs<span style="color: #000000; font-weight: bold;">/</span>myCA.crt <span style="color: #660033;">-out</span> server<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>lakmus.crt <span style="color: #660033;">-keyfile</span> private<span style="color: #000000; font-weight: bold;">/</span>myCA.key <span style="color: #660033;">-config</span> caconfig.cnf
&nbsp;
openssl x509 <span style="color: #660033;">-in</span> server<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>lakmus.crt <span style="color: #660033;">-text</span></pre></div></div>

<p>During <em><strong>signing</strong></em> we&#8217;ll see something like (expiry date and validity periode)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Certificate is to be certified <span style="color: #000000; font-weight: bold;">until</span> <span style="color: #000000; font-weight: bold;">&lt;</span>some <span style="color: #c20cb9; font-weight: bold;">date</span><span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">365</span> days<span style="color: #7a0874; font-weight: bold;">&#41;</span>
Sign the certificate? <span style="color: #7a0874; font-weight: bold;">&#91;</span>y<span style="color: #000000; font-weight: bold;">/</span>n<span style="color: #7a0874; font-weight: bold;">&#93;</span>:</pre></div></div>

<p>and <code>index.txt</code> is updated:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">V	140123034822Z		01	unknown	<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=ID<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=WEST JAVA<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=My Organization<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=lakm.us
V	140123041441Z		02	unknown	<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">C</span>=ID<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">ST</span>=WEST JAVA<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">O</span>=My Organization<span style="color: #000000; font-weight: bold;">/</span><span style="color: #007800;">CN</span>=client</pre></div></div>

<p>Finally, the same <em><strong>generate</strong></em> with own key and <em><strong>sign</strong></em> with CA except this time is for <strong>client</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl genrsa <span style="color: #660033;">-des3</span> <span style="color: #660033;">-out</span> user<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>client1.key <span style="color: #000000;">2048</span>
openssl req <span style="color: #660033;">-new</span> <span style="color: #660033;">-key</span> user<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>client1.key <span style="color: #660033;">-out</span> user<span style="color: #000000; font-weight: bold;">/</span>creqs<span style="color: #000000; font-weight: bold;">/</span>client1.csr <span style="color: #660033;">-config</span> caconfig.cnf
&nbsp;
openssl ca <span style="color: #660033;">-in</span> user<span style="color: #000000; font-weight: bold;">/</span>creqs<span style="color: #000000; font-weight: bold;">/</span>client1.csr <span style="color: #660033;">-cert</span> certs<span style="color: #000000; font-weight: bold;">/</span>myCA.crt <span style="color: #660033;">-keyfile</span> private<span style="color: #000000; font-weight: bold;">/</span>myCA.key <span style="color: #660033;">-out</span> user<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>client1.crt <span style="color: #660033;">-config</span> caconfig.cnf 
&nbsp;
openssl x509 <span style="color: #660033;">-in</span> user<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>client1.crt <span style="color: #660033;">-text</span></pre></div></div>

<p>For the client certificate to be usable when importing to browser, convert it to <a href="http://en.wikipedia.org/wiki/PKCS_12" title="PKCS 12" target="_blank">PKCS 12</a></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">openssl pkcs12 <span style="color: #660033;">-export</span> <span style="color: #660033;">-clcerts</span> <span style="color: #660033;">-in</span> user<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>client1.crt <span style="color: #660033;">-inkey</span> user<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>client1.key <span style="color: #660033;">-out</span> user<span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>client1.p12</pre></div></div>

<p>It will ask for pass phrase and export password (that will be prompted when importing to browser)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Enter pass phrase <span style="color: #000000; font-weight: bold;">for</span> user<span style="color: #000000; font-weight: bold;">/</span>ckeys<span style="color: #000000; font-weight: bold;">/</span>client1.key:
Enter Export Password:
Verifying - Enter Export Password:</pre></div></div>

<p><a id="Troubleshooting" href="Troubleshooting" rel="bookmark" title="Troubleshooting"><br />
<h4>Troubleshooting</h4>
<p></a></p>
<p>If the CA generation already worked smoothly, it is better to remove the key, request, and certificate files of subsequent signing process before repeating them when any error is found. Otherwise it will finally show error such as:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">failed to update database
TXT_DB error number <span style="color: #000000;">2</span></pre></div></div>

<p>Or something like</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">No certificate matches private key</pre></div></div>

<p>when exporting to PKCS 12.</p>
<p>We can check the <code>index.txt</code>, <code>index.old</code>, <code>serial</code>, and <code>serial.old</code> to figure our situation by evaluating indexes of signed certificate.</p>
<p><a id="CAConfig" href="#CAConfig" rel="bookmark" title="CAConfig"><br />
<h4>CA Config</h4>
<p></a></p>
<p>I used parts from <a href="http://codeghar.wordpress.com/2008/03/17/create-a-certificate-authority-and-certificates-with-openssl/" title="Create a Certificate Authority and Certificates with OpenSSL" target="_blank">Code Ghar post</a> for my <code>caconfig.cnf</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">&#91;</span> ca <span style="color: #7a0874; font-weight: bold;">&#93;</span>
default_ca = CA_default
<span style="color: #7a0874; font-weight: bold;">&#91;</span> CA_default <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #c20cb9; font-weight: bold;">dir</span> = <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>arif<span style="color: #000000; font-weight: bold;">/</span>ssl
serial = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>serial
database = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>index.txt
new_certs_dir = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>certs
certificate = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>certs<span style="color: #000000; font-weight: bold;">/</span>myCAcert.crt
private_key = <span style="color: #007800;">$dir</span><span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>myCA.key
default_days = <span style="color: #000000;">365</span>
default_md = md5
preserve = no
email_in_dn = no
nameopt = default_ca
certopt = default_ca
policy = policy_match
<span style="color: #7a0874; font-weight: bold;">&#91;</span> policy_match <span style="color: #7a0874; font-weight: bold;">&#93;</span>
countryName = match
stateOrProvinceName = match
organizationName = match
organizationalUnitName = optional
commonName = supplied
emailAddress = optional
<span style="color: #7a0874; font-weight: bold;">&#91;</span> req <span style="color: #7a0874; font-weight: bold;">&#93;</span>
default_bits = <span style="color: #000000;">2048</span> <span style="color: #666666; font-style: italic;"># Size of keys</span>
default_keyfile = key.pem <span style="color: #666666; font-style: italic;"># name of generated keys</span>
default_md = md5 <span style="color: #666666; font-style: italic;"># message digest algorithm</span>
string_mask = nombstr <span style="color: #666666; font-style: italic;"># permitted characters</span>
distinguished_name = req_distinguished_name
<span style="color: #7a0874; font-weight: bold;">&#91;</span> req_distinguished_name <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #666666; font-style: italic;"># Variable name Prompt string</span>
<span style="color: #666666; font-style: italic;">#------------------------- ----------------------------------</span>
0.organizationName = Organization Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>company<span style="color: #7a0874; font-weight: bold;">&#41;</span>
organizationalUnitName = Organizational Unit Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>department, division<span style="color: #7a0874; font-weight: bold;">&#41;</span>
emailAddress = Email Address
emailAddress_max = <span style="color: #000000;">40</span>
localityName = Locality Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>city, district<span style="color: #7a0874; font-weight: bold;">&#41;</span>
stateOrProvinceName = State or Province Name <span style="color: #7a0874; font-weight: bold;">&#40;</span>full name<span style="color: #7a0874; font-weight: bold;">&#41;</span>
countryName = Country Name <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span> letter code<span style="color: #7a0874; font-weight: bold;">&#41;</span>
countryName_min = <span style="color: #000000;">2</span>
countryName_max = <span style="color: #000000;">2</span>
commonName = Common Name <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">hostname</span>, IP, or your name<span style="color: #7a0874; font-weight: bold;">&#41;</span>
commonName_max = <span style="color: #000000;">64</span>
<span style="color: #666666; font-style: italic;"># Default values for the above, for consistency and less typing.</span>
<span style="color: #666666; font-style: italic;"># Variable name Value</span>
<span style="color: #666666; font-style: italic;">#------------------------ ------------------------------</span>
0.organizationName_default = My Organization
localityName_default = BOGOR
stateOrProvinceName_default = WEST JAVA
countryName_default = ID
emailAddress_default = fake<span style="color: #000000; font-weight: bold;">@</span>lakm.us
commonName_default = lakm.us</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2013/01/https-server-client-certificate-pair-1-generate-openssl/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Python 2.6 in Red Hat 5</title>
		<link>https://lakm.us/logit/2012/05/python-2-6-red-hat-5/</link>
		<comments>https://lakm.us/logit/2012/05/python-2-6-red-hat-5/#comments</comments>
		<pubDate>Mon, 14 May 2012 02:39:46 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[red hat]]></category>
		<category><![CDATA[repo]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=386</guid>
		<description><![CDATA[I need Gescheit Zabbix API implementation to run on RHEL5.2 Installing RPMs from Geekymedia seems to be the easiest. I only need the following to make it work: python26-2.6-geekymedia1.i386.rpm python26-libs-2.6-geekymedia1.i386.rpm]]></description>
				<content:encoded><![CDATA[<p>I need <a href="https://github.com/gescheit/scripts" title="Gescheit github" target="_blank">Gescheit Zabbix API implementation</a> to run on RHEL5.2</p>
<p>Installing RPMs from <a href="http://www.geekymedia.com/uncategorized/rhel5-centos5-rpms-for-python-2-5-and-2-6/" title="RHEL5/CentOS5 RPMs for Python 2.5 and 2.6" target="_blank">Geekymedia</a> seems to be the easiest. I only need the following to make it work: </p>
<ol>
<li>python26-2.6-geekymedia1.i386.rpm</li>
<li>python26-libs-2.6-geekymedia1.i386.rpm</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/05/python-2-6-red-hat-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SNMP: Mistake of Using Tabular OID in Practice</title>
		<link>https://lakm.us/logit/2012/03/snmp-mistake-tabular-oid-practice/</link>
		<comments>https://lakm.us/logit/2012/03/snmp-mistake-tabular-oid-practice/#comments</comments>
		<pubDate>Tue, 20 Mar 2012 07:57:58 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[appliance]]></category>
		<category><![CDATA[MIB]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[proprietary]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=372</guid>
		<description><![CDATA[Recently, I retrieve rectifier-related SNMP data from Eltek&#8217;s Smartpack Controller. This one has the following rear type where we can connect to the ethernet plug (see the purple area). It is presumably in its default configuration and I can snmpwalk through its corporate specific OIDs (under 12148 tree) to find i.e. output voltage, current, battery [...]]]></description>
				<content:encoded><![CDATA[<p>Recently, I retrieve rectifier-related SNMP data from <a href="http://www.eltek.com/wip4/detail_products.epl?k1=25507&#038;close=1&#038;id=1123846" title="Eltek Smartpack Controller" target="_blank">Eltek&#8217;s Smartpack Controller</a>. This one has the following rear type where we can connect to the ethernet plug (see the purple area).</p>
<div class="wp-caption aligncenter" style="width: 460px"><img alt="Eltek Smartpack Controller type with SNMP Support" src="../../../../images/eltek-smartpack-rear-1.jpg" title="Eltek Smartpack Controller type with SNMP Support" width="266" height="103" /><p class="wp-caption-text">Eltek Smartpack Controller rear view (type that comes with SNMP support)</p></div>
<p>It is presumably in its default configuration and I can <code>snmpwalk</code> through its corporate specific OIDs (under 12148 tree) to find i.e. output voltage, current, battery temperature, etc. Doing it without translating against the MIB will retrieve all the values perfectly fine. However, I want to show you a mistake in practice related to how the MIB is written and put to place, which is a version 4 by the name of <a href="http://forums.manageengine.com/viewFile.do?fileId=49000003919231&#038;forumGroupId=49000000002007" title="Manage Engine Forum: ELTEK-DISTRIBUTED-PLANTV4-MIB">ELTEK-DISTRIBUTED-PLANTV4-MIB</a>. It has tabular part as clipped in the following tree (see <a href="./2011/09/write-mib-file-tabular/" title="Write Your Own MIB File (Tabular)" target="_blank">previous post</a> on how to write such part in your own MIB):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">            <span style="color: #000000; font-weight: bold;">|</span>     +--eltek<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">12148</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        +--eltekDistributedPlantV4<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
...
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>     +--rectifierStatusTable<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>        +--rectifierStatusEntry<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>  Index: rectifierStatusID
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>           +-- <span style="color: #660033;">-R--</span> Integer32 rectifierStatusID<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>        Range: 1..100
...
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>           +-- <span style="color: #660033;">-R--</span> Integer32 rectifierStatusOutputVoltage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>           <span style="color: #000000; font-weight: bold;">|</span>        Range: 0..65535</pre></div></div>

<p>Looking at the above <code>rectifierStatusEntry</code> branch, it marks a tabular entry expected to range from 1 to 100 as defined by <code>rectifierStatusID</code>. Hence, putting 0 as one of the output voltage index will confuse the OID reported by <code>GET</code> as</p>
<ol>
<li>belong to the scalar type (a misconception that is)</li>
<li>belong to the tabular type but out of index range</li>
</ol>
<p><code>GET</code> against the MIB will return the following error</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> snmpget <span style="color: #660033;">-m</span> +ELTEK-DISTRIBUTED-PLANTV4-MIB <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public raddlex ELTEK-DISTRIBUTED-PLANTV4-MIB::rectifierStatusOutputCurrent.0
ELTEK-DISTRIBUTED-PLANTV4-MIB::rectifierStatusOutputCurrent.0: Unknown Object Identifier <span style="color: #7a0874; font-weight: bold;">&#40;</span>Index out of range: <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>rectifierStatusID<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>while the item (output current) actually has value in it as found below</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> snmpget <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public raddlex .1.3.6.1.4.1.12148.9.5.5.2.1.3.0
SNMPv2-SMI::enterprises.12148.9.5.5.2.1.3.0 = INTEGER: <span style="color: #000000;">1</span></pre></div></div>

<p>By this time the MIB is already the latest to be used with firmware version 4.3.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/03/snmp-mistake-tabular-oid-practice/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>USB WiFi Stick on Beagleboard xM Using wpa_supplicant</title>
		<link>https://lakm.us/logit/2012/03/usb-wifi-stick-beagleboard-xm-wpa_supplicant/</link>
		<comments>https://lakm.us/logit/2012/03/usb-wifi-stick-beagleboard-xm-wpa_supplicant/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 04:28:48 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[device driver]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=366</guid>
		<description><![CDATA[One of the most popular USB WiFi sticks in Indonesian market is TP Link which is actually a Ralink wireless adapter (looking at its vendor ID code). Attaching it using wpa_supplicant without explicit driver assignment will return the following error lines ioctl&#91;SIOCSIWENCODEEXT&#93;: Invalid argument ioctl&#91;SIOCSIWENCODEEXT&#93;: Invalid argument Within minutes it will also crash the system [...]]]></description>
				<content:encoded><![CDATA[<p>One of the most popular USB WiFi sticks in Indonesian market is <a href="http://www.tp-link.com/en/products/details/?model=TL-WN321G" title="TL-WN321G" target="_blank">TP Link</a> which is actually a Ralink wireless adapter (looking at its vendor ID code). Attaching it using <code>wpa_supplicant</code> without explicit driver assignment will return the following error lines</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">ioctl<span style="color: #7a0874; font-weight: bold;">&#91;</span>SIOCSIWENCODEEXT<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Invalid argument
ioctl<span style="color: #7a0874; font-weight: bold;">&#91;</span>SIOCSIWENCODEEXT<span style="color: #7a0874; font-weight: bold;">&#93;</span>: Invalid argument</pre></div></div>

<div class="wp-caption aligncenter" style="width: 460px"><img alt="TL-WN321G-01.jpg" src="../../../../images/TL-WN321G-01.jpg" title="TP Link TL-WN321G USB WiFi Stick" width="450" height="270" /><p class="wp-caption-text">TP Link TL-WN321G USB WiFi Stick</p></div>
<p>Within minutes it will also crash the system with messages similar to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">kernel: <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">5645.279693</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> SysRq : HELP : loglevel<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span>-<span style="color: #000000;">9</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> reBoot Crash terminate-all-tasks<span style="color: #7a0874; font-weight: bold;">&#40;</span>E<span style="color: #7a0874; font-weight: bold;">&#41;</span> memory-full-oom-kill<span style="color: #7a0874; font-weight: bold;">&#40;</span>F<span style="color: #7a0874; font-weight: bold;">&#41;</span> kill-all-tasks<span style="color: #7a0874; font-weight: bold;">&#40;</span>I<span style="color: #7a0874; font-weight: bold;">&#41;</span> thaw-filesystems<span style="color: #7a0874; font-weight: bold;">&#40;</span>J<span style="color: #7a0874; font-weight: bold;">&#41;</span> saK show-backtrace-all-active-cpus<span style="color: #7a0874; font-weight: bold;">&#40;</span>L<span style="color: #7a0874; font-weight: bold;">&#41;</span> show-memory-usage<span style="color: #7a0874; font-weight: bold;">&#40;</span>M<span style="color: #7a0874; font-weight: bold;">&#41;</span> nice-all-RT-tasks<span style="color: #7a0874; font-weight: bold;">&#40;</span>N<span style="color: #7a0874; font-weight: bold;">&#41;</span> powerOff show-registers<span style="color: #7a0874; font-weight: bold;">&#40;</span>P<span style="color: #7a0874; font-weight: bold;">&#41;</span> show-all-timers<span style="color: #7a0874; font-weight: bold;">&#40;</span>Q<span style="color: #7a0874; font-weight: bold;">&#41;</span> unRaw Sync show-task-states<span style="color: #7a0874; font-weight: bold;">&#40;</span>T<span style="color: #7a0874; font-weight: bold;">&#41;</span> Unmount ETM buffer dump show-blocked- tasks<span style="color: #7a0874; font-weight: bold;">&#40;</span>W<span style="color: #7a0874; font-weight: bold;">&#41;</span> dump-ftrace-buffer<span style="color: #7a0874; font-weight: bold;">&#40;</span>Z<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>The correct way to attach is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">wpa_supplicant <span style="color: #660033;">-B</span> <span style="color: #660033;">-Dnl80211</span> <span style="color: #660033;">-iwlan0</span> -c<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>wpa_supplicant.conf</pre></div></div>

<p>The config file content is just like what the <a href="https://help.ubuntu.com/community/WifiDocs/Adhoc#Encryption" title="https://help.ubuntu.com/community/WifiDocs/Adhoc#Encryption" target="_blank">community help</a> suggested. The stick with vendor &#038; product ID of <code>148f:2573</code> has been part of the <code>nl80211</code> development at <a href="http://linuxwireless.org/en/developers/Documentation/nl80211" title="http://linuxwireless.org/en/developers/Documentation/nl80211" target="_blank">Linux Wireless</a>.</p>
<p><code>wpa_supplicant</code> version is <code>v0.7.3</code>. Ubuntu version is 11.10 as described further in <a href="./2011/12/ubuntu-on-beagleboard-xm-with-easycap-video-capture-compiling-driver/" title="Ubuntu on Beagleboard xM with Easycap Video Capture (Compiling Driver)" target="_blank">previous post</a>.</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/03/usb-wifi-stick-beagleboard-xm-wpa_supplicant/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Compile USB Serial Modem Using option.c (Ubuntu on Beagleboard xM)</title>
		<link>https://lakm.us/logit/2012/01/compile-usb-serial-modem-using-option-c-ubuntu-on-beagleboard-xm/</link>
		<comments>https://lakm.us/logit/2012/01/compile-usb-serial-modem-using-option-c-ubuntu-on-beagleboard-xm/#comments</comments>
		<pubDate>Mon, 09 Jan 2012 08:54:18 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[ARM Linux]]></category>
		<category><![CDATA[General Linux]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[BeagleBoard]]></category>
		<category><![CDATA[driver]]></category>
		<category><![CDATA[embedded system]]></category>
		<category><![CDATA[kernel]]></category>
		<category><![CDATA[modem]]></category>
		<category><![CDATA[OMAP3]]></category>
		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://xp-racy.lan/it/?p=341</guid>
		<description><![CDATA[Despite possibility to use (1) $ modprobe -v usbserial vendor=0x05c6 product=0x0015 or (2) usb-modeswitch, (3) Matthias Urlichs initially wrote option.c driver as a way to insert USB modem as kernel module. This driver exists because the &#8220;normal&#8221; serial driver doesn&#8217;t work too well with GSM modems. Issues: - data loss &#8212; one single Receive URB [...]]]></description>
				<content:encoded><![CDATA[<p>Despite possibility to use (1)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ modprobe <span style="color: #660033;">-v</span> usbserial <span style="color: #007800;">vendor</span>=0x05c6 <span style="color: #007800;">product</span>=0x0015</pre></div></div>

<p>or (2) <code>usb-modeswitch</code>, (3) <a href="http://matthias.urlichs.de/">Matthias Urlichs</a> initially wrote <code>option.c</code> driver as a way to insert USB modem as kernel module.</p>
<blockquote><p>This driver exists because the &#8220;normal&#8221; serial driver doesn&#8217;t work too well<br />
with GSM modems. Issues:<br />
- data loss &#8212; one single Receive URB is not nearly enough<br />
- nonstandard flow (Option devices) control<br />
- controlling the baud rate doesn&#8217;t make sense</p></blockquote>
<p>Most modems will be successfully attached with this driver, appearing in one of the typical <code>/dev/ttyUSB0</code> to <code>/dev/ttyUSB2</code>. The product ID <code>0x0015</code> for GSM modem compiled here is a Qualcomm (vendor ID 0x05c6) OEM modem I received from <a href="http://www.armkits.com/product/devkit8500d.asp">Embest DevKit8500D</a> order. There are more than one form factor when searching for its images on Google. Closest one we have in Indonesia is ADVAN DT8-HT bundled in <a href="http://www.telkomsel.com/telkomselflash">Telkomsel Flash</a>.</p>
<div class="wp-caption aligncenter" style="width: 510px"><img alt="qualcomm-05c6-0015-telkomsel-advan.jpg" src="../../../../images/qualcomm-05c6-0015-telkomsel-advan.jpg" title="qualcomm-05c6-0015-telkomsel-advan.jpg" class="aligncenter" width="250" height="172" /><p class="wp-caption-text">Qualcomm 05c6:0015 from Indonesian operator</p></div>
<p>I&#8217;m compiling it for the <a href="http://beagleboard.org/hardware-xM">Beagleboard xM</a> Rev C running Ubuntu Oneiric (installed in <a href="../2011/12/ubuntu-on-beagleboard-xm-with-easycap-video-capture-compiling-driver">this post</a>). A quick look gives:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation <span style="color: #000000;">2.0</span> root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation <span style="color: #000000;">2.0</span> root hub
Bus 001 Device 002: ID 0424:<span style="color: #000000;">9514</span> Standard Microsystems Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 005: ID 05c6:0015 Qualcomm, Inc.</pre></div></div>

<p>The above <code>0x0015</code> product ID doesn&#8217;t exist inside <code>option.c</code> of linux <a href="https://launchpad.net/ubuntu/+source/linux/3.0.0-12.20">kernel 3.0.0-12 source</a>. Adding this to series of existing Qualcomm modems gives:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>635
636
637
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">	<span style="color: #7a0874; font-weight: bold;">&#123;</span> USB_DEVICE<span style="color: #7a0874; font-weight: bold;">&#40;</span>QUALCOMM_VENDOR_ID, 0x6000<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>, <span style="color: #000000; font-weight: bold;">/*</span> ZTE AC8700 <span style="color: #000000; font-weight: bold;">*/</span>
	<span style="color: #7a0874; font-weight: bold;">&#123;</span> USB_DEVICE<span style="color: #7a0874; font-weight: bold;">&#40;</span>QUALCOMM_VENDOR_ID, 0x6613<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>, <span style="color: #000000; font-weight: bold;">/*</span> Onda H600<span style="color: #000000; font-weight: bold;">/</span>ZTE MF330 <span style="color: #000000; font-weight: bold;">*/</span>
	<span style="color: #7a0874; font-weight: bold;">&#123;</span> USB_DEVICE<span style="color: #7a0874; font-weight: bold;">&#40;</span>QUALCOMM_VENDOR_ID, 0x0015<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>, <span style="color: #000000; font-weight: bold;">/*</span> Qualcomm no brand <span style="color: #000000; font-weight: bold;">*/</span></pre></td></tr></table></div>

<p>The <code>include</code> also needs <code>usb-wwan.h</code> from that kernel source. Copy them both under  <code>/usr/src/linux-headers-3.0.6-x3/drivers/usb/serial/</code>. For other <code>include</code> files, install:</p>
<ol>
<li><a href="http://ports.ubuntu.com/ubuntu-ports/pool/main/l/linux/linux-headers-3.0.0-12_3.0.0-12.20_all.deb">linux-headers-3.0.0-12_3.0.0-12.20_all.deb</a></li>
<li><a href="https://launchpad.net/ubuntu/oneiric/armel/linux-image-3.0.0-12-omap/3.0.0-12.20">linux-image-3.0.0-12-omap_3.0.0-12.20_armel.deb</a></li>
</ol>
<p>and create this link as <code>root</code></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-headers-3.0.6-x3<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-headers-3.0.0-<span style="color: #000000;">12</span><span style="color: #000000; font-weight: bold;">/</span>arch<span style="color: #000000; font-weight: bold;">/</span>arm<span style="color: #000000; font-weight: bold;">/</span>mach-versatile<span style="color: #000000; font-weight: bold;">/</span>include<span style="color: #000000; font-weight: bold;">/</span>mach mach</pre></td></tr></table></div>

<p>After removing the old one (pointed to <code>build -> /build/buildd/linux-3.0</code>), create a link inside <code>/lib/modules/3.0.6-x3</code> named <code>build</code> pointing to:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">build -<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-headers-3.0.6-x3</pre></div></div>

<p>Modify the original <code>Makefile</code> to contain only rule for <code>option.o</code></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">obj-m			+= option.o</pre></div></div>

<p>and then build the driver</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-C</span> <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>3.0.6-x3<span style="color: #000000; font-weight: bold;">/</span>build<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #007800;">M</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-headers-3.0.6-x3<span style="color: #000000; font-weight: bold;">/</span>drivers<span style="color: #000000; font-weight: bold;">/</span>usb<span style="color: #000000; font-weight: bold;">/</span>serial<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">make</span>: Entering directory <span style="color: #000000; font-weight: bold;">`/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-headers-3.0.6-x3<span style="color: #ff0000;">'
  LD      /usr/src/linux-headers-3.0.6-x3/drivers/usb/serial/built-in.o
  CC [M]  /usr/src/linux-headers-3.0.6-x3/drivers/usb/serial/option.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /usr/src/linux-headers-3.0.6-x3/drivers/usb/serial/option.mod.o
  LD [M]  /usr/src/linux-headers-3.0.6-x3/drivers/usb/serial/option.ko
make: Leaving directory `/usr/src/linux-headers-3.0.6-x3`</span></pre></div></div>

<p>Copy the build and deploy</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>linux-headers-3.0.6-x3<span style="color: #000000; font-weight: bold;">/</span>drivers<span style="color: #000000; font-weight: bold;">/</span>usb<span style="color: #000000; font-weight: bold;">/</span>serial<span style="color: #000000; font-weight: bold;">/</span>option.ko <span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>3.0.6-x3<span style="color: #000000; font-weight: bold;">/</span>kernel<span style="color: #000000; font-weight: bold;">/</span>drivers<span style="color: #000000; font-weight: bold;">/</span>usb<span style="color: #000000; font-weight: bold;">/</span>serial<span style="color: #000000; font-weight: bold;">/</span>
$ depmod <span style="color: #660033;">-a</span></pre></div></div>

<p>Now <code>syslog</code> will show the following lines if the modem is inserted:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4790.229888</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> usb <span style="color: #000000;">1</span>-<span style="color: #000000;">2.5</span>: GSM modem <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>-port<span style="color: #7a0874; font-weight: bold;">&#41;</span> converter now attached to ttyUSB0
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4790.237121</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> option <span style="color: #000000;">1</span>-<span style="color: #000000;">2.5</span>:<span style="color: #000000;">1.0</span>: GSM modem <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>-port<span style="color: #7a0874; font-weight: bold;">&#41;</span> converter detected
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4790.238250</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> usb <span style="color: #000000;">1</span>-<span style="color: #000000;">2.5</span>: GSM modem <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>-port<span style="color: #7a0874; font-weight: bold;">&#41;</span> converter now attached to ttyUSB1
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4790.240142</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> option <span style="color: #000000;">1</span>-<span style="color: #000000;">2.5</span>:<span style="color: #000000;">1.1</span>: GSM modem <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>-port<span style="color: #7a0874; font-weight: bold;">&#41;</span> converter detected
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4790.241210</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> usb <span style="color: #000000;">1</span>-<span style="color: #000000;">2.5</span>: GSM modem <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span>-port<span style="color: #7a0874; font-weight: bold;">&#41;</span> converter now attached to ttyUSB2
mtp-probe: checking bus <span style="color: #000000;">1</span>, device <span style="color: #000000;">9</span>: <span style="color: #ff0000;">&quot;/sys/devices/platform/usbhs-omap.0/ehci-omap.0/usb1/1-2/1-2.5&quot;</span>
mtp-probe: bus: <span style="color: #000000;">1</span>, device: <span style="color: #000000;">9</span> was not an MTP device
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4791.227294</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> scsi <span style="color: #000000;">2</span>:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>: Direct-Access     Qualcomm MMC Storage      <span style="color: #000000;">2.31</span> PQ: <span style="color: #000000;">0</span> ANSI: <span style="color: #000000;">2</span>
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4791.232238</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sd <span style="color: #000000;">2</span>:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>: Attached scsi generic sg0 <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #000000;">0</span>
kernel:<span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000;">4791.246887</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sd <span style="color: #000000;">2</span>:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>:<span style="color: #000000;">0</span>: <span style="color: #7a0874; font-weight: bold;">&#91;</span>sda<span style="color: #7a0874; font-weight: bold;">&#93;</span> Attached SCSI removable disk</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2012/01/compile-usb-serial-modem-using-option-c-ubuntu-on-beagleboard-xm/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Write Your Own MIB File (Tabular)</title>
		<link>https://lakm.us/logit/2011/09/write-mib-file-tabular/</link>
		<comments>https://lakm.us/logit/2011/09/write-mib-file-tabular/#comments</comments>
		<pubDate>Fri, 09 Sep 2011 11:23:19 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[MIB]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=355</guid>
		<description><![CDATA[When it comes to writing our own MIB, a practical choice might be to write the whole objects as of scalar type (RFC-1212). That means, let&#8217;s say we have 2 battery statuses, each of them must be explicitly written individually within the MIB file. Example of calling their voltages: $ snmpwalk -m +REKTRONIK-MIB -v 1 [...]]]></description>
				<content:encoded><![CDATA[<p>When it comes to writing our own <a href="http://en.wikipedia.org/wiki/Management_information_base" title="http://en.wikipedia.org/wiki/Management_information_base" target="_blank">MIB</a>, a practical choice might be to write the whole objects as of <strong>scalar</strong> type (<a href="http://tools.ietf.org/html/rfc1212#section-3" title="RFC-1212: Columnar Objects" target="_blank">RFC-1212</a>). That means, let&#8217;s say we have 2 battery statuses, each of them must be explicitly written individually within the MIB file. Example of calling their voltages:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmpwalk <span style="color: #660033;">-m</span> +REKTRONIK-MIB <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public monitored-host .1.3.6.1.4.1.38610
...
REKTRONIK-MIB::battery1Voltage.0 = INTEGER: <span style="color: #000000;">9</span>
REKTRONIK-MIB::battery2Voltage.0 = INTEGER: <span style="color: #000000;">11</span>
...</pre></div></div>

<p>If additional 3rd battery is to be monitored, <code>REKTRONIK-MIB.txt</code> in this example must be modified. In small scale we don&#8217;t need consistent MIB as changes are manageable, but if a whole bunch of different people must reference to this, a better way is to have <strong>tabular</strong> object where the above batteries are indexed instead of ended with &#8220;<code>.0</code>&#8221; scalar identifier.</p>
<p>Quick approach by checking established <code><a href="http://www.observium.org/svn/observer/trunk/mibs/LM-SENSORS-MIB" title="LM-SENSORS-MIB" target="_blank">LM-SENSORS-MIB.txt</a></code> shows at least we need three object definitions inside the MIB file:</p>
<div class="wp-caption aligncenter" style="width: 510px"><img alt="snmp-mib-tabular-object-basics.jpg" src="../../../../images/snmp-mib-tabular-object-basics.jpg" title="snmp-mib-tabular-object-basics.jpg" width="154" height="173" /><p class="wp-caption-text">Components of writing tabular MIB</p></div>
<p>
Its stemmed MIB tree to show the (1) <code>Table</code>, (2) <code>Entry</code>, and (3) <code>Index</code>:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">...
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     +--lmFanSensorsTable<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  +--lmFanSensorsEntry<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  Index: lmFanSensorsIndex
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>     +-- <span style="color: #660033;">-R--</span> Integer32 lmFanSensorsIndex<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>        Range: 0..65535
...</pre></div></div>

<p>Now the writing part of those three types to our MIB, plus the <code>batteryVoltage</code> which is the actual object to be indexed in the final SNMP monitoring.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">batteryTable OBJECT-TYPE
    SYNTAX     SEQUENCE OF BatteryEntry
    MAX-ACCESS not-accessible
    STATUS     current
    DESCRIPTION
        <span style="color: #ff0000;">&quot;The (conceptual) table of batteries contained by the
        module.&quot;</span>
    ::= <span style="color: #7a0874; font-weight: bold;">&#123;</span> monitor <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
batteryEntry OBJECT-TYPE
    SYNTAX     BatteryEntry
    MAX-ACCESS not-accessible
    STATUS     current
    DESCRIPTION
        <span style="color: #ff0000;">&quot;A (conceptual) entry for one battery contained by
        the module.  The batteryIndex in the index represents
        the entry in the batteryTable that corresponds to the
        batteryEntry.
&nbsp;
        As an example of how objects in this table are named,
        an instance of the batteryVoltage object might be
        named batteryVoltage.3&quot;</span>
    INDEX <span style="color: #7a0874; font-weight: bold;">&#123;</span> batteryIndex <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    ::= <span style="color: #7a0874; font-weight: bold;">&#123;</span> batteryTable <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
batteryIndex OBJECT-TYPE
    SYNTAX      DeviceIndex
    MAX-ACCESS  read-only
    STATUS      current
    DESCRIPTION
            <span style="color: #ff0000;">&quot;A unique value, greater than zero, for each battery. 
            It is recommended that values are assigned contiguously
            starting from 1.&quot;</span>
    ::= <span style="color: #7a0874; font-weight: bold;">&#123;</span> batteryEntry <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
batteryVoltage    OBJECT-TYPE 
   SYNTAX Integer32 
   ACCESS read-only 
   STATUS current 
   DESCRIPTION 
      <span style="color: #ff0000;">&quot;Voltage A/D value&quot;</span> 
   ::= <span style="color: #7a0874; font-weight: bold;">&#123;</span> batteryEntry <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></td></tr></table></div>

<p>There are some header parts of course, check the resulting <code>REKTRONIK-MIB.txt</code> <a href="../../../../upload/REKTRONIK-MIB.txt" title="REKTRONIK-MIB.txt" target="_blank">here</a>.</p>
<p>The tree view becomes:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">            +--private<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>  +--enterprises<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>     +--rektronik<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">39559</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
...
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        +--monitor<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  +--batteryTable<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>  +--batteryEntry<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  Index: batteryIndex
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     +-- <span style="color: #660033;">-R--</span> Integer32 batteryIndex<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>        Textual Convention: DeviceIndex
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>        Range: 1..2147483647
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     +-- <span style="color: #660033;">-R--</span> Integer32 batteryVoltage<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>     +-- <span style="color: #660033;">-R--</span> Integer32 batteryCurrent<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  +--environment<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>  +-- <span style="color: #660033;">-R--</span> Integer32 temperature<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>  +-- <span style="color: #660033;">-R--</span> Integer32 humidity<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
...</pre></div></div>

<p>and example of getting SNMP is</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmpwalk <span style="color: #660033;">-m</span> +REKTRONIK-MIB <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public monitored-host .1.3.6.1.4.1.38610
REKTRONIK-MIB::name.0 = STRING: <span style="color: #ff0000;">&quot;RekMini&quot;</span>
REKTRONIK-MIB::version.0 = STRING: <span style="color: #ff0000;">&quot;1.0&quot;</span>
REKTRONIK-MIB::date.0 = STRING: <span style="color: #ff0000;">&quot;2011-09-08&quot;</span>
REKTRONIK-MIB::batteryIndex.22 = INTEGER: <span style="color: #000000;">22</span>
REKTRONIK-MIB::batteryIndex.23 = INTEGER: <span style="color: #000000;">23</span>
REKTRONIK-MIB::batteryVoltage.22 = INTEGER: <span style="color: #000000;">9</span>
REKTRONIK-MIB::batteryVoltage.23 = INTEGER: <span style="color: #000000;">11</span>
REKTRONIK-MIB::batteryCurrent.22 = INTEGER: <span style="color: #000000;">2</span>
REKTRONIK-MIB::batteryCurrent.23 = INTEGER: <span style="color: #000000;">2</span>
...</pre></div></div>

<p>in the above example any additional 3rd battery voltage insertion will be OID &#8220;<code>REKTRONIK-MIB::batteryVoltage<strong>.24</strong></code>&#8220;</p>
]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2011/09/write-mib-file-tabular/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Running Raddle (2): snmpd &amp; Replay Custom Private Enterprise MIB</title>
		<link>https://lakm.us/logit/2011/08/running-raddle-2-snmpd-replay-custom-private-enterprise-mib/</link>
		<comments>https://lakm.us/logit/2011/08/running-raddle-2-snmpd-replay-custom-private-enterprise-mib/#comments</comments>
		<pubDate>Thu, 18 Aug 2011 03:13:44 +0000</pubDate>
		<dc:creator>Arif</dc:creator>
				<category><![CDATA[General Linux]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[emulator]]></category>
		<category><![CDATA[OSS]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[snmp]]></category>

		<guid isPermaLink="false">http://lakm.us/logit/?p=217</guid>
		<description><![CDATA[Net-SNMP wiki gives tutorial on extending snmpd using Perl. In basic run of Raddle (previous post) this involves r1.pl called by r1.conf fed to snmpd. Private enterprise MIB i.e. Microchip&#8217;s in this example can be replayed without really ever captured the real device&#8217;s SNMP data. This is necessary when the actual device is yet existed; normal [...]]]></description>
				<content:encoded><![CDATA[<p>Net-SNMP wiki gives tutorial on 	<a href="http://www.net-snmp.org/wiki/index.php/Tut:Extending_snmpd_using_perl">extending <code>snmpd</code> using Perl</a>. In basic run of Raddle (<a href="./215/running-raddle-in-rhel/">previous post</a>) this involves <code>r1.pl</code> called by <code>r1.conf</code> fed to <code>snmpd</code>. Private enterprise MIB i.e. <a href="http://read.pudn.com/downloads133/sourcecode/embed/567121/TCPIP%20Demo%20App/mchip.mib__.htm" target="_blank">Microchip&#8217;s </a>in this example can be replayed without really ever captured the real device&#8217;s SNMP data. This is necessary when the actual device is yet existed; normal situation when developing.  There are two simple ways of replaying this artificial SNMP data over which either way requires correct OID.</p>
<p>First put the <code>Microchip.TXT</code> (the MIB file) under <code>/usr/share/snmp/mibs</code> to easily exchange OID canonical form and name vice versa while making dummy. In this case I&#8217;ve modify the MIB to have some additional object i.e. <code>name</code>:<br />
<code>$ snmptranslate -m +Microchip -On Microchip::name<br />
.1.3.6.1.4.1.17095.1.1</code><br />
so we can then use this correct OID for our dummy.</p>
<p>How?</p>
<ol>
<li>use <code>SetMIBValue()</code> in <code>r1.pl</code>

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$agent</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">SetMIBValue</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">'.1.3.6.1.4.1.17095.1.1'</span><span style="color: #339933;">,</span> ASN_OCTET_STR<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Microchip&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$agent</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">SetMIBValue</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">'.1.3.6.1.4.1.17095.3.13'</span><span style="color: #339933;">,</span> ASN_INTEGER<span style="color: #339933;">,</span> <span style="color: #cc66cc;">82</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Feed <code>r1.snmp </code>for playing as in

<div class="wp_syntax"><div class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #0000ff;">$agent</span><span style="color: #339933;">-&gt;</span><span style="color: #006600;">ParseDataFile</span><span style="color: #009900;">&#40;</span> <span style="color: #ff0000;">'/usr/local/etc/snmp-emulator/r1.snmp'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #009900;">&#41;</span></pre></div></div>

<p>with the content of</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">.1.3.6.1.4.1.17095.1.1 = STRING: Microchip
.1.3.6.1.4.1.17095.3.13 = INTEGER: <span style="color: #000000;">82</span></pre></div></div>

</li>
</ol>
<p>In all above two examples we can only <code>GET</code> for Raddle to return an answer for each OID. <code>GETNEXT</code> as in bulk <code>snmpwalk</code> won&#8217;t give output because they are not sequenced.</p>
<p>A sample of sequenced data inside a real <code>snmpwalk</code> dump is:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmpwalk <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public <span style="color: #660033;">-On</span> localhost
&nbsp;
.1.3.6.1.2.1.1.1.0 = STRING: Linux xp-racy 2.6.38-<span style="color: #000000;">10</span>-generic <span style="color: #666666; font-style: italic;">#46~lucid1-Ubuntu SMP Wed Jul 6 18:40:11 UTC 2011 i686</span>
.1.3.6.1.2.1.1.2.0 = OID: .1.3.6.1.4.1.8072.3.2.10
.1.3.6.1.2.1.1.3.0 = Timeticks: <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">496371</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">1</span>:<span style="color: #000000;">22</span>:<span style="color: #000000;">43.71</span>
.1.3.6.1.2.1.1.4.0 = STRING: Root  <span style="color: #7a0874; font-weight: bold;">&#40;</span>configure <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>snmp<span style="color: #000000; font-weight: bold;">/</span>snmpd.local.conf<span style="color: #7a0874; font-weight: bold;">&#41;</span>
.1.3.6.1.2.1.1.5.0 = STRING:
.1.3.6.1.2.1.1.6.0 = STRING: Unknown <span style="color: #7a0874; font-weight: bold;">&#40;</span>configure <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>snmp<span style="color: #000000; font-weight: bold;">/</span>snmpd.local.conf<span style="color: #7a0874; font-weight: bold;">&#41;</span>
.1.3.6.1.2.1.1.8.0 = Timeticks: <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000;">0</span>:00:<span style="color: #000000;">00.00</span>
.1.3.6.1.2.1.1.9.1.2.1 = OID: .1.3.6.1.6.3.10.3.1.1
.1.3.6.1.2.1.1.9.1.2.2 = OID: .1.3.6.1.6.3.11.3.1.1</pre></div></div>

<p>thus, we can only</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmpget <span style="color: #660033;">-m</span> +Microchip <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public localhost Microchip::control.13
Microchip::control.13 = INTEGER: <span style="color: #000000;">82</span></pre></div></div>

<p>or from other system with no Microchip MIB use</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmpget <span style="color: #660033;">-v</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-c</span> public 192.168.40.105 .1.3.6.1.4.1.17095.3.13
SNMPv2-SMI::enterprises.17095.3.13 = INTEGER: <span style="color: #000000;">82</span></pre></div></div>

<p>The tree below may visually explains sequenced data for <code>GETNEXT</code> where our Microchip is branched at <code>private.enterprises.microchip</code> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmptranslate <span style="color: #660033;">-m</span> +Microchip <span style="color: #660033;">-Tp</span>
&nbsp;
+--iso<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
   <span style="color: #000000; font-weight: bold;">|</span>
   +--org<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #000000; font-weight: bold;">|</span>
      +--dod<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
         <span style="color: #000000; font-weight: bold;">|</span>
         +--internet<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>
            +--directory<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>
            +--mgmt<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>  +--mib-<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>     +--system<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
...
            +--private<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span>
...
            <span style="color: #000000; font-weight: bold;">|</span>  +--enterprises<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>
...
            <span style="color: #000000; font-weight: bold;">|</span>     +--microchip<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">17095</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>
            <span style="color: #000000; font-weight: bold;">|</span>        +--product<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
            <span style="color: #000000; font-weight: bold;">|</span>        <span style="color: #000000; font-weight: bold;">|</span>  <span style="color: #000000; font-weight: bold;">|</span></pre></div></div>

<p>How <code>GET</code> and <code>GETNEXT</code> appeared in SNMP can be viewed by running snmpd in debug mode with this options:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ snmpd <span style="color: #660033;">-m</span> +Microchip <span style="color: #660033;">-f</span> <span style="color: #660033;">-L</span> <span style="color: #660033;">-V</span> <span style="color: #660033;">-C</span> <span style="color: #660033;">-I</span> vacm_vars <span style="color: #660033;">-c</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>snmp-emulator<span style="color: #000000; font-weight: bold;">/</span>r1.conf
NET-SNMP version 5.3.1
Connection from UDP: <span style="color: #7a0874; font-weight: bold;">&#91;</span>127.0.0.1<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000;">32770</span>
Received SNMP packet<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> from UDP: <span style="color: #7a0874; font-weight: bold;">&#91;</span>127.0.0.1<span style="color: #7a0874; font-weight: bold;">&#93;</span>:<span style="color: #000000;">32770</span>
  GET message
    <span style="color: #660033;">--</span> control.13</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>https://lakm.us/logit/2011/08/running-raddle-2-snmpd-replay-custom-private-enterprise-mib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
