기존 이솝 임베디드 포럼의 지식인 서비스가 게시판 형태로 변경되었습니다.

안녕하세요.


특정 네트워크가 무선인지 유선인지 알고 싶습니다.


제 상황은 이더넷드라이버랑 무선드라이버가 2개가 있습니다.


현재 이더넷드라이버는 eth0으로 잡히고 무선드라이버는 eth1로 잡힙니다.


그런데 드라이버를 올리는 순서를 달리하여서 무선드라이버를 먼저올리고 이더넷드라이버를 나중에 올리면 


무선이 eth0이 되고 유선 이더넷이 eth1이 됩니다.


이런 상황에서 eth0는 무조건 이더넷이라고 단정하기도 애매한 상황같아서 특정 인터페이스가 유선인지 무선인지 알았으면 합니다.


이러저러한 방법을 찾아보다가 udev를 이용 할수 있을것 같아서 각각의 네트워크 인터페이스에 대해서 udev정보를 읽어보았습니다.


root@test:~# udevadm info -a -p /sys/class/net/eth0


Udevadm info starts with the device specified by the devpath and then

walks up the chain of parent devices. It prints for every device

found, all possible attributes in the udev rules key format.

A rule to match, can be composed by the attributes of the device

and the attributes from one single parent device.


looking at device '/devices/virtual/net/eth0':

KERNEL=="eth0"

SUBSYSTEM=="net"

DRIVER==""

ATTR{mtu}=="1500"

ATTR{type}=="1"

ATTR{netdev_group}=="0"

ATTR{flags}=="0x1003"

ATTR{dormant}=="0"

ATTR{addr_assign_type}=="0"

ATTR{dev_id}=="0x0"

ATTR{iflink}=="2"

ATTR{addr_len}=="6"

ATTR{address}=="00:15:1d:00:00:00"

ATTR{operstate}=="up"

ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"

ATTR{tx_queue_len}=="1000"

ATTR{ifalias}==""

ATTR{ifindex}=="2"

ATTR{link_mode}=="0"

ATTR{carrier}=="1"


root@test:~#



 root@test:~# udevadm info -a -p /sys/class/net/eth1


Udevadm info starts with the device specified by the devpath and then

walks up the chain of parent devices. It prints for every device

found, all possible attributes in the udev rules key format.

A rule to match, can be composed by the attributes of the device

and the attributes from one single parent device.


looking at device '/devices/platform/exynos4-sdhci.3/mmc_host/mmc1/mmc1:0001/mmc1:0001:1/net/eth1':

KERNEL=="eth1"

SUBSYSTEM=="net"

DRIVER==""

ATTR{mtu}=="1500"

ATTR{type}=="1"

ATTR{netdev_group}=="0"

ATTR{flags}=="0x1002"

ATTR{addr_assign_type}=="0"

ATTR{dev_id}=="0x0"

ATTR{iflink}=="3"

ATTR{addr_len}=="6"

ATTR{address}=="c4:23:7a:00:6e:93"

ATTR{operstate}=="down"

ATTR{broadcast}=="ff:ff:ff:ff:ff:ff"

ATTR{tx_queue_len}=="1000"

ATTR{ifalias}==""

ATTR{ifindex}=="3"

ATTR{link_mode}=="0"


looking at parent device '/devices/platform/exynos4-sdhci.3/mmc_host/mmc1/mmc1:0001/mmc1:0001:1':

KERNELS=="mmc1:0001:1"

SUBSYSTEMS=="sdio"

DRIVERS=="unifi"

ATTRS{class}=="0x00"

ATTRS{device}=="0x0007"

ATTRS{vendor}=="0x032a"


looking at parent device '/devices/platform/exynos4-sdhci.3/mmc_host/mmc1/mmc1:0001':

KERNELS=="mmc1:0001"

SUBSYSTEMS=="mmc"

DRIVERS==""

ATTRS{type}=="SDIO"


looking at parent device '/devices/platform/exynos4-sdhci.3/mmc_host/mmc1':

KERNELS=="mmc1"

SUBSYSTEMS=="mmc_host"

DRIVERS==""


looking at parent device '/devices/platform/exynos4-sdhci.3':

KERNELS=="exynos4-sdhci.3"

SUBSYSTEMS=="platform"

DRIVERS=="s3c-sdhci"


looking at parent device '/devices/platform':

KERNELS=="platform"

SUBSYSTEMS==""

DRIVERS==""


root@test:~#


정보를 보고 나름 생각하기로는 ATTR{flags}가 0x1002이면 무선이고 0x1003이면 유선이지 않을까 라고 생각도 해보았습니다. 그런데 이러한 flags에 대한 정보를 찾기가 힘들더군요. 이방법도 아닌거 같고...


특정 네트워크가 무선인지 유선인지 알 수 있는 방법이 있을까요 ? 


유형목

2014.11.12 23:31:36
*.200.239.210

SUSBSYSTEM 항목을 보면 알수 있네요.


무선랜은 SUBSYSTEMS=="sdio"

그냥 이더넷은 SUBSYSTEMS=="net"


으로 나오네요.

xoduddk123

2014.11.13 01:49:55
*.216.145.10

eth1의 경우에도 아랫부분은 사용하는 인터페이스가 SDIO인터페이스를  사용하는 무선랜이기 때문에 SDIO로 나오는것 같은데 맨위에는 동일하게 SUBSYSTEM 항목이 동일 하게 net이어서 구분하기 힘든 것 같습니다.

파일럿

2014.11.13 02:59:51
*.214.41.74

WiFi driver에서 network 장치 이름을 wlan0등으로 바꾸는게 쉽지 않을까요?

xoduddk123

2014.11.13 04:39:46
*.216.145.10

저도 다른 mlan0이나 wlan0이나 그런것들도 무선네트워크인것은 알고 있습니다. 

그런데 확실히 구분되게 현재 시스템이 있는 네트워크장치들은 하나씩 보면서 이건 무선 이건 유선 이렇게 알수있는 방법이 있지않을까해서요...   분명히 어디가에 그런정보가 있을거같기도 하고요 flags같기는 한데 .... ㅠㅠ 



배석헌

2014.11.15 04:40:34
*.236.10.19

iw (http://git.sipsolutions.net/iw.git/)

나 wireless tools 같은 툴을 참고하보세요.

$ iwconfig

eth0      no wireless extensions.


lo        no wireless extensions.


$ iw eth0

nl80211 not found

$ iw eth1



문철민

2014.12.02 00:38:53
*.37.242.22

cat /proc/net/wireless


하시면 무선 장비가 나옵니다

List of Articles
번호 제목 글쓴이 날짜 조회 수

사용자 로그인