proto_ncm.lua 1.4 KB

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