Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve OpenWrt wireless search error bug

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to solve the OpenWrt wireless search error bug, the content is concise and easy to understand, absolutely can make your eyes bright, through the detailed introduction of this article, I hope you can get something.

TP-LINK 841n routing updates the openwrt system to Barrier Breaker R41988, the "network"-> "wireless"-> "search" function is not available, and the trunk version also has this problem. In fact, playing HG255D routing in April and May this year had this problem, but the source code compiled to TP-LINK 841n at that time did not have this problem. It took me two days to find out where bug is (only for wr841n, there's something wrong with my hg255d).

Wireless search bug screenshot (note device parameter radio0):

After a search, it is found that the source code of this page is in the / usr/lib/lua/luci/view/admin_network/wifi_join.htm file of the system, and the source path of the corresponding openwrt is. / feeds/luci/modules/admin-full/luasrc/view/admin_network/wifi_join.htm. Finally, the code is as follows:

0 and qm > 0 then return math.floor ((100 / qm) * qc) else return 0 end end function format_wifi_encryption (info) if info.wep = = true then return "WEP" elseif info.wpa > 0 then return translatef ("% s -% s" Table.concat (info.pair_ciphers, ","), table.concat (info.group_ciphers, ",") (info.wpa = 3) and translate ("mixed WPA/WPA2") or (info.wpa = = 2 and "WPA2" or "WPA"), table.concat (info.auth_suites, " ") elseif info.enabled then return's"% translate ("unknown") else return "% s"% translate ("open") end end local dev = luci.http.formvalue ("device") local Iw = luci.sys.wifi.getiwinfo (dev) if not iw then luci.http.redirect (luci.dispatcher.build_url ("admin/network/wireless")) return end function scanlist (times) local I K, v local l = {} local s = {} for I = 1, times do for k V in ipairs (iw.scanlist or {}) do if not s [v.bssid] then l [# lumb1] = v s [v.bssid] = true end end End return l end-% >

% Channel: | Mode: | BSSID: | Encryption:

Further testing shows that the browser will see the error message when the generated web page is incomplete due to the exception of calling function scanlist (times). This function, in turn, is calling iw.scanlist for an exception. Find the sys.lua module by local iw = luci.sys.wifi.getiwinfo (dev), path / usr/lib/lua/luci/sys.lua, corresponding to openwrt source location. / feeds/luci/modules/base/luasrc/sys.lua. Main source code:

-Get wireless information for given interface.-- @ param ifname String containing the interface name-- @ return A wrapped iwinfo object instancefunction wifi.getiwinfo (ifname) local stat, iwinfo = pcall (require, "iwinfo") if ifname then local c = 0 local u = uci.cursor_state () local d N = ifname:match ("^ (% w+)% .network (% d +)") if d and n then ifname = d n = tonumber (n) u:foreach ("wireless", "wifi-iface") Function (s) if s.device = = d then c = c + 1 if c = n then Ifname = s.ifname or s.device return false end) elseif u:get ("wireless" Ifname) = "wifi-device" then u:foreach ("wireless", "wifi-iface") Function (s) if s.device = = ifname and s.ifname then ifname = s.ifname return false End end) end local t = stat and iwinfo.type (ifname) local x = t and iwinfo [t] or {} return setmetatable ({} {_ _ index = function (t K) if k = = "ifname" then return ifname elseif x [k] then return x [k] (ifname) end End}) endend

It turns out that the wireless search is completed by calling the iwinfo command. Run the iwinfo command under openwrt:

Root@OpenWrt:~# iwinfo-- helpUsage: iwinfo info iwinfo scan iwinfo txpowerlist iwinfo freqlist iwinfo assoclist iwinfo countrylistroot@OpenWrt:~# iwinfo radio0 scanCell 01-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 02-Address: 0000 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 03-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 04-Address: 0000 unknown Signal: 0000 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 05-Address: 00 Encryption: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 06-Address: 00 Encryption: unknown Mode: Unknown Channel: unknown Signal:- 256 dBm Quality: 0Address 0 Encryption: noneCell 07-Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 0000Address: 000000 : noneCell 09-Address: 00ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 10-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 11-Address: 00:00:00: 00:00:00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-00:00:00 dBm Quality: 0 Encryption: noneCell 12-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 13-Address: 0000 unknown Signal: 0000 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 14-Address: 00 dBm Quality 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 15-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 16-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 17-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 / 0 Encryption: noneCell 18-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 19-Address: 00 ESSID: Unknown Channel: unknown Signal:-256 dBm Quality: 0 Encryption: noneCell 20-Address: 00 ESSID: unknown Mode: Unknown Channel: unknown Signal:-256 dBm Quality: 0bank 0 Encryption: none

Look at Address, ESSID. It means that the iwinfo cannot scan to the wireless access point at all. It is no problem to run this command in the version compiled in April or May, and the access point can be searched. Iwinfo involves two files, one of which is the executable file / usr/bin/iwinfo on the openwrt system, and the other is the dynamic link library file / usr/lib/libiwinfo.so. So copy the iwinfo and libiwinfo.so files of the previous system (you can use the search function) to the / tmp directory of the problematic route, shell to the / tmp directory, and execute export LD_LIBRARY_PATH=.

Then execute. / iwinfo radio0 scan, and find that the search for the wireless access point is normal, and it seems to be on iwinfo and libiwinfo.so. Delete the libiwinfo.so in the / tmp directory directly and then. / iwinfo radio0 scan, the problem occurs again. It is inferred that the problem should be in libiwinfo.so. The source code of the iwinfo tool is under. / package/network/utils/iwinfo of the openwrt source code. Note that the Makefile file has the following code:

IWINFO_BACKENDS: (if $(CONFIG_PACKAGE_kmod-brcm-wl), wl)\ $(if $(CONFIG_PACKAGE_kmod-brcm-wl-mini), wl)\ $(if $(CONFIG_PACKAGE_kmod-brcm-wl-mimo), wl)\ $(if $(CONFIG_PACKAGE_kmod-madwifi), madwifi)\ $(if $(CONFIG_PACKAGE_kmod-mac80211), nl80211)

The Makefile file in the src directory has the following code:

Ifneq ($(filter wl,$ (IWINFO_BACKENDS)),) IWINFO_CFLAGS + =-DUSE_WL IWINFO_LIB_OBJ + = iwinfo_wl.oendififneq ($(filter madwifi,$ (IWINFO_BACKENDS)),) IWINFO_CFLAGS + =-DUSE_MADWIFI IWINFO_LIB_OBJ + = iwinfo_madwifi.oendififneq ($(filter nl80211,$ (IWINFO_BACKENDS) ) IWINFO_CFLAGS + =-DUSE_NL80211 IWINFO_CLI_LDFLAGS + =-lnl-tiny IWINFO_LIB_LDFLAGS + =-lnl-tiny IWINFO_LIB_OBJ + = iwinfo_nl80211.oendif

Wireless search has 3 implementations, and at first I don't know which one is used under 841n, so just write some debug output statements in the makefile file. Then make package/network/utils/iwinfo/compile Vackers recompiles iwinfo and finds that it is using nl80211, which means the code to be changed is in. / src/iwinfo_nl80211.c. After a series of debugging, we finally found the location of bug. Solutions are as follows:

/ / iwinfo_cli.c file static void print_scanlist (const struct iwinfo_ops * iw, const char * ifname) {int I, x, len=0; / / where len must be initialized to 0 char buf [IWINFO _ BUFSIZE]; struct iwinfo_scanlist_entry * e; if (iw- > scanlist (ifname, buf, & len)) {printf ("Scanning not possible\ n\ n"); return } else if (len-1) {if ((d = opendir ("/ sys/class/net"))! = NULL) {while ((e = readdir (d))! = NULL) {snprintf (buffer, sizeof (buffer)) "/ sys/class/net/%s/phy80211/index", e-> d_name) If (nl80211_readint (buffer) = = phyidx) {snprintf (buffer, sizeof (buffer), "/ sys/class/net/%s/ifindex", e-> d_name) If ((cifidx = nl80211_readint (buffer)) > = 0 & ((ifidx)

< 0) || (cifidx < ifidx))) { ifidx = cifidx; strncpy(nif, e->

D_name, sizeof (nif); ret = nif; / / add break / / add} closedir (d);}} return ret; / / modify}

Make package/network/utils/iwinfo/compile Vackers recompiles iwinfo and sends it to the routing test. Iwinfo radio0 scan has no problem, and you can search wireless normally. In fact, I do not like nl80211_phy2ifname functions to return as static variables, but prefer to use function parameters, such as declared as static char * nl80211_phy2ifname (const char * ifname, char * out).

The above content is how to solve the OpenWrt wireless search error bug, have you learned the knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report