diff --git a/iproute2/Makefile b/iproute2/Makefile new file mode 100755 index 000000000..7f4556e7d --- /dev/null +++ b/iproute2/Makefile @@ -0,0 +1,283 @@ +# +# Copyright (C) 2006-2015 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=iproute2 +PKG_VERSION:=6.5.0 +PKG_RELEASE:=1 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz +PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2 +PKG_HASH:=a70179085fa1b96d3c33b040c809b75e2b57563adc505a4ad05e2609df373463 +PKG_BUILD_PARALLEL:=1 +PKG_BUILD_DEPENDS:=iptables +PKG_LICENSE:=GPL-2.0 +PKG_CPE_ID:=cpe:/a:iproute2_project:iproute2 + +PKG_BUILD_FLAGS:=gc-sections lto + +include $(INCLUDE_DIR)/kernel.mk +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk + +define Package/iproute2/Default + SECTION:=net + CATEGORY:=Network + URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2 + SUBMENU:=Routing and Redirection + MAINTAINER:=Russell Senior +endef + +define Package/ip-tiny +$(call Package/iproute2/Default) + TITLE:=Routing control utility (minimal) + VARIANT:=iptiny + DEFAULT_VARIANT:=1 + PROVIDES:=ip + ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny + DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +endef + +define Package/ip-full +$(call Package/iproute2/Default) + TITLE:=Routing control utility (full) + VARIANT:=ipfull + PROVIDES:=ip + ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full + DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl +endef + +define Package/tc-tiny +$(call Package/iproute2/Default) + TITLE:=Traffic control utility (minimal) + VARIANT:=tctiny + DEFAULT_VARIANT:=1 + PROVIDES:=tc + ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny + DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +endef + +define Package/tc-bpf +$(call Package/iproute2/Default) + TITLE:=Traffic control utility (bpf) + VARIANT:=tcbpf + PROVIDES:=tc + ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-bpf + DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +endef + +define Package/tc-full +$(call Package/iproute2/Default) + TITLE:=Traffic control utility (full) + VARIANT:=tcfull + PROVIDES:=tc + ALTERNATIVES:=400:/sbin/tc:/usr/libexec/tc-full + DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +libxtables +tc-mod-iptables +endef + +define Package/tc-mod-iptables +$(call Package/iproute2/Default) + TITLE:=Traffic control module - iptables action + VARIANT:=tcfull + DEPENDS:=+libxtables +libbpf +endef + +define Package/genl +$(call Package/iproute2/Default) + TITLE:=General netlink utility frontend + DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +endef + +define Package/ip-bridge +$(call Package/iproute2/Default) + TITLE:=Bridge configuration utility from iproute2 + DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +endef + +define Package/ss +$(call Package/iproute2/Default) + TITLE:=Socket statistics utility + DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +kmod-netlink-diag +endef + +define Package/nstat +$(call Package/iproute2/Default) + TITLE:=Network statistics utility + DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +endef + +define Package/devlink +$(call Package/iproute2/Default) + TITLE:=Network devlink utility + DEPENDS:=+libmnl +endef + +define Package/rdma +$(call Package/iproute2/Default) + TITLE:=Network rdma utility + DEPENDS:=+libmnl +endef + +ifeq ($(BUILD_VARIANT),iptiny) + IP_CONFIG_TINY:=y + LIBBPF_FORCE:=off +endif + +ifeq ($(BUILD_VARIANT),ipfull) + HAVE_ELF:=y + LIBBPF_FORCE:=on +endif + +ifeq ($(BUILD_VARIANT),tctiny) + LIBBPF_FORCE:=off +endif + +ifeq ($(BUILD_VARIANT),tcbpf) + HAVE_ELF:=y + LIBBPF_FORCE:=on + SHARED_LIBS:=y +endif + +ifeq ($(BUILD_VARIANT),tcfull) + #enable iptables/xtables requirement only if tciptables variant is selected + TC_CONFIG_XT:=y + TC_CONFIG_XT_OLD:=y + TC_CONFIG_XT_OLD_H:=y + TC_CONFIG_IPSET:=y + HAVE_ELF:=y + LIBBPF_FORCE:=on + SHARED_LIBS:=y +else + #disable iptables requirement by default + TC_CONFIG_XT:=n + TC_CONFIG_XT_OLD:=n + TC_CONFIG_XT_OLD_H:=n + TC_CONFIG_IPSET:=n +endif + +ifdef CONFIG_PACKAGE_devlink + HAVE_MNL:=y +endif + +ifdef CONFIG_PACKAGE_rdma + HAVE_MNL:=y +endif + +define Build/Configure + echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \ + > $(PKG_BUILD_DIR)/include/SNAPSHOT.h +endef + +TARGET_LDFLAGS += -Wl,--as-needed +TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny + +MAKE_FLAGS += \ + KERNEL_INCLUDE="$(LINUX_DIR)/include/uapi" \ + SHARED_LIBS=$(SHARED_LIBS) \ + IP_CONFIG_TINY=$(IP_CONFIG_TINY) \ + BUILD_VARIANT=$(BUILD_VARIANT) \ + LIBBPF_FORCE=$(LIBBPF_FORCE) \ + HAVE_ELF=$(HAVE_ELF) \ + HAVE_MNL=$(HAVE_MNL) \ + HAVE_CAP=$(HAVE_CAP) \ + HAVE_TIRPC=n \ + IPT_LIB_DIR=/usr/lib/iptables \ + XT_LIB_DIR=/usr/lib/iptables \ + TC_CONFIG_XT=$(TC_CONFIG_XT) \ + TC_CONFIG_XT_OLD=$(TC_CONFIG_XT_OLD) \ + TC_CONFIG_XT_OLD_H=$(TC_CONFIG_XT_OLD_H) \ + TC_CONFIG_IPSET=$(TC_CONFIG_IPSET) \ + FPIC="$(FPIC)" \ + $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') + +define Build/Compile + +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/iproute2 + $(CP) $(PKG_BUILD_DIR)/include/bpf_elf.h $(1)/usr/include/iproute2 + $(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink}.h $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/ +endef + +define Package/ip-tiny/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-tiny +endef + +define Package/ip-full/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full +endef + +define Package/tc-tiny/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny +endef + +define Package/tc-bpf/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-bpf +endef + +define Package/tc-full/install + $(INSTALL_DIR) $(1)/usr/libexec + $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full +endef + +define Package/tc-mod-iptables/install + $(INSTALL_DIR) $(1)/usr/lib/tc + $(CP) $(PKG_BUILD_DIR)/tc/m_xt.so $(1)/usr/lib/tc +endef + +define Package/genl/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/ +endef + +define Package/ip-bridge/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/ +endef + +define Package/ss/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/ +endef + +define Package/nstat/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/ +endef + +define Package/devlink/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/ +endef + +define Package/rdma/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/ +endef + +$(eval $(call BuildPackage,ip-tiny)) +$(eval $(call BuildPackage,ip-full)) +# build tc-mod-iptables before its dependents, to avoid +# spurious rebuilds when building multiple variants. +$(eval $(call BuildPackage,tc-mod-iptables)) +$(eval $(call BuildPackage,tc-tiny)) +$(eval $(call BuildPackage,tc-bpf)) +$(eval $(call BuildPackage,tc-full)) +$(eval $(call BuildPackage,genl)) +$(eval $(call BuildPackage,ip-bridge)) +$(eval $(call BuildPackage,ss)) +$(eval $(call BuildPackage,nstat)) +$(eval $(call BuildPackage,devlink)) +$(eval $(call BuildPackage,rdma)) diff --git a/libmbim/Makefile b/libmbim/Makefile new file mode 100755 index 000000000..85024008e --- /dev/null +++ b/libmbim/Makefile @@ -0,0 +1,95 @@ +# +# Copyright (C) 2016 Velocloud Inc. +# Copyright (C) 2016 Aleksander Morgado +# +# This is free software, licensed under the GNU General Public License v2. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libmbim +PKG_SOURCE_VERSION:=1.30.0 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/libmbim.git +PKG_MIRROR_HASH:=8fc4e2d78d6a1003bf89303d3ce779283b176d74e84a241ba8efb0d468605268 + +PKG_BUILD_FLAGS:=gc-sections + +PKG_MAINTAINER:=Nicholas Smith + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include $(INCLUDE_DIR)/meson.mk + +TARGET_CFLAGS += -fno-merge-all-constants -fmerge-constants + +MESON_ARGS += \ + -Dintrospection=false \ + -Dman=false \ + -Dbash_completion=false \ + -Db_lto=true + +define Package/libmbim + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:=+glib2 + TITLE:=Helper library and utils to talk to MBIM enabled modems + URL:=https://www.freedesktop.org/wiki/Software/libmbim + LICENSE:=LGPL-2.0-or-later + LICENSE_FILES:=COPYING.LIB +endef + +define Package/libmbim/description + Helper library to talk to MBIM enabled modems. + Add mbim-utils for extra utilities. +endef + +define Package/mbim-utils + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libmbim + TITLE:=Utilities to talk to MBIM enabled modems + URL:=https://www.freedesktop.org/wiki/Software/libmbim + LICENSE:=GPL-2.0-or-later + LICENSE_FILES:=COPYING +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libmbim-glib \ + $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libmbim*.so* \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mbim-glib.pc \ + $(1)/usr/lib/pkgconfig +endef + +define Package/libmbim/install + $(INSTALL_DIR) \ + $(1)/usr/lib \ + $(1)/usr/libexec + + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libmbim*.so.* \ + $(1)/usr/lib/ + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/libexec/mbim-proxy $(1)/usr/libexec/ +endef + +define Package/mbim-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mbimcli $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mbim-network $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,libmbim)) +$(eval $(call BuildPackage,mbim-utils)) diff --git a/libqmi/Makefile b/libqmi/Makefile new file mode 100755 index 000000000..5652332fe --- /dev/null +++ b/libqmi/Makefile @@ -0,0 +1,112 @@ +# +# Copyright (C) 2016 Velocloud Inc. +# Copyright (C) 2016 Aleksander Morgado +# +# This is free software, licensed under the GNU General Public License v2. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=libqmi +PKG_SOURCE_VERSION:=1.34.0 +PKG_RELEASE:=1 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/libqmi.git +PKG_MIRROR_HASH:=af3dc760d0c40ef8af1f8b424435daa12bff698ed45b1cc9a9e38ea62ed047f0 + +PKG_BUILD_FLAGS:=gc-sections + +PKG_MAINTAINER:=Nicholas Smith + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include $(INCLUDE_DIR)/meson.mk + +TARGET_CFLAGS += -fno-merge-all-constants -fmerge-constants + +define Package/libqmi/config + source "$(SOURCE)/Config.in" +endef + +define Package/libqmi + SECTION:=libs + CATEGORY:=Libraries + DEPENDS:= \ + +glib2 \ + +LIBQMI_WITH_MBIM_QMUX:libmbim \ + +LIBQMI_WITH_QRTR_GLIB:libqrtr-glib + TITLE:=Helper library to talk to QMI enabled modems + URL:=https://www.freedesktop.org/wiki/Software/libqmi + LICENSE:=LGPL-2.0-or-later + LICENSE_FILES:=COPYING.LIB +endef + +define Package/libqmi/description + Helper library talk to QMI enabled modems. + Add qmi-utils for extra utilities. +endef + +define Package/qmi-utils + SECTION:=utils + CATEGORY:=Utilities + DEPENDS:=+libqmi + TITLE:=Utilities to talk to QMI enabled modems + URL:=https://www.freedesktop.org/wiki/Software/libqmi + LICENSE:=GPL-2.0-or-later + LICENSE_FILES:=COPYING +endef + +define Package/libqmi-utils/description + Utils to talk to QMI enabled modems +endef + +MESON_ARGS += \ + -Dudev=false \ + -Dintrospection=false \ + -Dman=false \ + -Dbash_completion=false \ + -Db_lto=true \ + -Dmbim_qmux=$(if $(CONFIG_LIBQMI_WITH_MBIM_QMUX),true,false) \ + -Dqrtr=$(if $(CONFIG_LIBQMI_WITH_QRTR_GLIB),true,false) \ + -Dcollection=$(if $(CONFIG_LIBQMI_COLLECTION_MINIMAL),minimal\ + ,$(if $(CONFIG_LIBQMI_COLLECTION_BASIC),basic,full)) + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) \ + $(PKG_INSTALL_DIR)/usr/include/libqmi-glib \ + $(1)/usr/include/ + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libqmi*.so* \ + $(1)/usr/lib/ + + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/qmi-glib.pc \ + $(1)/usr/lib/pkgconfig +endef + +define Package/libqmi/install + $(INSTALL_DIR) \ + $(1)/usr/lib \ + $(1)/usr/libexec + + $(CP) \ + $(PKG_INSTALL_DIR)/usr/lib/libqmi*.so.* \ + $(1)/usr/lib/ + + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/libexec/qmi-proxy $(1)/usr/libexec/ +endef + +define Package/qmi-utils/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qmicli $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qmi-network $(1)/usr/bin/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/qmi-firmware-update $(1)/usr/bin/ +endef + +$(eval $(call BuildPackage,libqmi)) +$(eval $(call BuildPackage,qmi-utils)) diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua index 222036652..018b3365f 100755 --- a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua +++ b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua @@ -960,7 +960,7 @@ function wizard_add() ucic:set("shadowsocks-libev","sss1","method","chacha20-ietf-poly1305") ucic:set("glorytun","vpn","chacha20","1") ucic:set("glorytun-udp","vpn","chacha","1") - ucic:set("openvpn","omr","cipher","AES-256-GCM") + ucic:set("openvpn","omr","cipher","chacha20-poly1305") ucic:set("mlvpn","general","cleartext_data","0") ucic:set("v2ray","omrout","s_vmess_user_security","chacha20-poly1305") ucic:set("v2ray","omrout","s_vless_user_security","chacha20-poly1305") diff --git a/modemmanager/Makefile b/modemmanager/Makefile new file mode 100755 index 000000000..d30b1a2e9 --- /dev/null +++ b/modemmanager/Makefile @@ -0,0 +1,138 @@ +# +# Copyright (C) 2016 Velocloud Inc. +# Copyright (C) 2016 Aleksander Morgado +# +# This is free software, licensed under the GNU General Public License v2. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=modemmanager +PKG_SOURCE_VERSION:=1.22.0 +PKG_RELEASE:=5 + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=https://gitlab.freedesktop.org/mobile-broadband/ModemManager.git +PKG_MIRROR_HASH:=98daa1a15075c88afb3ed0de20dc83fe51d2ba3c66318ce3f731da4616a2e192 + +PKG_MAINTAINER:=Nicholas Smith +PKG_LICENSE:=GPL-2.0-or-later +PKG_LICENSE_FILES:=COPYING + +PKG_BUILD_DEPENDS:=glib2/host libxslt/host +PKG_BUILD_FLAGS:=gc-sections + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/nls.mk +include $(INCLUDE_DIR)/meson.mk + +TARGET_CFLAGS += -fno-merge-all-constants -fmerge-constants + +define Package/modemmanager/config + source "$(SOURCE)/Config.in" +endef + +define Package/modemmanager + SECTION:=net + CATEGORY:=Network + TITLE:=Control utility for any kind of mobile broadband modem + URL:=https://www.freedesktop.org/wiki/Software/ModemManager + DEPENDS:= \ + $(INTL_DEPENDS) \ + +glib2 \ + +dbus \ + +ppp \ + +MODEMMANAGER_WITH_MBIM:libmbim \ + +MODEMMANAGER_WITH_QMI:libqmi \ + +MODEMMANAGER_WITH_QRTR:libqrtr-glib +endef + +define Package/modemmanager/description + ModemManager is a D-Bus-activated service which allows controlling mobile + broadband modems. Add kernel modules for your modems as needed. + Select Utilities/usb-modeswitch if needed. +endef + +MESON_ARGS += \ + -Dudev=false \ + -Dudevdir=/lib/udev \ + -Dtests=false \ + -Dsystemdsystemunitdir=no \ + -Dsystemd_suspend_resume=false \ + -Dsystemd_journal=false \ + -Dpolkit=no \ + -Dintrospection=false \ + -Dman=false \ + -Dbash_completion=false \ + -Db_lto=true \ + -Dmbim=$(if $(CONFIG_MODEMMANAGER_WITH_MBIM),true,false) \ + -Dqmi=$(if $(CONFIG_MODEMMANAGER_WITH_QMI),true,false) \ + -Dqrtr=$(if $(CONFIG_MODEMMANAGER_WITH_QRTR),true,false) \ + -Dat_command_via_dbus=$(if $(CONFIG_MODEMMANAGER_WITH_AT_COMMAND_VIA_DBUS),true,false) + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/ModemManager + $(CP) $(PKG_INSTALL_DIR)/usr/include/ModemManager/*.h $(1)/usr/include/ModemManager + $(INSTALL_DIR) $(1)/usr/include/libmm-glib + $(CP) $(PKG_INSTALL_DIR)/usr/include/libmm-glib/*.h $(1)/usr/include/libmm-glib + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmm-glib.so* $(1)/usr/lib + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/ModemManager.pc $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mm-glib.pc $(1)/usr/lib/pkgconfig +endef + +define Package/modemmanager/install + $(INSTALL_DIR) $(1)/lib/udev/rules.d + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/lib/udev/rules.d/*.rules $(1)/lib/udev/rules.d + + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/ModemManager $(1)/usr/sbin + $(INSTALL_BIN) ./files/usr/sbin/ModemManager-wrapper $(1)/usr/sbin + + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/mmcli $(1)/usr/bin + + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libmm-glib.so.* $(1)/usr/lib + + $(INSTALL_DIR) $(1)/usr/lib/ModemManager + $(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-shared-*.so* $(1)/usr/lib/ModemManager + $(CP) $(PKG_INSTALL_DIR)/usr/lib/ModemManager/libmm-plugin-*.so* $(1)/usr/lib/ModemManager + + $(INSTALL_DIR) $(1)/usr/lib/ModemManager/connection.d + $(INSTALL_BIN) ./files/10-report-down $(1)/usr/lib/ModemManager/connection.d + + $(INSTALL_DIR) $(1)/etc/dbus-1/system.d + $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/dbus-1/system.d/org.freedesktop.ModemManager1.conf $(1)/etc/dbus-1/system.d + + $(INSTALL_DIR) $(1)/usr/share/dbus-1/system-services + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/dbus-1/system-services/org.freedesktop.ModemManager1.service $(1)/usr/share/dbus-1/system-services + + $(INSTALL_DIR) $(1)/usr/share/ModemManager + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/*.conf $(1)/usr/share/ModemManager + $(INSTALL_DATA) ./files/modemmanager.common $(1)/usr/share/ModemManager + + $(INSTALL_DIR) $(1)/usr/share/ModemManager/fcc-unlock.available.d + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/ModemManager/fcc-unlock.available.d/* $(1)/usr/share/ModemManager/fcc-unlock.available.d + + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/modemmanager.init $(1)/etc/init.d/modemmanager + + $(INSTALL_DIR) $(1)/etc/hotplug.d/usb + $(INSTALL_DATA) ./files/25-modemmanager-usb $(1)/etc/hotplug.d/usb + + $(INSTALL_DIR) $(1)/etc/hotplug.d/net + $(INSTALL_DATA) ./files/25-modemmanager-net $(1)/etc/hotplug.d/net + + $(INSTALL_DIR) $(1)/etc/hotplug.d/tty + $(INSTALL_DATA) ./files/25-modemmanager-tty $(1)/etc/hotplug.d/tty + + $(INSTALL_DIR) $(1)/etc/hotplug.d/wwan + $(INSTALL_DATA) ./files/25-modemmanager-wwan $(1)/etc/hotplug.d/wwan + + $(INSTALL_DIR) $(1)/lib/netifd/proto + $(INSTALL_BIN) ./files/modemmanager.proto $(1)/lib/netifd/proto/modemmanager.sh +endef + +$(eval $(call BuildPackage,modemmanager)) diff --git a/modemmanager/files/modemmanager.common b/modemmanager/files/modemmanager.common new file mode 100755 index 000000000..2ba2036ce --- /dev/null +++ b/modemmanager/files/modemmanager.common @@ -0,0 +1,353 @@ +#!/bin/sh +# Copyright (C) 2016 Velocloud Inc +# Copyright (C) 2016 Aleksander Morgado + +################################################################################ + +. /lib/functions.sh +. /lib/netifd/netifd-proto.sh +INCLUDE_ONLY=1 . /lib/netifd/proto/modemmanager.sh + +################################################################################ +# Runtime state + +MODEMMANAGER_RUNDIR="/var/run/modemmanager" +MODEMMANAGER_PID_FILE="${MODEMMANAGER_RUNDIR}/modemmanager.pid" +MODEMMANAGER_CDCWDM_CACHE="${MODEMMANAGER_RUNDIR}/cdcwdm.cache" +MODEMMANAGER_SYSFS_CACHE="${MODEMMANAGER_RUNDIR}/sysfs.cache" +MODEMMANAGER_EVENTS_CACHE="${MODEMMANAGER_RUNDIR}/events.cache" + +################################################################################ +# Common logging + +mm_log() { + local level="$1"; shift + logger -p "daemon.${level}" -t "ModemManager[$$]" "hotplug: $*" +} + +################################################################################ +# Receives as input argument the full sysfs path of the device +# Returns the physical device sysfs path +# +# NOTE: this method only works when the device exists, i.e. it cannot be used +# on removal hotplug events + +mm_find_physdev_sysfs_path() { + local tmp_path="$1" + + while true; do + tmp_path=$(dirname "${tmp_path}") + + # avoid infinite loops iterating + [ -z "${tmp_path}" ] || [ "${tmp_path}" = "/" ] && return + + # For USB devices, the physical device will be that with a idVendor + # and idProduct pair of files + [ -f "${tmp_path}"/idVendor ] && [ -f "${tmp_path}"/idProduct ] && { + tmp_path=$(readlink -f "$tmp_path") + echo "${tmp_path}" + return + } + + # For PCI devices, the physical device will be that with a vendor + # and device pair of files + [ -f "${tmp_path}"/vendor ] && [ -f "${tmp_path}"/device ] && { + tmp_path=$(readlink -f "$tmp_path") + echo "${tmp_path}" + return + } + done +} + +################################################################################ + +# Returns the cdc-wdm name retrieved from sysfs +mm_track_cdcwdm() { + local wwan="$1" + local cdcwdm + + cdcwdm=$(ls "/sys/class/net/${wwan}/device/usbmisc/") + [ -n "${cdcwdm}" ] || return + + # We have to cache it for later, as we won't be able to get the + # associated cdc-wdm device on a remove event + echo "${wwan} ${cdcwdm}" >> "${MODEMMANAGER_CDCWDM_CACHE}" + + echo "${cdcwdm}" +} + +# Returns the cdc-wdm name retrieved from the cache +mm_untrack_cdcwdm() { + local wwan="$1" + local cdcwdm + + # Look for the cached associated cdc-wdm device + [ -f "${MODEMMANAGER_CDCWDM_CACHE}" ] || return + + cdcwdm=$(awk -v wwan="${wwan}" '!/^#/ && $0 ~ wwan { print $2 }' "${MODEMMANAGER_CDCWDM_CACHE}") + [ -n "${cdcwdm}" ] || return + + # Remove from cache + sed -i "/${wwan} ${cdcwdm}/d" "${MODEMMANAGER_CDCWDM_CACHE}" + + echo "${cdcwdm}" +} + +################################################################################ +# ModemManager needs some time from the ports being added until a modem object +# is exposed in DBus. With the logic here we do an explicit wait of N seconds +# for ModemManager to expose the new modem object, making sure that the wait is +# unique per device (i.e. per physical device sysfs path). + +# Gets the modem wait status as retrieved from the cache +mm_get_modem_wait_status() { + local sysfspath="$1" + + # If no sysfs cache file, we're done + [ -f "${MODEMMANAGER_SYSFS_CACHE}" ] || return + + # Get status of the sysfs path + awk -v sysfspath="${sysfspath}" '!/^#/ && $0 ~ sysfspath { print $2 }' "${MODEMMANAGER_SYSFS_CACHE}" +} + +# Clear the modem wait status from the cache, if any +mm_clear_modem_wait_status() { + local sysfspath="$1" + + local escaped_sysfspath + + [ -f "${MODEMMANAGER_SYSFS_CACHE}" ] && { + # escape '/', '\' and '&' for sed... + escaped_sysfspath=$(echo "$sysfspath" | sed -e 's/[\/&]/\\&/g') + sed -i "/${escaped_sysfspath}/d" "${MODEMMANAGER_SYSFS_CACHE}" + } +} + +# Sets the modem wait status in the cache +mm_set_modem_wait_status() { + local sysfspath="$1" + local status="$2" + + # Remove sysfs line before adding the new one with the new state + mm_clear_modem_wait_status "${sysfspath}" + + # Add the new status + echo "${sysfspath} ${status}" >> "${MODEMMANAGER_SYSFS_CACHE}" +} + +# Callback for config_foreach() +mm_get_modem_config_foreach_cb() { + local cfg="$1" + local sysfspath="$2" + + local dev + dev=$(uci_get network "${cfg}" device) + [ "${dev}" = "${sysfspath}" ] || return 0 + + echo "${cfg}" +} + +# Returns the name of the interface configured for this device +mm_get_modem_config() { + local sysfspath="$1" + + # Look for configuration for the given sysfs path + config_load network + config_foreach mm_get_modem_config_foreach_cb interface "${sysfspath}" +} + +# Wait for a modem in the specified sysfspath +mm_wait_for_modem() { + local cfg="$1" + local sysfspath="$2" + + # TODO: config max wait + local n=45 + local step=5 + + while [ $n -ge 0 ]; do + [ -d "${sysfspath}" ] || { + mm_log "error" "ignoring modem detection request: no device at ${sysfspath}" + proto_set_available "${cfg}" 0 + return 1 + } + + # Check if the modem exists at the given sysfs path + if ! mmcli -m "${sysfspath}" > /dev/null 2>&1 + then + mm_log "error" "modem not detected at sysfs path" + else + mm_log "info" "modem exported successfully at ${sysfspath}" + mm_log "info" "setting interface '${cfg}' as available" + proto_set_available "${cfg}" 1 + return 0 + fi + + sleep $step + n=$((n-step)) + done + + mm_log "error" "timed out waiting for the modem to get exported at ${sysfspath}" + proto_set_available "${cfg}" 0 + return 2 +} + +mm_report_modem_wait() { + local sysfspath=$1 + + local parent_sysfspath status + + parent_sysfspath=$(mm_find_physdev_sysfs_path "$sysfspath") + [ -n "${parent_sysfspath}" ] || { + mm_log "error" "parent device sysfspath not found" + return + } + + status=$(mm_get_modem_wait_status "${parent_sysfspath}") + case "${status}" in + "") + local cfg + + cfg=$(mm_get_modem_config "${parent_sysfspath}") + if [ -n "${cfg}" ]; then + mm_log "info" "interface '${cfg}' is set to configure device '${parent_sysfspath}'" + mm_log "info" "now waiting for modem at sysfs path ${parent_sysfspath}" + mm_set_modem_wait_status "${parent_sysfspath}" "processed" + # Launch subshell for the explicit wait + ( mm_wait_for_modem "${cfg}" "${parent_sysfspath}" ) > /dev/null 2>&1 & + else + mm_log "info" "no need to wait for modem at sysfs path ${parent_sysfspath}" + mm_set_modem_wait_status "${parent_sysfspath}" "ignored" + fi + ;; + "processed") + mm_log "info" "already waiting for modem at sysfs path ${parent_sysfspath}" + ;; + "ignored") + ;; + *) + mm_log "error" "unknown status read for device at sysfs path ${parent_sysfspath}" + ;; + esac +} + +################################################################################ +# Cleanup interfaces + +mm_cleanup_interfaces() { + local sysfs_path status + + # Do nothing if there is no sysfs cache + [ -f "${MODEMMANAGER_SYSFS_CACHE}" ] || return + + while IFS= read -r sysfs_cache_line; do + sysfs_path=$(echo "${sysfs_cache_line}" | awk '{print $1}') + status=$(echo "${sysfs_cache_line}" | awk '{print $2}') + + if [ "${status}" = "processed" ]; then + mm_log "debug" "call cleanup for: ${sysfs_path}" + mm_cleanup_interface_by_sysfspath "${sysfs_path}" + fi + done < ${MODEMMANAGER_SYSFS_CACHE} +} + +mm_cleanup_interface_by_sysfspath() { + local dev="$1" + + local cfg + cfg=$(mm_get_modem_config "$dev") + [ -n "${cfg}" ] || return + + mm_log "info" "setting interface '$cfg' as unavailable" + proto_set_available "${cfg}" 0 +} + +################################################################################ +# Event reporting + +# Receives as input the action, the device name and the subsystem +mm_report_event() { + local action="$1" + local name="$2" + local subsystem="$3" + local sysfspath="$4" + + # Do not save virtual devices + local virtual result + virtual="$(echo "$sysfspath" | cut -d'/' -f4)" + [ "$virtual" = "virtual" ] && { + mm_log "debug" "sysfspath is a virtual device ($sysfspath)" + return + } + + # Track/untrack events in cache + case "${action}" in + "add") + # On add events, store event details in cache (if not exists yet) + grep -qs "${name},${subsystem}" "${MODEMMANAGER_EVENTS_CACHE}" || \ + echo "${action},${name},${subsystem},${sysfspath}" >> "${MODEMMANAGER_EVENTS_CACHE}" + ;; + "remove") + # On remove events, remove old events from cache (match by subsystem+name) + sed -i "/${name},${subsystem}/d" "${MODEMMANAGER_EVENTS_CACHE}" + ;; + esac + + # Report the event + mm_log "debug" "Report event: action=${action}, name=${name}, subsystem=${subsystem}" + result=$(mmcli --report-kernel-event="action=${action},name=${name},subsystem=${subsystem}" 2>&1) + if [ "$?" -eq "0" ]; then + # Wait for added modem if a sysfspath is given + [ -n "${sysfspath}" ] && [ "$action" = "add" ] && mm_report_modem_wait "${sysfspath}" + else + mm_log "error" "Couldn't report kernel event: ${result}" + fi + +} + +mm_report_event_from_cache_line() { + local event_line="$1" + + local action name subsystem sysfspath + action=$(echo "${event_line}" | awk -F ',' '{ print $1 }') + name=$(echo "${event_line}" | awk -F ',' '{ print $2 }') + subsystem=$(echo "${event_line}" | awk -F ',' '{ print $3 }') + sysfspath=$(echo "${event_line}" | awk -F ',' '{ print $4 }') + + mm_log "debug" "cached event found: action=${action}, name=${name}, subsystem=${subsystem}, sysfspath=${sysfspath}" + mm_report_event "${action}" "${name}" "${subsystem}" "${sysfspath}" +} + +mm_report_events_from_cache() { + local n=60 + local step=1 + local mmrunning=0 + + # Wait for ModemManager to be available in the bus + while [ $n -ge 0 ]; do + sleep $step + mm_log "info" "checking if ModemManager is available..." + + if ! mmcli -L >/dev/null 2>&1 + then + mm_log "info" "ModemManager not yet available" + else + mmrunning=1 + break + fi + n=$((n-step)) + done + + [ ${mmrunning} -eq 1 ] || { + mm_log "error" "couldn't report initial kernel events: ModemManager not running" + return + } + + # Remove the sysfs cache + rm -f "${MODEMMANAGER_SYSFS_CACHE}" + + # Report cached kernel events + while IFS= read -r event_line; do + mm_report_event_from_cache_line "${event_line}" + done < ${MODEMMANAGER_EVENTS_CACHE} +} diff --git a/modemmanager/files/modemmanager.init b/modemmanager/files/modemmanager.init new file mode 100755 index 000000000..c19022031 --- /dev/null +++ b/modemmanager/files/modemmanager.init @@ -0,0 +1,27 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2016 Aleksander Morgado + +USE_PROCD=1 +START=70 + +start_service() { + # Setup ModemManager service + # + # We will make sure that the rundir always exists, and we initially cleanup + # all interfaces flagging them as unavailable. + # + # The cached events processing will wait for MM to be available in DBus + # and will make sure all ports are re-notified to ModemManager every time + # it starts. + # + # All these commands need to be executed on every MM start, even after + # procd-triggered respawns, which is why this is wrapped in a startup + # wrapper script called '/usr/sbin/ModemManager-wrapper'. + # + . /usr/share/ModemManager/modemmanager.common + procd_open_instance + procd_set_param command /usr/sbin/ModemManager-wrapper + procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}" + procd_set_param pidfile "${MODEMMANAGER_PID_FILE}" + procd_close_instance +} diff --git a/modemmanager/files/usr/sbin/ModemManager-wrapper b/modemmanager/files/usr/sbin/ModemManager-wrapper new file mode 100755 index 000000000..e06d943e9 --- /dev/null +++ b/modemmanager/files/usr/sbin/ModemManager-wrapper @@ -0,0 +1,33 @@ +#!/bin/sh + +trap_with_arg() { + func="$1" ; shift + for sig ; do + # shellcheck disable=SC2064 + trap "$func $sig" "$sig" + done +} + +func_trap() { + logger "ModemManager-wrapper[$$]" "Sending signal ${1}..." + kill "-${1}" "$CHILD" 2>/dev/null +} + +main() { + . /usr/share/ModemManager/modemmanager.common + + trap_with_arg func_trap INT TERM KILL + + mkdir -p "${MODEMMANAGER_RUNDIR}" + chmod 0755 "${MODEMMANAGER_RUNDIR}" + + /usr/sbin/ModemManager "$@" 1>/dev/null 2>/dev/null & + CHILD="$!" + + mm_report_events_from_cache + + wait "$CHILD" + mm_cleanup_interfaces +} + +main "$@" diff --git a/mptcp/files/usr/bin/multipath b/mptcp/files/usr/bin/multipath index d7fa77354..a44d7f24b 100755 --- a/mptcp/files/usr/bin/multipath +++ b/mptcp/files/usr/bin/multipath @@ -141,7 +141,9 @@ else ID=$(ip mptcp endpoint show | grep -m 1 "dev $DEVICE" | awk '{print $3}') IFF=$(ip mptcp endpoint show | grep -m 1 "dev $DEVICE" | awk '{print $4}') - IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') + #IP=$(ip a show $DEVICE | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') + [ -f /usr/bin/jsonfilter ] && IP=$(ip -j a show $DEVICE | jsonfilter -e '@[0].addr_info[*].local') + [ -f /usr/bin/jq ] && IP=$(ip -j a show $DEVICE | jq -r '.[0].addr_info[].local') [ -z "$ID" ] && [ -n "$IP" ] && ID=$(ip mptcp endpoint show | grep "$IP" | awk '{print $3}') RMID=$(ip mptcp endpoint show | grep '::ffff' | awk '{ print $3 }') [ -n "$RMID" ] && ip mptcp endpoint delete id $RMID 2>&1 >/dev/null diff --git a/omr-tracker/files/bin/omr-tracker-server b/omr-tracker/files/bin/omr-tracker-server index 9990647fb..940c119b8 100755 --- a/omr-tracker/files/bin/omr-tracker-server +++ b/omr-tracker/files/bin/omr-tracker-server @@ -79,9 +79,18 @@ _check_master() { EOF if [ "$count" -eq "0" ]; then uci -q batch <<-EOF >/dev/null + set xray.omrout.s_vmess_address=$ip + set xray.omrout.s_vless_address=$ip + set xray.omrout.s_vless_reality_address=$ip + set xray.omrout.s_trojan_address=$ip + set xray.omrout.s_socks_address=$ip + set xray.omrout.s_shadowsocks_address=$ip set v2ray.omrout.s_vmess_address=$ip set v2ray.omrout.s_vless_address=$ip + set v2ray.omrout.s_trojan_address=$ip + set v2ray.omrout.s_socks_address=$ip commit v2ray + commit xray set glorytun.vpn.host=$ip commit glorytun glorytun-udp.vpn.host=$ip @@ -98,6 +107,7 @@ _check_master() { EOF /etc/init.d/openmptcprouter-vps get_openvpn_key $name >/dev/null 2>/dev/null /etc/init.d/v2ray restart >/dev/null 2>/dev/null + /etc/init.d/xray restart >/dev/null 2>/dev/null /etc/init.d/glorytun restart >/dev/null 2>/dev/null /etc/init.d/glorytun-udp restart >/dev/null 2>/dev/null /etc/init.d/mlvpn restart >/dev/null 2>/dev/null @@ -194,9 +204,18 @@ _check_backup() { EOF if [ "$count" -eq "0" ]; then uci -q batch <<-EOF >/dev/null + set xray.omrout.s_vmess_address=$ip + set xray.omrout.s_vless_address=$ip + set xray.omrout.s_vless_reality_address=$ip + set xray.omrout.s_trojan_address=$ip + set xray.omrout.s_socks_address=$ip + set xray.omrout.s_shadowsocks_address=$ip set v2ray.omrout.s_vmess_address=$ip set v2ray.omrout.s_vless_address=$ip + set v2ray.omrout.s_trojan_address=$ip + set v2ray.omrout.s_socks_address=$ip commit v2ray + commit xray set glorytun.vpn.host=$ip commit glorytun glorytun-udp.vpn.host=$ip diff --git a/openmptcprouter/files/etc/init.d/openmptcprouter-vps b/openmptcprouter/files/etc/init.d/openmptcprouter-vps index bff3342a3..e9a3c420c 100755 --- a/openmptcprouter/files/etc/init.d/openmptcprouter-vps +++ b/openmptcprouter/files/etc/init.d/openmptcprouter-vps @@ -135,7 +135,7 @@ _set_glorytun_vps() { _set_openvpn_vps() { local enabled port key - enabled="$(uci -q get openvpn.omr.enable)" + enabled="$(uci -q get openvpn.omr.enabled)" [ "$enabled" != "1" ] && echo "OpenVPN disabled" && return port="$(uci -q get openvpn.omr.port)" cipher="$(uci -q get openvpn.omr.cipher)" diff --git a/openmptcprouter/files/etc/uci-defaults/2020-omr-vpn b/openmptcprouter/files/etc/uci-defaults/2020-omr-vpn index 5e1e38c7a..a8a84193c 100755 --- a/openmptcprouter/files/etc/uci-defaults/2020-omr-vpn +++ b/openmptcprouter/files/etc/uci-defaults/2020-omr-vpn @@ -154,9 +154,10 @@ if [ "$(uci -q get network.tun0.mtu)" = "1200" ] || [ -z "$(uci -q get network.t EOF fi +# Set the default VPN if [ "$(uci -q get openmptcprouter.settings.vpn)" = "" ]; then uci -q batch <<-EOF >/dev/null - set openmptcprouter.settings.vpn='glorytun_tcp' + set openmptcprouter.settings.vpn='openvpn' set glorytun.vpn.enable='1' commit glorytun commit openmptcprouter