From 8c6da73f0f012a2a00c5e51adff77f2f1e10a713 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Thu, 11 Apr 2024 22:23:27 +0800 Subject: [PATCH] luci-proto-modemmanager: fix register_error_code API support --- modules/luci-base/luasrc/model/network.lua | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/modules/luci-base/luasrc/model/network.lua b/modules/luci-base/luasrc/model/network.lua index 32d59802..342e2cc4 100644 --- a/modules/luci-base/luasrc/model/network.lua +++ b/modules/luci-base/luasrc/model/network.lua @@ -25,6 +25,22 @@ IFACE_PATTERNS_VIRTUAL = { } IFACE_PATTERNS_IGNORE = { "^wmaster%d", "^wifi%d", "^hwsim%d", "^imq%d", "^ifb%d", "^mon%.wlan%d", "^sit%d", "^gre%d", "^gretap%d", "^ip6gre%d", "^ip6tnl%d", "^tunl%d", "^lo$" } IFACE_PATTERNS_WIRELESS = { "^wlan%d", "^wl%d", "^ath%d", "^rausb%d", "^rai%d", "^rax%d", "^ra%d", "^wdsi%d", "^wdsx%d", "^wds%d", "^apclii%d", "^apclix%d", "^apcli%d", "^apcliusb%d", "^%w+%.network%d" } +IFACE_ERRORS = { + CONNECT_FAILED = lng.translate("Connection attempt failed"), + INVALID_ADDRESS = lng.translate("IP address is invalid"), + INVALID_GATEWAY = lng.translate("Gateway address is invalid"), + INVALID_LOCAL_ADDRESS = lng.translate("Local IP address is invalid"), + MISSING_ADDRESS = lng.translate("IP address is missing"), + MISSING_PEER_ADDRESS = lng.translate("Peer address is missing"), + NO_DEVICE = lng.translate("Network device is not present"), + NO_IFACE = lng.translate("Unable to determine device name"), + NO_IFNAME = lng.translate("Unable to determine device name"), + NO_WAN_ADDRESS = lng.translate("Unable to determine external IP address"), + NO_WAN_LINK = lng.translate("Unable to determine upstream interface"), + PEER_RESOLVE_FAIL = lng.translate("Unable to resolve peer host name"), + PIN_FAILED = lng.translate("PIN code rejected") +} + protocol = utl.class() @@ -393,6 +409,17 @@ function register_pattern_virtual(self, pat) IFACE_PATTERNS_VIRTUAL[#IFACE_PATTERNS_VIRTUAL+1] = pat end +function register_error_code(self, code, message) + if type(code) == "string" and + type(message) == "string" and + not IFACE_ERRORS[code] + then + IFACE_ERRORS[code] = message + return true + end + + return false +end function has_ipv6(self) return nfs.access("/proc/net/ipv6_route")