From 46f2c7e07f89def48699d8bda1e7818d5301d4fd Mon Sep 17 00:00:00 2001 From: Beginner <70857188+Beginner-Go@users.noreply.github.com> Date: Thu, 19 May 2022 21:49:13 +0800 Subject: [PATCH] luci-proto-mbim: move to luci feeds --- package/wwan/app/luci-proto-mbim/Makefile | 53 --------- .../model/cbi/admin_network/proto_mbim.lua | 45 -------- .../lib/lua/luci/model/network/proto_mbim.lua | 55 --------- .../luci-static/resources/protocol/mbim.js | 107 ------------------ 4 files changed, 260 deletions(-) delete mode 100644 package/wwan/app/luci-proto-mbim/Makefile delete mode 100644 package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua delete mode 100644 package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua delete mode 100644 package/wwan/app/luci-proto-mbim/files/www/luci-static/resources/protocol/mbim.js diff --git a/package/wwan/app/luci-proto-mbim/Makefile b/package/wwan/app/luci-proto-mbim/Makefile deleted file mode 100644 index 14b4e4fbf..000000000 --- a/package/wwan/app/luci-proto-mbim/Makefile +++ /dev/null @@ -1,53 +0,0 @@ -# -# Copyright (C) 2007-2013 OpenWrt.org -# Copyright (C) 2010 Vertical Communications -# -# This is free software, licensed under the GNU General Public License v2. -# See /LICENSE for more information. -# - -include $(TOPDIR)/rules.mk - -PKG_NAME:=luci-proto-mbim -PKG_VERSION:=1.0 -PKG_RELEASE:=1 -PKG_MAINTAINER:=Dairyman -PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)-$(PKG_RELEASE) - -include $(INCLUDE_DIR)/package.mk - -define Package/luci-proto-mbim/Default - VERSION:=$(PKG_VERSION)-$(PKG_RELEASE) - URL:=http://openwrt.org/ - MAINTAINER:=Dairyman -endef - -define Package/luci-proto-mbim -$(call Package/luci-proto-mbim/Default) - SECTION:=net - CATEGORY:=ROOter - SUBMENU:=Protocols - TITLE:=Support for mbim -endef - -define Package/luci-proto-mbim/description - This package contains LuCI support for mbim -endef - -define Build/Prepare - mkdir -p $(PKG_BUILD_DIR) -endef - -define Build/Configure -endef - -define Build/Compile/Default -endef - -Build/Compile = $(Build/Compile/Default) - -define Package/luci-proto-mbim/install - $(CP) ./files/* $(1)/ -endef - -$(eval $(call BuildPackage,luci-proto-mbim)) diff --git a/package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua b/package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua deleted file mode 100644 index 380f47112..000000000 --- a/package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/cbi/admin_network/proto_mbim.lua +++ /dev/null @@ -1,45 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -local map, section, net = ... - -local device, apn, pincode, username, password -local auth, ipv6 - - -device = section:taboption("general", Value, "device", translate("Modem device")) -device.rmempty = false - -local device_suggestions = nixio.fs.glob("/dev/cdc-wdm*") - -if device_suggestions then - local node - for node in device_suggestions do - device:value(node) - end -end - - -apn = section:taboption("general", Value, "apn", translate("APN")) - - -pincode = section:taboption("general", Value, "pincode", translate("PIN")) - - -username = section:taboption("general", Value, "username", translate("PAP/CHAP username")) - - -password = section:taboption("general", Value, "password", translate("PAP/CHAP password")) -password.password = true - -auth = section:taboption("general", Value, "auth", translate("Authentication Type")) -auth:value("", translate("-- Please choose --")) -auth:value("both", "PAP/CHAP (both)") -auth:value("pap", "PAP") -auth:value("chap", "CHAP") -auth:value("none", "NONE") - -if luci.model.network:has_ipv6() then - ipv6 = section:taboption("advanced", Flag, "ipv6", translate("Enable IPv6 negotiation")) - ipv6.default = ipv6.disabled -end \ No newline at end of file diff --git a/package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua b/package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua deleted file mode 100644 index 3007480fc..000000000 --- a/package/wwan/app/luci-proto-mbim/files/usr/lib/lua/luci/model/network/proto_mbim.lua +++ /dev/null @@ -1,55 +0,0 @@ --- Copyright 2016 David Thornley --- Licensed to the public under the Apache License 2.0. - -local netmod = luci.model.network -local interface = luci.model.network.interface -local proto = netmod:register_protocol("mbim") - -function proto.get_i18n(self) - return luci.i18n.translate("MBIM Cellular") -end - -function proto.ifname(self) - local base = netmod._M.protocol - local ifname = base.ifname(self) -- call base class "protocol.ifname(self)" - - -- Note: ifname might be nil if the adapter could not be determined through ubus (default name to mbim-wan in this case) - if ifname == nil then - ifname = "mbim-" .. self.sid - end - return ifname -end - -function proto.get_interface(self) - return interface(self:ifname(), self) -end - -function proto.opkg_package(self) - return "rmbim" -end - -function proto.is_installed(self) - return nixio.fs.access("/lib/netifd/proto/mbim.sh") -end - -function proto.is_floating(self) - return true -end - -function proto.is_virtual(self) - return true -end - -function proto.get_interfaces(self) - return nil -end - -function proto.contains_interface(self, ifc) - return (netmod:ifnameof(ifc) == self:ifname()) -end - -netmod:register_pattern_virtual("^mbim%-%w") - -netmod:register_error_code("CALL_FAILED", luci.i18n.translate("Call failed")) -netmod:register_error_code("NO_CID", luci.i18n.translate("Unable to obtain client ID")) -netmod:register_error_code("PLMN_FAILED", luci.i18n.translate("Setting PLMN failed")) diff --git a/package/wwan/app/luci-proto-mbim/files/www/luci-static/resources/protocol/mbim.js b/package/wwan/app/luci-proto-mbim/files/www/luci-static/resources/protocol/mbim.js deleted file mode 100644 index 337cdd364..000000000 --- a/package/wwan/app/luci-proto-mbim/files/www/luci-static/resources/protocol/mbim.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict'; -'require rpc'; -'require form'; -'require network'; - -var callFileList = rpc.declare({ - object: 'file', - method: 'list', - params: [ 'path' ], - expect: { entries: [] }, - filter: function(list, params) { - var rv = []; - for (var i = 0; i < list.length; i++) - if (list[i].name.match(/^cdc-wdm/)) - rv.push(params.path + list[i].name); - return rv.sort(); - } -}); - -network.registerPatternVirtual(/^mbim-.+$/); -network.registerErrorCode('CALL_FAILED', _('Call failed')); -network.registerErrorCode('NO_CID', _('Unable to obtain client ID')); -network.registerErrorCode('PLMN_FAILED', _('Setting PLMN failed')); - -return network.registerProtocol('mbim', { - getI18n: function() { - return _('MBIM Cellular'); - }, - - getIfname: function() { - return this._ubus('l3_device') || 'mbim-%s'.format(this.sid); - }, - - getOpkgPackage: function() { - return 'rmbim'; - }, - - isFloating: function() { - return true; - }, - - isVirtual: function() { - return true; - }, - - getDevices: function() { - return null; - }, - - containsDevice: function(ifname) { - return (network.getIfnameOf(ifname) == this.getIfname()); - }, - - renderFormOptions: function(s) { - var dev = this.getL3Device() || this.getDevice(), o; - - o = s.taboption('general', form.Value, 'device', _('Modem device')); - o.rmempty = false; - o.load = function(section_id) { - return callFileList('/dev/').then(L.bind(function(devices) { - for (var i = 0; i < devices.length; i++) - this.value(devices[i]); - return form.Value.prototype.load.apply(this, [section_id]); - }, this)); - }; - - s.taboption('general', form.Value, 'apn', _('APN')); - s.taboption('general', form.Value, 'pincode', _('PIN')); - - o = s.taboption('general', form.ListValue, 'auth', _('Authentication Type')); - o.value('both', 'PAP/CHAP'); - o.value('pap', 'PAP'); - o.value('chap', 'CHAP'); - o.value('none', 'NONE'); - o.default = 'none'; - - o = s.taboption('general', form.Value, 'username', _('PAP/CHAP username')); - o.depends('auth', 'pap'); - o.depends('auth', 'chap'); - o.depends('auth', 'both'); - - o = s.taboption('general', form.Value, 'password', _('PAP/CHAP password')); - o.depends('auth', 'pap'); - o.depends('auth', 'chap'); - o.depends('auth', 'both'); - o.password = true; - - if (L.hasSystemFeature('ipv6')) { - o = s.taboption('advanced', form.Flag, 'ipv6', _('Enable IPv6 negotiation')); - o.default = o.disabled; - } - - o = s.taboption('advanced', form.Value, 'delay', _('Modem init timeout'), _('Maximum amount of seconds to wait for the modem to become ready')); - o.placeholder = '10'; - o.datatype = 'min(1)'; - - o = s.taboption('advanced', form.Value, 'mtu', _('Override MTU')); - o.placeholder = dev ? (dev.getMTU() || '1500') : '1500'; - o.datatype = 'max(9200)'; - - o = s.taboption('general', form.ListValue, 'pdptype', _('PDP Type')); - o.value('ipv4v6', 'IPv4/IPv6'); - o.value('ipv4', 'IPv4'); - o.value('ipv6', 'IPv6'); - o.default = 'ipv4v6'; - } -});