# Linux-wlan-ng problems... "/sbin/prism2dl"?

## Kesereti

So I grabbed myself a shiny new Linksys WUSB12 usb wireless adapter, and went to setting it up...on my other machine, I use HostAP, but it apparently doesn't support USB Prism2 devices just yet, so I had to use the prism2_usb driver from the linux-wlan-ng package.  Now here's my question...I've emerged the package, set up wlan.conf correctly and all that, but when I try to do a /etc/init.d/wlan start, it complains about not being able to find 'prism2dl', and then stops.  Now, the script is working just find, because I sure can't find prism2dl myself, either =P  Reading through the config files and the docs, it seems like it's some utility for updating firmware in Prism2 cards...why is this requried to even get the card up and running?  And if it isn't...how badly do I need to change that script?  And if so...where do I get it, and how do I know it's not going to randomly fry my new adapter? =)

----------

## Kesereti

Never mind, I managed to cut the script apart enough to not load that part...I had to tear it to pieces anyway, just to get 128-bit WEP working for some reason =\  Ah, well, it works now!

----------

## dyno

would you mind posting the changes that you made? I have a microsoft usb wlan adaptor that I tried setting up yesterday (uses the prism2 drivers as well) with no luck. I was doing it from source in a tar though (didn't realize there was an ebuild). 

I'm going to try tonight with the ebuild, but I too will also need WEP working. If you don't mind, it would be nice to have that info incase I have problems.

-dyno

----------

## Kesereti

Sure...here's a listing of the lines that are changed from the default wlan-ng install =)  It's actually not that much, except for basically removing an entire function (the firmware loading one) and enabling wep (which for some reason in the scripts is not ever checked for enabling)...

/etc/wlan/shared.prism2:

prism2_fwload() {

  (all lines commented out except for "return 0" at the end)

}

/etc/init.d/wlan:

  (after the line "wlan_user_mibs $DEVICE")

  wlan_wep $DEVICE

Of course, you also have to add the correct settings in your /etc/conf.d/wlan.conf and /etc/conf.d/wlancfg-your_ssid_here files...but with the wlan_wep function called, it actually *reads* those settings =P

----------

## dyno

Thanks! I got it working without having to edit those things though. Well, I don't have WEP going yet, but I haven't really tried either.  That will be something for me to try tomorrow night  :Smile: 

-dyno

----------

## Kesereti

WEP was the big part for me...I have no idea where this prism2dl stuff came from, but the most recent version of linux-wlan-ng sure doesn't behave well on my computer =P  I honestly couldn't find a place in the script where the function that inits the WEP settings would be called...hence having to add it by hand =)

----------

## dyno

that line that you added was already in the script that i had installed. One thing I don't understand is, in my wireless router, i have the encryption setup using letters and numbers (hex), but in the config file for the adapter, it wants in the form of xx:xx:xx:xx...etc

How do I convert it to that?

-dyno

----------

## Kesereti

Really?  Wow...I guess it's just me that's having a problem =)  And that's fine, you just split the hex into two-character sets, like 12:34:56:78:9A:BC or however =)

----------

## dyno

ahhhhhh...knew it had to be something simple. I'll try that when i get home from work. Thanks!

-dyno

----------

## dyno

how do you get the network to start and grab an ip off of a boot?

i tried doing:

rc-update add wlan default

and it didn't seem to work. suggestions?

-dyno

----------

## Kesereti

Using DHCP?  Well, first, make sure that the following line is in your /etc/conf.d/net:

iface_wlan0="dhcp"

Then, add wlan and net.wlan0 (just do a 'cp /etc/init.d/net.eth0 /etc/init.d/net.wlan0 if it's not there) with:

rc-update add wlan default

rc-update add net.wlan0 default

And that should do it...

(note: you may need to add the "need wlan" line to the net.wlan0 file in the depend section, to ensure that your device is configured before the system tries to bring it up and use DHCP on it -- it's especially crucial if you're using WEP) =)

----------

## dyno

I followed your directions and now I'm getting a couple errors at boot.  I don't think "/etc/init.d/wlan start" is being executed. I get an error about needed programs not being there. 

-dyno

----------

## Kesereti

What exactly is the error?

----------

## dyno

```

Failed to Bring wlan0 up

Problem starting needed services

netmount was not started

Problem starting needed services

sshd was not started

```

Also, which setting did you change in the config file to get WEP to work? I'm a little confused as to what each one means.

-dyno

----------

## Kesereti

OK, so it looks like net.wlan0 isn't being brought up...what's in the depend() section of /etc/init.d/net.wlan0?

And, in the /etc/conf.d/wlancfg-yourssidhere (or /etc/conf.d/wlancfg-DEFAULT if you didn't set such a thing), here's what I changed:

```

dot11PrivacyInvoked=true

dot11ExcludeUnencrypted=true

dot11WEPDefaultKey0=(your key here)

AuthType="sharedkey"

```

----------

## dyno

```
use hotplug pcmcia

```

and that's it. i tried using "wlan" as well, but it broke things in the same manner.

-dyno

----------

## Kesereti

...and with it looking like this:

depend () {

  use hotplug pcmcia

  need wlan

}

?  How does that work?

----------

## dyno

i get this: (there is a bunch of other [ok] stuff in between some of these errors that is unrealted)

```

*Can't find service wlan

*ERROR: Some services needed are missing. Run './net.wlan0 broken' for  a list of those services. "net.wlan0" was not started.

*ERROR: Problem starting needed services. "netmount" was not started.

*ERROR: Problem starting needed services. "sshd" was not started.

```

----------

## Kesereti

OK, well, it looks like it doesn't know about the wlan service =)  You're using linux-wlan-ng, right?  It should have created an /etc/init.d/wlan file...is that file there?  If so, have you done an 'rc-update add wlan default' to add it to the default runlevel?

----------

## dyno

yes, I've ran rc-update add wlan default.  when it fails to load everything on boot I do this to bring it up:

/etc/init.d/wlan start

dhcpcd wlan0

and then everything works. I just can't get it to do it automatically on boot.

-dyno

----------

## Kesereti

What happens when you try to bring it up manually like this, instead:

```

/etc/init.d/wlan start

/etc/init.d/net.wlan0 start

```

...using the script instead of dhcpcd manually?  I'm just wondering why it claims it can't find the wlan service, if it exists in /etc/init.d *and* is symlinked in /etc/runlevels/default =\

----------

## dyno

When I try it that way, of course /etc/init.d/wlan start works, but when I do the next command I get:

```

*ERROR:  Some services needed are missing.  Run './net.wlan0 broken' for a list of those services. "net.wlan0" was not started.

```

When I run ./net.wlan broken, I get:

```

* Could not get dependency info for "wlan"!

```

So it must be my net.wlan0 that is messed up?

-dyno

----------

## dyno

Okay, I got it to work when I enter the two commands manually. I got rid of the dependency in net.wlan0, and then deleted, and readded it using rc-update.

Problem still is though that it looks like "/etc/init.d/wlan start" is not being run at boot. It doesn't say anywhere during boot time that it's trying to start it. it gets to trying to start wlan0, and it fails, and I think this is because wlan hasn't been run yet.  this in turn also causes netmount and sshd to fail. i've tried deleting and readding it using rc-update with no luck...

-dyno

----------

## Kesereti

Wow...that's really strange...I've never seen a service that was in the appropriate runtime directory /etc/runlevels/default, for example) that didn't start...right after booting, do a "dmesg | more", look for anything that looks like the card might be having problems with the kernel...

----------

## dyno

I didn't notice anything too weird. It loads the prism module fine, usb identifies it and such, and then a bunch of other usb stuff is configured.  The only thing odd that noticed is that my dvdrom is running in PIO mode at ATA33. Ack. Guess I better fix that too  :Razz: 

But yeah, I'm confused now.

-dyno

----------

## Kesereti

So am I ... alright, here's a copy of my /etc/init.d/wlan and /etc/init.d/net.wlan0 ... try dropping them into your system, rc-update del'ing and rc-update add'ing them back into the default runlevel, and giving that a try?  Make certain, also, that the scripts are executable; all mine have permissions 755 (global read/execute, user write)...

OK, here's /etc/init.d/wlan:

```

#!/sbin/runscript

source_config() {

   if [ -f /etc/wlan/shared ]

   then

      source /etc/wlan/shared

   else

      return 1

   fi

   return 0

}

start() {

   ebegin "Starting WLAN devices"

   if ! source_config

   then

      eerror "Error loading /etc/wlan/shared"

      eend 1

      return 1

   fi

   # NOTE: We don't explicitly insmod the card driver here.  The

   #  best thing to do is to specify an alias in /etc/modules.conf.

   #  Then, the first time we call wlanctl with the named device,

   #  the kernel module autoload stuff will take over.

   echo "Staring up"

   for DEVICE in $WLAN_DEVICES; do

   #=======ENABLE========================================

   # Do we want to init the card at all?

      eval 'WLAN_ENABLE=$ENABLE_'$DEVICE

      if ! is_true $WLAN_ENABLE ; then

         continue

      fi

      if is_true $WLAN_DOWNLOAD; then

         wlan_download $DEVICE

      fi

      wlan_enable $DEVICE

   #=======MAC STARTUP=========================================

      wlan_supports_scan $DEVICE

      if [ $? = 0 ] ; then

         wlan_scan $DEVICE

         if [ $? = 0 ] ; then

            wlan_source_config_for_ssid "$ssid:$bssid"

      

            wlan_user_mibs $DEVICE

            wlan_wep $DEVICE

            # make it quiet

            error=`eval wlan_wep $DEVICE`

      

            grep 'autojoin' /proc/net/p80211/$DEVICE/wlandev > /dev/null

               if [ $? = 0 ]; then

                  wlan_infra $DEVICE

               else

                  wlan_dot11_join $DEVICE

               fi

         else

            echo "network not found.  maybe start IBSS?"

         fi

      else

         wlan_source_config $DEVICE

   

         wlan_user_mibs $DEVICE

         wlan_wep $DEVICE

         # make it quiet

         error=`eval wlan_wep $DEVICE`

   

         if is_true $IS_ADHOC ; then

            wlan_adhoc $DEVICE

         else

            wlan_infra $DEVICE

         fi

      fi

   done

   eend 0

}

stop() {

   ebegin "Shutting Down WLAN Devices"

   if ! source_config

   then

      eerror "Error loading /etc/wlan/shared"

      eend 1

      return 1

   fi

   # Do a reset on each device to make sure none of them are still

   #  trying to generate interrupts.

   for DEVICE in $WLAN_DEVICES; do

      # This just makes it quiet...

      error="$(eval wlan_disable $DEVICE)"

   done

   eend 0

}

```

And here is /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: /home/cvsroot/gentoo-src/rc-scripts/init.d/net.eth0,v 1.28 2003/03/16 08:03:19 azarah Exp $

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

# For pcmcia users. note that pcmcia must be added to the same

# runlevel as the net.* script that needs it.

depend() {

   use hotplug pcmcia

   need wlan

}

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" }')"

}

start() {

   local retval=0

   setup_env

   checkconfig || return 1

   

   ebegin "Bringing ${IFACE} up"

   if [ "${iface_IFACE}" != "dhcp" ]

   then

      /sbin/ifconfig ${IFACE} ${iface_IFACE} >/dev/null || {

         retval=$?

         eend ${retval} "Failed to bring ${IFACE} up"

         return ${retval}

      }

      # ifconfig do not always return failure ..

      /sbin/ifconfig ${IFACE} &> /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} >/dev/null || {

            retval=$?

            eend ${retval} "Failed to bring ${IFACE} up"

            return ${retval}

         }

      fi

   fi

   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} >/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} >/dev/null

         eend 0

      done

      save_options "inet6" "${inet6_IFACE}"

   fi

   

   if [ -n "${gateway}" ] && [ "${gateway%/*}" = "${IFACE}" ]

   then

      ebegin "  Setting default gateway"

      # First delete any existing routes if it was setup by kernel ..

      /sbin/route del default dev ${gateway%/*} &>/dev/null

      /sbin/route add default gw ${gateway#*/} dev ${gateway%/*} \

         netmask 0.0.0.0 metric 1 >/dev/null || {

         

         local error=$?

         ifconfig ${IFACE} down &>/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 > /proc/sys/net/ipv4/conf/${IFACE}/rp_filter

   fi

}

stop() {

   local myalias="$(get_options alias)"

   local myinet6="$(get_options inet6)"

   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} >/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 >/dev/null

         num=$((num + 1))

      done

   fi

   if [ "${iface_IFACE}" = "dhcp" ]

   then

      local count=0

      while /sbin/dhcpcd -k ${IFACE} &>/dev/null && [ "${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"

      fi

   else

      /sbin/ifconfig ${IFACE} down >/dev/null

   fi

   eend 0

}

# vim:ts=4

```

----------

## dyno

yay! well that made it work. thanks for all the help, I appreciate it. Now that it's working off of boot, I'll try to get WEP working.

-dyno

----------

## Kesereti

Woohoo =)  Let me know how the WEP goes, that script will automatically turn it on once you set the key =P

----------

## dyno

Hmm...I can't seem to get WEP to work.  I'll post my wlancfg-DEFAULT file for you to look at. I think I made the changes you suggested. I also tried a few other combinations of settings and wasn't able to get it to work. I know the WEP on my base station does in fact work because my pocketpc works with it.

```

#=======USER MIB SETTINGS=============================

# You can add the assignments for various MIB items

#  of your choosing to this variable, separated by

#  whitespace.  The wlan-ng script will then set each one.

# Just uncomment the variable and set the assignments

#  the way you want them.

#USER_MIBS="p2CnfRoamingMode=1 p2CnfShortPreamble=mixed"

#=======WEP===========================================

# [Dis/En]able WEP.  Settings only matter if PrivacyInvoked is true

lnxreq_hostWEPEncrypt=false     # true|false

lnxreq_hostWEPDecrypt=flase     # true|false

dot11PrivacyInvoked=true        # true|false

dot11WEPDefaultKeyID=1          # 0|1|2|3

dot11ExcludeUnencrypted=true    # true|false, in AP this means WEP is required.

# If PRIV_GENSTR is not empty, use PRIV_GENTSTR to generate

#  keys (just a convenience)

PRIV_GENERATOR=/sbin/nwepgen    # nwepgen, Neesus compatible

PRIV_KEY128=false               # keylength to generate

PRIV_GENSTR=""

# or set them explicitly.  Set genstr or keys, not both.

dot11WEPDefaultKey0=            # format: xx:xx:xx:xx:xx   or

dot11WEPDefaultKey1=1892af819c0d10b018d8190aa8

dot11WEPDefaultKey2=            #  e.g.   01:20:03:40:05   or

dot11WEPDefaultKey3=            #         01:02:03:04:05:06:07:08:09:0a:0b:0c:0d

#=======SELECT STATION MODE===================

IS_ADHOC=n                      # y|n, y - adhoc, n - infrastructure

#======= INFRASTRUCTURE STATION  ===================

# What kind of authentication?

AuthType="sharedkey"            # opensystem | sharedkey (requires WEP)

#======= ADHOC STATION ============================

BCNINT=100                      # Beacon interval (in Kus)

CHANNEL=6                       # DS channel for BSS (1-14, depends

                                #   on regulatory domain)

BASICRATES="2 4"                # Rates for mgmt&ctl frames (in 500Kb/s)

OPRATES="2 4 11 22"             # Supported rates in BSS (in 500Kb/s)

```

note: for the encryption key, I did orginially try it in the xx:xx:xx format, but it didn't work so I tried it without the colons, and that was the last modification that I tried.

----------

## Kesereti

Hrm...ok...what does your /etc/conf.d/wlan.conf look like?  The way that the wlan-ng package likes to work is this: in wlan.conf, you set an SSID for each interface, like so:

```

SSID_wlan0="some_ssid"

ENABLE_wlan0=y

```

Then, that tells the package to look for /etc/conf.d/wlancfg-some_ssid for the settings particular to that network.  Here, for example, is my file, with the key edited out, of course ^_^

```

#=======USER MIB SETTINGS=============================

# You can add the assignments for various MIB items

#  of your choosing to this variable, separated by

#  whitespace.  The wlan-ng script will then set each one.

# Just uncomment the variable and set the assignments

#  the way you want them.

#USER_MIBS="p2CnfRoamingMode=1 p2CnfShortPreamble=mixed"

#=======WEP===========================================

# [Dis/En]able WEP.  Settings only matter if PrivacyInvoked is true

lnxreq_hostWEPEncrypt=true     # true|false

lnxreq_hostWEPDecrypt=true     # true|false

dot11PrivacyInvoked=true        # true|false

dot11WEPDefaultKeyID=0          # 0|1|2|3

dot11ExcludeUnencrypted=true    # true|false, in AP this means WEP is required.

# If PRIV_GENSTR is not empty, use PRIV_GENTSTR to generate

#  keys (just a convenience)

# add-ons/ in the tarball contains other key generators.

PRIV_GENERATOR=/sbin/keygen     # nwepgen, Neesus compatible

PRIV_KEY128=true                # keylength to generate

PRIV_GENSTR="some_genstr"

# or set them explicitly.  Set genstr or keys, not both.

dot11WEPDefaultKey0=            # format: xx:xx:xx:xx:xx   or

dot11WEPDefaultKey1=            #         xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx

dot11WEPDefaultKey2=            #  e.g.   01:20:03:40:05   or

dot11WEPDefaultKey3=            #         01:02:03:04:05:06:07:08:09:0a:0b:0c:0d

#=======SELECT STATION MODE===================

IS_ADHOC=n                      # y|n, y - adhoc, n - infrastructure

#======= INFRASTRUCTURE STATION  ===================

# What kind of authentication?

AuthType="sharedkey"            # opensystem | sharedkey (requires WEP)

#======= ADHOC STATION ============================

BCNINT=100                      # Beacon interval (in Kus)

CHANNEL=6                       # DS channel for BSS (1-14, depends

                                #   on regulatory domain)

BASICRATES="2 4"                # Rates for mgmt&ctl frames (in 500Kb/s)

OPRATES="2 4 11 22"             # Supported rates in BSS (in 500Kb/s)

```

You can also just set the "dot11WEPDefaultKey0" setting with your key instead, but I made it easier on myself and just let it generate the key from the passphrase ("some_genstr" in the above, but of course that's not *my* passphrase ^_^)  If you want to just set it by hand, though, make sure it's in the format the script asks for, i.e. "18:92:af:81:9c:0d:10:b0:18:d8:19:0a:a8", instead of what you have in yours currently. On the other hand, the scripts will just generate the key dynamically each time you bring the interface up, with the way I have the script set...this way (with the specific SSID set in /etc/conf.d/wlan.conf) works well if you don't have multiple wireless networks that you have to attach to; you can set up multiple /etc/conf.d/wlancfg-some_ssid files, and just change one line in /etc/conf.d/wlan.conf each time you go to a new network if you need to associate with multiple networks with different keys and SSIDs =)

----------

## dyno

i was leaving ssid blank so that it would point to wlancfg-DEFAULT. I tried setting it to the network name I use and then creating wlancfg-"myssid" but it didn't work. same results.

I'm not too sure I understand what you mean by generating a new key each time. I thought the client key had to match the key that's in the WAP?

-dyno

----------

## Kesereti

Well, yes, it does...but how does your WAP generate a key?  With a passphrase that you type in?  Mine does...say, for example, I use the word 'gentoo' as my passphrase...the 128-bit key associated with that passphrase is 65:de:7a:a8:3d:b1:ff:32:96:80:21:b5:1b.  Now, instead of typing that mess into my config file, see where the line "PRIV_GENSTR="some_genstr"" is in my config?  You put your passphrase there, replacing "some_genstr", and then the script calls the program mentioned in the PRIV_GENERATOR line (/sbin/keygen works just fine, no need to mess with it); if you're using 128-bit keys (which I recommend), you need to set the PRIV_KEY128 line to 'true' as well.  That way, you don't have a passphrase in cleartext on a config file *shrug* =)  Does that make any sense?

----------

## dyno

ah okay. i don't think my WAP supports key generation via a passphrase. I've always just made up a random key off the top of my head.  I guess I'll fiddle with settings a little more.

-dyno

----------

## Kesereti

Ah, OK...in that case, make sure that PRIV_GENSTR is empty, because otherwise the script will ignore keys that you set in the config file =)

----------

## shawndubya

I'm having similar setup problems with a D-Link USB wireless adapter; created a new topic here. Could either of you with your knowledge take a look and see if anything comes to mind. Thanks ...

----------

## gondoi

hey guys, i'm having trouble here too... i got everything working except that WEP just WILL not cooperate. i'm using linux-wlan-ng 0.2.1-pre20  anyway, i set up all the scripts accordingly, don't get any error messages... but still when i start up wlan and try just a dhcpcd wlan0 it times out.. .and my router doesn't ever see the machine show up...

got any ideas?

----------

