diff --git a/luci-app-hypermodem/Makefile b/luci-app-hypermodem/Makefile new file mode 100644 index 0000000..67ad65d --- /dev/null +++ b/luci-app-hypermodem/Makefile @@ -0,0 +1,23 @@ +# +# Copyright (C) 2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=Hyper Modem Server +LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \ + +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \ + +kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial \ + +kmod-usb-serial-option +kmod-usb-wdm \ + +kmod-usb2 +kmod-usb3 \ + +kmod-usb-net-cdc-mbim \ + +kmod-qmi_wwan_q \ + +kmod-pcie_mhi +pciutils \ + +quectel-CM-5G \ + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-hypermodem/README.md b/luci-app-hypermodem/README.md new file mode 100644 index 0000000..72dd3b0 --- /dev/null +++ b/luci-app-hypermodem/README.md @@ -0,0 +1,3 @@ +# luci-app-hypermodem + +支持USB和PCIE两种连接模式的5G模块进行IPv6拨号,然后下发给内网设备 \ No newline at end of file diff --git a/luci-app-hypermodem/luasrc/controller/hypermodem.lua b/luci-app-hypermodem/luasrc/controller/hypermodem.lua new file mode 100644 index 0000000..d46e21b --- /dev/null +++ b/luci-app-hypermodem/luasrc/controller/hypermodem.lua @@ -0,0 +1,9 @@ +module("luci.controller.hypermodem", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/hypermodem") then + return + end + + entry({"admin", "network", "hypermodem"}, cbi("hypermodem"), _("Hyper Modem Server"), 80).dependent = false +end diff --git a/luci-app-hypermodem/luasrc/model/cbi/hypermodem.lua b/luci-app-hypermodem/luasrc/model/cbi/hypermodem.lua new file mode 100644 index 0000000..9f94f78 --- /dev/null +++ b/luci-app-hypermodem/luasrc/model/cbi/hypermodem.lua @@ -0,0 +1,48 @@ +-- Copyright 2016 David Thornley +-- Licensed to the public under the Apache License 2.0. + +mp = Map("hypermodem") +mp.title = translate("Hyper Modem Server") +mp.description = translate("Modem Server For OpenWrt") + +s = mp:section(TypedSection, "service", "Base Setting") +s.anonymous = true + +enabled = s:option(Flag, "enabled", translate("Enable")) +enabled.default = 0 +enabled.rmempty = false + +ipv6 = s:option(Flag, "ipv6", translate("Enable IPv6")) +ipv6.default = 1 +ipv6.rmempty = false + +device = s:option(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 = s:option(Value, "apn", translate("APN")) +apn.rmempty = true + +username = s:option(Value, "username", translate("PAP/CHAP username")) +username.rmempty = true + +password = s:option(Value, "password", translate("PAP/CHAP password")) +password.rmempty = true + +auth = s:option(Value, "auth", translate("Authentication Type")) +auth.rmempty = true +auth:value("", translate("-- Please choose --")) +auth:value("both", "PAP/CHAP (both)") +auth:value("pap", "PAP") +auth:value("chap", "CHAP") +auth:value("none", "NONE") + +return mp diff --git a/luci-app-hypermodem/po/zh-cn/hypermodem.po b/luci-app-hypermodem/po/zh-cn/hypermodem.po new file mode 100644 index 0000000..2434a41 --- /dev/null +++ b/luci-app-hypermodem/po/zh-cn/hypermodem.po @@ -0,0 +1,24 @@ +msgid "" +msgstr "" +"Project-Id-Version: \n" +"POT-Creation-Date: \n" +"PO-Revision-Date: \n" +"Last-Translator: momokind \n" +"Language-Team: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Language: zh_CN\n" +"X-Generator: Poedit 2.3.1\n" + +msgid "Base Setting" +msgstr "基本设置" + +msgid "Hyper Modem Server" +msgstr "超级移动网络拨号服务" + +msgid "Modem Server For OpenWrt" +msgstr "OpenWrt移动网络拨号服务" + +msgid "Enable IPv6" +msgstr "启用IPv6协商" diff --git a/luci-app-hypermodem/root/etc/config/hypermodem b/luci-app-hypermodem/root/etc/config/hypermodem new file mode 100644 index 0000000..0e9654e --- /dev/null +++ b/luci-app-hypermodem/root/etc/config/hypermodem @@ -0,0 +1,5 @@ +config service + option device '/dev/cdc-wdm0' + option ipv6 '1' + option enabled '0' + diff --git a/luci-app-hypermodem/root/etc/init.d/hypermodem b/luci-app-hypermodem/root/etc/init.d/hypermodem new file mode 100644 index 0000000..539e3b0 --- /dev/null +++ b/luci-app-hypermodem/root/etc/init.d/hypermodem @@ -0,0 +1,122 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2014 OpenWrt.org + +START=94 +STOP=13 +USE_PROCD=1 + +pre_set() +{ + [ "$(uci get network.wan.ifname)" != "$1" ] && { + uci set network.wwan='interface' + uci set network.wwan.ifname="$1" + uci set network.wwan.proto='dhcp' + if [ "$ipv6" = 1 ]; then + uci set network.wwan6='interface' + uci set network.wwan6.ifname="$1" + uci set network.wwan6.proto='dhcpv6' + uci set network.wwan6.extendprefix='1' + fi + uci commit network + + num=`uci show firewall |grep "name='wan'" |wc -l` + wwan_num=`uci get firewall.@zone[$num].network |grep -w wwan |wc -l` + wwan6_num=`uci get firewall.@zone[$num].network |grep -w wwan6 |wc -l` + if [ "$wwan_num" = "0" ]; then + uci add_list firewall.@zone[$num].network='wan' + fi + if [ "$ipv6" = 1 ]; then + if [ "$wwan6_num" = "0" ]; then + uci add_list firewall.@zone[$num].network='wwan6' + fi + fi + uci commit firewall + + ifup wwan + if [ "$ipv6" = 1 ]; then + ifup wwan6 + fi + } + + [ "$(uci get network.wan6.ifname)" == "$1" ] && { + uci set network.wan6.extendprefix='1' + uci commit network + } +} + +run_dial() +{ + local enabled + config_get_bool enabled $1 enabled + + if [ "$enabled" = "1" ]; then + local apn + local user + local password + local auth + local ipv6 + local device + + config_get apn $1 apn + config_get user $1 user + config_get password $1 password + config_get auth $1 auth + config_get ipv6 $1 ipv6 + config_get device $1 device + + devname="$(basename "$device")" + devicepath="$(find /sys/class/ -name $devname)" + devpath="$(readlink -f $devicepath/device/)" + ifname="$( ls "$devpath"/net )" + + procd_open_instance + procd_set_param command quectel-CM + if [ "$ipv6" = 1 ]; then + procd_append_param command -4 -6 + fi + if [ "$apn" != "" ];then + procd_append_param command -s $apn + fi + if [ "$user" != "" ]; then + procd_append_param command $user + fi + if [ "$password" != "" ]; then + procd_append_param command $password + fi + if [ "$auth" != "" ]; then + procd_append_param command $auth + fi + if [ "$device" != "" ]; then + procd_append_param command -i $ifname + fi + procd_set_param respawn + procd_close_instance + + if [ -d /sys/class/net/rmnet_mhi0 ]; then + pre_set rmnet_mhi0.1 + elif [ -d /sys/class/net/wwan0_1 ]; then + pre_set wwan0_1 + elif [ -d /sys/class/net/wwan0.1 ]; then + pre_set wwan0.1 + elif [ -d /sys/class/net/wwan0 ]; then + pre_set wwan0 + fi + fi + + sleep 15 +} + +service_triggers() +{ + procd_add_reload_trigger "hypermodem" +} + +start_service() { + config_load hypermodem + config_foreach run_dial service +} + +stop_service() +{ + killall quectel-CM >/dev/null 2>&1 +} diff --git a/luci-app-hypermodem/root/etc/uci-defaults/luci-hypermodem b/luci-app-hypermodem/root/etc/uci-defaults/luci-hypermodem new file mode 100644 index 0000000..531e07b --- /dev/null +++ b/luci-app-hypermodem/root/etc/uci-defaults/luci-hypermodem @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@hypermodem[-1] + add ucitrack hypermodem + set ucitrack.@hypermodem[-1].init=hypermodem + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/luci-app-usbmodem/Makefile b/luci-app-usbmodem/Makefile index 2214f0c..5411c43 100644 --- a/luci-app-usbmodem/Makefile +++ b/luci-app-usbmodem/Makefile @@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk LUCI_TITLE:=Modem Server -LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \ +LUCI_DEPENDS:=+luci-compat +kmod-usb-net +kmod-usb-net-cdc-ether +kmod-usb-acm \ +kmod-usb-net-qmi-wwan +kmod-usb-net-rndis +kmod-usb-serial-qualcomm \ +kmod-usb-net-sierrawireless +kmod-usb-ohci +kmod-usb-serial \ +kmod-usb-serial-option +kmod-usb-wdm \