新路程------wlan0 连接wifi操作

/usr # ifconfig wlan0 up
==> rtl8188e_iol_efuse_patch
/usr #
/usr #
/usr #
/usr # ifconfig
eth0      Link encap:Ethernet  HWaddr 5E:F1:A1:49:56:A6
          inet addr:192.168.1.155  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:57


lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


wlan0     Link encap:Ethernet  HWaddr 28:F3:66:F8:AC:20
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
 
 /usr # iwconfig
lo        no wireless extensions.


wlan0     IEEE 802.11bgn  ESSID:"123456"  Nickname:"<WIFI@REALTEK>"
          Mode:Managed  Frequency:2.437 GHz  Access Point: B0:E2:35:28:14:09
          Bit Rate:72.2 Mb/s   Sensitivity:0/0
          Retry:off   RTS thr:off   Fragment thr:off
          Encryption key:****-****-****-****-****-****-****-****   Security mode
:open
          Power Management:off
          Link Quality=95/100  Signal level=84/100  Noise level=0/100
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0


eth0      no wireless extensions.


/usr #  wpa_supplicant -Dwext -iwlan0 -C/var/run/wpa_supplicant -c/etc/wpa_supplicant.conf  -B &

链接wifi

/usr # udhcpc -i wlan0
udhcpc (v1.20.2) started
Sending discover...
Sending discover...
Sending select for 192.168.43.4...
Lease of 192.168.43.4 obtained, lease time 3600


/usr # ifconfig wlan0 192.168.43.4
/usr # ifconfig
eth0      Link encap:Ethernet  HWaddr 5E:F1:A1:49:56:A6
          inet addr:192.168.1.155  Bcast:192.168.1.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:57


lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


wlan0     Link encap:Ethernet  HWaddr 28:F3:66:F8:AC:20
          inet addr:192.168.43.4  Bcast:192.168.43.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:30 errors:0 dropped:0 overruns:0 frame:0
          TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:2461 (2.4 KiB)  TX bytes:1358 (1.3 KiB)
 
 
/usr # ping 192.168.43.1
PING 192.168.43.1 (192.168.43.1): 56 data bytes
64 bytes from 192.168.43.1: seq=0 ttl=64 time=7.267 ms
64 bytes from 192.168.43.1: seq=1 ttl=64 time=4.245 ms

--- 192.168.43.1 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 4.245/5.756/7.267 ms


/usr # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
ping: sendto: Network is unreachable


/usr # route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0
192.168.43.0    *               255.255.255.0   U     0      0        0 wlan0


/usr # route add default gw 192.168.43.1   //写默认路由的下一跳地址  默认网关一般填写192.168.x.1,网关实质上是一个网络通向其他网络的IP地址
/usr # ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=53 time=259.829 ms
64 bytes from 8.8.8.8: seq=1 ttl=53 time=134.150 ms

--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 packets received, 0% packet loss
round-trip min/avg/max = 134.150/196.989/259.829 ms




/usr # route
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         192.168.43.1    0.0.0.0         UG    0      0        0 wlan0  
192.168.1.0     *               255.255.255.0   U     0      0        0 eth0

192.168.43.0    *               255.255.255.0   U     0      0        0 wlan0


wpa_supplicant.conf:

ctrl_interface=/var/run/wpa_supplicant


update_config=1


network={  


ssid="123456"  


key_mgmt=WPA-PSK


psk="123456789"


}

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在Qt中,你可以使用QNetworkConfigurationManager类来扫描WiFi Mesh网络。首先,你需要创建一个QNetworkConfigurationManager实例并调用其updateConfigurations()函数来获取当前可用的网络配置。 接下来,你可以使用QNetworkSession类来连接WiFi Mesh网络。创建一个QNetworkSession实例,并使用setConfiguration()函数将其配置为Mesh网络配置。然后,调用open()函数打开会话。 一旦会话已经打开,你可以使用QNetworkInterface类来获取所有相关接口的列表。使用QNetworkInterface::interfaceFromName()函数获取指定接口的详细信息,包括其IP地址和MAC地址等。使用QNetworkInterface::allAddresses()函数获取接口的所有IPv4和IPv6地址。 最后,你可以使用QNetworkConfigurationManager类中的updateConfigurations()函数来获取当前可用的网络配置。 以下是一个简单的示例代码: ```cpp QNetworkConfigurationManager manager; manager.updateConfigurations(); QNetworkConfiguration config; QList<QNetworkConfiguration> configs = manager.allConfigurations(QNetworkConfiguration::Discovered); foreach (const QNetworkConfiguration &config, configs) { if (config.bearerType() == QNetworkConfiguration::BearerWLANMesh) { QNetworkSession session(config); session.open(); QList<QNetworkInterface> interfaces = QNetworkInterface::allInterfaces(); foreach (const QNetworkInterface &interface, interfaces) { if (interface.type() == QNetworkInterface::Wlan && interface.flags().testFlag(QNetworkInterface::IsUp) && interface.flags().testFlag(QNetworkInterface::IsRunning)) { qDebug() << "Interface name:" << interface.name(); qDebug() << "MAC address:" << interface.hardwareAddress(); QList<QHostAddress> addresses = interface.allAddresses(); foreach (const QHostAddress &address, addresses) { if (address.protocol() == QAbstractSocket::IPv4Protocol) { qDebug() << "IPv4 address:" << address.toString(); } } } } } } ``` 请注意,这只是一个简单的示例代码,仅适用于特定的情况。你可能需要根据你的具体需求进行修改和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值