Get Wifi Interface name on Android

前端 未结 6 929
无人及你
无人及你 2021-01-06 18:24

I am currently developing a sort of wifi sniffer. To achieve that I use a tcpdump binary compiled for arm. But it\'s assume that I know the name of the Wifi Interface.

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-06 18:49

    You can call /system/ip link and parse the results.

    bash-3.2# ip link
    ip link
    1: lo:  mtu 16436 qdisc noqueue state UNKNOWN
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: usb0:  mtu 1500 qdisc noop state DOWN qlen 1000
        link/ether 6e:3d:7a:3a:62:ee brd ff:ff:ff:ff:ff:ff
    3: usb1:  mtu 1500 qdisc noop state DOWN qlen 1000
        link/ether da:bb:3f:04:1b:cd brd ff:ff:ff:ff:ff:ff
    4: sit0:  mtu 1480 qdisc noop state DOWN
        link/sit 0.0.0.0 brd 0.0.0.0
    5: ip6tnl0:  mtu 1460 qdisc noop state DOWN
        link/tunnel6 :: brd ::
    6: ifb0:  mtu 1500 qdisc noop state DOWN qlen 32
        link/ether 76:3c:4e:23:cc:f8 brd ff:ff:ff:ff:ff:ff
    7: ifb1:  mtu 1500 qdisc noop state DOWN qlen 32
        link/ether 02:17:54:31:ff:bd brd ff:ff:ff:ff:ff:ff
    8: tun:  mtu 1500 qdisc noop state DOWN qlen 500
        link/ether b2:b7:11:da:7c:6a brd ff:ff:ff:ff:ff:ff
    16: tiwlan0:  mtu 1500 qdisc pfifo_fast state UP qlen 100
        link/ether 40:fc:89:e4:67:4c brd ff:ff:ff:ff:ff:ff
    

提交回复
热议问题