LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   How does my computer determine which wireless device to use? (https://www.linuxquestions.org/questions/slackware-14/how-does-my-computer-determine-which-wireless-device-to-use-479775/)

drkstr 09-02-2006 12:25 PM

How does my computer determine which wireless device to use?
 
Hello Slackers,

First, let me explain the question a little bit more. I need to know how the device name is chosen for a wireless card. I know how to figure this out myself (by knowing the type of card and what driver it uses, ath_pci=ath0 in my case), but I need a script that I'm writing to be able to tell this, preferably with having to search google. ;)

First off, does it even matter? Can I just tell the system to use whichever device name I tell it to? I doubt it, but thought I should ask anyways.

If it does matter, then what's the best way to determine the device name my script should be configuring? Can I extract it from some text like in like 'cat /proc/stuff' for instance? If not, what do you think the easiest way to if-then it is?

Thanks for the help!
...drkstr

**edit**
The script will be generating an /etc/rc.d/rc.inet1.conf if it makes any difference.

raska 09-02-2006 01:47 PM

I don't know if this helps, but I had this script somewhere in my machine. Asks for the network devices' names to ifconfig and cuts out everything else
Code:

# cat ~/zeeDevices.sh
#!/bin/bash

/sbin/ifconfig | /bin/grep "Link encap:" | /bin/awk -F: {'print $1'} | /bin/cut -d\  -f 1

The original script was to know the ip addresses (or only one by the given interface name) on the system, which I found somewhere in this forum a long long time ago
Code:

#cat ~/myIp.sh
#!/bin/bash

/sbin/ifconfig $1 | /bin/grep "inet addr:" | /bin/awk -F: {'print $2'} | /bin/cut -d\  -f 1


raska 09-02-2006 01:50 PM

I though you might find this useful as well,
I found in man ifconfig that the required files for the command are
  • /proc/net/socket
  • /proc/net/dev
  • /proc/net/if_inet6

I checked /proc/net/dev and guess what....

drkstr 09-02-2006 03:17 PM

Awsome, thanks for the help! That was exactly what I was looking for.

Quick question though. I notice that it also shows wifi0 in the listing. Now from what I read, this isn't an actual device. I also noticed that in the rc.inet1.conf, the example device name is for wlan0.

My question is this (and sorry, if you can't tell allready, I don't know anything about this wireless stuff).

How are the device names decided? Is it just whatever the user defines? And is ath0 just the default? Would it be safe to assume when reading in the /proc/net/dev that if it is not any of these:

lo
eth*
wifi*

then it must be the wireless device I'm looking for? Everything I've been reading either refers to a wlan0 or an ath0, can I just check if it's one or the other?

Programming became so much more complicated now that I'm not just doing it for my own use ;)

thanks again for your help!
...drkstr

Alien Bob 09-03-2006 02:21 PM

Quote:

Originally Posted by drkstr
I notice that it also shows wifi0 in the listing. Now from what I read, this isn't an actual device. I also noticed that in the rc.inet1.conf, the example device name is for wlan0.

Correct. The wifi0 device which the madwifi driver creates is not something you'd want to mess with.
And yes, the example in rc.inet1.conf uses "wlan0", but you're free to change it to whatever name your real wireless device uses of course.

Quote:

How are the device names decided? Is it just whatever the user defines? And is ath0 just the default? Would it be safe to assume when reading in the /proc/net/dev that if it is not any of these:

lo
eth*
wifi*
If only it were that easy :-)
The ndiswrapper driver for instance creates an eth? device. The ralink drivers create a ra? device. And there will probably even more variants, too. If you want to determine whether an interface is wireless, check how I do int in /etc/rc.d/rc.wireless (the is_wireless_device{} function)

Cheers, Eric

drkstr 09-03-2006 02:50 PM

Ahhh, neato!

So it looks like I can extract all the device names from /proc/net/dev and put them in an array. I could then loop through them using each one as a parameter to iwconfig. If it returns back "no wireless extensions.", then it's not a wireless device. Brilliant, thanks Eric!

Thanks for both your help, think I got what I need now.
...drkstr

PS:
A little off topic, sorry. Eric, have you ever met Pat? Just curious since you have a webpage on the official Slackware site, and contributions to the Slackware project. Are there any other parts of Slackware that you've done/helped with?

masonm 09-03-2006 02:52 PM

Quote:

Originally Posted by Alien Bob
The ndiswrapper driver for instance creates an eth? device.

Really? Not on my system. My card is being driven with ndiswrapper and is wlan0. ndiswrapper doesn't "create" a device name, it's just a driver wrapper.

The card names are determined by how your config files are set up.

Alien Bob 09-03-2006 03:27 PM

Quote:

Originally Posted by masonm
Really? Not on my system. My card is being driven with ndiswrapper and is wlan0. ndiswrapper doesn't "create" a device name, it's just a driver wrapper.

You're right and I should have said "the ip2w2200 driver creates a eth? device...".
The ndiswrapper *does* create the ethernet device. The Windows driver it "wraps" does not know anything about Linux network interfaces.

Quote:

The card names are determined by how your config files are set up.
Well some drivers do not allow to define the device name in a config file, and some do (using "modinfo drivername" sometimes reveals what you can do to the interface name).

Eric

Alien Bob 09-03-2006 03:34 PM

Quote:

Originally Posted by drkstr
Eric, have you ever met Pat? Just curious since you have a webpage on the official Slackware site, and contributions to the Slackware project. Are there any other parts of Slackware that you've done/helped with?

No, I've never met him in person (we're 9 timezone hours apart) but we exchange emails frequently - just like anyone else with Slackware feedback/bug reports/suggestions by the way.
I added the wireless support a couple of years ago, and the arbitrary interface names (instead of just eth?) and for the rest it is just a lot of suggestions/bug reports/feedback over the years :-)
It helps actually sending patches instead of just reporting weird stuff. Then there are the SlackBuilds I wrote and the Wiki I started, which are not contributions to the Slackware distro but to the Slackware community if you will.

Eric

masonm 09-03-2006 03:53 PM

Quote:

Originally Posted by Alien Bob
You're right and I should have said "the ip2w2200 driver creates a eth? device...".

Yep.

Quote:

The ndiswrapper *does* create the ethernet device. The Windows driver it "wraps" does not know anything about Linux network interfaces.
Yeah, ok, I get your point here.


Quote:

Well some drivers do not allow to define the device name in a config file, and some do (using "modinfo drivername" sometimes reveals what you can do to the interface name).

Eric
That's also true, and I concede that point. I suppose I would have done better in saying that in some cases the device name is determined by your config files. (I'm on my 4th beer, ya can't expect perfection at this point LOL)


All times are GMT -5. The time now is 08:58 AM.