LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 09-02-2006, 12:25 PM   #1
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Rep: Reputation: 45
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.

Last edited by drkstr; 09-02-2006 at 12:27 PM.
 
Old 09-02-2006, 01:47 PM   #2
raska
Member
 
Registered: Aug 2004
Location: Aguascalientes, AGS. Mexico.
Distribution: Slackware 13.0 kernel 2.6.29.6
Posts: 816

Rep: Reputation: 30
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
 
Old 09-02-2006, 01:50 PM   #3
raska
Member
 
Registered: Aug 2004
Location: Aguascalientes, AGS. Mexico.
Distribution: Slackware 13.0 kernel 2.6.29.6
Posts: 816

Rep: Reputation: 30
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....
 
Old 09-02-2006, 03:17 PM   #4
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
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
 
Old 09-03-2006, 02:21 PM   #5
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,223

Rep: Reputation: Disabled
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
 
Old 09-03-2006, 02:50 PM   #6
drkstr
Senior Member
 
Registered: Feb 2006
Location: Seattle, WA: USA
Distribution: Slackware 11.0
Posts: 1,191

Original Poster
Rep: Reputation: 45
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?
 
Old 09-03-2006, 02:52 PM   #7
masonm
Senior Member
 
Registered: Mar 2003
Location: Following the white rabbit
Distribution: Slackware64 13.37 Android 4.0
Posts: 2,248

Rep: Reputation: 46
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.
 
Old 09-03-2006, 03:27 PM   #8
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,223

Rep: Reputation: Disabled
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
 
Old 09-03-2006, 03:34 PM   #9
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,223

Rep: Reputation: Disabled
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
 
Old 09-03-2006, 03:53 PM   #10
masonm
Senior Member
 
Registered: Mar 2003
Location: Following the white rabbit
Distribution: Slackware64 13.37 Android 4.0
Posts: 2,248

Rep: Reputation: 46
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)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to determine your boot device haertig Linux - General 3 04-06-2006 07:24 PM
Can't determine modem as device on list Deke1955 Linux - Hardware 1 09-26-2005 12:04 PM
Determine Computer name lel800 Linux - Networking 5 01-26-2004 05:02 PM
how do you determine the static ip your computer should use jooper317 Linux - Hardware 1 01-06-2004 07:16 PM
How to determine device names yian Linux - General 2 10-21-2002 07:56 PM


All times are GMT -5. The time now is 05:10 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration