luci-proto-modemmanager: fix register_error_code API support

This commit is contained in:
coolsnowwolf 2024-04-11 22:23:27 +08:00
parent 537229d470
commit 8c6da73f0f

View File

@ -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")