@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=wwan
PKG_VERSION:=2014-07-17
-PKG_RELEASE=1
+PKG_RELEASE=2
PKG_LICENSE:=GPL-2.0
PKG_LICENSE_FILES:=
@@ -24,6 +24,7 @@ endef
define Package/wwan/install
$(INSTALL_DIR) $(1)/lib/netifd/proto/
$(CP) ./files/wwan.sh $(1)/lib/netifd/proto/
+ $(CP) ./files/hilink.sh $(1)/lib/netifd/proto/
$(INSTALL_DIR) $(1)/etc/hotplug.d/usb
$(INSTALL_BIN) ./files/wwan.usb $(1)/etc/hotplug.d/usb/00_wwan.sh
$(INSTALL_DIR) $(1)/etc/hotplug.d/usbmisc
new file mode 100644
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+[ -n "$INCLUDE_ONLY" ] || {
+ . /lib/functions.sh
+ . ../netifd-proto.sh
+ init_proto "$@"
+}
+
+proto_hilink_init_config() {
+ available=1
+ no_device=1
+ proto_config_add_string metric
+}
+
+proto_hilink_setup() {
+ local interface="$1"
+ local ifname="$ctl_device"
+ local metric
+
+ json_get_vars metric
+
+ [ -n "$ifname" ] || {
+ proto_notify_error "$interface" NO_IFNAME
+ proto_set_available "$interface" 0
+ return 1
+ }
+
+ logger -p daemon.info -t "hilink[$$]" "Starting DHCP on $ifname"
+ proto_init_update "$ifname" 1
+ proto_send_update "$interface"
+
+ json_init
+ json_add_string name "${interface}_4"
+ json_add_string ifname "@$interface"
+ json_add_string proto "dhcp"
+ json_add_int metric $metric
+ json_close_object
+ ubus call network add_dynamic "$(json_dump)"
+
+ return 0
+}
+
+proto_hilink_teardown() {
+ local interface="$1"
+
+ proto_init_update "*" 0
+ proto_send_update "$interface"
+}
+
+[ -n "$INCLUDE_ONLY" ] || {
+ add_protocol hilink
+}
@@ -14,12 +14,14 @@ proto_qmi_setup() { echo "wwan[$$] qmi proto is missing"; }
proto_ncm_setup() { echo "wwan[$$] ncm proto is missing"; }
proto_3g_setup() { echo "wwan[$$] 3g proto is missing"; }
proto_directip_setup() { echo "wwan[$$] directip proto is missing"; }
+proto_hilink_setup() { echo "wwan[$$] hilink proto is missing"; }
[ -f ./mbim.sh ] && . ./mbim.sh
[ -f ./ncm.sh ] && . ./ncm.sh
[ -f ./qmi.sh ] && . ./qmi.sh
[ -f ./3g.sh ] && { . ./ppp.sh; . ./3g.sh; }
[ -f ./directip.sh ] && . ./directip.sh
+[ -f ./hilink.sh ] && . ./hilink.sh
proto_wwan_init_config() {
available=1
@@ -66,7 +68,7 @@ proto_wwan_setup() {
}
}
- [ -z "$ctl_device" ] && for net in $(ls /sys/class/net/ | grep wwan); do
+ [ -z "$ctl_device" ] && for net in $(ls /sys/class/net/ | grep -E "wwan|eth"); do
[ -z "$ctl_device" ] || continue
driver=$(grep DRIVER /sys/class/net/$net/device/uevent | cut -d= -f2)
case "$driver" in
@@ -76,6 +78,9 @@ proto_wwan_setup() {
sierra_net|*cdc_ncm)
ctl_device=/dev/$(cd /sys/class/net/$net/; find ../../../ -name ttyUSB* |xargs basename | head -n1)
;;
+ cdc_ether)
+ ctl_device=$net
+ ;;
*) continue;;
esac
echo "wwan[$$]" "Using proto:$proto device:$ctl_device iface:$net desc:$desc"
@@ -98,6 +103,7 @@ proto_wwan_setup() {
sierra_net) proto_directip_setup $@ ;;
comgt) proto_3g_setup $@ ;;
*cdc_ncm) proto_ncm_setup $@ ;;
+ cdc_ether) proto_hilink_setup $@ ;;
esac
}
@@ -113,6 +119,7 @@ proto_wwan_teardown() {
sierra_net) proto_mbim_teardown $@ ;;
comgt) proto_3g_teardown $@ ;;
*cdc_ncm) proto_ncm_teardown $@ ;;
+ cdc_ether) proto_hilink_teardown $@ ;;
esac
}
Huawei HiLink ("h" model names) modems just provide a CDC Ethernet interface where we have to run DHCP to get an IP address (usually in the 192.168.8.0 range). While this may be bad design in general it's sometimes necessary to support these modems. This adds autodetection and handling of these to wwan. Tested with Huawei E3030h-1. Signed-off-by: Bruno Randolf <br1@einfach.org> --- package/network/utils/wwan/Makefile | 3 +- package/network/utils/wwan/files/hilink.sh | 52 ++++++++++++++++++++++++++++++ package/network/utils/wwan/files/wwan.sh | 9 +++++- 3 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 package/network/utils/wwan/files/hilink.sh