proto_ncm.lua 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. --[[
  2. LuCI - Network model - NCM protocol extension
  3. Copyright 2015 Cezary Jackiewicz <cezary.jackiewicz@gmail.com>
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. ]]--
  14. local netmod = luci.model.network
  15. local proto = netmod:register_protocol("ncm")
  16. local interface = luci.model.network.interface
  17. function proto.get_i18n(self)
  18. return luci.i18n.translate("NCM")
  19. end
  20. function proto.opkg_package(self)
  21. return "comgt-ncm"
  22. end
  23. function proto.is_installed(self)
  24. return nixio.fs.access("/lib/netifd/proto/ncm.sh")
  25. end
  26. function proto.is_floating(self)
  27. return true
  28. end
  29. function proto.is_virtual(self)
  30. return true
  31. end
  32. function proto.get_interface(self)
  33. local _ifname=netmod.protocol.ifname(self)
  34. if not _ifname then
  35. _ifname = "wan"
  36. end
  37. return interface(_ifname, self)
  38. end
  39. function proto.get_interfaces(self)
  40. return nil
  41. end
  42. function proto.contains_interface(self, ifc)
  43. return (netmod:ifnameof(ifc) == self:ifname())
  44. end
  45. netmod:register_pattern_virtual("^ncm%-%w")
  46. netmod:register_error_code("CONFIGURE_FAILED", luci.i18n.translate("Configuration failed"))
  47. netmod:register_error_code("DISCONNECT_FAILED", luci.i18n.translate("Disconnection attempt failed"))
  48. netmod:register_error_code("FINALIZE_FAILED", luci.i18n.translate("Finalizing failed"))
  49. netmod:register_error_code("GETINFO_FAILED", luci.i18n.translate("Modem information query failed"))
  50. netmod:register_error_code("INITIALIZE_FAILED", luci.i18n.translate("Initialization failure"))
  51. netmod:register_error_code("SETMODE_FAILED", luci.i18n.translate("Setting operation mode failed"))
  52. netmod:register_error_code("UNSUPPORTED_MODEM", luci.i18n.translate("Unsupported modem"))