<?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>Blog Amain &#187; atheros</title>
	<atom:link href="http://blog.zoomeren.nl/tag/atheros/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.zoomeren.nl</link>
	<description>Open Source / Linux</description>
	<lastBuildDate>Fri, 21 May 2010 21:47:50 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Ad-Hoc Wireless connection fails on Ubuntu with NetworkManager on Atheros wireless device</title>
		<link>http://blog.zoomeren.nl/2008/12/14/adhoc-networkmanager/</link>
		<comments>http://blog.zoomeren.nl/2008/12/14/adhoc-networkmanager/#comments</comments>
		<pubDate>Sun, 14 Dec 2008 18:53:11 +0000</pubDate>
		<dc:creator>Amain</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[atheros]]></category>
		<category><![CDATA[networkmanager]]></category>
		<category><![CDATA[wireless]]></category>
		<category><![CDATA[wpasupplicant]]></category>

		<guid isPermaLink="false">http://blog.zoomeren.nl/?p=1</guid>
		<description><![CDATA[For some time now I experience problems with my Atherios Wireless NIC in combination with NetworkManager. For quite some time now, it&#8217;s possible for me to connect to a normal Wireless Access Point. Now I have an iPhone and want to use PDANet to connect a Laptop to the Internet using the iPhone 3G fast [...]]]></description>
			<content:encoded><![CDATA[<p>For some time now I experience problems with my Atherios Wireless NIC in combination with NetworkManager. For quite some time now, it&#8217;s possible for me to connect to a normal Wireless Access Point. Now I have an iPhone and want to use <a href="http://www.junefabrics.com/iphone/index.php">PDANet</a> to connect a Laptop to the Internet using the iPhone 3G fast Internet capabilities. PDANet requires an Ad-Hoc wirless connection with the iPhone and works very similar to IP Masquarading(NAT).</p>
<p>With NetworkManager (which uses WPA supplicant) it&#8217;s not possible to do so. NetorkManager tries to connect to the selected Ad-Hoc network, but fails.  Analizing logfiles, I concluded that this is because the mode change from &#8220;Managed&#8221; to &#8220;Ad-Hoc&#8221; does not work. WPA supplicant is instructed by NetworkManager to do so (using DBus communication).</p>
<p>Ubuntu 8.10 and 8.04 both have compiled WPA Supplicant with a limited set of drivers. 8.10 was compiled with:</p>
<ul>
<li>wext = Linux wireless extensions (generic)</li>
<li>atmel = ATMEL AT76C5XXx (USB, PCMCIA)</li>
<li>wired = wpa_supplicant wired Ethernet driver</li>
</ul>
<p>NetworkManager instructs (at least for my card) to use the wext <a href="http://wireless.kernel.org/en/developers/Documentation/Wireless-Extensions">(Linux Wireless Extensions)</a> driver to communicate with the hardware.  Using iwconfig manualy (part wext) give an error:</p>
<p><em>root@jvz:~# iwconfig ath0 mode Managed<br />
Error for wireless request &#8220;Set Mode&#8221; (8B06) :<br />
SET failed on device ath0 ; Invalid argument</em></p>
<p>So it&#8217;s not strange for WPA Supplicant to fail to change the mode. ath_pci is the driver I&#8217;m using for my Atheros wireless card. See <a href="https://help.ubuntu.com/community/WifiDocs/Driver/Madwifi">WifiDocs</a> on ubuntu documentation for some more info on this driver.</p>
<p>Following the <a href="http://madwifi-project.org/wiki/UserDocs/AdHocInterface">MadWifi UserDocs</a> changing the mode of and MadWifi based card the following commands should be used:</p>
<p><em>wlanconfig ath0 destroy<br />
wlanconfig ath0 create wlandev wifi0 wlanmode adhoc</em></p>
<p>Possible Solutions:</p>
<ol>
<li>Use <a href="http://madwifi-project.org/">ath5k</a> new MadWifi driver, but I have tested it and the link stability was not good, but it works out of the box with NetworkManager</li>
<li>Recompile WPA Supplicant to support the madwifi driver extensions and patch NetworkManager to use madfiwi instead of wext as commandline parameter for WPA Supplicant &#8211; not my favorite option!</li>
<li>Create a sudo script which stops NetworkManager and issue the above madwifi wlanconfig command from the script and connect manualy</li>
</ol>
<p>I choose to use the third option. Here is my <a href="http://blog.zoomeren.nl/wp-content/uploads/2008/12/adhoc1.sh">adhoc.sh</a> bash sudo script:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;sudo&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">exec</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;$0&quot;</span> <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #ff0000;">&quot;$1&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> reload<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>NetworkManager stop
	<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> ath0 down
	rmmod ath_pci
	modprobe ath_pci
	wlanconfig ath0 destroy
	wlanconfig ath0 create wlandev wifi0 wlanmode adhoc
	<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">2</span>
	iwconfig ath0 key s:<span style="color: #000000;">11111</span>
	iwconfig ath0 essid J3G
	iwconfig
	<span style="color: #c20cb9; font-weight: bold;">sleep</span> <span style="color: #000000;">10</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> dhcp<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	dhclient ath0
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> mail <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
   <span style="color: #c20cb9; font-weight: bold;">netstat</span> <span style="color: #660033;">-pan</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt;<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;:25&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;tcpW&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> LISTEN <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{print $7}'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s!/ssh!!'</span> 
      <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> pid; <span style="color: #000000; font-weight: bold;">do</span>
  		<span style="color: #7a0874; font-weight: bold;">echo</span> killing <span style="color: #c20cb9; font-weight: bold;">ssh</span>: <span style="color: #007800;">$pid</span>
   		<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-9</span> <span style="color: #007800;">$pid</span>
        <span style="color: #000000; font-weight: bold;">done</span>
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">&quot;Starting SMTP tunnel....&quot;</span>
   <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #660033;">-N</span> <span style="color: #660033;">-f</span> <span style="color: #660033;">-L</span> <span style="color: #000000;">25</span>:mailserver:<span style="color: #000000;">25</span> user<span style="color: #000000; font-weight: bold;">@</span>domain.tld
   <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;done&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> stop<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
	<span style="color: #c20cb9; font-weight: bold;">ifconfig</span> ath0 down
	rmmod ath_pci
	modprobe ath_pci
	<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>NetworkManager start
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;mail&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	mail
 	<span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;all&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
	reload
   	dhcp
	mail
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;dhcp&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        dhcp
<span style="color: #000000; font-weight: bold;">elif</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$2&quot;</span> == <span style="color: #ff0000;">&quot;stop&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
 	stop
<span style="color: #000000; font-weight: bold;">else</span>
	<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;usage: $0 all|dhcp|mail|stop&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.zoomeren.nl/2008/12/14/adhoc-networkmanager/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
