<?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::2310 &#187; Gentoo</title>
	<atom:link href="http://blog.2310.net/archives/category/linux/gentoo/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.2310.net</link>
	<description>2310</description>
	<lastBuildDate>Sat, 14 Aug 2010 15:17:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gentooで無線LANを</title>
		<link>http://blog.2310.net/archives/206</link>
		<comments>http://blog.2310.net/archives/206#comments</comments>
		<pubDate>Tue, 30 Dec 2008 13:58:51 +0000</pubDate>
		<dc:creator>2310</dc:creator>
				<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://k2310.s332.xrea.com/blog.2310.net/?p=206</guid>
		<description><![CDATA[設定した時の旧いメモ。WLI-PCI-G54での設定。



#emerge wireless-tools
#emerge ndiswrapper


ドライバをインストールする。私の場合使用しているのがWLI-PCI-G54であるため、wdrv_392.exeを展開した後、
    #ndiswrapper -i netcbg54.inf
(ただし現在ではbcmwl5aを使用しています。)

/etc/conf.d/netに以下を追加

# wlan0
iface_wlan0="dhcp"
dhcpcd_wlan0="-DN"
iface_&#60;ESSIDを記入&#62;="dhcp"
essid_&#60;ESSIDを記入&#62;="00074DAF9888"
key_&#60;ESSIDを記入&#62;="s:&#60;WEPを記入&#62;"


以上でおしまいですが、/etc/init.d/net.wlan0をどこからか拾ってきて、ちょっと改造して使用しているので下に全文掲載。
私もあまり理解していませんので、不具合等発生した場合は自己責任でお願いします。

#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /etc/init.d/net.eth0,v 1.30 2003/10/18 18:03:19 faye Exp $

#NB: Config is in /etc/conf.d/net



checkconfig() {
  if [ -z "${iface_IFACE}" ]
    then
      eerror [...]]]></description>
			<content:encoded><![CDATA[<p>設定した時の旧いメモ。WLI-PCI-G54での設定。</p>

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

<pre><code>#emerge wireless-tools
#emerge ndiswrapper
</code></pre>

<p>ドライバをインストールする。私の場合使用しているのがWLI-PCI-G54であるため、wdrv_392.exeを展開した後、
    #ndiswrapper -i netcbg54.inf
(ただし現在ではbcmwl5aを使用しています。)</p>

<p>/etc/conf.d/netに以下を追加</p>

<pre><code># wlan0
iface_wlan0="dhcp"
dhcpcd_wlan0="-DN"
iface_&lt;ESSIDを記入&gt;="dhcp"
essid_&lt;ESSIDを記入&gt;="00074DAF9888"
key_&lt;ESSIDを記入&gt;="s:&lt;WEPを記入&gt;"
</code></pre>

<p>以上でおしまいですが、/etc/init.d/net.wlan0をどこからか拾ってきて、ちょっと改造して使用しているので下に全文掲載。
私もあまり理解していませんので、不具合等発生した場合は自己責任でお願いします。</p>

<pre><code>#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /etc/init.d/net.eth0,v 1.30 2003/10/18 18:03:19 faye Exp $

#NB: Config is in /etc/conf.d/net



checkconfig() {
  if [ -z "${iface_IFACE}" ]
    then
      eerror "Please make sure that /etc/conf.d/net has \$iface_$IFACE set"
      return 1
  fi
}

setup_env() {
    # No reason to check these multiple times in the file
    iface_IFACE="$(eval echo \$\{iface_${IFACE}\})"
    dhcpcd_IFACE="$(eval echo \$\{dhcpcd_${IFACE}\})"
    inet6_IFACE="$(eval echo \$\{inet6_${IFACE}\})"
    alias_IFACE="$(eval echo \$\{alias_${IFACE}\})"
    status_IFACE="$(ifconfig | gawk -v IFACE="${IFACE}" '/Link/ { if ($1 == IFACE) print "up" }')"
    if [ -x `which iwconfig` ]; then
        wireless_IFACE="$(iwconfig 2&gt;/dev/null | gawk -v IFACE="${IFACE}" '/ESSID/ { if ($1 == IFACE) print "yes" }')"
    fi
    wireless_IFACE=${wireless_IFACE:-"no"}
    if [ -x `which mii-tool` ]; then
        link_IFACE=$(mii-tool ${IFACE} 2&gt;/dev/null | gawk '{print $2}')
    fi
    link_IFACE=${link_IFACE:-"yes"}
}

setup_wireless() {
    # Reset to some defaults
    iwconfig $IFACE mode Managed
    iwconfig $IFACE rate auto
    iwconfig $IFACE key off
    # iwconfig $IFACE rts off
    # iwconfig $IFACE frag off
    iwconfig $IFACE essid any
    # Initiate a scan
    ifconfig $IFACE up
    # Wait for a response
    sleep 2
    # Find known access points
    for AP in `iwlist ${IFACE} scan 2&gt;/dev/null | grep ESSID | awk -F: '{print $2}' | sed 's/[-"]//g'`; do
        if [ -z ${essid_AP} ]; then
            essid_AP="$(eval echo \$\{essid_${AP}\})"
            if [ ! -z ${essid_AP} ]; then
                # setup variables
                key_AP="$(eval echo \$\{key_${AP}\})"
                iface_IFACE="$(eval echo \$\{iface_${AP}\})"
                if [  "$(eval echo \$\{gateway_${AP}\})" != "" ];
                then
                    gateway="${IFACE}/$(eval echo \$\{gateway_${AP}\})"
                fi
            fi
        fi
    done
    # Bring interface down to apply changes
    ifconfig $IFACE down
    #ewarn "Setting wireless parameters ${essid_AP} and ${key_AP}"
    iw_param=""
    if [ ! -z ${essid_AP} ]; then
        iw_param="essid ${essid_AP}"
    fi
    if [ ! -z ${key_AP} ]; then
        iw_param="${iw_param} key ${key_AP}"
    fi
    iwconfig ${IFACE} ${iw_param}
    # Bring the interface up
    ifconfig $IFACE up
    # Wait for the system to associate
    #    repair below 20060326 by 2310
    #    while [ `iwconfig $IFACE | awk '/\&lt;..:..:..:..:..:..\&gt;/{print}' |
    #    sed 's/^.*\&lt;\(..:..:..:..:..:..\)\&gt;.*$/\1/g'` = FF:FF:FF:FF:FF:FF ]; do
    while [ x$ACCESS_POINT_CHECK_VALUE = x -o x$ACCESS_POINT_CHECK_VALUE = xFF:FF:FF:FF:FF:FF ]; do
       LC_NUMERIC=C sleep 0.5
       ACCESS_POINT_CHECK_VALUE=\
       `iwconfig $IFACE | awk '/\&lt;..:..:..:..:..:..\&gt;/{print}' | sed 's/^.*\&lt;\(..:..:..:..:..:..\)\&gt;.*$/\1/g'`
    done
    return 0
}

start() {
    local retval=0
    setup_env
    checkconfig || return 1
    if [ ${wireless_IFACE} == "yes" ]; then
        ebegin "Detecting network for ${IFACE}"
        setup_wireless
        eend 0
    fi
    ebegin "Bringing ${IFACE} up"
    if [ ${link_IFACE} == "no" ];then
        retval=1
        eend ${retval} "Failed to bring ${IFACE} up"
        return ${retval}
    fi
    if [ "${iface_IFACE}" != "dhcp" ]
    then
        /sbin/ifconfig ${IFACE} ${iface_IFACE} &gt;/dev/null || {
            retval=$?
            eend ${retval} "Failed to bring ${IFACE} up"
            return ${retval}
        }
        # ifconfig do not always return failure ..
        /sbin/ifconfig ${IFACE} &amp;&gt; /dev/null || {
            retval=$?
            eend ${retval} "Failed to bring ${IFACE} up"
            return ${retval}
        }
    else
        # Check that eth0 was not brough up by the kernel ...
#       if [ "${status_IFACE}" != "up" ]
#       then
            /sbin/dhcpcd ${dhcpcd_IFACE} ${IFACE} &gt;/dev/null || {
                retval=$?
                eend ${retval} "Failed to bring ${IFACE} up"
                return ${retval}
            }
#       fi
    fi

    ip_address=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' | cut -d: -f2)
    [[ -n ${ip_address} ]] &amp;&amp; einfo "  ${IFACE} received address ${ip_address}"



    eend 0

    if [ -n "${alias_IFACE}" ]
    then
        local x=""
        local num=0
        local aliasbcast=""
        local aliasnmask=""

        ebegin "  Adding aliases"
        for x in ${alias_IFACE}
        do
            aliasbcast="$(eval echo \$\{broadcast_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"
            if [ -n "${aliasbcast}" ]
            then
                aliasbcast="broadcast ${aliasbcast}"
            fi

            aliasnmask="$(eval echo \$\{netmask_${IFACE}\} \| awk \'\{ print \$$((num + 1)) \}\')"
            if [ -n "${aliasnmask}" ]
            then
                aliasnmask="netmask ${aliasnmask}"
            fi

            ebegin "    ${IFACE}:${num}"
            /sbin/ifconfig ${IFACE}:${num} ${x} \
                ${aliasbcast} ${aliasnmask} &gt;/dev/null
            num=$((num + 1))
            eend 0
        done
        save_options "alias" "${alias_IFACE}"
    fi

    if [ -n "${inet6_IFACE}" ]
    then
        local x=""
        ebegin "  Adding inet6 addresses"
        for x in ${inet6_IFACE}
        do
            ebegin "    ${IFACE} inet6 add ${x}"
            /sbin/ifconfig ${IFACE} inet6 add ${x} &gt;/dev/null
            eend 0
        done
        save_options "inet6" "${inet6_IFACE}"
    fi

    if [ -n "${gateway}" ] &amp;&amp; [ "${gateway%/*}" = "${IFACE}" ]
    then
        ebegin "  Setting default gateway"
        # First delete any existing routes if it was setup by kernel ..
        /sbin/route del default dev ${gateway%/*} &amp;&gt;/dev/null
        /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \
            netmask 0.0.0.0 metric 1 &gt;/dev/null || {

            local error=$?
            ifconfig ${IFACE} down &amp;&gt;/dev/null
            eend ${error} "Failed to bring ${IFACE} up"
            stop
            return ${error}
        }
        eend 0
    fi

    # Enabling rp_filter causes wacky packets to be auto-dropped by
    # the kernel
    if [ -e /proc/sys/net/ipv4/conf/${IFACE}/rp_filter ]
    then
        echo 1 &gt; /proc/sys/net/ipv4/conf/${IFACE}/rp_filter
    fi
    # If started by hotplug, this doesn't get done.
    # perhaps the right fix is in hotplug
    ln -sf /etc/init.d/net.${IFACE} /var/lib/init.d/started/net.${IFACE}
}

stop() {
    local myalias="$(get_options alias)"
    local myinet6="$(get_options inet6)"
    local myinet6="$(get_options inet6)"
    local ip_address=$(ifconfig ${IFACE} | grep -m1 -o 'inet addr:[^ ]*' | cut -d: -f2)

    setup_env

    ebegin "Bringing ${IFACE} down"

    # Also down the inet6 interfaces
    if [ -n "${myinet6}" ]
    then
        local x=""
        for x in ${myinet6}
        do
           /sbin/ifconfig ${IFACE} inet6 del ${x} &gt;/dev/null
        done
    fi

    # Do some cleanup in case the amount of aliases change
    if [ -n "${myalias}" ]
    then
        local x=""
        local num=0
        for x in ${myalias}
        do
            /sbin/ifconfig ${IFACE}:${num} down &gt;/dev/null
            num=$((num + 1))
        done
    fi

    if [ "${iface_IFACE}" = "dhcp" ]
    then
       local count=0
#      while /sbin/dhcpcd -k ${IFACE} &amp;&gt;/dev/null &amp;&amp; [ "${count}" -lt 15 ]
       while [ `/sbin/dhcpcd -k ${IFACE} &amp;&gt;/dev/null` ] &amp;&amp; [ "${count}" -lt 9 ]
       do
        # Give dhcpcd time to properly shutdown
        sleep 1
        count=$((count + 1))
       done
       if [ "${count}" -ge 9 ]
       then
        eerror "Timed out trying to stop dhcpcd"
       else
        [[ -n ${ip_address} ]] &amp;&amp; einfo "  ${IFACE} released address ${ip_address}"
       fi
     else
        /sbin/ifconfig ${IFACE} down &gt;/dev/null
     fi
     eend 0
}


# vim:ts=4
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.2310.net/archives/206/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
