diff --git a/6in4/Makefile b/6in4/Makefile old mode 100755 new mode 100644 diff --git a/aquantia/Makefile b/aquantia/Makefile old mode 100755 new mode 100644 diff --git a/atinout/Makefile b/atinout/Makefile old mode 100755 new mode 100644 diff --git a/bcm27xx-eeprom/Makefile b/bcm27xx-eeprom/Makefile old mode 100755 new mode 100644 diff --git a/bcm27xx-eeprom/patches/0001-rpi-eeprom-update-OpenWrt-defaults.patch b/bcm27xx-eeprom/patches/0001-rpi-eeprom-update-OpenWrt-defaults.patch old mode 100755 new mode 100644 diff --git a/bcm27xx-eeprom/patches/0003-rpi-eeprom-update-change-default-include-path.patch b/bcm27xx-eeprom/patches/0003-rpi-eeprom-update-change-default-include-path.patch old mode 100755 new mode 100644 diff --git a/bcm27xx-eeprom/patches/0004-rpi-eeprom-update-chmod-silent-f-is-not-supported.patch b/bcm27xx-eeprom/patches/0004-rpi-eeprom-update-chmod-silent-f-is-not-supported.patch old mode 100755 new mode 100644 diff --git a/bcm27xx-eeprom/patches/0005-rpi-eeprom-config-change-default-text-editor.patch b/bcm27xx-eeprom/patches/0005-rpi-eeprom-config-change-default-text-editor.patch old mode 100755 new mode 100644 diff --git a/contributors/cr3ative.md b/contributors/cr3ative.md old mode 100755 new mode 100644 diff --git a/contributors/example.md b/contributors/example.md old mode 100755 new mode 100644 diff --git a/contributors/flesser.md b/contributors/flesser.md old mode 100755 new mode 100644 diff --git a/contributors/ta264.md b/contributors/ta264.md old mode 100755 new mode 100644 diff --git a/contributors/yostyle.md b/contributors/yostyle.md old mode 100755 new mode 100644 diff --git a/cryptodev-linux/Makefile b/cryptodev-linux/Makefile old mode 100755 new mode 100644 diff --git a/dsvpn/Makefile b/dsvpn/Makefile old mode 100755 new mode 100644 diff --git a/dsvpn/patches/nostrip.patch b/dsvpn/patches/nostrip.patch old mode 100755 new mode 100644 diff --git a/fullconenat/Makefile b/fullconenat/Makefile old mode 100755 new mode 100644 diff --git a/fullconenat/patches/001-fix-init-Repeat-definition.patch b/fullconenat/patches/001-fix-init-Repeat-definition.patch old mode 100755 new mode 100644 diff --git a/fullconenat/patches/001-linux-6.1-support.patch b/fullconenat/patches/001-linux-6.1-support.patch old mode 100755 new mode 100644 diff --git a/fullconenat/src/Makefile b/fullconenat/src/Makefile old mode 100755 new mode 100644 diff --git a/glorytun-udp/Makefile b/glorytun-udp/Makefile old mode 100755 new mode 100644 diff --git a/glorytun-udp/patches/aegis-arm.patch b/glorytun-udp/patches/aegis-arm.patch old mode 100755 new mode 100644 diff --git a/glorytun/Makefile b/glorytun/Makefile old mode 100755 new mode 100644 diff --git a/glorytun/glorytun.config b/glorytun/glorytun.config old mode 100755 new mode 100644 diff --git a/golang-protobuf/Makefile b/golang-protobuf/Makefile old mode 100755 new mode 100644 diff --git a/golang/golang-build.sh b/golang/golang-build.sh old mode 100755 new mode 100644 diff --git a/golang/golang-compiler.mk b/golang/golang-compiler.mk old mode 100755 new mode 100644 diff --git a/golang/golang-golang-x-crypto/Makefile b/golang/golang-golang-x-crypto/Makefile old mode 100755 new mode 100644 diff --git a/golang/golang-golang-x-net/Makefile b/golang/golang-golang-x-net/Makefile old mode 100755 new mode 100644 diff --git a/golang/golang-golang-x-sys/Makefile b/golang/golang-golang-x-sys/Makefile old mode 100755 new mode 100644 diff --git a/golang/golang-golang-x-text/Makefile b/golang/golang-golang-x-text/Makefile old mode 100755 new mode 100644 diff --git a/golang/golang-host-build.mk b/golang/golang-host-build.mk old mode 100755 new mode 100644 diff --git a/golang/golang-package.mk b/golang/golang-package.mk old mode 100755 new mode 100644 diff --git a/golang/golang-values.mk b/golang/golang-values.mk old mode 100755 new mode 100644 diff --git a/golang/golang/Config.in b/golang/golang/Config.in old mode 100755 new mode 100644 diff --git a/golang/golang/Makefile b/golang/golang/Makefile old mode 100755 new mode 100644 diff --git a/golang/golang/files/go-gcc-helper b/golang/golang/files/go-gcc-helper old mode 100755 new mode 100644 diff --git a/golang/golang/patches/001-default-enable-mptcp.patch b/golang/golang/patches/001-default-enable-mptcp.patch old mode 100755 new mode 100644 diff --git a/grpcurl/Makefile b/grpcurl/Makefile old mode 100755 new mode 100644 diff --git a/https-dns-proxy/Makefile b/https-dns-proxy/Makefile old mode 100755 new mode 100644 index abfb4be7a..73d0a07cf --- a/https-dns-proxy/Makefile +++ b/https-dns-proxy/Makefile @@ -1,15 +1,15 @@ include $(TOPDIR)/rules.mk PKG_NAME:=https-dns-proxy -PKG_VERSION:=2021-11-22 -PKG_RELEASE:=3 +PKG_VERSION:=2021-06-03 +PKG_RELEASE:=1 PKG_SOURCE_PROTO:=git -PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy/ -PKG_SOURCE_DATE:=2021-11-22 -PKG_SOURCE_VERSION:=9336fd6272d67e8bb6e304fa54f3139a3d26f08f -PKG_MIRROR_HASH:=60b1ddabaf1db3a9ee19f3294a1df714364d580cef5e3c2161363c371a557456 -PKG_MAINTAINER:=Stan Grishin +PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy +PKG_SOURCE_DATE:=2021-06-03 +PKG_SOURCE_VERSION:=5651b984f770a8bcecb14aeffc224703f8f82586 +PKG_MIRROR_HASH:=b65161936269aa3117debad0fcfce157024726b78d7e7da77c226f7aa8da5b4d +PKG_MAINTAINER:=Stan Grishin PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE @@ -38,10 +38,7 @@ define Package/https-dns-proxy/conffiles endef define Package/https-dns-proxy/install - $(INSTALL_DIR) $(1)/usr/sbin - $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_DIR) ${1}/etc/config - $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d ${1}/etc/config $(INSTALL_BIN) $(PKG_BUILD_DIR)/https_dns_proxy $(1)/usr/sbin/https-dns-proxy $(INSTALL_BIN) ./files/https-dns-proxy.init $(1)/etc/init.d/https-dns-proxy $(SED) "s|^\(PKG_VERSION\).*|\1='$(PKG_VERSION)-$(PKG_RELEASE)'|" $(1)/etc/init.d/https-dns-proxy diff --git a/https-dns-proxy/files/README.md b/https-dns-proxy/files/README.md old mode 100755 new mode 100644 diff --git a/https-dns-proxy/files/https-dns-proxy.config b/https-dns-proxy/files/https-dns-proxy.config old mode 100755 new mode 100644 index f08e03ca9..3c5eecf4d --- a/https-dns-proxy/files/https-dns-proxy.config +++ b/https-dns-proxy/files/https-dns-proxy.config @@ -1,24 +1,5 @@ config main 'config' option update_dnsmasq_config '*' - option force_dns '1' - list force_dns_port '53' - list force_dns_port '853' -# ports listed below are used by some -# of the dnscrypt-proxy v1 resolvers -# list force_dns_port '553' -# list force_dns_port '1443' -# list force_dns_port '4343' -# list force_dns_port '4434' -# list force_dns_port '5443' -# list force_dns_port '8443' - -config https-dns-proxy - option bootstrap_dns '1.1.1.1,1.0.0.1' - option resolver_url 'https://cloudflare-dns.com/dns-query' - option listen_addr '127.0.0.1' - option listen_port '5054' - option user 'nobody' - option group 'nogroup' config https-dns-proxy option bootstrap_dns '8.8.8.8,8.8.4.4' @@ -27,3 +8,11 @@ config https-dns-proxy option listen_port '5053' option user 'nobody' option group 'nogroup' + +config https-dns-proxy + option bootstrap_dns '1.1.1.1,1.0.0.1' + option resolver_url 'https://cloudflare-dns.com/dns-query' + option listen_addr '127.0.0.1' + option listen_port '5054' + option user 'nobody' + option group 'nogroup' diff --git a/https-dns-proxy/files/https-dns-proxy.hotplug.iface b/https-dns-proxy/files/https-dns-proxy.hotplug.iface deleted file mode 100755 index c25b9e26d..000000000 --- a/https-dns-proxy/files/https-dns-proxy.hotplug.iface +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -if [ "$ACTION" = 'ifup' ] && [ "$INTERFACE" = 'wan' ] && /etc/init.d/https-dns-proxy enabled; then - logger -t "https-dns-proxy" "Restarting https-dns-proxy due to $ACTION of $INTERFACE" - /etc/init.d/https-dns-proxy restart -fi diff --git a/https-dns-proxy/patches/010-fix-cmakelists.patch b/https-dns-proxy/patches/010-fix-cmakelists.patch deleted file mode 100755 index 106142579..000000000 --- a/https-dns-proxy/patches/010-fix-cmakelists.patch +++ /dev/null @@ -1,15 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -21,9 +21,9 @@ if(NOT CMAKE_BUILD_TYPE) - message(STATUS "Setting build type to '${CMAKE_BUILD_TYPE}' as none was specified.") - endif() - --set(CMAKE_C_FLAGS "-Wall -Wextra --pedantic -Wno-strict-aliasing -Wno-variadic-macros") --set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") --set(CMAKE_C_FLAGS_RELEASE "-O2") -+#set(CMAKE_C_FLAGS "-Wall -Wextra --pedantic -Wno-strict-aliasing -Wno-variadic-macros") -+#set(CMAKE_C_FLAGS_DEBUG "-g -DDEBUG") -+#set(CMAKE_C_FLAGS_RELEASE "-O2") - - if ((CMAKE_C_COMPILER_ID MATCHES GNU AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 9) OR - (CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10)) diff --git a/https-dns-proxy/test.sh b/https-dns-proxy/test.sh old mode 100755 new mode 100644 diff --git a/ipcalc/Makefile b/ipcalc/Makefile old mode 100755 new mode 100644 diff --git a/iperf3/Makefile b/iperf3/Makefile old mode 100755 new mode 100644 diff --git a/iproute2/Makefile b/iproute2/Makefile old mode 100755 new mode 100644 diff --git a/iproute2/patches/100-configure.patch b/iproute2/patches/100-configure.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/110-darwin_fixes.patch b/iproute2/patches/110-darwin_fixes.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/115-add-config-xtlibdir.patch b/iproute2/patches/115-add-config-xtlibdir.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/120-no_arpd_ifstat_rtacct_lnstat.patch b/iproute2/patches/120-no_arpd_ifstat_rtacct_lnstat.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/130-no_netem_tipc_dcb_man_vdpa.patch b/iproute2/patches/130-no_netem_tipc_dcb_man_vdpa.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/140-allow_pfifo_fast.patch b/iproute2/patches/140-allow_pfifo_fast.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/140-keep_libmnl_optional.patch b/iproute2/patches/140-keep_libmnl_optional.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/145-keep_libelf_optional.patch b/iproute2/patches/145-keep_libelf_optional.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/150-keep_libcap_optional.patch b/iproute2/patches/150-keep_libcap_optional.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/155-keep_tirpc_optional.patch b/iproute2/patches/155-keep_tirpc_optional.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/160-libnetlink-pic.patch b/iproute2/patches/160-libnetlink-pic.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/170-ip_tiny.patch b/iproute2/patches/170-ip_tiny.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/175-reduce-dynamic-syms.patch b/iproute2/patches/175-reduce-dynamic-syms.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/180-drop_FAILED_POLICY.patch b/iproute2/patches/180-drop_FAILED_POLICY.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/190-fix-nls-rpath-link.patch b/iproute2/patches/190-fix-nls-rpath-link.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/195-build_variant_ip_tc.patch b/iproute2/patches/195-build_variant_ip_tc.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/200-drop_libbsd_dependency.patch b/iproute2/patches/200-drop_libbsd_dependency.patch old mode 100755 new mode 100644 diff --git a/iproute2/patches/300-selinux-configurable.patch b/iproute2/patches/300-selinux-configurable.patch old mode 100755 new mode 100644 diff --git a/lcd4linux/Config.in b/lcd4linux/Config.in old mode 100755 new mode 100644 diff --git a/lcd4linux/Makefile b/lcd4linux/Makefile old mode 100755 new mode 100644 diff --git a/lcd4linux/files/lcd4linux.init b/lcd4linux/files/lcd4linux.init old mode 100755 new mode 100644 diff --git a/lcd4linux/patches/120-remove-as-needed-linker-option.patch b/lcd4linux/patches/120-remove-as-needed-linker-option.patch old mode 100755 new mode 100644 diff --git a/lcd4linux/patches/140-no_repnop_T6963.patch b/lcd4linux/patches/140-no_repnop_T6963.patch old mode 100755 new mode 100644 diff --git a/lcd4linux/patches/150-addlibmpdclient.patch b/lcd4linux/patches/150-addlibmpdclient.patch old mode 100755 new mode 100644 diff --git a/lcd4linux/patches/160-uinput_defs.patch b/lcd4linux/patches/160-uinput_defs.patch old mode 100755 new mode 100644 diff --git a/lcd4linux/patches/170-add-generic-spidev-driver.patch b/lcd4linux/patches/170-add-generic-spidev-driver.patch old mode 100755 new mode 100644 diff --git a/lcd4linux/patches/173-glcd2usb-bigendian-fix.patch b/lcd4linux/patches/173-glcd2usb-bigendian-fix.patch old mode 100755 new mode 100644 diff --git a/libell/Makefile b/libell/Makefile old mode 100755 new mode 100644 diff --git a/libmbim/Makefile b/libmbim/Makefile old mode 100755 new mode 100644 diff --git a/libqmi/Config.in b/libqmi/Config.in old mode 100755 new mode 100644 diff --git a/libqmi/Makefile b/libqmi/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/Makefile b/luci-app-dsvpn/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/htdocs/luci-static/resources/view/services/dsvpn.js b/luci-app-dsvpn/htdocs/luci-static/resources/view/services/dsvpn.js old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/po/fr/dsvpn.po b/luci-app-dsvpn/po/fr/dsvpn.po old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/po/fr/dsvpn.po~ b/luci-app-dsvpn/po/fr/dsvpn.po~ old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/po/ru/dsvpn.po b/luci-app-dsvpn/po/ru/dsvpn.po old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/po/templates/dsvpn.pot b/luci-app-dsvpn/po/templates/dsvpn.pot old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/po/zh_Hans/dsvpn.po b/luci-app-dsvpn/po/zh_Hans/dsvpn.po old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/po/zh_Hans/dsvpn.po~ b/luci-app-dsvpn/po/zh_Hans/dsvpn.po~ old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/root/usr/share/luci/menu.d/luci-app-dsvpn.json b/luci-app-dsvpn/root/usr/share/luci/menu.d/luci-app-dsvpn.json old mode 100755 new mode 100644 diff --git a/luci-app-dsvpn/root/usr/share/rpcd/acl.d/luci-app-dsvpn.json b/luci-app-dsvpn/root/usr/share/rpcd/acl.d/luci-app-dsvpn.json old mode 100755 new mode 100644 diff --git a/luci-app-firewall/Makefile b/luci-app-firewall/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js b/luci-app-firewall/htdocs/luci-static/resources/tools/firewall.js old mode 100755 new mode 100644 diff --git a/luci-app-firewall/htdocs/luci-static/resources/view/firewall/custom.js b/luci-app-firewall/htdocs/luci-static/resources/view/firewall/custom.js old mode 100755 new mode 100644 diff --git a/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js b/luci-app-firewall/htdocs/luci-static/resources/view/firewall/forwards.js old mode 100755 new mode 100644 diff --git a/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js b/luci-app-firewall/htdocs/luci-static/resources/view/firewall/rules.js old mode 100755 new mode 100644 diff --git a/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js b/luci-app-firewall/htdocs/luci-static/resources/view/firewall/snats.js old mode 100755 new mode 100644 diff --git a/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js b/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js old mode 100755 new mode 100644 index 73eaa4a22..5ece96be2 --- a/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js +++ b/luci-app-firewall/htdocs/luci-static/resources/view/firewall/zones.js @@ -145,14 +145,14 @@ return view.extend({ o = s.taboption('general', form.Flag, 'masq', _('Masquerading')); o.editable = true; - o = s.taboption('general', form.Flag, 'fullcone', _('Full Cone')); + + o = s.taboption('general', form.Flag, 'fullcone', _('Full Cone')); o.editable = true; - o.depends('masq', '1'); - o = s.taboption('general', form.Flag, 'mtu_fix', _('MSS clamp')); - o.modalonly = true; + o.depends('masq', '1'); + o = s.taboption('general', form.Flag, 'mtu_fix', _('MSS clamping')); o.modalonly = true; - + o = s.taboption('general', widgets.NetworkSelect, 'network', _('Covered networks')); o.modalonly = true; o.multiple = true; diff --git a/luci-app-firewall/po/bg/firewall.po b/luci-app-firewall/po/bg/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/ca/firewall.po b/luci-app-firewall/po/ca/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/cs/firewall.po b/luci-app-firewall/po/cs/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/de/firewall.po b/luci-app-firewall/po/de/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/el/firewall.po b/luci-app-firewall/po/el/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/en/firewall.po b/luci-app-firewall/po/en/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/es/firewall.po b/luci-app-firewall/po/es/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/fr/firewall.po b/luci-app-firewall/po/fr/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/he/firewall.po b/luci-app-firewall/po/he/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/hi/firewall.po b/luci-app-firewall/po/hi/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/hu/firewall.po b/luci-app-firewall/po/hu/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/it/firewall.po b/luci-app-firewall/po/it/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/ja/firewall.po b/luci-app-firewall/po/ja/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/ko/firewall.po b/luci-app-firewall/po/ko/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/mr/firewall.po b/luci-app-firewall/po/mr/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/ms/firewall.po b/luci-app-firewall/po/ms/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/nb_NO/firewall.po b/luci-app-firewall/po/nb_NO/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/pl/firewall.po b/luci-app-firewall/po/pl/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/pt/firewall.po b/luci-app-firewall/po/pt/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/pt_BR/firewall.po b/luci-app-firewall/po/pt_BR/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/ro/firewall.po b/luci-app-firewall/po/ro/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/ru/firewall.po b/luci-app-firewall/po/ru/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/sk/firewall.po b/luci-app-firewall/po/sk/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/sv/firewall.po b/luci-app-firewall/po/sv/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/templates/firewall.pot b/luci-app-firewall/po/templates/firewall.pot old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/tr/firewall.po b/luci-app-firewall/po/tr/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/uk/firewall.po b/luci-app-firewall/po/uk/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/vi/firewall.po b/luci-app-firewall/po/vi/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/zh_Hans/firewall.po b/luci-app-firewall/po/zh_Hans/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/po/zh_Hant/firewall.po b/luci-app-firewall/po/zh_Hant/firewall.po old mode 100755 new mode 100644 diff --git a/luci-app-firewall/root/usr/share/luci/menu.d/luci-app-firewall.json b/luci-app-firewall/root/usr/share/luci/menu.d/luci-app-firewall.json old mode 100755 new mode 100644 diff --git a/luci-app-firewall/root/usr/share/rpcd/acl.d/luci-app-firewall.json b/luci-app-firewall/root/usr/share/rpcd/acl.d/luci-app-firewall.json old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/Makefile b/luci-app-glorytun-tcp/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/htdocs/luci-static/resources/view/services/glorytun-tcp.js b/luci-app-glorytun-tcp/htdocs/luci-static/resources/view/services/glorytun-tcp.js old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/po/fr/glorytun-tcp.po b/luci-app-glorytun-tcp/po/fr/glorytun-tcp.po old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/po/fr/glorytun-tcp.po~ b/luci-app-glorytun-tcp/po/fr/glorytun-tcp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/po/ru/glorytun-tcp.po b/luci-app-glorytun-tcp/po/ru/glorytun-tcp.po old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/po/templates/glorytun-tcp.pot b/luci-app-glorytun-tcp/po/templates/glorytun-tcp.pot old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/po/zh_Hans/glorytun-tcp.po b/luci-app-glorytun-tcp/po/zh_Hans/glorytun-tcp.po old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/po/zh_Hans/glorytun-tcp.po~ b/luci-app-glorytun-tcp/po/zh_Hans/glorytun-tcp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/root/etc/hotplug.d/iface/30-glorytun b/luci-app-glorytun-tcp/root/etc/hotplug.d/iface/30-glorytun old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun b/luci-app-glorytun-tcp/root/etc/uci-defaults/1200-luci-glorytun old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/root/usr/share/luci/menu.d/luci-app-glorytun-tcp.json b/luci-app-glorytun-tcp/root/usr/share/luci/menu.d/luci-app-glorytun-tcp.json old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-tcp/root/usr/share/rpcd/acl.d/luci-app-glorytun-tcp.json b/luci-app-glorytun-tcp/root/usr/share/rpcd/acl.d/luci-app-glorytun-tcp.json old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/Makefile b/luci-app-glorytun-udp/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/htdocs/luci-static/resources/view/services/glorytun-udp.js b/luci-app-glorytun-udp/htdocs/luci-static/resources/view/services/glorytun-udp.js old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/po/fr/glorytun-udp.po b/luci-app-glorytun-udp/po/fr/glorytun-udp.po old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/po/fr/glorytun-udp.po~ b/luci-app-glorytun-udp/po/fr/glorytun-udp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/po/ru/glorytun-udp.po b/luci-app-glorytun-udp/po/ru/glorytun-udp.po old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/po/templates/glorytun-udp.pot b/luci-app-glorytun-udp/po/templates/glorytun-udp.pot old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/po/zh_Hans/glorytun-udp.po b/luci-app-glorytun-udp/po/zh_Hans/glorytun-udp.po old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/po/zh_Hans/glorytun-udp.po~ b/luci-app-glorytun-udp/po/zh_Hans/glorytun-udp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/root/etc/config/glorytun-udp b/luci-app-glorytun-udp/root/etc/config/glorytun-udp old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/root/etc/hotplug.d/iface/30-glorytun-udp b/luci-app-glorytun-udp/root/etc/hotplug.d/iface/30-glorytun-udp old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/root/etc/uci-defaults/1201-luci-glorytun-udp b/luci-app-glorytun-udp/root/etc/uci-defaults/1201-luci-glorytun-udp old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/root/usr/share/luci/menu.d/luci-app-glorytun-udp.json b/luci-app-glorytun-udp/root/usr/share/luci/menu.d/luci-app-glorytun-udp.json old mode 100755 new mode 100644 diff --git a/luci-app-glorytun-udp/root/usr/share/rpcd/acl.d/luci-app-glorytun-udp.json b/luci-app-glorytun-udp/root/usr/share/rpcd/acl.d/luci-app-glorytun-udp.json old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/LICENSE b/luci-app-haproxy-tcp/LICENSE old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/Makefile b/luci-app-haproxy-tcp/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/README.md b/luci-app-haproxy-tcp/README.md old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/luasrc/controller/haproxy-tcp.lua b/luci-app-haproxy-tcp/luasrc/controller/haproxy-tcp.lua old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/luasrc/model/cbi/haproxy-tcp.lua b/luci-app-haproxy-tcp/luasrc/model/cbi/haproxy-tcp.lua old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/po/fr/haproxy-tcp.po b/luci-app-haproxy-tcp/po/fr/haproxy-tcp.po old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/po/templates/haproxy-tcp.pot b/luci-app-haproxy-tcp/po/templates/haproxy-tcp.pot old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/po/zh-cn/haproxy-tcp.po b/luci-app-haproxy-tcp/po/zh-cn/haproxy-tcp.po old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/root/etc/config/haproxy-tcp b/luci-app-haproxy-tcp/root/etc/config/haproxy-tcp old mode 100755 new mode 100644 diff --git a/luci-app-haproxy-tcp/root/etc/uci-defaults/41_luci-haproxy-tcp b/luci-app-haproxy-tcp/root/etc/uci-defaults/41_luci-haproxy-tcp old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/Makefile b/luci-app-https-dns-proxy/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/controller/https-dns-proxy.lua b/luci-app-https-dns-proxy/luasrc/controller/https-dns-proxy.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers.disabled/ch.digitale-gesellschaft.dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers.disabled/ch.digitale-gesellschaft.dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers.disabled/cn.rubyfish.dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers.disabled/cn.rubyfish.dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers.disabled/sb.dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers.disabled/sb.dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.adguard.dns-family.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.adguard.dns-family.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.adguard.dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.adguard.dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.cloudflare-dns-family.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.cloudflare-dns-family.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.cloudflare-dns-malware.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.cloudflare-dns-malware.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.cloudflare-dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/com.cloudflare-dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/cz.nic.odvr.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/cz.nic.odvr.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/google.dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/google.dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/gr.libredns.doh-ads.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/gr.libredns.doh-ads.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/gr.libredns.doh.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/gr.libredns.doh.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns10.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns10.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns11.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns11.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns9.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/net.quad9.dns9.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/org.cleanbrowsing.doh-adult.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/org.cleanbrowsing.doh-adult.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/org.cleanbrowsing.doh-family.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/org.cleanbrowsing.doh-family.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/org.cleanbrowsing.doh-security.lua b/luci-app-https-dns-proxy/luasrc/https-dns-proxy/providers/org.cleanbrowsing.doh-security.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/model/cbi/https-dns-proxy.lua b/luci-app-https-dns-proxy/luasrc/model/cbi/https-dns-proxy.lua old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/buttons.htm b/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/buttons.htm old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/css.htm b/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/css.htm old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/js.htm b/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/js.htm old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/status-textarea.htm b/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/status-textarea.htm old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/status.htm b/luci-app-https-dns-proxy/luasrc/view/https-dns-proxy/status.htm old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/bg/https-dns-proxy.po b/luci-app-https-dns-proxy/po/bg/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/ca/https-dns-proxy.po b/luci-app-https-dns-proxy/po/ca/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/cs/https-dns-proxy.po b/luci-app-https-dns-proxy/po/cs/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/de/https-dns-proxy.po b/luci-app-https-dns-proxy/po/de/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/el/https-dns-proxy.po b/luci-app-https-dns-proxy/po/el/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/en/https-dns-proxy.po b/luci-app-https-dns-proxy/po/en/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/es/https-dns-proxy.po b/luci-app-https-dns-proxy/po/es/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/fr/https-dns-proxy.po b/luci-app-https-dns-proxy/po/fr/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/he/https-dns-proxy.po b/luci-app-https-dns-proxy/po/he/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/hi/https-dns-proxy.po b/luci-app-https-dns-proxy/po/hi/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/hu/https-dns-proxy.po b/luci-app-https-dns-proxy/po/hu/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/it/https-dns-proxy.po b/luci-app-https-dns-proxy/po/it/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/ja/https-dns-proxy.po b/luci-app-https-dns-proxy/po/ja/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/ko/https-dns-proxy.po b/luci-app-https-dns-proxy/po/ko/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/mr/https-dns-proxy.po b/luci-app-https-dns-proxy/po/mr/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/ms/https-dns-proxy.po b/luci-app-https-dns-proxy/po/ms/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/nb_NO/https-dns-proxy.po b/luci-app-https-dns-proxy/po/nb_NO/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/pl/https-dns-proxy.po b/luci-app-https-dns-proxy/po/pl/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/pt/https-dns-proxy.po b/luci-app-https-dns-proxy/po/pt/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/pt_BR/https-dns-proxy.po b/luci-app-https-dns-proxy/po/pt_BR/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/ro/https-dns-proxy.po b/luci-app-https-dns-proxy/po/ro/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/ru/https-dns-proxy.po b/luci-app-https-dns-proxy/po/ru/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/sk/https-dns-proxy.po b/luci-app-https-dns-proxy/po/sk/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/sv/https-dns-proxy.po b/luci-app-https-dns-proxy/po/sv/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/templates/https-dns-proxy.pot b/luci-app-https-dns-proxy/po/templates/https-dns-proxy.pot old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/tr/https-dns-proxy.po b/luci-app-https-dns-proxy/po/tr/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/uk/https-dns-proxy.po b/luci-app-https-dns-proxy/po/uk/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/vi/https-dns-proxy.po b/luci-app-https-dns-proxy/po/vi/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/zh_Hans/https-dns-proxy.po b/luci-app-https-dns-proxy/po/zh_Hans/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/po/zh_Hant/https-dns-proxy.po b/luci-app-https-dns-proxy/po/zh_Hant/https-dns-proxy.po old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/root/etc/uci-defaults/40_luci-https-dns-proxy b/luci-app-https-dns-proxy/root/etc/uci-defaults/40_luci-https-dns-proxy old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/root/usr/share/luci/menu.d/luci-app-https-dns-proxy.json b/luci-app-https-dns-proxy/root/usr/share/luci/menu.d/luci-app-https-dns-proxy.json old mode 100755 new mode 100644 diff --git a/luci-app-https-dns-proxy/root/usr/share/rpcd/acl.d/luci-app-https-dns-proxy.json b/luci-app-https-dns-proxy/root/usr/share/rpcd/acl.d/luci-app-https-dns-proxy.json old mode 100755 new mode 100644 diff --git a/luci-app-iperf/Makefile b/luci-app-iperf/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-iperf/luasrc/controller/iperf.lua b/luci-app-iperf/luasrc/controller/iperf.lua old mode 100755 new mode 100644 diff --git a/luci-app-iperf/luasrc/view/iperf/test.htm b/luci-app-iperf/luasrc/view/iperf/test.htm old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/de/iperf.po b/luci-app-iperf/po/de/iperf.po old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/de/iperf.po~ b/luci-app-iperf/po/de/iperf.po~ old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/fr/iperf.po b/luci-app-iperf/po/fr/iperf.po old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/fr/iperf.po~ b/luci-app-iperf/po/fr/iperf.po~ old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/it/iperf.po b/luci-app-iperf/po/it/iperf.po old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/it/iperf.po~ b/luci-app-iperf/po/it/iperf.po~ old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/oc/iperf.po b/luci-app-iperf/po/oc/iperf.po old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/oc/iperf.po~ b/luci-app-iperf/po/oc/iperf.po~ old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/ru/iperf.po b/luci-app-iperf/po/ru/iperf.po old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/templates/iperf.pot b/luci-app-iperf/po/templates/iperf.pot old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/zh_Hans/iperf.po b/luci-app-iperf/po/zh_Hans/iperf.po old mode 100755 new mode 100644 diff --git a/luci-app-iperf/po/zh_Hans/iperf.po~ b/luci-app-iperf/po/zh_Hans/iperf.po~ old mode 100755 new mode 100644 diff --git a/luci-app-iperf/root/etc/config/iperf b/luci-app-iperf/root/etc/config/iperf old mode 100755 new mode 100644 diff --git a/luci-app-iperf/root/usr/share/luci/menu.d/luci-app-iperf.json b/luci-app-iperf/root/usr/share/luci/menu.d/luci-app-iperf.json old mode 100755 new mode 100644 diff --git a/luci-app-iperf/root/usr/share/rpcd/acl.d/luci-app-iperf.json b/luci-app-iperf/root/usr/share/rpcd/acl.d/luci-app-iperf.json old mode 100755 new mode 100644 diff --git a/luci-app-macvlan/po/zh_Hans/macvlan.po b/luci-app-macvlan/po/zh_Hans/macvlan.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/Makefile b/luci-app-mail/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-mail/luasrc/controller/mail.lua b/luci-app-mail/luasrc/controller/mail.lua old mode 100755 new mode 100644 diff --git a/luci-app-mail/luasrc/model/cbi/mail.lua b/luci-app-mail/luasrc/model/cbi/mail.lua old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/de/mail.po b/luci-app-mail/po/de/mail.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/de/mail.po~ b/luci-app-mail/po/de/mail.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/fr/mail.po b/luci-app-mail/po/fr/mail.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/fr/mail.po~ b/luci-app-mail/po/fr/mail.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/it/mail.po b/luci-app-mail/po/it/mail.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/it/mail.po~ b/luci-app-mail/po/it/mail.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/oc/mail.po b/luci-app-mail/po/oc/mail.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/oc/mail.po~ b/luci-app-mail/po/oc/mail.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/ru/mail.po b/luci-app-mail/po/ru/mail.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/templates/mail.pot b/luci-app-mail/po/templates/mail.pot old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/zh_Hans/mail.po b/luci-app-mail/po/zh_Hans/mail.po old mode 100755 new mode 100644 diff --git a/luci-app-mail/po/zh_Hans/mail.po~ b/luci-app-mail/po/zh_Hans/mail.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mail/root/etc/config/mail b/luci-app-mail/root/etc/config/mail old mode 100755 new mode 100644 diff --git a/luci-app-mail/root/usr/share/luci/menu.d/luci-app-mail.json b/luci-app-mail/root/usr/share/luci/menu.d/luci-app-mail.json old mode 100755 new mode 100644 diff --git a/luci-app-mail/root/usr/share/rpcd/acl.d/luci-app-mail.json b/luci-app-mail/root/usr/share/rpcd/acl.d/luci-app-mail.json old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/Makefile b/luci-app-mlvpn/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/htdocs/luci-static/resources/view/services/mlvpn.js b/luci-app-mlvpn/htdocs/luci-static/resources/view/services/mlvpn.js old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/po/fr/mlvpn.po b/luci-app-mlvpn/po/fr/mlvpn.po old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/po/fr/mlvpn.po~ b/luci-app-mlvpn/po/fr/mlvpn.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/po/ru/mlvpn.po b/luci-app-mlvpn/po/ru/mlvpn.po old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/po/templates/mlvpn.pot b/luci-app-mlvpn/po/templates/mlvpn.pot old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/po/zh_Hans/mlvpn.po b/luci-app-mlvpn/po/zh_Hans/mlvpn.po old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/po/zh_Hans/mlvpn.po~ b/luci-app-mlvpn/po/zh_Hans/mlvpn.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/root/usr/share/luci/menu.d/luci-app-mlvpn.json b/luci-app-mlvpn/root/usr/share/luci/menu.d/luci-app-mlvpn.json old mode 100755 new mode 100644 diff --git a/luci-app-mlvpn/root/usr/share/rpcd/acl.d/luci-app-mlvpn.json b/luci-app-mlvpn/root/usr/share/rpcd/acl.d/luci-app-mlvpn.json old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/Makefile b/luci-app-mptcp/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/htdocs/luci-static/resources/seedrandom.js b/luci-app-mptcp/htdocs/luci-static/resources/seedrandom.js old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/controller/mptcp.lua b/luci-app-mptcp/luasrc/controller/mptcp.lua old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/model/cbi/mptcp.lua b/luci-app-mptcp/luasrc/model/cbi/mptcp.lua old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm b/luci-app-mptcp/luasrc/view/mptcp/mptcp_check.htm old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/view/mptcp/mptcp_connections.htm b/luci-app-mptcp/luasrc/view/mptcp/mptcp_connections.htm old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/view/mptcp/mptcp_fullmesh.htm b/luci-app-mptcp/luasrc/view/mptcp/mptcp_fullmesh.htm old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/view/mptcp/mptcp_monitor.htm b/luci-app-mptcp/luasrc/view/mptcp/mptcp_monitor.htm old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/luasrc/view/mptcp/multipath.htm b/luci-app-mptcp/luasrc/view/mptcp/multipath.htm old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/de/mptcp.po b/luci-app-mptcp/po/de/mptcp.po old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/de/mptcp.po~ b/luci-app-mptcp/po/de/mptcp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/fr/mptcp.po b/luci-app-mptcp/po/fr/mptcp.po old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/it/mptcp.po b/luci-app-mptcp/po/it/mptcp.po old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/it/mptcp.po~ b/luci-app-mptcp/po/it/mptcp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/oc/mptcp.po b/luci-app-mptcp/po/oc/mptcp.po old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/oc/mptcp.po~ b/luci-app-mptcp/po/oc/mptcp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/ru/mptcp.po b/luci-app-mptcp/po/ru/mptcp.po old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/templates/mptcp.pot b/luci-app-mptcp/po/templates/mptcp.pot old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/po/zh_Hans/mptcp.po b/luci-app-mptcp/po/zh_Hans/mptcp.po old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/root/usr/share/luci/menu.d/luci-app-mptcp.json b/luci-app-mptcp/root/usr/share/luci/menu.d/luci-app-mptcp.json old mode 100755 new mode 100644 diff --git a/luci-app-mptcp/root/usr/share/rpcd/acl.d/luci-app-mptcp.json b/luci-app-mptcp/root/usr/share/rpcd/acl.d/luci-app-mptcp.json old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/LICENSE b/luci-app-nginx-ha/LICENSE old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/Makefile b/luci-app-nginx-ha/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/luasrc/controller/nginx-ha.lua b/luci-app-nginx-ha/luasrc/controller/nginx-ha.lua old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/luasrc/model/cbi/nginx-ha.lua b/luci-app-nginx-ha/luasrc/model/cbi/nginx-ha.lua old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/po/fr/nginx-ha.po b/luci-app-nginx-ha/po/fr/nginx-ha.po old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/po/templates/nginx-ha.pot b/luci-app-nginx-ha/po/templates/nginx-ha.pot old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/root/etc/config/nginx-ha b/luci-app-nginx-ha/root/etc/config/nginx-ha old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/root/etc/uci-defaults/42_luci-nginx-ha b/luci-app-nginx-ha/root/etc/uci-defaults/42_luci-nginx-ha old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/root/usr/share/luci/menu.d/luci-app-nginx-ha.json b/luci-app-nginx-ha/root/usr/share/luci/menu.d/luci-app-nginx-ha.json old mode 100755 new mode 100644 diff --git a/luci-app-nginx-ha/root/usr/share/rpcd/acl.d/luci-app-nginx-ha.json b/luci-app-nginx-ha/root/usr/share/rpcd/acl.d/luci-app-nginx-ha.json old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/Makefile b/luci-app-omr-dscp/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/luasrc/controller/omr-dscp.lua b/luci-app-omr-dscp/luasrc/controller/omr-dscp.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/luasrc/model/cbi/dscp-domains.lua b/luci-app-omr-dscp/luasrc/model/cbi/dscp-domains.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/luasrc/model/cbi/dscp.lua b/luci-app-omr-dscp/luasrc/model/cbi/dscp.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/de/omr-dscp.po b/luci-app-omr-dscp/po/de/omr-dscp.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/de/omr-dscp.po~ b/luci-app-omr-dscp/po/de/omr-dscp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/fr/omr-dscp.po b/luci-app-omr-dscp/po/fr/omr-dscp.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/fr/omr-dscp.po~ b/luci-app-omr-dscp/po/fr/omr-dscp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/it/omr-dscp.po b/luci-app-omr-dscp/po/it/omr-dscp.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/it/omr-dscp.po~ b/luci-app-omr-dscp/po/it/omr-dscp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/oc/omr-dscp.po b/luci-app-omr-dscp/po/oc/omr-dscp.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/oc/omr-dscp.po~ b/luci-app-omr-dscp/po/oc/omr-dscp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/templates/omr-dscp.pot b/luci-app-omr-dscp/po/templates/omr-dscp.pot old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/zh_Hans/omr-dscp.po b/luci-app-omr-dscp/po/zh_Hans/omr-dscp.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/po/zh_Hans/omr-dscp.po~ b/luci-app-omr-dscp/po/zh_Hans/omr-dscp.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/root/etc/config/dscp b/luci-app-omr-dscp/root/etc/config/dscp old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/root/usr/share/luci/menu.d/luci-app-omr-dscp.json b/luci-app-omr-dscp/root/usr/share/luci/menu.d/luci-app-omr-dscp.json old mode 100755 new mode 100644 diff --git a/luci-app-omr-dscp/root/usr/share/rpcd/acl.d/luci-app-omr-dscp.json b/luci-app-omr-dscp/root/usr/share/rpcd/acl.d/luci-app-omr-dscp.json old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/Makefile b/luci-app-omr-quota/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/luasrc/controller/quota.lua b/luci-app-omr-quota/luasrc/controller/quota.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/luasrc/model/cbi/quota/quota.lua b/luci-app-omr-quota/luasrc/model/cbi/quota/quota.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/luasrc/view/omr-quota/cbi-select-add.htm b/luci-app-omr-quota/luasrc/view/omr-quota/cbi-select-add.htm old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/de/omr-quota.po b/luci-app-omr-quota/po/de/omr-quota.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/de/omr-quota.po~ b/luci-app-omr-quota/po/de/omr-quota.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/fr/omr-quota.po b/luci-app-omr-quota/po/fr/omr-quota.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/fr/omr-quota.po~ b/luci-app-omr-quota/po/fr/omr-quota.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/it/omr-quota.po b/luci-app-omr-quota/po/it/omr-quota.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/it/omr-quota.po~ b/luci-app-omr-quota/po/it/omr-quota.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/oc/omr-quota.po b/luci-app-omr-quota/po/oc/omr-quota.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/oc/omr-quota.po~ b/luci-app-omr-quota/po/oc/omr-quota.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/ru/omr-quota.po b/luci-app-omr-quota/po/ru/omr-quota.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/templates/omr-quota.pot b/luci-app-omr-quota/po/templates/omr-quota.pot old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/zh_Hans/omr-quota.po b/luci-app-omr-quota/po/zh_Hans/omr-quota.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/po/zh_Hans/omr-quota.po~ b/luci-app-omr-quota/po/zh_Hans/omr-quota.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/root/usr/share/luci/menu.d/luci-app-omr-quota.json b/luci-app-omr-quota/root/usr/share/luci/menu.d/luci-app-omr-quota.json old mode 100755 new mode 100644 diff --git a/luci-app-omr-quota/root/usr/share/rpcd/acl.d/luci-app-omr-quota.json b/luci-app-omr-quota/root/usr/share/rpcd/acl.d/luci-app-omr-quota.json old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/Makefile b/luci-app-omr-tracker/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/luasrc/controller/omr-tracker.lua b/luci-app-omr-tracker/luasrc/controller/omr-tracker.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/luasrc/model/cbi/omr-tracker.lua b/luci-app-omr-tracker/luasrc/model/cbi/omr-tracker.lua old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/luasrc/view/omr-tracker/cbi-select-add.htm b/luci-app-omr-tracker/luasrc/view/omr-tracker/cbi-select-add.htm old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/de/omr-tracker.po b/luci-app-omr-tracker/po/de/omr-tracker.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/de/omr-tracker.po~ b/luci-app-omr-tracker/po/de/omr-tracker.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/fr/omr-tracker.po b/luci-app-omr-tracker/po/fr/omr-tracker.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/fr/omr-tracker.po~ b/luci-app-omr-tracker/po/fr/omr-tracker.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/it/omr-tracker.po b/luci-app-omr-tracker/po/it/omr-tracker.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/it/omr-tracker.po~ b/luci-app-omr-tracker/po/it/omr-tracker.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/oc/omr-tracker.po b/luci-app-omr-tracker/po/oc/omr-tracker.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/oc/omr-tracker.po~ b/luci-app-omr-tracker/po/oc/omr-tracker.po~ old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/templates/omr-tracker.pot b/luci-app-omr-tracker/po/templates/omr-tracker.pot old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/po/zh_Hans/omr-tracker.po b/luci-app-omr-tracker/po/zh_Hans/omr-tracker.po old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/root/etc/uci-defaults/42_luci-omr-tracker b/luci-app-omr-tracker/root/etc/uci-defaults/42_luci-omr-tracker old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/root/usr/share/luci/menu.d/luci-app-omr-tracker.json b/luci-app-omr-tracker/root/usr/share/luci/menu.d/luci-app-omr-tracker.json old mode 100755 new mode 100644 diff --git a/luci-app-omr-tracker/root/usr/share/rpcd/acl.d/luci-app-omr-tracker.json b/luci-app-omr-tracker/root/usr/share/rpcd/acl.d/luci-app-omr-tracker.json old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/Makefile b/luci-app-openmptcprouter/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/css/wanstatus.css b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/css/wanstatus.css old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-doing.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-doing.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-done.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-done.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-error.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-error.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-todo.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-todo.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-warn.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/status-warn.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/statusError.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/statusError.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/statusOK.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/statusOK.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/statusWarning.png b/luci-app-openmptcprouter/htdocs/luci-static/resources/openmptcprouter/images/statusWarning.png old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/htdocs/luci-static/resources/spinner.gif b/luci-app-openmptcprouter/htdocs/luci-static/resources/spinner.gif old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua b/luci-app-openmptcprouter/luasrc/controller/openmptcprouter.lua old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/backup.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/backup.htm old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/debug.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/debug.htm old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/settings.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/settings.htm old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wanstatus.htm old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm b/luci-app-openmptcprouter/luasrc/view/openmptcprouter/wizard.htm old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/de/openmptcprouter.po b/luci-app-openmptcprouter/po/de/openmptcprouter.po old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/de/openmptcprouter.po~ b/luci-app-openmptcprouter/po/de/openmptcprouter.po~ old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/fr/openmptcprouter.po b/luci-app-openmptcprouter/po/fr/openmptcprouter.po old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/fr/openmptcprouter.po~ b/luci-app-openmptcprouter/po/fr/openmptcprouter.po~ old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/it/openmptcprouter.po b/luci-app-openmptcprouter/po/it/openmptcprouter.po old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/it/openmptcprouter.po~ b/luci-app-openmptcprouter/po/it/openmptcprouter.po~ old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/oc/openmptcprouter.po b/luci-app-openmptcprouter/po/oc/openmptcprouter.po old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/oc/openmptcprouter.po~ b/luci-app-openmptcprouter/po/oc/openmptcprouter.po~ old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/templates/openmptcprouter.pot b/luci-app-openmptcprouter/po/templates/openmptcprouter.pot old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/zh_Hans/openmptcprouter.po b/luci-app-openmptcprouter/po/zh_Hans/openmptcprouter.po old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/po/zh_Hans/openmptcprouter.po~ b/luci-app-openmptcprouter/po/zh_Hans/openmptcprouter.po~ old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/root/bin/omr-modemmanager b/luci-app-openmptcprouter/root/bin/omr-modemmanager index d53865837..3cdbbda6f 100755 --- a/luci-app-openmptcprouter/root/bin/omr-modemmanager +++ b/luci-app-openmptcprouter/root/bin/omr-modemmanager @@ -6,13 +6,11 @@ timeout 1 mmcli -L | while read MODEM; do MODEM_ID=$(echo $MODEM | awk -F' ' '{print $1}' | awk -F/ '{print $6}') MODEM_INFO="$(timeout 1 mmcli -m $MODEM_ID --output-keyvalue)" if [ -n "$MODEM_INFO" ] && [ "$(echo "$MODEM_INFO" | grep 'modem.generic.device ' | awk -F": " '{print $2}')" = "$MODEM_INTF" ]; then - PERCENT=$(echo "$MODEM_INFO" | grep 'modem.generic.signal-quality.value ' | awk -F": " '{print $2}') - [ -z "$PERCENT" ] && PERCENT=$(awk -v n="$(mmcli -m $MODEM_ID --command 'AT+CSQ')" 'BEGIN{ print int(n*10) }') - OPERATOR=$(echo "$MODEM_INFO" | grep 'modem.3gpp.operator-name ' | awk -F": " '{print $2}') - [ -z "$OPERATOR" ] && OPERATOR=$(mmcli -m $MODEM_ID --command 'AT+QSPN' | awk -F[\"\"] '{ print $2 }') - NUMBER=$(echo "$MODEM_INFO" | grep 'modem.generic.own-numbders.value[1]' | awk -F": " '{print $2}') - STATE=$(echo "$MODEM_INFO" | grep 'modem.generic.state ' | awk -F": " '{print $2}') - TYPE=$(echo "$MODEM_INFO" | grep 'modem.generic.access-technologies.value\[1\]' | awk -F": " '{print $2}') + PERCENT=$(echo "$MODEM_INFO" | grep -m 1 'modem.generic.signal-quality.value ' | awk -F": " '{print $2}') + OPERATOR=$(echo "$MODEM_INFO" | grep -m 1 'modem.3gpp.operator-name ' | awk -F": " '{print $2}') + NUMBER=$(echo "$MODEM_INFO" | grep -m 1 'modem.generic.own-numbders.value[1]' | awk -F": " '{print $2}') + STATE=$(echo "$MODEM_INFO" | grep -m 1 'modem.generic.state ' | awk -F": " '{print $2}') + TYPE=$(echo "$MODEM_INFO" | grep -m 1 'modem.generic.access-technologies.value\[1\]' | awk -F": " '{print $2}') [ -z "$INFO" ] && echo $PERCENT [ "$INFO" = "all" ] && echo "$PERCENT;$OPERATOR;$NUMBER;$STATE;$TYPE" exit diff --git a/luci-app-openmptcprouter/root/etc/config/openmptcprouter b/luci-app-openmptcprouter/root/etc/config/openmptcprouter old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/root/usr/share/luci/menu.d/luci-app-openmptcprouter.json b/luci-app-openmptcprouter/root/usr/share/luci/menu.d/luci-app-openmptcprouter.json old mode 100755 new mode 100644 diff --git a/luci-app-openmptcprouter/root/usr/share/rpcd/acl.d/luci-app-openmptcprouter.json b/luci-app-openmptcprouter/root/usr/share/rpcd/acl.d/luci-app-openmptcprouter.json old mode 100755 new mode 100644 diff --git a/luci-app-ouad/LICENSE b/luci-app-ouad/LICENSE new file mode 100755 index 000000000..e963df829 --- /dev/null +++ b/luci-app-ouad/LICENSE @@ -0,0 +1,622 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + diff --git a/luci-app-ouad/Makefile b/luci-app-ouad/Makefile new file mode 100755 index 000000000..7f855b068 --- /dev/null +++ b/luci-app-ouad/Makefile @@ -0,0 +1,20 @@ +# +# Copyright (C) 2020 Nate Ding +# +# This is free software, licensed under the GUN General Public License v3. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +LUCI_Title:=LuCI support for ssd1306 0.91\' 138x32 display +LUCI_DEPENDS:=+i2c-tools +coreutils-nohup +libuci +LUCI_PKGARCH:=all + +PKG_LICENSE:=GPLv3 +PKG_LINCESE_FILES:=LICENSE +PKF_MAINTAINER:=natelol + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature diff --git a/luci-app-ouad/README.md b/luci-app-ouad/README.md new file mode 100755 index 000000000..8f78c1d2b --- /dev/null +++ b/luci-app-ouad/README.md @@ -0,0 +1,80 @@ +# luci-app-oled + +This is the LuCI app written for openwrt (**tested ~~only~~ on NanoPi R2S**) which supports ssd 1306 0.91' oled display. + +**Raspberry Pi CM4** + +This has been tested on Raspberry Pi CM4 as described in issue [#10](https://github.com/NateLol/luci-app-oled/issues/10#issuecomment-922245476). +You can find what revisions you need to make to have it work on your device. +Enjoy! + +## Features|功能 +--- +### Dispaly Info|显示信息 + +**0. Enable|开启** + +开启oled显示。 + +**1. Autoswitch|定时开关** + +由于夜间oled的显示屏太亮,并且也几乎不会看它,所以应邀提供定时开关的功能,选中autoswitch之后,可以设置**显示**的起始和结束时间。 + +**2. Time|时间** + +显示时间。 + +**3. IP|IP地址** + +显示LAN口的IP地址,记得LAN口不可以去除**桥接**选项,否则失效。由于使用的是`br-lan`,因为不同固件可能会交换`eth0`和`eth1`。 + +**4. CPU Temp|CPU温度** + +显示CPU温度。 + +**5. CPU Freq|CPU频率** + +显示实时CPU频率 + +**6. Network Speed|网速** + +提供不同接口的选择,`eth0`和`eth1`,个人可以按需修改。网速单位基准为字节(Byte)而不是一般的位(bit),[MB/s, KB/s, B/s]这样显示的数字能够比较小,不至于过长。 + +**7. Display Interval|显示间隔** + +为了延缓oled的光衰,提供屏保服务,每隔设定的时间运行一次屏保程序。 + +--- +### Screensavers|屏保 + +屏保提供不同的选择,默认推荐的是`Scroll Text|文字滚动`,其他的选择自行探索。 + +## Q&A + +Q0. 如何使用该程序?|在那里找到luci界面? + +A0. 该程序安装位置在luci界面的`services|服务`下的`OLED`,点击即可找到。 + +--- + +Q1. 是否会支持其他oled屏幕,例如同系列的0.96'的? + +A1. 由于开发者身边并没有相应的屏幕去调试,所以是暂时不考虑吧。如果你想贡献代码,非常欢迎,请开PR。 + +--- + + +Q2. 为什么我的IP地址显示错误? + +A2. 很大原因是你修改了LAN接口的属性,例如去除了该接口的**桥接**属性。 + +--- + + +Q3. 为什么我的oled不显示? + +A3. 很有可能是您的固件内核驱动不完整,该程序的运行需要在内核驱动中加上**kmod-i2c-xxx**,见issue [#10](https://github.com/NateLol/luci-app-oled/issues/10)。 + +--- + +如果你在使用过程中还遇到问题,请开issue。 diff --git a/luci-app-ouad/luasrc/controller/oled.lua b/luci-app-ouad/luasrc/controller/oled.lua new file mode 100755 index 000000000..554ceadd8 --- /dev/null +++ b/luci-app-ouad/luasrc/controller/oled.lua @@ -0,0 +1,17 @@ +module("luci.controller.oled", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/oled") then + return + end + entry({"admin", "services", "oled"}, alias("admin", "services", "oled", "setting"),_("OLED"), 90).dependent = true + entry({"admin", "services", "oled", "status"}, call("act_status")) + entry({"admin", "services", "oled", "setting"}, cbi("oled/setting"),_("Setting"),30).leaf = true +end + +function act_status() + local e={} + e.running = luci.sys.call("pgrep -f /usr/bin/oled > /dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci-app-ouad/luasrc/model/cbi/oled/setting.lua b/luci-app-ouad/luasrc/model/cbi/oled/setting.lua new file mode 100755 index 000000000..7204bc017 --- /dev/null +++ b/luci-app-ouad/luasrc/model/cbi/oled/setting.lua @@ -0,0 +1,84 @@ +m = Map("oled", translate("OLED"), translate("A LuCI app that helps you config your oled display (SSD1306, 0.91', 128X32) with screensavers!

Any issues, please go to: ")..[[luci-app-oled]]) + +--m.chain("luci") + +m:section(SimpleSection).template="oled/status" + +s = m:section(TypedSection, "oled", translate("")) +s.anonymous=true +s.addremove=false + +--OPTIONS +s:tab("info", translate("Info Display")) +s:tab("screensaver", translate("screensaver")) + +o = s:taboption("info", Flag, "enable", translate("Enable")) +o.default=0 +o = s:taboption("info", Value, "path", translate("I2C PATH")) +o.default='/dev/i2c-0' +o = s:taboption("info", Flag, "rotate", translate("180 degree rotation")) +o.default=0 +o = s:taboption("info", Flag, "autoswitch", translate("Enable Auto switch")) +o.default=0 +from = s:taboption("info", ListValue, "from", translate("From")) +to = s:taboption("info", ListValue, "to", translate("To")) +for i=0,23 do + for j=0,30,30 do + from:value(i*60+j,string.format("%02d:%02d",i,j)) + to:value(i*60+j,string.format("%02d:%02d",i,j)) + end +end +from:value(1440,"24:00") +to:value(1440,"24:00") +from:depends("autoswitch",'1') +to:depends("autoswitch",'1') +from.default=0 +to.default=1440 + +--informtion options---- +o = s:taboption("info", Flag, "date", translate("Date"), translate('Format YYYY-MM-DD HH:MM:SS')) +o.default=0 +o = s:taboption("info", Flag, "lanip", translate("IP"), translate("LAN IP address")) +o.default=0 +o = s:taboption("info", Flag, "cputemp", translate("CPU temperature")) +o.default=0 +o = s:taboption("info", Flag, "cpufreq", translate("CPU frequency")) +o.default=0 +o = s:taboption("info", Flag, "netspeed", translate("Network speed"), translate("1Mbps(m/s)=1,000Kbps(k/s)=1,000,000bps(b/s)")) +o.default=0 +o = s:taboption("info", Value, "netsource", translate("which eth to monitor")) +o:depends("netspeed",'1') +o.default='eth0' +o = s:taboption("info", Value, "time", translate("Display interval(s)"), translate('Screensaver will activate in set seconds')) +o.default=0 + +--screensaver options-- +o = s:taboption("screensaver", Flag, "scroll", translate("Scroll Text")) +o.default=1 +o = s:taboption("screensaver", Value, "text", translate("Text you want to scroll")) +o:depends("scroll",'1') +o.default='OPENWRT' +o = s:taboption("screensaver", Flag, "drawline", translate("Draw Many Lines")) +o.default=0 +o = s:taboption("screensaver", Flag, "drawrect", translate("Draw Rectangles")) +o.default=0 +o = s:taboption("screensaver", Flag, "fillrect", translate("Draw Multiple Rectangles")) +o.default=0 +o = s:taboption("screensaver", Flag, "drawcircle", translate("Draw Multiple Circles")) +o.default=0 +o = s:taboption("screensaver", Flag, "drawroundrect", translate("Draw a white circle, 10 pixel radius")) +o.default=0 +o = s:taboption("screensaver", Flag, "fillroundrect", translate("Fill the Round Rectangles")) +o.default=0 +o = s:taboption("screensaver", Flag, "drawtriangle", translate("Draw Triangles")) +o.default=0 +o = s:taboption("screensaver", Flag, "filltriangle", translate("Fill Triangles")) +o.default=0 +o = s:taboption("screensaver", Flag, "displaybitmap", translate("Display miniature bitmap")) +o.default=0 +o = s:taboption("screensaver", Flag, "displayinvertnormal", translate("Invert Display Normalize it")) +o.default=0 +o = s:taboption("screensaver", Flag, "drawbitmapeg", translate("Draw a bitmap and animate")) +o.default=0 + +return m diff --git a/luci-app-ouad/luasrc/view/oled/status.htm b/luci-app-ouad/luasrc/view/oled/status.htm new file mode 100755 index 000000000..0da0c6426 --- /dev/null +++ b/luci-app-ouad/luasrc/view/oled/status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+
diff --git a/luci-app-ouad/po/zh_Hans/oled.po b/luci-app-ouad/po/zh_Hans/oled.po new file mode 100755 index 000000000..ae01eab33 --- /dev/null +++ b/luci-app-ouad/po/zh_Hans/oled.po @@ -0,0 +1,154 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:1 +msgid "" +"A LuCI app that helps you config your oled display (SSD1306, 0.91', 128X32) " +"with screensavers!

Any issues, please go to:" +msgstr "" +"这是一款支持在ssd1306,0.91寸,128x32像素的oled显示屏上显示你要的信息,包含屏" +"保的程序。

任何问题请到:" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:24 +msgid "CPU frequency" +msgstr "CPU 频率" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:22 +msgid "CPU temperature" +msgstr "CPU 温度" + +msgid "Scroll Text" +msgstr "文字滚动" + +msgid "Enable Auto switch" +msgstr "启用定时开关" + +msgid "From" +msgstr "起始时间" + +msgid "To" +msgstr "结束时间" + +msgid "Text you want to scroll" +msgstr "你想要显示的文字" + +msgid "which eth to monitor" +msgstr "选择监控哪个网口" + +#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:20 +msgid "Collecting data..." +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:18 +msgid "Date" +msgstr "时间" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:48 +msgid "Display miniature bitmap" +msgstr "小图案" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:28 +msgid "Display interval(s)" +msgstr "信息显示间隔(秒)" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:28 +msgid "Screensaver will activate in set seconds" +msgstr "屏保每间隔设置的时间运行一次" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:32 +msgid "Draw Many Lines" +msgstr "直线" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:38 +msgid "Draw Multiple Circles" +msgstr "多圆" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:36 +msgid "Draw Multiple Rectangles" +msgstr "多方块" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:34 +msgid "Draw Rectangles" +msgstr "方块" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:44 +msgid "Draw Triangles" +msgstr "三角形" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:54 +msgid "Draw a bitmap and animate" +msgstr "动图" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:52 +msgid "Draw a bitmap and animate movement" +msgstr "变化图" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:40 +msgid "Draw a white circle, 10 pixel radius" +msgstr "实心圆" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:15 +msgid "Enable" +msgstr "启用" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:46 +msgid "Fill Triangles" +msgstr "三角填充" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:42 +msgid "Fill the Round Rectangles" +msgstr "方形填充" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:18 +msgid "Format YYYY-MM-DD HH:MM:SS" +msgstr "日期格式 YYYY-MM-DD HH:MM:SS" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:17 +msgid "I2C PATH" +msgstr "I2C 路径" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:20 +msgid "IP" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:12 +msgid "Info Display" +msgstr "显示信息" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:50 +msgid "Invert Display Normalize it" +msgstr "反转" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:20 +msgid "LAN IP address" +msgstr "LAN 地址" + +#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:10 +msgid "NOT RUNNING" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:26 +msgid "Network speed" +msgstr "网速" + +#: ../../package/new/luci-app-oled/luasrc/controller/oled.lua:7 +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:1 +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:7 +msgid "OLED" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:7 +msgid "RUNNING" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/controller/oled.lua:9 +msgid "Setting" +msgstr "设置" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:13 +msgid "screensaver" +msgstr "屏保" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:19 +msgid "180 degree rotation" +msgstr "180 度旋转" diff --git a/luci-app-ouad/po/zh_Hant/oled.po b/luci-app-ouad/po/zh_Hant/oled.po new file mode 100755 index 000000000..4a24e35fb --- /dev/null +++ b/luci-app-ouad/po/zh_Hant/oled.po @@ -0,0 +1,135 @@ +msgid "" +msgstr "Content-Type: text/plain; charset=UTF-8" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:1 +msgid "" +"A LuCI app that helps you config your oled display (SSD1306, 0.91', 128X32) " +"with screensavers!

Any issues, please go to:" +msgstr "這是壹款支持在ssd1306,0.91寸,128x32像素的oled顯示屏上顯示妳要的信息,包含屏保的程序。

任何問題請到:" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:24 +msgid "CPU frequency" +msgstr "CPU頻率" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:22 +msgid "CPU temperature" +msgstr "CPU溫度" + +msgid "Scroll Text" +msgstr "文字滾動" + +msgid "Text you want to scroll" +msgstr "妳想要顯示的文字" + +msgid "which eth to monitor" +msgstr "選擇監控哪個網口" + +#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:20 +msgid "Collecting data..." +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:18 +msgid "Date" +msgstr "時間" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:48 +msgid "Display miniature bitmap" +msgstr "小圖案" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:28 +msgid "Display interval(s)" +msgstr "信息顯示間隔(秒)" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:28 +msgid "Screensaver will activate in set seconds" +msgstr "屏保每間隔設置的時間運行壹次" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:32 +msgid "Draw Many Lines" +msgstr "直線" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:38 +msgid "Draw Multiple Circles" +msgstr "多圓" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:36 +msgid "Draw Multiple Rectangles" +msgstr "多方塊" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:34 +msgid "Draw Rectangles" +msgstr "方塊" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:44 +msgid "Draw Triangles" +msgstr "三角形" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:54 +msgid "Draw a bitmap and animate" +msgstr "動圖" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:52 +msgid "Draw a bitmap and animate movement" +msgstr "變化圖" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:40 +msgid "Draw a white circle, 10 pixel radius" +msgstr "實心圓" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:15 +msgid "Enable" +msgstr "啟用" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:46 +msgid "Fill Triangles" +msgstr "三角填充" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:42 +msgid "Fill the Round Rectangles" +msgstr "方形填充" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:18 +msgid "Format YYYY-MM-DD HH:MM:SS" +msgstr "日期格式 YYYY-MM-DD HH:MM:SS" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:20 +msgid "IP" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:12 +msgid "Info Display" +msgstr "顯示信息" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:50 +msgid "Invert Display Normalize it" +msgstr "反轉" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:20 +msgid "LAN IP address" +msgstr "LAN地址" + +#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:10 +msgid "NOT RUNNING" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:26 +msgid "Network speed" +msgstr "網速" + +#: ../../package/new/luci-app-oled/luasrc/controller/oled.lua:7 +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:1 +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:7 +msgid "OLED" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/view/oled/status.htm:7 +msgid "RUNNING" +msgstr "" + +#: ../../package/new/luci-app-oled/luasrc/controller/oled.lua:9 +msgid "Setting" +msgstr "設置" + +#: ../../package/new/luci-app-oled/luasrc/model/cbi/oled/setting.lua:13 +msgid "screensaver" +msgstr "屏保" diff --git a/luci-app-ouad/root/etc/config/oled b/luci-app-ouad/root/etc/config/oled new file mode 100755 index 000000000..e89ab41aa --- /dev/null +++ b/luci-app-ouad/root/etc/config/oled @@ -0,0 +1,27 @@ +config oled + option enable '0' + option drawline '0' + option drawrect '0' + option fillrect '0' + option drawcircle '0' + option drawroundrect '0' + option fillroundrect '0' + option drawtriangle '0' + option filltriangle '0' + option displaybitmap '0' + option displayinvertnormal '0' + option drawbitmapeg '0' + option date '1' + option netspeed '0' + option lanip '1' + option cpufreq '1' + option cputemp '1' + option time '60' + option from '0' + option to '1440' + option autoswitch '0' + option rotate '0' + option scroll '0' + option text 'OPENWRT' + option netsource 'eth0' + option path '/dev/i2c-0' diff --git a/luci-app-ouad/root/etc/init.d/oled b/luci-app-ouad/root/etc/init.d/oled new file mode 100755 index 000000000..6f61278f8 --- /dev/null +++ b/luci-app-ouad/root/etc/init.d/oled @@ -0,0 +1,138 @@ +#!/bin/sh /etc/rc.common +START=88 + +PROG=/usr/bin/oled + +stop() { + kill -2 $(pgrep /usr/bin/oled) + kill -9 $(pgrep -f /usr/sbin/netspeed) + echo "oled exit..." +} + +start() { + enabled=$(uci get oled.@oled[0].enable) + if [ $enabled -eq 0 ]; then + exit 0 + fi + + autoswitch=$(uci get oled.@oled[0].autoswitch) + from=$(uci get oled.@oled[0].from) + to=$(uci get oled.@oled[0].to) + + if [ ${autoswitch} -eq 1 ]; then + hour=$(date +"%H") + min=$(date +"%M") + ihour=`expr $hour + 0` + imin=`expr $min + 0` + now=$(($ihour*60+$imin)) + if [[ $now -lt $from || $now -gt $to ]]; then + stop + exit 0 + fi + fi + + #crontab daemon + if ! grep "/etc/init.d/oled \+restart" /etc/crontabs/root >/dev/null 2>&1; then + echo "*/5 * * * * /etc/init.d/oled restart >/dev/null 2>&1" >> /etc/crontabs/root + fi + + date=$(uci get oled.@oled[0].date) + lanip=$(uci get oled.@oled[0].lanip) + cputemp=$(uci get oled.@oled[0].cputemp) + cpufreq=$(uci get oled.@oled[0].cpufreq) + netspeed=$(uci get oled.@oled[0].netspeed) + time=$(uci get oled.@oled[0].time) + drawline=$(uci get oled.@oled[0].drawline) + drawrect=$(uci get oled.@oled[0].drawrect) + fillrect=$(uci get oled.@oled[0].fillrect) + drawcircle=$(uci get oled.@oled[0].drawcircle) + drawroundrect=$(uci get oled.@oled[0].drawroundrect) + fillroundrect=$(uci get oled.@oled[0].fillroundrect) + drawtriangle=$(uci get oled.@oled[0].drawtriangle) + filltriangle=$(uci get oled.@oled[0].filltriangle) + displaybitmap=$(uci get oled.@oled[0].displaybitmap) + displayinvertnormal=$(uci get oled.@oled[0].displayinvertnormal) + drawbitmapeg=$(uci get oled.@oled[0].drawbitmapeg) + rotate=$(uci get oled.@oled[0].rotate) + scroll=$(uci get oled.@oled[0].scroll) + text=$(uci get oled.@oled[0].text) + netsource=$(uci get oled.@oled[0].netsource) + path=$(uci get oled.@oled[0].path) + + if [ ${netspeed} -eq 1 ]; then + nohup /usr/sbin/netspeed ${netsource} >/dev/null 2>&1 & + else + kill -9 $(pgrep -f /usr/sbin/netspeed) + rm -f /tmp/netspeed + fi + nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" "${path}" ${rotate} 1 > /dev/null 2>&1 & +} + +restart() { + enabled=$(uci get oled.@oled[0].enable) + pgrep -f ${PROG} >/dev/null + if [ $? -eq 0 ]; then + if [ $enabled -eq 1 ]; then + autoswitch=$(uci get oled.@oled[0].autoswitch) + from=$(uci get oled.@oled[0].from) + to=$(uci get oled.@oled[0].to) + if [ ${autoswitch} -eq 1 ]; then + hour=$(date +"%H") + min=$(date +"%M") + ihour=`expr $hour + 0` + imin=`expr $min + 0` + now=$(($ihour*60+$imin)) + if [[ $now -lt $from || $now -gt $to ]]; then + stop + exit 0 + fi + fi + + date=$(uci get oled.@oled[0].date) + lanip=$(uci get oled.@oled[0].lanip) + cputemp=$(uci get oled.@oled[0].cputemp) + cpufreq=$(uci get oled.@oled[0].cpufreq) + netspeed=$(uci get oled.@oled[0].netspeed) + time=$(uci get oled.@oled[0].time) + drawline=$(uci get oled.@oled[0].drawline) + drawrect=$(uci get oled.@oled[0].drawrect) + fillrect=$(uci get oled.@oled[0].fillrect) + drawcircle=$(uci get oled.@oled[0].drawcircle) + drawroundrect=$(uci get oled.@oled[0].drawroundrect) + fillroundrect=$(uci get oled.@oled[0].fillroundrect) + drawtriangle=$(uci get oled.@oled[0].drawtriangle) + filltriangle=$(uci get oled.@oled[0].filltriangle) + displaybitmap=$(uci get oled.@oled[0].displaybitmap) + displayinvertnormal=$(uci get oled.@oled[0].displayinvertnormal) + drawbitmapeg=$(uci get oled.@oled[0].drawbitmapeg) + rotate=$(uci get oled.@oled[0].rotate) + scroll=$(uci get oled.@oled[0].scroll) + text=$(uci get oled.@oled[0].text) + netsource=$(uci get oled.@oled[0].netsource) + path=$(uci get oled.@oled[0].path) + + kill -9 $(pgrep /usr/bin/oled) + kill -9 $(pgrep -f /usr/sbin/netspeed) + + if [ ${netspeed} -eq 1 ]; then + nohup /usr/sbin/netspeed ${netsource} >/dev/null 2>&1 & + else + kill -9 $(pgrep -f /usr/sbin/netspeed) + rm -f /tmp/netspeed + fi + nohup ${PROG} ${date} ${lanip} ${cputemp} ${cpufreq} ${netspeed} ${time} ${drawline} ${drawrect} ${fillrect} ${drawcircle} ${drawroundrect} ${fillroundrect} ${drawtriangle} ${filltriangle} ${displaybitmap} ${displayinvertnormal} ${drawbitmapeg} ${scroll} "${text}" "${netsource}" "${path}" ${rotate} 0 > /dev/null 2>&1 & + else + stop + fi + else + if [ $enabled -eq 1 ]; then + start + else + exit 0 + fi + fi +} + +boot() { + start +} diff --git a/luci-app-ouad/root/etc/uci-defaults/oled b/luci-app-ouad/root/etc/uci-defaults/oled new file mode 100755 index 000000000..2e6ae5c01 --- /dev/null +++ b/luci-app-ouad/root/etc/uci-defaults/oled @@ -0,0 +1,25 @@ +#!/bin/sh + +uci_write_config() { + uci -q set oled.@oled[0].path="$1" + uci -q set oled.@oled[0].rotate="$2" + uci -q commit oled +} + +. /lib/functions/system.sh + +case "$(board_name)" in +hinlink,opc-h69k) + uci_write_config '/dev/i2c-5' 1 + ;; +esac + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@oled[-1] + add ucitrack oled + set ucitrack.@oled[-1].init=oled + commit ucitrack +EOF + +rm -rf /tmp/luci-* +exit 0 diff --git a/luci-app-ouad/root/usr/sbin/netspeed b/luci-app-ouad/root/usr/sbin/netspeed new file mode 100755 index 000000000..6be8ca48d --- /dev/null +++ b/luci-app-ouad/root/usr/sbin/netspeed @@ -0,0 +1,20 @@ +#!/bin/ash +IF=$1 +if [ -z "$IF" ]; then + IF=`ls -1 /sys/class/net/ | head -1` +fi +RXPREV=-1 +TXPREV=-1 +echo "Listening $IF..." +while [ 1 == 1 ] ; do + RX=`cat /sys/class/net/${IF}/statistics/rx_bytes` + TX=`cat /sys/class/net/${IF}/statistics/tx_bytes` + if [ $RXPREV -ne -1 ] ; then + let BWRX=$RX-$RXPREV + let BWTX=$TX-$TXPREV + echo "$BWRX $BWTX">/tmp/netspeed + fi + RXPREV=$RX + TXPREV=$TX + sleep 1 +done diff --git a/luci-app-ouad/root/usr/share/rpcd/acl.d/luci-app-oled.json b/luci-app-ouad/root/usr/share/rpcd/acl.d/luci-app-oled.json new file mode 100755 index 000000000..7c436b871 --- /dev/null +++ b/luci-app-ouad/root/usr/share/rpcd/acl.d/luci-app-oled.json @@ -0,0 +1,11 @@ +{ + "luci-app-oled": { + "description": "Grant UCI access for luci-app-oled", + "read": { + "uci": [ "oled" ] + }, + "write": { + "uci": [ "oled" ] + } + } +} diff --git a/luci-app-ouad/src/Example_Code/Main.c b/luci-app-ouad/src/Example_Code/Main.c new file mode 100755 index 000000000..2ec3e610e --- /dev/null +++ b/luci-app-ouad/src/Example_Code/Main.c @@ -0,0 +1,238 @@ +/* + * Main.c + * + * Created on : Sep 6, 2017 + * Author : Vinay Divakar + * Description : Example usage of the SSD1306 Driver API's + * Website : www.deeplyembedded.org + */ + +/* Lib Includes */ +#include +#include +#include +#include +#include + +/* Header Files */ +#include "I2C.h" +#include "SSD1306_OLED.h" +#include "example_app.h" + +/* Oh Compiler-Please leave me as is */ +volatile unsigned char flag = 0; + +/* Alarm Signal Handler */ +void ALARMhandler(int sig) +{ + /* Set flag */ + flag = 5; +} + +void BreakDeal(int sig) +{ + clearDisplay(); + usleep(1000000); + Display(); + exit(0); +} + +int main(int argc, char* argv[]) +{ + int date=atoi(argv[1]); + int lanip=atoi(argv[2]); + int cputemp=atoi(argv[3]); + int cpufreq=atoi(argv[4]); + int netspeed=atoi(argv[5]); + int time=atoi(argv[6]); + int drawline=atoi(argv[7]); + int drawrect=atoi(argv[8]); + int fillrect=atoi(argv[9]); + int drawcircle=atoi(argv[10]); + int drawroundcircle=atoi(argv[11]); + int fillroundcircle=atoi(argv[12]); + int drawtriangle=atoi(argv[13]); + int filltriangle=atoi(argv[14]); + int displaybitmap=atoi(argv[15]); + int displayinvertnormal=atoi(argv[16]); + int drawbitmapeg=atoi(argv[17]); + int scroll=atoi(argv[18]); + char *text=argv[19]; + char *eth=argv[20]; + char *path=argv[21]; + int rotate=atoi(argv[22]); + int needinit=atoi(argv[23]); + + if(path == NULL) + path = I2C_DEV0_PATH; + + /* Initialize I2C bus and connect to the I2C Device */ + if(init_i2c_dev(path, SSD1306_OLED_ADDR) == 0) + { + printf("I2C: Bus Connected to SSD1306\r\n"); + } + else + { + printf("I2C: OOPS! Something Went Wrong\r\n"); + exit(1); + } + + /* Register the Alarm Handler */ + signal(SIGALRM, ALARMhandler); + signal(SIGINT, BreakDeal); + //signal(SIGTERM, BreakDeal); + + /* Run SDD1306 Initialization Sequence */ + if (needinit==1) + display_Init_seq(); + + if (rotate==1) + display_rotate(); + else + display_normal(); + + /* Clear display */ + clearDisplay(); + + // draw a single pixel +// drawPixel(0, 1, WHITE); +// Display(); +// usleep(1000000); +// clearDisplay(); + + // draw many lines + while(1){ + if(scroll){ + testscrolltext(text); + usleep(1000000); + clearDisplay(); + } + + if(drawline){ + testdrawline(); + usleep(1000000); + clearDisplay(); + } + + // draw rectangles + if(drawrect){ + testdrawrect(); + usleep(1000000); + clearDisplay(); + } + + // draw multiple rectangles + if(fillrect){ + testfillrect(); + usleep(1000000); + clearDisplay(); + } + + // draw mulitple circles + if(drawcircle){ + testdrawcircle(); + usleep(1000000); + clearDisplay(); + } + + // draw a white circle, 10 pixel radius + if(drawroundcircle){ + testdrawroundrect(); + usleep(1000000); + clearDisplay(); + } + + // Fill the round rectangle + if(fillroundcircle){ + testfillroundrect(); + usleep(1000000); + clearDisplay(); + } + + // Draw triangles + if(drawtriangle){ + testdrawtriangle(); + usleep(1000000); + clearDisplay(); + } + // Fill triangles + if(filltriangle){ + testfilltriangle(); + usleep(1000000); + clearDisplay(); + } + + // Display miniature bitmap + if(displaybitmap){ + display_bitmap(); + Display(); + usleep(1000000); + }; + + // Display Inverted image and normalize it back + if(displayinvertnormal){ + display_invert_normal(); + clearDisplay(); + usleep(1000000); + Display(); + } + + // Generate Signal after 20 Seconds + + // draw a bitmap icon and 'animate' movement + if(drawbitmapeg){ + alarm(10); + flag=0; + testdrawbitmap_eg(); + clearDisplay(); + usleep(1000000); + Display(); + } + + //setCursor(0,0); + setTextColor(WHITE); + + // info display + int sum = date+lanip+cpufreq+cputemp+netspeed; + if (sum == 0) { + clearDisplay(); + return 0; + } + + for(int i = 1; i < time; i++){ + if (sum == 1){//only one item for display + if (date) testdate(CENTER, 8); + if (lanip) testlanip(CENTER, 8); + if (cpufreq) testcpufreq(CENTER, 8); + if (cputemp) testcputemp(CENTER, 8); + if (netspeed) testnetspeed(SPLIT,0); + Display(); + usleep(1000000); + clearDisplay(); + }else if (sum == 2){//two items for display + if(date) {testdate(CENTER, 16*(date-1));} + if(lanip) {testlanip(CENTER, 16*(date+lanip-1));} + if(cpufreq) {testcpufreq(CENTER, 16*(date+lanip+cpufreq-1));} + if(cputemp) {testcputemp(CENTER, 16*(date+lanip+cpufreq+cputemp-1));} + if(netspeed) {testnetspeed(MERGE, 16*(date+lanip+cpufreq+cputemp+netspeed-1));} + Display(); + usleep(1000000); + clearDisplay(); + }else{//more than two items for display + if(date) {testdate(FULL, 8*(date-1));} + if(lanip) {testlanip(FULL, 8*(date+lanip-1));} + if(cpufreq && cputemp) { + testcpu(8*(date+lanip)); + if(netspeed) {testnetspeed(FULL, 8*(date+lanip+1+netspeed-1));} + }else{ + if(cpufreq) {testcpufreq(FULL, 8*(date+lanip+cpufreq-1));} + if(cputemp) {testcputemp(FULL, 8*(date+lanip+cpufreq+cputemp-1));} + if(netspeed) {testnetspeed(FULL, 8*(date+lanip+cpufreq+cputemp+netspeed-1));} + } + Display(); + usleep(1000000); + clearDisplay(); + } + } + } +} diff --git a/luci-app-ouad/src/Example_Code/example_app.c b/luci-app-ouad/src/Example_Code/example_app.c new file mode 100755 index 000000000..9ce62d025 --- /dev/null +++ b/luci-app-ouad/src/Example_Code/example_app.c @@ -0,0 +1,650 @@ +/* + * MIT License + +Copyright (c) 2017 DeeplyEmbedded + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + * example_app.c + * + * Created on : Sep 6, 2017 + * Author : Vinay Divakar + * Website : www.deeplyembedded.org + */ + +/* Lib Includes */ +#include +#include +#include +#include +#include +#include +#include +#include "SSD1306_OLED.h" +#include "example_app.h" + +#define BUFMAX SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT + +/* MACRO's */ +#define LOGO16_GLCD_HEIGHT 16 +#define LOGO16_GLCD_WIDTH 16 +#define NUMFLAKES 10 +#define XPOS 0 +#define YPOS 1 +#define DELTAY 2 + + + +#define TIMESIZE 64 +//temperature +#define TEMPPATH "/sys/class/thermal/thermal_zone0/temp" +#define TEMPSIZE 5 +//cpu +#define FREQSIZE 8 +#define FREQPATH "cat /sys/devices/system/cpu/cpu[04]/cpufreq/cpuinfo_cur_freq" +//ip +#define IPPATH "ifconfig br-lan|grep 'inet addr:'|cut -d: -f2|awk '{print $1}'" +#define IPSIZE 20 +//netspeed +#define NETPATH "cat /tmp/netspeed" + +/* Extern volatile */ +extern volatile unsigned char flag; + +/* Bit Map - Taken from Adafruit SSD1306 OLED Library */ +static const unsigned char logo16_glcd_bmp[] = +{ + 0b00000000, 0b11000000, + 0b00000001, 0b11000000, + 0b00000001, 0b11000000, + 0b00000011, 0b11100000, + 0b11110011, 0b11100000, + 0b11111110, 0b11111000, + 0b01111110, 0b11111111, + 0b00110011, 0b10011111, + 0b00011111, 0b11111100, + 0b00001101, 0b01110000, + 0b00011011, 0b10100000, + 0b00111111, 0b11100000, + 0b00111111, 0b11110000, + 0b01111100, 0b11110000, + 0b01110000, 0b01110000, + 0b00000000, 0b00110000 +}; + +FILE *fp; +char content_buff[BUFMAX]; +char buf[BUFMAX]; +int display_offset =7; +/* draw many lines */ +void testdrawline() +{ + short i = 0; + for (i=0; i=0; i-=4) + { + drawLine(0, SSD1306_LCDHEIGHT-1, SSD1306_LCDWIDTH-1, i, WHITE); + Display(); + usleep(1000); + } + usleep(250000); + + clearDisplay(); + for (i=SSD1306_LCDWIDTH-1; i>=0; i-=4) + { + drawLine(SSD1306_LCDWIDTH-1, SSD1306_LCDHEIGHT-1, i, 0, WHITE); + Display(); + usleep(1000); + } + for (i=SSD1306_LCDHEIGHT-1; i>=0; i-=4) + { + drawLine(SSD1306_LCDWIDTH-1, SSD1306_LCDHEIGHT-1, 0, i, WHITE); + Display(); + usleep(1000); + } + usleep(250000); + + clearDisplay(); + for (i=0; i0; i-=5) + { + fillTriangle(SSD1306_LCDWIDTH/2, SSD1306_LCDHEIGHT/2-i, + SSD1306_LCDWIDTH/2-i, SSD1306_LCDHEIGHT/2+i, + SSD1306_LCDWIDTH/2+i, SSD1306_LCDHEIGHT/2+i, WHITE); + if (color == WHITE) + color = BLACK; + else + color = WHITE; + Display(); + usleep(1000); + } +} + +/* Display a bunch of characters and emoticons */ +void testdrawchar() +{ + unsigned char i = 0; + setTextSize(1); + setTextColor(WHITE); + setCursor(0,0); + + for (i=0; i < 168; i++) + { + if (i == '\n') + continue; + oled_write(i); + if ((i > 0) && (i % 21 == 0)) + println(); + } + Display(); + usleep(1000); +} + +/* Display "scroll" and scroll around */ +void testscrolltext(char* str) +{ + setTextSize(2); + setTextColor(WHITE); + setCursor(10,8); + sprintf(buf,"%s",str); + print_strln(buf); + Display(); + usleep(1000); + startscrollright(0x00, 0x0F); + usleep(5000000); + stopscroll(); + usleep(1000000); + startscrollleft(0x00, 0x0F); + usleep(5000000); + stopscroll(); + usleep(1000000); + startscrolldiagright(0x00, 0x07); + usleep(5000000); + startscrolldiagleft(0x00, 0x07); + usleep(5000000); + stopscroll(); +} + + + +/* Display Texts */ +void display_texts() +{ + setTextSize(1); + setTextColor(WHITE); + setCursor(10,0); + print_str("HELLO FELLAS!"); + println(); + printFloat_ln(3.141592, 4); //Print 4 No's after the decimal Pt. + printNumber_L_ln(-1234, DEC); + printNumber_UC_ln(170, BIN); + setTextSize(2); + setTextColor(WHITE); + print_str("0x"); + printNumber_UL_ln(0xDEADBEEF, HEX); +} + +/* Display miniature bitmap */ +void display_bitmap() +{ + drawBitmap(30, 16, logo16_glcd_bmp, 16, 16, 1); +} + +/* Invert Display and Normalize it */ +void display_invert_normal() +{ + invertDisplay(SSD1306_INVERT_DISPLAY); + usleep(1000000); + invertDisplay(SSD1306_NORMALIZE_DISPLAY); + usleep(1000000); +} + +/* Draw a bitmap and 'animate' movement */ +void testdrawbitmap(const unsigned char *bitmap, unsigned char w, unsigned char h) +{ + unsigned char icons[NUMFLAKES][3], f = 0; + + // initialize + for (f=0; f< NUMFLAKES; f++) + { + icons[f][XPOS] = rand() % SSD1306_LCDWIDTH; + icons[f][YPOS] = 0; + icons[f][DELTAY] = (rand() % 5) + 1; + + /* Looks kinna ugly to me - Un-Comment if you need it */ + //print_str("x: "); + //printNumber_UC(icons[f][XPOS], DEC); + //print_str("y: "); + //printNumber_UC(icons[f][YPOS], DEC); + //print_str("dy: "); + //printNumber_UC(icons[f][DELTAY], DEC); + } + + while (flag != 5) + { + // draw each icon + for (f=0; f< NUMFLAKES; f++) + { + drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, WHITE); + } + Display(); + usleep(200000); + + // then erase it + move it + for (f=0; f< NUMFLAKES; f++) + { + drawBitmap(icons[f][XPOS], icons[f][YPOS], bitmap, w, h, BLACK); + + // move it + icons[f][YPOS] += icons[f][DELTAY]; + + // if its gone, reinit + if (icons[f][YPOS] > SSD1306_LCDHEIGHT) + { + icons[f][XPOS] = rand() % SSD1306_LCDWIDTH; + icons[f][YPOS] = 0; + icons[f][DELTAY] = (rand() % 5) + 1; + } + } + } +} + +/* Draw bitmap and animate */ +void testdrawbitmap_eg() +{ + setTextSize(1); + setTextColor(WHITE); + setCursor(10,0); + testdrawbitmap(logo16_glcd_bmp, LOGO16_GLCD_HEIGHT, LOGO16_GLCD_WIDTH); +} + +/* Intro */ +void deeplyembedded_credits() +{ + setTextSize(1); + setTextColor(WHITE); + setCursor(1,0); + print_strln("deeplyembedded.org"); + println(); + print_strln("Author:Vinay Divakar"); + println(); + println(); + print_strln("THANK YOU"); +} + + +void testdate(int mode, int y) +{ + time_t rawtime; + time_t curtime; + uint8_t timebuff[TIMESIZE]; + curtime = time(NULL); + time(&rawtime); + switch (mode) + { + case CENTER: + setTextSize(2); + strftime(timebuff,80,"%H:%M",localtime(&rawtime)); + sprintf(buf,"%s",timebuff); + setCursor((127-strlen(buf)*11)/2-4, y); + break; + case FULL: + setTextSize(1); + strftime(timebuff,80,"%Y-%m-%d %H:%M:%S",localtime(&rawtime)); + sprintf(buf,"%s",timebuff); + setCursor(display_offset, y); + } + print_strln(buf); +} + + +void testlanip(int mode, int y) +{ + setTextSize(1); + if((fp=popen(IPPATH,"r"))!=NULL) + { + fscanf(fp,"%s",content_buff); + fclose(fp); + //ipbuff[strlen(ipbuff)-1]=32; + switch(mode) + { + case CENTER: + setTextSize(1); + sprintf(buf,"%s",content_buff); + setCursor((127-strlen(buf)*6)/2, y+4); + break; + + case FULL: + setTextSize(1); + sprintf(buf,"IP:%s",content_buff); + setCursor(display_offset, y); + } + print_strln(buf); + } + +} + + +void testcputemp(int mode, int y) +{ + if((fp=fopen(TEMPPATH,"r"))!=NULL) + { + fgets(content_buff,TEMPSIZE,fp); + fclose(fp); + switch (mode) + { + case CENTER: + setTextSize(2); + sprintf(buf, "%.2f",atoi(content_buff)/100.0); + setCursor((127-(strlen(buf)+2)*11)/2-4, y); + print_str(buf); + oled_write(0); + oled_write(67); + drawCircle(getCursorX()-16, getCursorY()+3, 2, WHITE); + break; + case FULL: + setTextSize(1); + sprintf(buf,"CPU TEMP:%.2f",atoi(content_buff)/100.0); + setCursor(display_offset, y); + print_str(buf); + oled_write(0); + oled_write(67); + drawCircle(getCursorX()-8, getCursorY()+1, 1, WHITE); + } + + } + +} + + +void testcpufreq(int mode, int y) +{ + if((fp=popen(FREQPATH,"r")) != NULL) + { + fgets(content_buff,FREQSIZE,fp); + fclose(fp); + switch(mode) + { + case CENTER: + setTextSize(2); + sprintf(buf,"%4dMHz",atoi(content_buff)/1000); + setCursor((127-strlen(buf)*11)/2-4, y); + break; + case FULL: + setTextSize(1); + sprintf(buf,"CPU FREQ:%4dMHz",atoi(content_buff)/1000); + setCursor(display_offset, y); + } + print_strln(buf); + } + +} + +void testnetspeed(int mode, int y) +{ + int rx,tx; + if((fp=popen(NETPATH,"r")) != NULL) + { + fscanf(fp,"%d %d", &rx, &tx); + fclose(fp); + rx = rx; + tx = tx; + switch(mode) + { + case SPLIT: + setTextSize(2); + if (tx < 1000) sprintf(buf, "%03dB", tx); + else if (tx > 1000000) sprintf(buf, "%03dM", tx/1000000); + else sprintf(buf, "%03dK", tx/1000); + setCursor((127-(strlen(buf)+1)*11)/2,0); + oled_write(24); + print_str(buf); + + if (rx < 1000) sprintf(buf, "%03dB", rx); + else if (rx > 1000000) sprintf(buf, "%03dM", rx/1000000); + else sprintf(buf, "%03dK", rx/1000); + setCursor((127-(strlen(buf)+1)*11)/2,16); + oled_write(25); + print_str(buf); + break; + case MERGE: + setTextSize(1); + if (tx < 1000) sprintf(buf, "%03dB ", tx); + else if (tx > 1000000) sprintf(buf, "%03dM", tx/1000000); + else sprintf(buf, "%03dK ", tx/1000); + setCursor((127-(2*strlen(buf)-1)*6)/2-4, y+4); + oled_write(24); + print_str(buf); + + if (rx < 1000) sprintf(buf, "%03dB", rx); + else if (rx > 1000000) sprintf(buf, "%03dM", rx/1000000); + else sprintf(buf, "%03dK", rx/1000); + oled_write(25); + print_str(buf); + break; + case FULL: + setTextSize(1); + setCursor(display_offset, y); + oled_write(24); + if (tx < 1000) sprintf(buf, "%03dB ", tx); + else if (tx > 1000000) sprintf(buf, "%03dM", tx/1000000); + else sprintf(buf, "%03dK ", tx/1000); + print_str(buf); + + oled_write(25); + if (rx < 1000) sprintf(buf, "%03dB", rx); + else if (rx > 1000000) sprintf(buf, "%03dM", rx/1000000); + else sprintf(buf, "%03dK", rx/1000); + print_str(buf); + } + } +} +void testcpu(int y) +{ +//freq + setTextSize(1); + setCursor(display_offset, y); + if((fp=popen(FREQPATH,"r")) != NULL) + { + fgets(content_buff,FREQSIZE,fp); + fclose(fp); + sprintf(buf,"CPU:%4dMHz ", atoi(content_buff)/1000); + print_str(buf); + } + + +//temp + if((fp=fopen(TEMPPATH,"r"))!=NULL) + { + fgets(content_buff,TEMPSIZE,fp); + fclose(fp); + sprintf(buf, "%.2f",atoi(content_buff)/100.0); + print_str(buf); + oled_write(0); + oled_write(67); + drawCircle(getCursorX()-8, getCursorY()+1, 1, WHITE); + } +} + +void testprintinfo() +{ + setTextSize(1); + setTextColor(WHITE); + setCursor(0,0); +//DATE + + time_t rawtime; + time_t curtime; + uint8_t timebuff[TIMESIZE]; + curtime = time(NULL); + time(&rawtime); + strftime(timebuff,80,"%Y-%m-%d_%w %H:%M:%S",localtime(&rawtime)); + sprintf(buf,"%s",timebuff); + print_strln(buf); + + //br-lan ip + if((fp=popen(IPPATH,"r"))!=NULL) + { + fscanf(fp,"%s",content_buff); + fclose(fp); + //ipbuff[strlen(ipbuff)-1]=32; + sprintf(buf,"IP:%s",content_buff); + print_strln(buf); + } + + //CPU temp + if((fp=popen(FREQPATH,"r")) != NULL) + { + fgets(content_buff,FREQSIZE,fp); + fclose(fp); + sprintf(buf,"CPU freq:%d MHz ",atoi(content_buff)/1000); + print_strln(buf); + } + + //cpu freq + if((fp=fopen(TEMPPATH,"r"))!=NULL) + { + fgets(content_buff,TEMPSIZE,fp); + fclose(fp); + sprintf(buf,"CPU temp:%.2f C",atoi(content_buff)/100.0); + print_strln(buf); + } + + + +} + diff --git a/luci-app-ouad/src/Example_Code/example_app.h b/luci-app-ouad/src/Example_Code/example_app.h new file mode 100755 index 000000000..eb0435826 --- /dev/null +++ b/luci-app-ouad/src/Example_Code/example_app.h @@ -0,0 +1,30 @@ +#define CENTER 0 //single item display +#define SPLIT 1 //two items +#define MERGE 2 +#define FULL 3 + +void testdrawline(); +void testdrawrect(); +void testfillrect(); +void testdrawcircle(); +void testdrawroundrect(); +void testfillroundrect(); +void testdrawtriangle(); +void testfilltriangle(); +void testdrawchar(); +void testscrolltext(char *str); +void display_texts(); +void display_bitmap(); +void display_invert_normal(); +void testdrawbitmap(const unsigned char *bitmap, unsigned char w, unsigned char h); +void testdrawbitmap_eg(); +void deeplyembedded_credits(); +void testprintinfo(); +void testdate(int mode, int y); +void testlanip(int mode, int y); +void testcpufreq(int mode, int y); +void testcputemp(int mode, int y); +void testnetspeed(int mode, int y); +void testcpu(int y); + + diff --git a/luci-app-ouad/src/I2C_Library/I2C.c b/luci-app-ouad/src/I2C_Library/I2C.c new file mode 100755 index 000000000..7177f8424 --- /dev/null +++ b/luci-app-ouad/src/I2C_Library/I2C.c @@ -0,0 +1,281 @@ +/* + * MIT License + +Copyright (c) 2017 DeeplyEmbedded + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + * I2C.c + * + * Created on : September 19, 2017 + * Author : Vinay Divakar + * Description : This is an I2C Library for the BeagleBone that consists of the API's to support the standard + * I2C operations. + * Website : www.deeplyembedded.org + */ + +/*Libs Includes*/ +#include +#include +#include +#include +#include +// heuristic to guess what version of i2c-dev.h we have: +// the one installed with `apt-get install libi2c-dev` +// would conflict with linux/i2c.h, while the stock +// one requires linus/i2c.h +#ifndef I2C_SMBUS_BLOCK_MAX +// If this is not defined, we have the "stock" i2c-dev.h +// so we include linux/i2c.h +#include +typedef unsigned char i2c_char_t; +#else +typedef char i2c_char_t; +#endif + +/* Header Files */ +#include "I2C.h" + + +/* Exposed objects for i2c-x */ +I2C_DeviceT I2C_DEV_2; + +/**************************************************************** + * Function Name : Open_device + * Description : Opens the I2C device to use + * Returns : 0 on success, -1 on failure + * Params @i2c_dev_path: Path to the I2C device + * @fd: Variable to store the file handler + ****************************************************************/ +int Open_device(char *i2c_dev_path, int *fd) +{ + if((*fd = open(i2c_dev_path, O_RDWR))<0) + return -1; + else + return 0; +} + + +/**************************************************************** + * Function Name : Close_device + * Description : Closes the I2C device in use + * Returns : 0 on success, -1 on failure + * Params : @fd: file descriptor + ****************************************************************/ +int Close_device(int fd) +{ + if(close(fd) == -1) + return -1; + else + return 0; +} + + +/**************************************************************** + * Function Name : Set_slave_addr + * Description : Connect to the Slave device + * Returns : 0 on success, -1 on failure + * Params @fd: File descriptor + * @slave_addr: Address of the slave device to + * talk to. + ****************************************************************/ +int Set_slave_addr(int fd, unsigned char slave_addr) +{ + if(ioctl(fd, I2C_SLAVE, slave_addr) < 0) + return -1; + else + return 0; +} + + +/**************************************************************** + * Function Name : i2c_write + * Description : Write a byte on SDA + * Returns : No. of bytes written on success, -1 on failure + * Params @fd: File descriptor + * @data: data to write on SDA + ****************************************************************/ +int i2c_write(int fd, unsigned char data) +{ + int ret = 0; + ret = write(fd, &data, I2C_ONE_BYTE); + if((ret == -1) || (ret != 1)) + return -1; + else + return(ret); +} + + +/**************************************************************** + * Function Name : i2c_read + * Description : Read a byte on SDA + * Returns : No. of bytes read on success, -1 on failure + * Params @fd: File descriptor + * @read_data: Points to the variable that stores + * the read data byte + ****************************************************************/ +int i2c_read(int fd, unsigned char *read_data) +{ + int ret = 0; + ret = read(fd, &read_data, I2C_ONE_BYTE); + if(ret == -1) + perror("I2C: Failed to read |"); + if(ret == 0) + perror("I2C: End of FILE |"); + return(ret); +} + + +/**************************************************************** + * Function Name : i2c_read_register + * Description : Read a single register of the slave device + * Returns : No. of bytes read on success, -1 on failure + * Params @fd: File descriptor + * @read_addr: Register address to be read + * @read_data: Points to the variable that stores + * the read data byte + ****************************************************************/ +int i2c_read_register(int fd, unsigned char read_addr, unsigned char *read_data) +{ + int ret = 0; + if(i2c_write(fd, read_addr) == -1) + { + perror("I2C: Failed to write |"); + return -1; + } + ret = read(fd, &read_data, I2C_ONE_BYTE); + if(ret == -1) + perror("I2C: Failed to read |"); + if(ret == 0) + perror("I2C: End of FILE |"); + return(ret); +} + + +/**************************************************************** + * Function Name : i2c_read_registers + * Description : Read a multiple registers on the slave device + * from starting address + * Returns : No. of bytes read on success, -1 on failure + * Params @fd: File descriptor + * @num: Number of registers/bytes to read from. + * @starting_addr: Starting address to read from + * @buff_Ptr: Buffer to store the read bytes + ****************************************************************/ +int i2c_read_registers(int fd, int num, unsigned char starting_addr, + unsigned char *buff_Ptr) +{ + int ret = 0; + if(i2c_write(fd, starting_addr) == -1) + { + perror("I2C: Failed to write |"); + return -1; + } + ret = read(fd, buff_Ptr, num); + if(ret == -1) + perror("I2C: Failed to read |"); + if(ret == 0) + perror("I2C: End of FILE |"); + return(ret); +} + + +/**************************************************************** + * Function Name : i2c_multiple_writes + * Description : Write multiple bytes on SDA + * Returns : No. of bytes written on success, -1 on failure + * Params @fd: file descriptor + * @num: No. of bytes to write + * @Ptr_buff: Pointer to the buffer containing the + * bytes to be written on the SDA + ****************************************************************/ +int i2c_multiple_writes(int fd, int num, unsigned char *Ptr_buff) +{ + int ret = 0; + ret = write(fd, Ptr_buff, num); + if((ret == -1) || (ret != num)) + return -1; + else + return(ret); +} + + +/**************************************************************** + * Function Name : i2c_write_register + * Description : Write a control byte or byte to a register + * Returns : No. of bytes written on success, -1 on failure + * Params @fd: file descriptor + * @reg_addr_or_cntrl: Control byte or Register + * address to be written + * @val: Command or value to be written in the + * addressed register + ****************************************************************/ +int i2c_write_register(int fd, unsigned char reg_addr_or_cntrl, unsigned char val) +{ + unsigned char buff[2]; + int ret = 0; + buff[0] = reg_addr_or_cntrl; + buff[1] = val; + ret = write(fd, buff, I2C_TWO_BYTES); + if((ret == -1) || (ret != I2C_TWO_BYTES)) + return -1; + else + return(ret); +} + + +/**************************************************************** + * Function Name : config_i2c_struct + * Description : Initialize the I2C device structure + * Returns : NONE + * Params @i2c_dev_path: Device path + * @slave_addr: Slave device address + * @i2c_dev: Pointer to the device structure + ****************************************************************/ +void config_i2c_struct(char *i2c_dev_path, unsigned char slave_addr, I2C_DevicePtr i2c_dev) +{ + i2c_dev->i2c_dev_path = i2c_dev_path; + i2c_dev->fd_i2c = 0; + i2c_dev->i2c_slave_addr = slave_addr; +} + + +/**************************************************************** + * Function Name : init_i2c_dev + * Description : Connect the i2c bus to the slave device + * Returns : 0 on success, -1 on failure + * Params @i2c_path: the path to the device + * @slave_addr: Slave device address + ****************************************************************/ +int init_i2c_dev(const char* i2c_path, unsigned char slave_address) +{ + config_i2c_struct((char*)i2c_path, slave_address, &I2C_DEV_2); + if(Open_device(I2C_DEV_2.i2c_dev_path, &I2C_DEV_2.fd_i2c) == -1) + { + perror("I2C: Failed to open device |"); + return -1; + } + if(Set_slave_addr(I2C_DEV_2.fd_i2c, I2C_DEV_2.i2c_slave_addr) == -1) + { + perror("I2C: Failed to connect to slave device |"); + return -1; + } + + return 0; +} diff --git a/luci-app-ouad/src/I2C_Library/I2C.h b/luci-app-ouad/src/I2C_Library/I2C.h new file mode 100755 index 000000000..ffcc45933 --- /dev/null +++ b/luci-app-ouad/src/I2C_Library/I2C.h @@ -0,0 +1,69 @@ +/* + * MIT License + +Copyright (c) 2017 DeeplyEmbedded + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + * I2C.h + * + * Created on : Sep 4, 2017 + * Author : Vinay Divakar + * Website : www.deeplyembedded.org + */ + +#ifndef I2C_H_ +#define I2C_H_ + +#include + +/* No. of bytes per transaction */ +#define I2C_ONE_BYTE 1 +#define I2C_TWO_BYTES 2 +#define I2C_THREE_BYTES 3 + +/*Definitions specific to i2c-x */ +#define I2C_DEV0_PATH "/dev/i2c-0" +#define I2C_DEV1_PATH "/dev/i2c-1" +#define I2C_DEV2_PATH "/dev/i2c-2" + +/*I2C device configuration structure*/ +typedef struct{ + char* i2c_dev_path; + int fd_i2c; + unsigned char i2c_slave_addr; +}I2C_DeviceT, *I2C_DevicePtr; + +/* Exposed Generic I2C Functions */ +extern int Open_device(char *i2c_dev_path, int *fd); +extern int Close_device(int fd); +extern int Set_slave_addr(int fd, unsigned char slave_addr); +extern int i2c_write(int fd, unsigned char data); +extern int i2c_read(int fd, unsigned char *read_data); +extern int i2c_read_register(int fd, unsigned char read_addr, unsigned char *read_data); +extern int i2c_read_registers(int fd, int num, unsigned char starting_addr, + unsigned char *buff_Ptr); +extern void config_i2c_struct(char *i2c_dev_path, unsigned char slave_addr, I2C_DevicePtr i2c_dev); +extern int i2c_multiple_writes(int fd, int num, unsigned char *Ptr_buff); +extern int i2c_write_register(int fd, unsigned char reg_addr_or_cntrl, unsigned char val); + +/* Exposed I2C-x Specific Functions */ +extern int init_i2c_dev(const char* i2c_path, unsigned char slave_address); + +#endif /* I2C_H_ */ diff --git a/luci-app-ouad/src/LICENSE b/luci-app-ouad/src/LICENSE new file mode 100755 index 000000000..e99e91b40 --- /dev/null +++ b/luci-app-ouad/src/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 DeeplyEmbedded + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/luci-app-ouad/src/Makefile b/luci-app-ouad/src/Makefile new file mode 100755 index 000000000..0f1b25559 --- /dev/null +++ b/luci-app-ouad/src/Makefile @@ -0,0 +1,19 @@ +CC = gcc +LD = gcc + +SOURCES = SSD1306_OLED_Library/SSD1306_OLED.c Example_Code/Main.c Example_Code/example_app.c I2C_Library/I2C.c +OBJS := $(SOURCES:.c=.o) +CPPFLAGS := -I SSD1306_OLED_Library -I I2C_Library +CFLAGS := -g + +oled: $(OBJS) + $(CC) $^ -o $@ + +clean: + rm -rf oled $(OBJS) + +compile: oled + +install: compile + mkdir -p $(DESTDIR)/usr/bin + cp oled $(DESTDIR)/usr/bin/oled diff --git a/luci-app-ouad/src/README.md b/luci-app-ouad/src/README.md new file mode 100755 index 000000000..080474f06 --- /dev/null +++ b/luci-app-ouad/src/README.md @@ -0,0 +1,21 @@ +# SSD1306-OLED-display-driver-for-BeagleBone +This is a SSD1306 OLED Display Library fully compatible with the BeagleBone. + +The Library has 3 components: +1. I2C component for enabling communication between the BeagleBone and display. +2. Control component for sending I2C commands to configure and control the display. +3. Graphics component for drawing geometrical figures, bitmaps, texts, characters, emoticons and numbers. + +Author: Vinay Divakar + +References: +1. https://github.com/adafruit/Adafruit_SSD1306 +2. https://github.com/adafruit/Adafruit-GFX-Library + +Youtube demo: https://youtu.be/sDKf6zW6Pyg + +MIT license, check LICENSE file for more information + +This Library is written in C. To use it, just include the I2C and SSD1306 Libraries in your project. + +Enjoy :) diff --git a/luci-app-ouad/src/SSD1306_OLED_Library/SSD1306_OLED.c b/luci-app-ouad/src/SSD1306_OLED_Library/SSD1306_OLED.c new file mode 100755 index 000000000..b15660356 --- /dev/null +++ b/luci-app-ouad/src/SSD1306_OLED_Library/SSD1306_OLED.c @@ -0,0 +1,2761 @@ +/* + * MIT License + +Copyright (c) 2017 DeeplyEmbedded + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + * SSD1306_OLED.c + * + * Created on : Sep 26, 2017 + * Author : Vinay Divakar + * Description : SSD1306 OLED Driver, Graphics API's. + * Website : www.deeplyembedded.org + */ + +/* Lib Includes */ +#include +#include +#include +#include +#include +#include "I2C.h" +#include "SSD1306_OLED.h" +#include "gfxfont.h" + +/* Enable or Disable DEBUG Prints */ +//#define SSD1306_DBG + +/* MACROS */ +#define SWAP(x,y) {short temp; temp = x; x = y; y = temp;} +#define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#define pgm_read_word(addr) (*(const unsigned long *)(addr)) +#define pgm_read_dword(addr) (*(const unsigned long *)(addr)) +#define pgm_read_pointer(addr) ((void *)pgm_read_word(addr)) + +/* static Variables */ +static unsigned char _rotation = 0,textsize = 0; +static short _width = SSD1306_LCDWIDTH; +static short _height = SSD1306_LCDHEIGHT; +static short cursor_x = 0, cursor_y = 0, textcolor = 0, textbgcolor = 0; +static bool _cp437 = false, wrap = true; + +/* static struct objects */ +static GFXfontPtr gfxFont; + +/* Externs - I2C.c */ +extern I2C_DeviceT I2C_DEV_2; + +/* Chunk Buffer */ +static unsigned char chunk[17] = {0}; + +/* Memory buffer for displaying data on LCD - This is an Apple - Fruit */ +static unsigned char screen[DISPLAY_BUFF_SIZE] ={0}; + +/* Static Functions */ +static void transfer(); +static void drawFastVLine(short x, short y,short h, short color); +static void writeFastVLine(short x, short y, short h, short color); +static void drawFastHLine(short x, short y,short w, short color); +static void writeFastHLine(short x, short y, short w, short color); +static short print(const unsigned char *buffer, short size); + +// Standard ASCII 5x7 font +static const unsigned char ssd1306_font5x7[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, //space + 0x3E, 0x5B, 0x4F, 0x5B, 0x3E, + 0x3E, 0x6B, 0x4F, 0x6B, 0x3E, + 0x1C, 0x3E, 0x7C, 0x3E, 0x1C, + 0x18, 0x3C, 0x7E, 0x3C, 0x18, + 0x1C, 0x57, 0x7D, 0x57, 0x1C, + 0x1C, 0x5E, 0x7F, 0x5E, 0x1C, + 0x00, 0x18, 0x3C, 0x18, 0x00, + 0xFF, 0xE7, 0xC3, 0xE7, 0xFF, + 0x00, 0x18, 0x24, 0x18, 0x00, + 0xFF, 0xE7, 0xDB, 0xE7, 0xFF, + 0x30, 0x48, 0x3A, 0x06, 0x0E, + 0x26, 0x29, 0x79, 0x29, 0x26, + 0x40, 0x7F, 0x05, 0x05, 0x07, + 0x40, 0x7F, 0x05, 0x25, 0x3F, + 0x5A, 0x3C, 0xE7, 0x3C, 0x5A, + 0x7F, 0x3E, 0x1C, 0x1C, 0x08, + 0x08, 0x1C, 0x1C, 0x3E, 0x7F, + 0x14, 0x22, 0x7F, 0x22, 0x14, + 0x5F, 0x5F, 0x00, 0x5F, 0x5F, + 0x06, 0x09, 0x7F, 0x01, 0x7F, + 0x00, 0x66, 0x89, 0x95, 0x6A, + 0x60, 0x60, 0x60, 0x60, 0x60, + 0x94, 0xA2, 0xFF, 0xA2, 0x94, + 0x08, 0x04, 0x7E, 0x04, 0x08,//up INDEX 24 + 0x10, 0x20, 0x7E, 0x20, 0x10,//down INDEX 25 + 0x08, 0x08, 0x2A, 0x1C, 0x08, + 0x08, 0x1C, 0x2A, 0x08, 0x08, + 0x1E, 0x10, 0x10, 0x10, 0x10, + 0x0C, 0x1E, 0x0C, 0x1E, 0x0C, + 0x30, 0x38, 0x3E, 0x38, 0x30, + 0x06, 0x0E, 0x3E, 0x0E, 0x06, + 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x5F, 0x00, 0x00, + 0x00, 0x07, 0x00, 0x07, 0x00, + 0x14, 0x7F, 0x14, 0x7F, 0x14, + 0x24, 0x2A, 0x7F, 0x2A, 0x12, + 0x23, 0x13, 0x08, 0x64, 0x62, + 0x36, 0x49, 0x56, 0x20, 0x50, + 0x00, 0x08, 0x07, 0x03, 0x00, + 0x00, 0x1C, 0x22, 0x41, 0x00, + 0x00, 0x41, 0x22, 0x1C, 0x00, + 0x2A, 0x1C, 0x7F, 0x1C, 0x2A, + 0x08, 0x08, 0x3E, 0x08, 0x08, + 0x00, 0x80, 0x70, 0x30, 0x00, + 0x08, 0x08, 0x08, 0x08, 0x08, + 0x00, 0x00, 0x60, 0x60, 0x00, + 0x20, 0x10, 0x08, 0x04, 0x02, + 0x3E, 0x51, 0x49, 0x45, 0x3E, + 0x00, 0x42, 0x7F, 0x40, 0x00, + 0x72, 0x49, 0x49, 0x49, 0x46, + 0x21, 0x41, 0x49, 0x4D, 0x33, + 0x18, 0x14, 0x12, 0x7F, 0x10, + 0x27, 0x45, 0x45, 0x45, 0x39, + 0x3C, 0x4A, 0x49, 0x49, 0x31, + 0x41, 0x21, 0x11, 0x09, 0x07, + 0x36, 0x49, 0x49, 0x49, 0x36, + 0x46, 0x49, 0x49, 0x29, 0x1E, + 0x00, 0x00, 0x14, 0x00, 0x00, + 0x00, 0x40, 0x34, 0x00, 0x00, + 0x00, 0x08, 0x14, 0x22, 0x41, + 0x14, 0x14, 0x14, 0x14, 0x14, + 0x00, 0x41, 0x22, 0x14, 0x08, + 0x02, 0x01, 0x59, 0x09, 0x06, + 0x3E, 0x41, 0x5D, 0x59, 0x4E, + 0x7C, 0x12, 0x11, 0x12, 0x7C, + 0x7F, 0x49, 0x49, 0x49, 0x36, + 0x3E, 0x41, 0x41, 0x41, 0x22,//C + 0x7F, 0x41, 0x41, 0x41, 0x3E,//D + 0x7F, 0x49, 0x49, 0x49, 0x41,//E + 0x7F, 0x09, 0x09, 0x09, 0x01,//F + 0x3E, 0x41, 0x41, 0x51, 0x73, + 0x7F, 0x08, 0x08, 0x08, 0x7F, + 0x00, 0x41, 0x7F, 0x41, 0x00, + 0x20, 0x40, 0x41, 0x3F, 0x01, + 0x7F, 0x08, 0x14, 0x22, 0x41, + 0x7F, 0x40, 0x40, 0x40, 0x40, + 0x7F, 0x02, 0x1C, 0x02, 0x7F, + 0x7F, 0x04, 0x08, 0x10, 0x7F, + 0x3E, 0x41, 0x41, 0x41, 0x3E, + 0x7F, 0x09, 0x09, 0x09, 0x06, + 0x3E, 0x41, 0x51, 0x21, 0x5E, + 0x7F, 0x09, 0x19, 0x29, 0x46, + 0x26, 0x49, 0x49, 0x49, 0x32, + 0x03, 0x01, 0x7F, 0x01, 0x03, + 0x3F, 0x40, 0x40, 0x40, 0x3F, + 0x1F, 0x20, 0x40, 0x20, 0x1F, + 0x3F, 0x40, 0x38, 0x40, 0x3F, + 0x63, 0x14, 0x08, 0x14, 0x63, + 0x03, 0x04, 0x78, 0x04, 0x03, + 0x61, 0x59, 0x49, 0x4D, 0x43, + 0x00, 0x7F, 0x41, 0x41, 0x41, + 0x02, 0x04, 0x08, 0x10, 0x20, + 0x00, 0x41, 0x41, 0x41, 0x7F, + 0x04, 0x02, 0x01, 0x02, 0x04, + 0x40, 0x40, 0x40, 0x40, 0x40, + 0x00, 0x03, 0x07, 0x08, 0x00, + 0x20, 0x54, 0x54, 0x78, 0x40, + 0x7F, 0x28, 0x44, 0x44, 0x38, + 0x38, 0x44, 0x44, 0x44, 0x28, + 0x38, 0x44, 0x44, 0x28, 0x7F, + 0x38, 0x54, 0x54, 0x54, 0x18, + 0x00, 0x08, 0x7E, 0x09, 0x02, + 0x18, 0xA4, 0xA4, 0x9C, 0x78, + 0x7F, 0x08, 0x04, 0x04, 0x78, + 0x00, 0x44, 0x7D, 0x40, 0x00, + 0x20, 0x40, 0x40, 0x3D, 0x00, + 0x7F, 0x10, 0x28, 0x44, 0x00, + 0x00, 0x41, 0x7F, 0x40, 0x00, + 0x7C, 0x04, 0x78, 0x04, 0x78, + 0x7C, 0x08, 0x04, 0x04, 0x78, + 0x38, 0x44, 0x44, 0x44, 0x38, + 0xFC, 0x18, 0x24, 0x24, 0x18, + 0x18, 0x24, 0x24, 0x18, 0xFC, + 0x7C, 0x08, 0x04, 0x04, 0x08, + 0x48, 0x54, 0x54, 0x54, 0x24, + 0x04, 0x04, 0x3F, 0x44, 0x24, + 0x3C, 0x40, 0x40, 0x20, 0x7C, + 0x1C, 0x20, 0x40, 0x20, 0x1C, + 0x3C, 0x40, 0x30, 0x40, 0x3C, + 0x44, 0x28, 0x10, 0x28, 0x44, + 0x4C, 0x90, 0x90, 0x90, 0x7C, + 0x44, 0x64, 0x54, 0x4C, 0x44, + 0x00, 0x08, 0x36, 0x41, 0x00, + 0x00, 0x00, 0x77, 0x00, 0x00, + 0x00, 0x41, 0x36, 0x08, 0x00, + 0x02, 0x01, 0x02, 0x04, 0x02, + 0x3C, 0x26, 0x23, 0x26, 0x3C, + 0x1E, 0xA1, 0xA1, 0x61, 0x12, + 0x3A, 0x40, 0x40, 0x20, 0x7A, + 0x38, 0x54, 0x54, 0x55, 0x59, + 0x21, 0x55, 0x55, 0x79, 0x41, + 0x22, 0x54, 0x54, 0x78, 0x42, // a-umlaut + 0x21, 0x55, 0x54, 0x78, 0x40, + 0x20, 0x54, 0x55, 0x79, 0x40, + 0x0C, 0x1E, 0x52, 0x72, 0x12, + 0x39, 0x55, 0x55, 0x55, 0x59, + 0x39, 0x54, 0x54, 0x54, 0x59, + 0x39, 0x55, 0x54, 0x54, 0x58, + 0x00, 0x00, 0x45, 0x7C, 0x41, + 0x00, 0x02, 0x45, 0x7D, 0x42, + 0x00, 0x01, 0x45, 0x7C, 0x40, + 0x7D, 0x12, 0x11, 0x12, 0x7D, // A-umlaut + 0xF0, 0x28, 0x25, 0x28, 0xF0, + 0x7C, 0x54, 0x55, 0x45, 0x00, + 0x20, 0x54, 0x54, 0x7C, 0x54, + 0x7C, 0x0A, 0x09, 0x7F, 0x49, + 0x32, 0x49, 0x49, 0x49, 0x32, + 0x3A, 0x44, 0x44, 0x44, 0x3A, // o-umlaut + 0x32, 0x4A, 0x48, 0x48, 0x30, + 0x3A, 0x41, 0x41, 0x21, 0x7A, + 0x3A, 0x42, 0x40, 0x20, 0x78, + 0x00, 0x9D, 0xA0, 0xA0, 0x7D, + 0x3D, 0x42, 0x42, 0x42, 0x3D, // O-umlaut + 0x3D, 0x40, 0x40, 0x40, 0x3D, + 0x3C, 0x24, 0xFF, 0x24, 0x24, + 0x48, 0x7E, 0x49, 0x43, 0x66, + 0x2B, 0x2F, 0xFC, 0x2F, 0x2B, + 0xFF, 0x09, 0x29, 0xF6, 0x20, + 0xC0, 0x88, 0x7E, 0x09, 0x03, + 0x20, 0x54, 0x54, 0x79, 0x41, + 0x00, 0x00, 0x44, 0x7D, 0x41, + 0x30, 0x48, 0x48, 0x4A, 0x32, + 0x38, 0x40, 0x40, 0x22, 0x7A, + 0x00, 0x7A, 0x0A, 0x0A, 0x72, + 0x7D, 0x0D, 0x19, 0x31, 0x7D, + 0x26, 0x29, 0x29, 0x2F, 0x28, + 0x26, 0x29, 0x29, 0x29, 0x26, + 0x30, 0x48, 0x4D, 0x40, 0x20, + 0x38, 0x08, 0x08, 0x08, 0x08, + 0x08, 0x08, 0x08, 0x08, 0x38, + 0x2F, 0x10, 0xC8, 0xAC, 0xBA, + 0x2F, 0x10, 0x28, 0x34, 0xFA, + 0x00, 0x00, 0x7B, 0x00, 0x00, + 0x08, 0x14, 0x2A, 0x14, 0x22, + 0x22, 0x14, 0x2A, 0x14, 0x08, + 0x55, 0x00, 0x55, 0x00, 0x55, // #176 (25% block) missing in old code + 0xAA, 0x55, 0xAA, 0x55, 0xAA, // 50% block + 0xFF, 0x55, 0xFF, 0x55, 0xFF, // 75% block + 0x00, 0x00, 0x00, 0xFF, 0x00, + 0x10, 0x10, 0x10, 0xFF, 0x00, + 0x14, 0x14, 0x14, 0xFF, 0x00, + 0x10, 0x10, 0xFF, 0x00, 0xFF, + 0x10, 0x10, 0xF0, 0x10, 0xF0, + 0x14, 0x14, 0x14, 0xFC, 0x00, + 0x14, 0x14, 0xF7, 0x00, 0xFF, + 0x00, 0x00, 0xFF, 0x00, 0xFF, + 0x14, 0x14, 0xF4, 0x04, 0xFC, + 0x14, 0x14, 0x17, 0x10, 0x1F, + 0x10, 0x10, 0x1F, 0x10, 0x1F, + 0x14, 0x14, 0x14, 0x1F, 0x00, + 0x10, 0x10, 0x10, 0xF0, 0x00, + 0x00, 0x00, 0x00, 0x1F, 0x10, + 0x10, 0x10, 0x10, 0x1F, 0x10, + 0x10, 0x10, 0x10, 0xF0, 0x10, + 0x00, 0x00, 0x00, 0xFF, 0x10, + 0x10, 0x10, 0x10, 0x10, 0x10, + 0x10, 0x10, 0x10, 0xFF, 0x10, + 0x00, 0x00, 0x00, 0xFF, 0x14, + 0x00, 0x00, 0xFF, 0x00, 0xFF, + 0x00, 0x00, 0x1F, 0x10, 0x17, + 0x00, 0x00, 0xFC, 0x04, 0xF4, + 0x14, 0x14, 0x17, 0x10, 0x17, + 0x14, 0x14, 0xF4, 0x04, 0xF4, + 0x00, 0x00, 0xFF, 0x00, 0xF7, + 0x14, 0x14, 0x14, 0x14, 0x14, + 0x14, 0x14, 0xF7, 0x00, 0xF7, + 0x14, 0x14, 0x14, 0x17, 0x14, + 0x10, 0x10, 0x1F, 0x10, 0x1F, + 0x14, 0x14, 0x14, 0xF4, 0x14, + 0x10, 0x10, 0xF0, 0x10, 0xF0, + 0x00, 0x00, 0x1F, 0x10, 0x1F, + 0x00, 0x00, 0x00, 0x1F, 0x14, + 0x00, 0x00, 0x00, 0xFC, 0x14, + 0x00, 0x00, 0xF0, 0x10, 0xF0, + 0x10, 0x10, 0xFF, 0x10, 0xFF, + 0x14, 0x14, 0x14, 0xFF, 0x14, + 0x10, 0x10, 0x10, 0x1F, 0x00, + 0x00, 0x00, 0x00, 0xF0, 0x10, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, + 0xFF, 0xFF, 0xFF, 0x00, 0x00, + 0x00, 0x00, 0x00, 0xFF, 0xFF, + 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, + 0x38, 0x44, 0x44, 0x38, 0x44, + 0xFC, 0x4A, 0x4A, 0x4A, 0x34, // sharp-s or beta + 0x7E, 0x02, 0x02, 0x06, 0x06, + 0x02, 0x7E, 0x02, 0x7E, 0x02, + 0x63, 0x55, 0x49, 0x41, 0x63, + 0x38, 0x44, 0x44, 0x3C, 0x04, + 0x40, 0x7E, 0x20, 0x1E, 0x20, + 0x06, 0x02, 0x7E, 0x02, 0x02, + 0x99, 0xA5, 0xE7, 0xA5, 0x99, + 0x1C, 0x2A, 0x49, 0x2A, 0x1C, + 0x4C, 0x72, 0x01, 0x72, 0x4C, + 0x30, 0x4A, 0x4D, 0x4D, 0x30, + 0x30, 0x48, 0x78, 0x48, 0x30, + 0xBC, 0x62, 0x5A, 0x46, 0x3D, + 0x3E, 0x49, 0x49, 0x49, 0x00, + 0x7E, 0x01, 0x01, 0x01, 0x7E, + 0x2A, 0x2A, 0x2A, 0x2A, 0x2A, + 0x44, 0x44, 0x5F, 0x44, 0x44, + 0x40, 0x51, 0x4A, 0x44, 0x40, + 0x40, 0x44, 0x4A, 0x51, 0x40, + 0x00, 0x00, 0xFF, 0x01, 0x03, + 0xE0, 0x80, 0xFF, 0x00, 0x00, + 0x08, 0x08, 0x6B, 0x6B, 0x08, + 0x36, 0x12, 0x36, 0x24, 0x36, + 0x06, 0x0F, 0x09, 0x0F, 0x06, + 0x00, 0x00, 0x18, 0x18, 0x00, + 0x00, 0x00, 0x10, 0x10, 0x00, + 0x30, 0x40, 0xFF, 0x01, 0x01, + 0x00, 0x1F, 0x01, 0x01, 0x1E, + 0x00, 0x19, 0x1D, 0x17, 0x12, + 0x00, 0x3C, 0x3C, 0x3C, 0x3C, + 0x00, 0x00, 0x00, 0x00, 0x00 // #255 NBSP +}; + +/**************************************************************** + * Function Name : clearDisplay + * Description : Clear the display memory buffer + * Returns : NONE. + * Params : NONE. + ****************************************************************/ +void clearDisplay() +{ + memset(screen, 0x00, DISPLAY_BUFF_SIZE); +} + +/**************************************************************** + * Function Name : display_Init_seq + * Description : Performs SSD1306 OLED Initialization Sequence + * Returns : NONE. + * Params : NONE. + ****************************************************************/ +void display_Init_seq() +{ + /* Add the reset code, If needed */ + + /* Send display OFF command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DISPLAY_OFF) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display OFF Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display OFF Command Failed\r\n"); +#endif + exit(1); + } + + /* Set display clock frequency */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_DISP_CLK) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display CLK Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display CLK Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display CLK command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DISPCLK_DIV) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display CLK Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display CLK Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display multiplex */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_MULTIPLEX) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display MULT Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display MULT Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display MULT command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_MULT_DAT) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display MULT Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display MULT Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display OFFSET */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_DISP_OFFSET) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display OFFSET Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display OFFSET Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display OFFSET command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DISP_OFFSET_VAL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display OFFSET Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display OFFSET Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display START LINE - Check this command if something weird happens */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_DISP_START_LINE) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display START LINE Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display START LINE Command Failed\r\n"); +#endif + exit(1); + } + + /* Enable CHARGEPUMP*/ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_CONFIG_CHARGE_PUMP) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display CHARGEPUMP Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display CHARGEPUMP Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display CHARGEPUMP command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_CHARGE_PUMP_EN) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display CHARGEPUMP Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display CHARGEPUMP Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display MEMORYMODE */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_MEM_ADDR_MODE) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display MEMORYMODE Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display MEMORYMODE Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display HORIZONTAL MEMORY ADDR MODE command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_HOR_MM) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display HORIZONTAL MEMORY ADDR MODE Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display HORIZONTAL MEMORY ADDR MODE Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display COM */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_COMPINS) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display COM Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display COM Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display COM command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_CONFIG_COM_PINS) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display COM Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display COM Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display CONTRAST */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_CONTRAST) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display CONTRAST Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display CONTRAST Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display CONTRAST command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_CONTRAST_VAL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display CONTRAST Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display CONTRAST Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display PRECHARGE */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_PRECHARGE) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display PRECHARGE Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display PRECHARGE Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display PRECHARGE command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_PRECHARGE_VAL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display PRECHARGE Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display PRECHARGE Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display VCOMH */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_VCOMDETECT) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display VCOMH Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display VCOMH Command Failed\r\n"); +#endif + exit(1); + } + + /* Send display VCOMH command parameter */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_VCOMH_VAL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display VCOMH Command Parameter Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display VCOMH Command Parameter Failed\r\n"); +#endif + exit(1); + } + + /* Set display ALL-ON */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DISPLAYALLON_RESUME) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display ALL-ON Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display ALL-ON Command Failed\r\n"); +#endif + exit(1); + } + + /* Set display to NORMAL-DISPLAY */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_NORMAL_DISPLAY) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display NORMAL-DISPLAY Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display NORMAL-DISPLAY Command Failed\r\n"); +#endif + exit(1); + } + + /* Set display to DEACTIVATE_SCROLL */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DEACTIVATE_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display DEACTIVATE_SCROLL Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display DEACTIVATE_SCROLL Command Failed\r\n"); +#endif + exit(1); + } + + /* Set display to TURN-ON */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DISPLAYON) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display TURN-ON Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display TURN-ON Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : display_normal + * Description : Normal display + * Returns : NONE. + * Params : NONE. + ****************************************************************/ +void display_normal() +{ + /* Set display SEG_REMAP */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SEG_REMAP) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display SEG_REMAP Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display SEG_REMAP Command Failed\r\n"); +#endif + exit(1); + } + + /* Set display COMSCANDEC */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_COMSCANDEC) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display DIR Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display DIR Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : display_rotate + * Description : 180 degree rotation + * Returns : NONE. + * Params : NONE. + ****************************************************************/ +void display_rotate() +{ + /* Set display SEG_REMAP1 */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SEG_REMAP1) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display SEG_REMAP Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display SEG_REMAP Command Failed\r\n"); +#endif + exit(1); + } + + /* Set display COMSCANDEC1 */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_COMSCANDEC1) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display DIR Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display DIR Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : transfer + * Description : Transfer the frame buffer onto the display + * Returns : NONE. + * Params : NONE. + ****************************************************************/ +void transfer() +{ + short loop_1 = 0, loop_2 = 0; + short index = 0x00; + for (loop_1 = 0; loop_1 < 1024; loop_1++) + { + chunk[0] = 0x40; + for(loop_2 = 1; loop_2 < 17; loop_2++) + chunk[loop_2] = screen[index++]; + if(i2c_multiple_writes(I2C_DEV_2.fd_i2c, 17, chunk) == 17) + { +#ifdef SSD1306_DBG + printf("Chunk written to RAM - Completed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Chunk written to RAM - Failed\r\n"); +#endif + exit(1); + } + + memset(chunk,0x00,17); + if(index == 1024) + break; + } +} + + +/**************************************************************** + * Function Name : Display + * Description : 1. Resets the column and page addresses. + * 2. Displays the contents of the memory buffer. + * Returns : NONE. + * Params : NONE. + * Note : Each new form can be preceded by a clearDisplay. + ****************************************************************/ +void Display() +{ + Init_Col_PG_addrs(SSD1306_COL_START_ADDR,SSD1306_COL_END_ADDR, + SSD1306_PG_START_ADDR,SSD1306_PG_END_ADDR); + transfer(); +} + +/**************************************************************** + * Function Name : Init_Col_PG_addrs + * Description : Sets the column and page, start and + * end addresses. + * Returns : NONE. + * Params : @col_start_addr: Column start address + * @col_end_addr: Column end address + * @pg_start_addr: Page start address + * @pg_end_addr: Page end address + ****************************************************************/ +void Init_Col_PG_addrs(unsigned char col_start_addr, unsigned char col_end_addr, + unsigned char pg_start_addr, unsigned char pg_end_addr) +{ + /* Send COLMN address setting command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_COL_ADDR) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display COLMN Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display COLMN Command Failed\r\n"); +#endif + exit(1); + } + + /* Set COLMN start address */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, col_start_addr) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display COLMN Start Address param Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display COLMN Start Address param Failed\r\n"); +#endif + exit(1); + } + + /* Set COLMN end address */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, col_end_addr) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display COLMN End Address param Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display COLMN End Address param Failed\r\n"); +#endif + exit(1); + } + + /* Send PAGE address setting command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_PAGEADDR) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display PAGE Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display PAGE Command Failed\r\n"); +#endif + exit(1); + } + + /* Set PAGE start address */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, pg_start_addr) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display PAGE Start Address param Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display PAGE Start Address param Failed\r\n"); +#endif + exit(1); + } + + /* Set PAGE end address */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, pg_end_addr) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display PAGE End Address param Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display PAGE End Address param Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : setRotation + * Description : Set the display rotation + * Returns : NONE. + * Params : @x: Display rotation parameter + ****************************************************************/ +void setRotation(unsigned char x) +{ + _rotation = x & 3; + switch(_rotation) + { + case 0: + case 2: + _width = SSD1306_LCDWIDTH; + _height = SSD1306_LCDHEIGHT; + break; + case 1: + case 3: + _width = SSD1306_LCDHEIGHT; + _height = SSD1306_LCDWIDTH; + break; + } +} + +/**************************************************************** + * Function Name : startscrollright + * Description : Activate a right handed scroll for rows start + * through stop + * Returns : NONE. + * Params : @start: Start location + * @stop: Stop location + * HINT. : the display is 16 rows tall. To scroll the whole + * display, run: display.scrollright(0x00, 0x0F) + ****************************************************************/ +void startscrollright(unsigned char start, unsigned char stop) +{ + /* Send SCROLL horizontal right command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_RIGHT_HORIZONTAL_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display HORIZONTAL SCROLL RIGHT Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display HORIZONTAL SCROLL RIGHT Command Failed\r\n"); +#endif + exit(1); + } + + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_1 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_1 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, start) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_2 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_2 Passed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_3 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_3 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, stop) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_4 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_4 Passed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_5 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_5 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0xFF) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_6 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_6 Passed\r\n"); +#endif + exit(1); + } + /* Send SCROLL Activate command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_ACTIVATE_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : startscrollleft + * Description : Activate a left handed scroll for rows start + * through stop + * Returns : NONE. + * Params : @start: Start location + * @stop: Stop location + * HINT. : the display is 16 rows tall. To scroll the whole + * display, run: display.scrollright(0x00, 0x0F) + ****************************************************************/ +void startscrollleft(unsigned char start, unsigned char stop) +{ + /* Send SCROLL horizontal left command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_LEFT_HORIZONTAL_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display HORIZONTAL SCROLL LEFT Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display HORIZONTAL SCROLL LEFT Command Failed\r\n"); +#endif + exit(1); + } + + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_1 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_1 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, start) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_2 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_2 Passed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_3 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_3 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, stop) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_4 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_4 Passed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_5 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_5 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0xFF) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_6 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("HORI_SR Param_6 Passed\r\n"); +#endif + exit(1); + } + /* Send SCROLL Activate command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_ACTIVATE_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : startscrolldiagright + * Description : Activate a diagonal scroll for rows start + * through stop + * Returns : NONE. + * Params : @start: Start location + * @stop: Stop location + * HINT. : the display is 16 rows tall. To scroll the whole + * display, run: display.scrollright(0x00, 0x0F) + ****************************************************************/ +void startscrolldiagright(unsigned char start, unsigned char stop) +{ + /* Send SCROLL diagonal right command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_VERTICAL_SCROLL_AREA) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display DIAGONAL SCROLL RIGHT Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display DIAGONAL SCROLL RIGHT Command Failed\r\n"); +#endif + exit(1); + } + + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_1 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_1 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_LCDHEIGHT) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_2 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_2 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Cmd Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Cmd Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_3 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_3 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, start) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_4 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_4 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, stop) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_6 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_6 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x01) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Failed\r\n"); +#endif + exit(1); + } + + /* Send SCROLL Activate command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_ACTIVATE_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : startscrolldiagleft + * Description : Activate a diagonal scroll for rows start + * through stop + * Returns : NONE. + * Params : @start: Start location + * @stop: Stop location + * HINT. : the display is 16 rows tall. To scroll the whole + * display, run: display.scrollright(0x00, 0x0F) + ****************************************************************/ +void startscrolldiagleft(unsigned char start, unsigned char stop) +{ + /* Send SCROLL diagonal right command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_SET_VERTICAL_SCROLL_AREA) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Display DIAGONAL SCROLL RIGHT Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Display DIAGONAL SCROLL RIGHT Command Failed\r\n"); +#endif + exit(1); + } + + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_1 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_1 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_LCDHEIGHT) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_2 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_2 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("Cmd Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("Cmd Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_3 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_3 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, start) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_4 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_4 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x00) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, stop) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_6 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_6 Failed\r\n"); +#endif + exit(1); + } + + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, 0x01) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("DIAG_SR Param_5 Failed\r\n"); +#endif + exit(1); + } + + /* Send SCROLL Activate command */ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_ACTIVATE_SCROLL) == I2C_TWO_BYTES) + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Passed\r\n"); +#endif + } + else + { +#ifdef SSD1306_DBG + printf("SCROLL Activate Command Failed\r\n"); +#endif + exit(1); + } +} + +/**************************************************************** + * Function Name : stopscroll + * Description : Stop scrolling + * Returns : NONE. + * Params : NONE. + ****************************************************************/ +void stopscroll() +{ + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_DEACTIVATE_SCROLL) == I2C_TWO_BYTES) + { + printf("De-activate SCROLL Command Passed\r\n"); + } + else + { + printf("De-activate SCROLL Command Passed Failed\r\n"); + exit(1); + } +} + +/**************************************************************** + * Function Name : invertDisplay + * Description : Invert or Normalize the display + * Returns : NONE. + * Params : @i: 0x00 to Normal and 0x01 for Inverting + ****************************************************************/ +void invertDisplay(unsigned char i) +{ + if (i) + { + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_INVERTDISPLAY) == I2C_TWO_BYTES) + { + printf("Display Inverted - Passed\r\n"); + } + else + { + printf("Display Inverted - Failed\r\n"); + exit(1); + } + } + else + { + if(i2c_write_register(I2C_DEV_2.fd_i2c, SSD1306_CNTRL_CMD, SSD1306_NORMAL_DISPLAY) == I2C_TWO_BYTES) + { + printf("Display Normal - Passed\r\n"); + } + else + { + printf("Display Normal - Failed\r\n"); + exit(1); + } + } +} + +/**************************************************************** + * Function Name : drawPixel + * Description : Draw a pixel + * Returns : -1 on error and 0 on success + * Params : @x: X - Co-ordinate + * @y: Y - Co-ordinate + * @color: Color + ****************************************************************/ +signed char drawPixel(short x, short y, short color) +{ + /* Return if co-ordinates are out of display dimension's range */ + if ((x < 0) || (x >= _width) || (y < 0) || (y >= _height)) + return -1; + switch(_rotation) + { + case 1: + SWAP(x,y); + x = _width - x - 1; + break; + case 2: + x = _width - x - 1; + y = _height - y - 1; + break; + case 3: + SWAP(x,y); + y = _height - y - 1; + break; + } + + /* x is the column */ + switch(color) + { + case WHITE: screen[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << (y&7)); break; + case BLACK: screen[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << (y&7)); break; + case INVERSE: screen[x+ (y/8)*SSD1306_LCDWIDTH] ^= (1 << (y&7)); break; + } + return 0; +} + +/**************************************************************** + * Function Name : writeLine + * Description : Bresenham's algorithm + * Returns : NONE + * Params : @x0: X0 Co-ordinate + * @y0: Y0 Co-ordinate + * @x1: X1 Co-ordinate + * @y1: Y1 Co-ordinate + * @color: Pixel color + ****************************************************************/ +void writeLine(short x0, short y0, short x1, short y1, short color) +{ + short steep = 0, dx = 0, dy = 0, err = 0, ystep = 0; + steep = abs(y1 - y0) > abs(x1 - x0); + if (steep) + { + SWAP(x0, y0); + SWAP(x1, y1); + } + + if (x0 > x1) + { + SWAP(x0, x1); + SWAP(y0, y1); + } + dx = x1 - x0; + dy = abs(y1 - y0); + + err = dx / 2; + + if (y0 < y1) + { + ystep = 1; + } else + { + ystep = -1; + } + + for (; x0<=x1; x0++) + { + if (steep) + { + drawPixel(y0, x0, color); + } else + { + drawPixel(x0, y0, color); + } + err -= dy; + if (err < 0) + { + y0 += ystep; + err += dx; + } + } +} + +/* (x,y) is topmost point; if unsure, calling function +should sort endpoints or call writeLine() instead */ +void drawFastVLine(short x, short y,short h, short color) +{ + //startWrite(); + writeLine(x, y, x, y+h-1, color); + //endWrite(); +} + +/* (x,y) is topmost point; if unsure, calling function +should sort endpoints or call writeLine() instead */ +void writeFastVLine(short x, short y, short h, short color) +{ + drawFastVLine(x, y, h, color); +} + +/* (x,y) is leftmost point; if unsure, calling function + should sort endpoints or call writeLine() instead */ +void drawFastHLine(short x, short y,short w, short color) +{ + //startWrite(); + writeLine(x, y, x+w-1, y, color); + //endWrite(); +} + +// (x,y) is leftmost point; if unsure, calling function +// should sort endpoints or call writeLine() instead +void writeFastHLine(short x, short y, short w, short color) +{ + drawFastHLine(x, y, w, color); +} + +/**************************************************************** + * Function Name : drawCircleHelper + * Description : Draw a.... + * Returns : NONE + * Params : @x: X Co-ordinate + * @y: Y Co-ordinate + * @w: Width + * @h: height + * @r: Corner radius + * @color: Pixel color + ****************************************************************/ +void drawCircleHelper( short x0, short y0, short r, unsigned char cornername, short color) +{ + short f = 1 - r; + short ddF_x = 1; + short ddF_y = -2 * r; + short x = 0; + short y = r; + + while (x= 0) + { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x; + if (cornername & 0x4) + { + drawPixel(x0 + x, y0 + y, color); + drawPixel(x0 + y, y0 + x, color); + } + if (cornername & 0x2) + { + drawPixel(x0 + x, y0 - y, color); + drawPixel(x0 + y, y0 - x, color); + } + if (cornername & 0x8) + { + drawPixel(x0 - y, y0 + x, color); + drawPixel(x0 - x, y0 + y, color); + } + if (cornername & 0x1) + { + drawPixel(x0 - y, y0 - x, color); + drawPixel(x0 - x, y0 - y, color); + } + } +} + +/**************************************************************** + * Function Name : drawLine + * Description : Draw line between two points + * Returns : NONE + * Params : @x0: X0 Starting X Co-ordinate + * @y0: Y0 Starting Y Co-ordinate + * @x1: X1 Ending X Co-ordinate + * @y1: Y1 Ending Y Co-ordinate + * @color: Pixel color + ****************************************************************/ +void drawLine(short x0, short y0, short x1, short y1, short color) +{ + if(x0 == x1) + { + if(y0 > y1) + SWAP(y0, y1); + drawFastVLine(x0, y0, y1 - y0 + 1, color); + } + else if(y0 == y1) + { + if(x0 > x1) SWAP(x0, x1); + drawFastHLine(x0, y0, x1 - x0 + 1, color); + } + else + { + //startWrite(); + writeLine(x0, y0, x1, y1, color); + //endWrite(); + } +} + +/**************************************************************** + * Function Name : drawRect + * Description : Draw a rectangle + * Returns : NONE + * Params : @x: Corner X Co-ordinate + * @y: Corner Y Co-ordinate + * @w: Width in pixels + * @h: Height in pixels + * @color: Pixel color + ****************************************************************/ +void drawRect(short x, short y, short w, short h, short color) +{ + //startWrite(); + writeFastHLine(x, y, w, color); + writeFastHLine(x, y+h-1, w, color); + writeFastVLine(x, y, h, color); + writeFastVLine(x+w-1, y, h, color); + //endWrite(); +} + +/**************************************************************** + * Function Name : fillRect + * Description : Fill the rectangle + * Returns : NONE + * Params : @x: Starting X Co-ordinate + * @y: Starting Y Co-ordinate + * @w: Width in pixels + * @h: Height in pixels + * @color: Pixel color + ****************************************************************/ +void fillRect(short x, short y, short w, short h, short color) +{ + short i = 0; + //startWrite(); + for (i=x; i= 0) + { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x; + + drawPixel(x0 + x, y0 + y, color); + drawPixel(x0 - x, y0 + y, color); + drawPixel(x0 + x, y0 - y, color); + drawPixel(x0 - x, y0 - y, color); + drawPixel(x0 + y, y0 + x, color); + drawPixel(x0 - y, y0 + x, color); + drawPixel(x0 + y, y0 - x, color); + drawPixel(x0 - y, y0 - x, color); + } + //endWrite(); +} + +/**************************************************************** + * Function Name : fillCircleHelper + * Description : Used to do circles and roundrects + * Returns : NONE + * Params : @x: Center X Co-ordinate + * @y: Center Y Co-ordinate + * @r: Radius in pixels + * @cornername: Corner radius in pixels + * @color: Pixel color + ****************************************************************/ +void fillCircleHelper(short x0, short y0, short r, unsigned char cornername, short delta, short color) +{ + + short f = 1 - r; + short ddF_x = 1; + short ddF_y = -2 * r; + short x = 0; + short y = r; + + while (x= 0) + { + y--; + ddF_y += 2; + f += ddF_y; + } + x++; + ddF_x += 2; + f += ddF_x; + + if (cornername & 0x1) + { + writeFastVLine(x0+x, y0-y, 2*y+1+delta, color); + writeFastVLine(x0+y, y0-x, 2*x+1+delta, color); + } + if (cornername & 0x2) + { + writeFastVLine(x0-x, y0-y, 2*y+1+delta, color); + writeFastVLine(x0-y, y0-x, 2*x+1+delta, color); + } + } +} + +/**************************************************************** + * Function Name : fillCircle + * Description : Fill the circle + * Returns : NONE + * Params : @x0: Center X Co-ordinate + * @y0: Center Y Co-ordinate + * @r: Radius in pixels + * @color: Pixel color + ****************************************************************/ +void fillCircle(short x0, short y0, short r, short color) +{ + //startWrite(); + writeFastVLine(x0, y0-r, 2*r+1, color); + fillCircleHelper(x0, y0, r, 3, 0, color); + //endWrite(); +} + +/**************************************************************** + * Function Name : drawTriangle + * Description : Draw a triangle + * Returns : NONE + * Params : @x0: Corner-1 X Co-ordinate + * @y0: Corner-1 Y Co-ordinate + * @x1: Corner-2 X Co-ordinate + * @y1: Corner-2 Y Co-ordinate + * @x2: Corner-3 X Co-ordinate + * @y2: Corner-3 Y Co-ordinate + * @color: Pixel color + ****************************************************************/ +void drawTriangle(short x0, short y0, short x1, short y1, short x2, short y2, short color) +{ + drawLine(x0, y0, x1, y1, color); + drawLine(x1, y1, x2, y2, color); + drawLine(x2, y2, x0, y0, color); +} + +/**************************************************************** + * Function Name : fillTriangle + * Description : Fill a triangle + * Returns : NONE + * Params : @x0: Corner-1 X Co-ordinate + * @y0: Corner-1 Y Co-ordinate + * @x1: Corner-2 X Co-ordinate + * @y1: Corner-2 Y Co-ordinate + * @x2: Corner-3 X Co-ordinate + * @y2: Corner-3 Y Co-ordinate + * @color: Pixel color + ****************************************************************/ +void fillTriangle(short x0, short y0, short x1, short y1, short x2, short y2, short color) +{ + short a, b, y, last, dx01, dy01, dx02, dy02, dx12, dy12; + int sa, sb; + + // Sort coordinates by Y order (y2 >= y1 >= y0) + if (y0 > y1) + { + SWAP(y0, y1); + SWAP(x0, x1); + } + if (y1 > y2) + { + SWAP(y2, y1); + SWAP(x2, x1); + } + if (y0 > y1) + { + SWAP(y0, y1); + SWAP(x0, x1); + } + + //startWrite(); + if(y0 == y2) + { // Handle awkward all-on-same-line case as its own thing + a = b = x0; + if(x1 < a) + a = x1; + else if(x1 > b) + b = x1; + if(x2 < a) + a = x2; + else if(x2 > b) + b = x2; + writeFastHLine(a, y0, b-a+1, color); + // endWrite(); + return; + } + + dx01 = x1 - x0; + dy01 = y1 - y0; + dx02 = x2 - x0; + dy02 = y2 - y0; + dx12 = x2 - x1; + dy12 = y2 - y1; + sa = 0; + sb = 0; + + // For upper part of triangle, find scanline crossings for segments + // 0-1 and 0-2. If y1=y2 (flat-bottomed triangle), the scanline y1 + // is included here (and second loop will be skipped, avoiding a /0 + // error there), otherwise scanline y1 is skipped here and handled + // in the second loop...which also avoids a /0 error here if y0=y1 + // (flat-topped triangle). + if(y1 == y2) + last = y1; // Include y1 scanline + else + last = y1-1; // Skip it + + for(y=y0; y<=last; y++) + { + a = x0 + sa / dy01; + b = x0 + sb / dy02; + sa += dx01; + sb += dx02; + /* longhand: + a = x0 + (x1 - x0) * (y - y0) / (y1 - y0); + b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); + */ + if(a > b) + SWAP(a,b); + writeFastHLine(a, y, b-a+1, color); + } + + // For lower part of triangle, find scanline crossings for segments + // 0-2 and 1-2. This loop is skipped if y1=y2. + sa = dx12 * (y - y1); + sb = dx02 * (y - y0); + for(; y<=y2; y++) + { + a = x1 + sa / dy12; + b = x0 + sb / dy02; + sa += dx12; + sb += dx02; + /* longhand: + a = x1 + (x2 - x1) * (y - y1) / (y2 - y1); + b = x0 + (x2 - x0) * (y - y0) / (y2 - y0); + */ + if(a > b) + SWAP(a,b); + writeFastHLine(a, y, b-a+1, color); + } + //endWrite(); +} + +/**************************************************************** + * Function Name : drawRoundRect + * Description : Draw a rounded rectangle + * Returns : NONE + * Params : @x: X Co-ordinate + * @y: Y Co-ordinate + * @w: Width + * @h: height + * @r: Corner radius + * @color: Pixel color + ****************************************************************/ +void drawRoundRect(short x, short y, short w, short h, short r, short color) +{ + // smarter version + //startWrite(); + writeFastHLine(x+r , y , w-2*r, color); // Top + writeFastHLine(x+r , y+h-1, w-2*r, color); // Bottom + writeFastVLine(x , y+r , h-2*r, color); // Left + writeFastVLine(x+w-1, y+r , h-2*r, color); // Right + // draw four corners + drawCircleHelper(x+r , y+r , r, 1, color); + drawCircleHelper(x+w-r-1, y+r , r, 2, color); + drawCircleHelper(x+w-r-1, y+h-r-1, r, 4, color); + drawCircleHelper(x+r , y+h-r-1, r, 8, color); + //endWrite(); +} + +/**************************************************************** + * Function Name : fillRoundRect + * Description : Fill a rounded rectangle + * Returns : NONE + * Params : @x: X Co-ordinate + * @y: Y Co-ordinate + * @w: Width + * @h: height + * @r: Corner radius + * @color: Pixel color + ****************************************************************/ +void fillRoundRect(short x, short y, short w, short h, short r, short color) +{ + // smarter version + //startWrite(); + fillRect(x+r, y, w-2*r, h, color); + + // draw four corners + fillCircleHelper(x+w-r-1, y+r, r, 1, h-2*r-1, color); + fillCircleHelper(x+r , y+r, r, 2, h-2*r-1, color); + //endWrite(); +} + +/*---------------------------------------------------------------------------- + * BITMAP API's + ----------------------------------------------------------------------------*/ + +/**************************************************************** + * Function Name : drawBitmap + * Description : Draw a bitmap + * Returns : NONE + * Params : @x: X Co-ordinate + * @y: Y Co-ordinate + * @bitmap: bitmap to display + * @w: Width + * @h: height + * @color: Pixel color + ****************************************************************/ +void drawBitmap(short x, short y, const unsigned char bitmap[], short w, short h, short color) +{ + short byteWidth = 0, j = 0, i = 0; + unsigned char byte = 0; + byteWidth = (w + 7) / 8; // Bitmap scanline pad = whole byte + + for(j=0; j 0) ? s : 1; +} + +/**************************************************************** + * Function Name : setTextColor + * Description : Set text color + * Returns : @c - Color + ****************************************************************/ +void setTextColor(short c) +{ + // For 'transparent' background, we'll set the bg + // to the same as fg instead of using a flag + textcolor = textbgcolor = c; +} + +/**************************************************************** + * Function Name : setTextWrap + * Description : Wraps the text + * Returns : @w - enable or disbale wrap + ****************************************************************/ +void setTextWrap(bool w) +{ + wrap = w; +} + +/**************************************************************** + * Function Name : getRotation + * Description : Get the rotation value + * Returns : NONE. + ****************************************************************/ +unsigned char getRotation() +{ + return _rotation; +} + +/**************************************************************** + * Function Name : drawBitmap + * Description : Draw a character + * Returns : NONE + * Params : @x: X Co-ordinate + * @y: Y Co-ordinate + * @c: Character + * @size: Scaling factor + * @bg: Background color + * @color: Pixel color + ****************************************************************/ +void drawChar(short x, short y, unsigned char c, short color, short bg, unsigned char size) +{ + unsigned char line = 0, *bitmap = NULL, w = 0, h = 0, xx = 0, yy = 0, bits = 0, bit = 0; + char i = 0, j = 0, xo = 0, yo = 0; + short bo = 0, xo16 = 0, yo16 = 0; + GFXglyphPtr glyph; + if(!gfxFont) + { + // 'Classic' built-in font + if((x >= _width) || (y >= _height) || ((x + 6 * size - 1) < 0) || ((y + 8 * size - 1) < 0)) + return; + + // Handle 'classic' charset behavior + if(!_cp437 && (c >= 176)) + c++; + + // Char bitmap = 5 columns + for(i=0; i<5; i++ ) + { + line = pgm_read_byte(&ssd1306_font5x7[c * 5 + i]); + for(j=0; j<8; j++, line >>= 1) + { + if(line & 1) + { + if(size == 1) + drawPixel(x+i, y+j, color); + else + fillRect(x+i*size, y+j*size, size, size, color); + } + else if(bg != color) + { + if(size == 1) + drawPixel(x+i, y+j, bg); + else + fillRect(x+i*size, y+j*size, size, size, bg); + } + } + } + + // If opaque, draw vertical line for last column + if(bg != color) + { + if(size == 1) + writeFastVLine(x+5, y, 8, bg); + else + fillRect(x+5*size, y, size, 8*size, bg); + } + + } + // Custom font + else + { + // Character is assumed previously filtered by write() to eliminate + // newlines, returns, non-printable characters, etc. Calling + // drawChar() directly with 'bad' characters of font may cause mayhem! + + c -= (unsigned char)pgm_read_byte(&gfxFont->first); + glyph = &(((GFXglyphT *)pgm_read_pointer(&gfxFont->glyph))[c]); + bitmap = (unsigned char *)pgm_read_pointer(&gfxFont->bitmap); + bo = pgm_read_word(&glyph->bitmapOffset); + w = pgm_read_byte(&glyph->width); + h = pgm_read_byte(&glyph->height); + xo = pgm_read_byte(&glyph->xOffset); + yo = pgm_read_byte(&glyph->yOffset); + + if(size > 1) + { + xo16 = xo; + yo16 = yo; + } + + // Todo: Add character clipping here + + // NOTE: THERE IS NO 'BACKGROUND' COLOR OPTION ON CUSTOM FONTS. + // THIS IS ON PURPOSE AND BY DESIGN. The background color feature + // has typically been used with the 'classic' font to overwrite old + // screen contents with new data. This ONLY works because the + // characters are a uniform size; it's not a sensible thing to do with + // proportionally-spaced fonts with glyphs of varying sizes (and that + // may overlap). To replace previously-drawn text when using a custom + // font, use the getTextBounds() function to determine the smallest + // rectangle encompassing a string, erase the area with fillRect(), + // then draw new text. This WILL unfortunately 'blink' the text, but + // is unavoidable. Drawing 'background' pixels will NOT fix this, + // only creates a new set of problems. Have an idea to work around + // this (a canvas object type for MCUs that can afford the RAM and + // displays supporting setAddrWindow() and pushColors()), but haven't + // implemented this yet. + for(yy=0; yy _width)) + { + // Off right? + cursor_x = 0; // Reset x to zero, + cursor_y += textsize * 8; // advance y one line + } + drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize); + cursor_x += textsize * 6; // Advance x one char + } + + } + else + { + // Custom font + if(c == '\n') + { + cursor_x = 0; + cursor_y += (short)textsize *(unsigned char)pgm_read_byte(&gfxFont->yAdvance); + } + else if(c != '\r') + { + first = pgm_read_byte(&gfxFont->first); + if((c >= first) && (c <= (unsigned char)pgm_read_byte(&gfxFont->last))) + { + glyph = &(((GFXglyphT*)pgm_read_pointer(&gfxFont->glyph))[c - first]); + w = pgm_read_byte(&glyph->width); + h = pgm_read_byte(&glyph->height); + if((w > 0) && (h > 0)) + { + // Is there an associated bitmap? + xo = (char)pgm_read_byte(&glyph->xOffset); // sic + if(wrap && ((cursor_x + textsize * (xo + w)) > _width)) + { + cursor_x = 0; + cursor_y += (short)textsize *(unsigned char)pgm_read_byte(&gfxFont->yAdvance); + } + drawChar(cursor_x, cursor_y, c, textcolor, textbgcolor, textsize); + } + cursor_x += (unsigned char)pgm_read_byte(&glyph->xAdvance) * (short)textsize; + } + } + } + return 1; +} + +/**************************************************************** + * Function Name : print + * Description : Base function for printing strings + * Returns : No. of characters printed + * Params : @buffer: Ptr to buffer containing the string + * @size: Length of the string. + ****************************************************************/ +short print(const unsigned char *buffer, short size) +{ + short n = 0; + while(size--) + { + if(oled_write(*buffer++)) + n++; + else + break; + } + return (n); +} + +/**************************************************************** + * Function Name : print_str + * Description : Print strings + * Returns : No. of characters printed + * Params : @strPtr: Ptr to buffer containing the string + ****************************************************************/ +short print_str(const unsigned char *strPtr) +{ + return print(strPtr, strlen(strPtr)); +} + +/**************************************************************** + * Function Name : println + * Description : Move to next line + * Returns : No. of characters printed + * Params : NONE. + ****************************************************************/ +short println() +{ + return print_str("\r\n"); +} + +/**************************************************************** + * Function Name : print_strln + * Description : Print strings and move to next line + * Returns : No. of characters printed + * Params : @strPtr: Ptr to buffer containing the string + ****************************************************************/ +short print_strln(const unsigned char *strPtr) +{ + short n = 0; + n = print(strPtr, strlen(strPtr)); + n += print_str("\r\n"); + return (n); +} + +/*---------------------------------------------------------------------------- + * NUMBERS HANDLING API's + ----------------------------------------------------------------------------*/ + +/**************************************************************** + * Function Name : printNumber + * Description : Base function to print unsigned numbers + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber(unsigned long n, unsigned char base) +{ + unsigned long m = 0; + char c = 0; + char buf[8 * sizeof(long) + 1]; // Assumes 8-bit chars plus zero byte. + char *str = &buf[sizeof(buf) - 1]; + + *str = '\0'; + + // prevent crash if called with base == 1 + if(base < 2) + base = 10; + do + { + m = n; + n /= base; + c = m - base * n; + *--str = c < 10 ? c + '0' : c + 'A' - 10; + } + while(n); + //return oled_write((unsigned char)str); + return print_str(str); +} + +/**************************************************************** + * Function Name : printNumber_UL + * Description : Print unsigned long data types + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_UL(unsigned long n, int base) +{ + if(base == 0) + return oled_write(n); + else + return printNumber(n, base); +} + +/**************************************************************** + * Function Name : printNumber_UL_ln + * Description : Print unsigned long & advance to next line + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_UL_ln(unsigned long num, int base) +{ + short n = 0; + n = printNumber(num, base); + n += println(); + return (n); +} + +/**************************************************************** + * Function Name : printNumber_UI + * Description : Print unsigned int data types + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_UI(unsigned int n, int base) +{ + return printNumber((unsigned long) n, base); +} + +/**************************************************************** + * Function Name : printNumber_UI_ln + * Description : Print unsigned int & advance to next line + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_UI_ln(unsigned int n, int base) +{ + short a = 0; + a = printNumber((unsigned long) n, base); + a += println(); + return (a); +} + +/**************************************************************** + * Function Name : printNumber_UC + * Description : Print unsigned char data types + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_UC(unsigned char b, int base) +{ + return printNumber((unsigned long) b, base); +} + +/**************************************************************** + * Function Name : printNumber_UC_ln + * Description : Print unsigned char & advance to next line + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_UC_ln(unsigned char b, int base) +{ + short n = 0; + n = printNumber((unsigned long) b, base); + n += println(); + return (n); +} + +/**************************************************************** + * Function Name : printNumber_L + * Description : Print Long data types + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_L(long n, int base) +{ + int t = 0; + if(base == 0) + { + return oled_write(n); + } + else if(base == 10) + { + if(n < 0) + { + t = oled_write('-'); + n = -n; + return printNumber(n, 10) + t; + } + return printNumber(n, 10); + } + else + { + return printNumber(n, base); + } +} + +/**************************************************************** + * Function Name : printNumber_UC_ln + * Description : Print long & advance to next line + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_L_ln(long num, int base) +{ + short n = 0; + n = printNumber_L(num, base); + n += println(); + return n; +} + +/**************************************************************** + * Function Name : printNumber_I + * Description : Print int data types + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_I(int n, int base) +{ + return printNumber_L((long) n, base); +} + +/**************************************************************** + * Function Name : printNumber_I_ln + * Description : Print int & advance to next line + * Returns : No. of characters printed + * Params : @n: Number + * @base: Base e.g. HEX, BIN... + ****************************************************************/ +short printNumber_I_ln(int n, int base) +{ + short a = 0; + a = printNumber_L((long) n, base); + a += println(); + return a; +} + +/**************************************************************** + * Function Name : printFloat + * Description : Print floating Pt. No's. + * Returns : No. of characters printed + * Params : @n: Number + * @digits: Resolution + ****************************************************************/ +short printFloat(double number, unsigned char digits) +{ + unsigned char i = 0; + short n = 0; + unsigned long int_part = 0; + double remainder = 0.0; + int toPrint = 0; + + // Round correctly so that print(1.999, 2) prints as "2.00" + double rounding = 0.5; + + if(isnan(number)) + return print_str("nan"); + if(isinf(number)) + return print_str("inf"); + if(number > 4294967040.0) + return print_str("ovf"); // constant determined empirically + if(number < -4294967040.0) + return print_str("ovf"); // constant determined empirically + + // Handle negative numbers + if(number < 0.0) + { + n += oled_write('-'); + number = -number; + } + + + for(i = 0; i < digits; ++i) + rounding /= 10.0; + + number += rounding; + + // Extract the integer part of the number and print it + int_part = (unsigned long) number; + remainder = number - (double) int_part; + n += printNumber_UL(int_part,DEC); + + // Print the decimal point, but only if there are digits beyond + if(digits > 0) + { + n += print_str("."); + } + + // Extract digits from the remainder one at a time + while(digits-- > 0) + { + remainder *= 10.0; + toPrint = (int)remainder; + n += printNumber_I(toPrint,DEC); + remainder -= toPrint; + } + return n; +} + +/**************************************************************** + * Function Name : printFloat_ln + * Description : Print floating Pt. No and advance to next line + * Returns : No. of characters printed + * Params : @n: Number + * @digits: Resolution + ****************************************************************/ +short printFloat_ln(double num, int digits) +{ + short n = 0; + n = printFloat(num, digits); + n += println(); + return n; +} diff --git a/luci-app-ouad/src/SSD1306_OLED_Library/SSD1306_OLED.h b/luci-app-ouad/src/SSD1306_OLED_Library/SSD1306_OLED.h new file mode 100755 index 000000000..fa7d39657 --- /dev/null +++ b/luci-app-ouad/src/SSD1306_OLED_Library/SSD1306_OLED.h @@ -0,0 +1,204 @@ +/* + * MIT License + +Copyright (c) 2017 DeeplyEmbedded + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + * SSD1306_OLED.h + * + * Created on : Sep 21, 2017 + * Author : Vinay Divakar + * Website : www.deeplyembedded.org + */ + +#ifndef SSD1306_OLED_H_ +#define SSD1306_OLED_H_ + +/* Lib's */ +#include + +/* Find Min and Max - MACROS */ +#define MIN(a,b) (((a)<(b))?(a):(b)) +#define MAX(a,b) (((a)>(b))?(a):(b)) + +/* I2C Address of SSD1306 */ +#define SSD1306_OLED_ADDR 0x3C +#define DISPLAY_BUFF_SIZE (SSD1306_LCDWIDTH*SSD1306_LCDHEIGHT/8) + +/* COLOR MACROS */ +#define WHITE 1 +#define BLACK 0 +#define INVERSE 2 + +/* Number output format */ +#define DEC 10 +#define HEX 16 +#define OCT 8 +#define BIN 2 +#define DEFAULT 0 + +/*D/C# bit is '0' indicating that following + * byte is a command. '1' is for data + */ +#define SSD1306_CNTRL_CMD 0x00 +#define SSD1306_CNTRL_DATA 0x40 + + +/*-----------------------Enable the WxL of the Display ---------------------------*/ +#define SSD1306_128_64 +//#define SSD1306_128_32 +//#define SSD1306_96_16 +/*--------------------------------------------------------------------------------*/ + +/* LCD HxW i.e. 64x128 || WxL i.e. 128x64 */ +#if defined SSD1306_128_64 +#define SSD1306_LCDWIDTH 128 +#define SSD1306_LCDHEIGHT 64 +#endif +#if defined SSD1306_128_32 + #define SSD1306_LCDWIDTH 128 + #define SSD1306_LCDHEIGHT 32 +#endif +#if defined SSD1306_96_16 + #define SSD1306_LCDWIDTH 96 + #define SSD1306_LCDHEIGHT 16 +#endif + +/* SSD1306 Commands */ +#define SSD1306_DISPLAY_OFF 0xAE +#define SSD1306_SET_DISP_CLK 0xD5 +#define SSD1306_SET_MULTIPLEX 0xA8 +#define SSD1306_SET_DISP_OFFSET 0xD3 +#define SSD1306_SET_DISP_START_LINE 0x40 +#define SSD1306_CONFIG_CHARGE_PUMP 0x8D +#define SSD1306_SET_MEM_ADDR_MODE 0x20 +#define SSD1306_SEG_REMAP (0xA0 | 0x01) +#define SSD1306_SEG_REMAP1 0xA0 +#define SSD1306_SET_COMSCANDEC 0xC8 +#define SSD1306_SET_COMSCANDEC1 0xC0 +#define SSD1306_SET_COMPINS 0xDA +#define SSD1306_SET_CONTRAST 0x81 +#define SSD1306_SET_PRECHARGE 0xD9 +#define SSD1306_SET_VCOMDETECT 0xDB +#define SSD1306_DISPLAYALLON_RESUME 0xA4 +#define SSD1306_NORMAL_DISPLAY 0xA6 +#define SSD1306_DISPLAYON 0xAF +#define SSD1306_SET_COL_ADDR 0x21 +#define SSD1306_PAGEADDR 0x22 +#define SSD1306_INVERT_DISPLAY 0x01 +#define SSD1306_NORMALIZE_DISPLAY 0x00 + +/* SDD1306 Scroll Commands */ +#define SSD1306_SET_VERTICAL_SCROLL_AREA 0xA3 +#define SSD1306_ACTIVATE_SCROLL 0x2F +#define SSD1306_DEACTIVATE_SCROLL 0x2E +#define SSD1306_RIGHT_HORIZONTAL_SCROLL 0x26 +#define SSD1306_LEFT_HORIZONTAL_SCROLL 0x27 +#define SSD1306_VERTICAL_AND_RIGHT_HORIZONTAL_SCROLL 0x29 +#define SSD1306_VERTICAL_AND_LEFT_HORIZONTAL_SCROLL 0x2A +#define SSD1306_INVERTDISPLAY 0xA7 + +/* SSD1306 Configuration Commands */ +#define SSD1306_DISPCLK_DIV 0x80 +#if defined SSD1306_128_64 +#define SSD1306_MULT_64 0x3F +#endif +#if defined SSD1306_128_32 + #define SSD1306_MULT_64 0x1F +#endif +#define SSD1306_MULT_64 0x1F +#define SSD1306_DISP_OFFSET_VAL 0x00 +#define SSD1306_COL_START_ADDR 0x00 //Reset to = 0 +#define SSD1306_COL_END_ADDR (SSD1306_LCDWIDTH - 1) //Reset to = 127 +#define SSD1306_PG_START_ADDR 0x00 +#define SSD1306_PG_END_ADDR 7 +#define SSD1306_CHARGE_PUMP_EN 0x14 +#if defined SSD1306_128_64 +#define SSD1306_CONFIG_COM_PINS 0x12 +#endif +#if defined SSD1306_128_32 + #define SSD1306_CONFIG_COM_PINS 0x02 +#endif +#define SSD1306_CONTRAST_VAL 0xCF //207 +#define SSD1306_PRECHARGE_VAL 0xF1 +#define SSD1306_VCOMH_VAL 0x40 +#define SSD1306_MULT_DAT (SSD1306_LCDHEIGHT - 1) +#define SSD1306_HOR_MM 0x00 + +/*SSD1306 Display API's */ +extern void clearDisplay(); +extern void display_Init_seq(); +extern void Display(); +extern void Init_Col_PG_addrs(unsigned char col_start_addr, unsigned char col_end_addr, + unsigned char pg_start_addr, unsigned char pg_end_addr); +extern void setRotation(unsigned char x); +extern void startscrollright(unsigned char start, unsigned char stop); +extern void startscrollleft(unsigned char start, unsigned char stop); +extern void startscrolldiagright(unsigned char start, unsigned char stop); +extern void startscrolldiagleft(unsigned char start, unsigned char stop); +extern void stopscroll(); +extern void setCursor(short x, short y); +extern short getCursorX(); +extern short getCursorY(); +extern unsigned char getRotation(); +extern void invertDisplay(unsigned char i); + +/*SSD1306 Graphics Handling API's */ +extern signed char drawPixel(short x, short y, short color); +extern void writeLine(short x0, short y0, short x1, short y1, short color); +extern void drawCircleHelper( short x0, short y0, short r, unsigned char cornername, short color); +extern void drawLine(short x0, short y0, short x1, short y1, short color); +extern void drawRect(short x, short y, short w, short h, short color); +extern void fillRect(short x, short y, short w, short h, short color); +extern void drawCircle(short x0, short y0, short r, short color); +extern void fillCircleHelper(short x0, short y0, short r, unsigned char cornername, short delta, short color); +extern void fillCircle(short x0, short y0, short r, short color); +extern void drawTriangle(short x0, short y0, short x1, short y1, short x2, short y2, short color); +extern void fillTriangle(short x0, short y0, short x1, short y1, short x2, short y2, short color); +extern void drawRoundRect(short x, short y, short w, short h, short r, short color); +extern void fillRoundRect(short x, short y, short w, short h, short r, short color); +extern void drawBitmap(short x, short y, const unsigned char bitmap[], short w, short h, short color); +extern short oled_write(unsigned char c); + +/*SSD1306 Text and Character Handling API's */ +extern void setTextSize(unsigned char s); +extern void setTextColor(short c); +extern void setTextWrap(bool w); +extern void drawChar(short x, short y, unsigned char c, short color, short bg, unsigned char size); +extern short print_str(const unsigned char *strPtr); +extern short println(); +extern short print_strln(const unsigned char *strPtr); + +/*SSD1306 Number Handling API's */ +extern short printNumber(unsigned long n, unsigned char base); +extern short printNumber_UL(unsigned long n, int base); +extern short printNumber_UL_ln(unsigned long num, int base); +extern short printNumber_UI(unsigned int n, int base); +extern short printNumber_UI_ln(unsigned int n, int base); +extern short printNumber_UC(unsigned char b, int base); +extern short printNumber_UC_ln(unsigned char b, int base); +extern short printNumber_L(long n, int base); +extern short printNumber_L_ln(long num, int base); +extern short printNumber_I(int n, int base); +extern short printNumber_I_ln(int n, int base); +extern short printFloat(double number, unsigned char digits); +extern short printFloat_ln(double num, int digits); +#endif /* SSD1306_OLED_H_ */ + diff --git a/luci-app-ouad/src/SSD1306_OLED_Library/gfxfont.h b/luci-app-ouad/src/SSD1306_OLED_Library/gfxfont.h new file mode 100755 index 000000000..e66128a88 --- /dev/null +++ b/luci-app-ouad/src/SSD1306_OLED_Library/gfxfont.h @@ -0,0 +1,18 @@ +#ifndef _GFXFONT_H_ +#define _GFXFONT_H_ + +typedef struct { // Data stored PER GLYPH + unsigned short bitmapOffset; // Pointer into GFXfont->bitmap + unsigned char width, height; // Bitmap dimensions in pixels + unsigned char xAdvance; // Distance to advance cursor (x axis) + char xOffset, yOffset; // Dist from cursor pos to UL corner +} GFXglyphT, *GFXglyphPtr; + +typedef struct { // Data stored for FONT AS A WHOLE: + unsigned char *bitmap; // Glyph bitmaps, concatenated + GFXglyphPtr glyph; // Glyph array + unsigned char first, last; // ASCII extents + unsigned char yAdvance; // Newline distance (y axis) +} GFXfontT, *GFXfontPtr; + +#endif // _GFXFONT_H_ diff --git a/luci-app-packet-capture/Makefile b/luci-app-packet-capture/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/htdocs/luci-static/resources/view/packet_capture/tcpdump.js b/luci-app-packet-capture/htdocs/luci-static/resources/view/packet_capture/tcpdump.js old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/po/fr/packet-capture.po b/luci-app-packet-capture/po/fr/packet-capture.po old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/po/templates/packet-capture.pot b/luci-app-packet-capture/po/templates/packet-capture.pot old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/po/zh_Hans/packet-capture.po b/luci-app-packet-capture/po/zh_Hans/packet-capture.po old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/root/etc/config/packet_capture b/luci-app-packet-capture/root/etc/config/packet_capture old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/root/usr/share/luci/menu.d/luci-app-packet-capture.json b/luci-app-packet-capture/root/usr/share/luci/menu.d/luci-app-packet-capture.json old mode 100755 new mode 100644 diff --git a/luci-app-packet-capture/root/usr/share/rpcd/acl.d/luci-app-packet-capture.json b/luci-app-packet-capture/root/usr/share/rpcd/acl.d/luci-app-packet-capture.json old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/Makefile b/luci-app-shadowsocks-libev/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/htdocs/luci-static/resources/shadowsocks-libev.js b/luci-app-shadowsocks-libev/htdocs/luci-static/resources/shadowsocks-libev.js old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/htdocs/luci-static/resources/view/shadowsocks-libev/instances.js b/luci-app-shadowsocks-libev/htdocs/luci-static/resources/view/shadowsocks-libev/instances.js old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/htdocs/luci-static/resources/view/shadowsocks-libev/rules.js b/luci-app-shadowsocks-libev/htdocs/luci-static/resources/view/shadowsocks-libev/rules.js old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/htdocs/luci-static/resources/view/shadowsocks-libev/servers.js b/luci-app-shadowsocks-libev/htdocs/luci-static/resources/view/shadowsocks-libev/servers.js old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua b/luci-app-shadowsocks-libev/luasrc/controller/shadowsocks-libev.lua old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/bg/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/bg/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/ca/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/ca/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/cs/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/cs/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/de/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/de/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/el/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/el/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/en/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/en/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/es/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/es/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/fr/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/fr/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/he/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/he/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/hi/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/hi/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/hu/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/hu/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/it/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/it/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/ja/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/ja/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/ko/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/ko/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/ms/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/ms/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/nb_NO/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/nb_NO/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/pl/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/pl/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/pt/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/pt/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/pt_BR/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/pt_BR/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/ro/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/ro/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/ru/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/ru/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/sk/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/sk/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/sv/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/sv/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/templates/shadowsocks-libev.pot b/luci-app-shadowsocks-libev/po/templates/shadowsocks-libev.pot old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/tr/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/tr/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/uk/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/uk/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/vi/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/vi/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/zh-cn/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/zh-cn/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/po/zh-tw/shadowsocks-libev.po b/luci-app-shadowsocks-libev/po/zh-tw/shadowsocks-libev.po old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/root/etc/uci-defaults/40_luci-shadowsocks-libev b/luci-app-shadowsocks-libev/root/etc/uci-defaults/40_luci-shadowsocks-libev old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/root/usr/share/luci/menu.d/luci-app-shadowsocks-libev.json b/luci-app-shadowsocks-libev/root/usr/share/luci/menu.d/luci-app-shadowsocks-libev.json old mode 100755 new mode 100644 diff --git a/luci-app-shadowsocks-libev/root/usr/share/rpcd/acl.d/luci-app-shadowsocks-libev.json b/luci-app-shadowsocks-libev/root/usr/share/rpcd/acl.d/luci-app-shadowsocks-libev.json old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/Makefile b/luci-app-shutdown/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/htdocs/luci-static/resources/view/system/shutdown.js b/luci-app-shutdown/htdocs/luci-static/resources/view/system/shutdown.js old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/de/shutdown.po b/luci-app-shutdown/po/de/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/fr/shutdown.po b/luci-app-shutdown/po/fr/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/it/shutdown.po b/luci-app-shutdown/po/it/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/oc/shutdown.po b/luci-app-shutdown/po/oc/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/pl/shutdown.po b/luci-app-shutdown/po/pl/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/ru/shutdown.po b/luci-app-shutdown/po/ru/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/templates/shutdown.pot b/luci-app-shutdown/po/templates/shutdown.pot old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/po/zh_Hans/shutdown.po b/luci-app-shutdown/po/zh_Hans/shutdown.po old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/root/usr/share/luci/menu.d/luci-app-shutdown.json b/luci-app-shutdown/root/usr/share/luci/menu.d/luci-app-shutdown.json old mode 100755 new mode 100644 diff --git a/luci-app-shutdown/root/usr/share/rpcd/acl.d/luci-app-shutdown.json b/luci-app-shutdown/root/usr/share/rpcd/acl.d/luci-app-shutdown.json old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/Makefile b/luci-app-snmpd/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/luasrc/controller/snmpd.lua b/luci-app-snmpd/luasrc/controller/snmpd.lua old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/luasrc/model/cbi/snmpd.lua b/luci-app-snmpd/luasrc/model/cbi/snmpd.lua old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/luasrc/view/snmpd.htm b/luci-app-snmpd/luasrc/view/snmpd.htm old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/po/de/snmpd.po b/luci-app-snmpd/po/de/snmpd.po old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/po/fr/snmpd.po b/luci-app-snmpd/po/fr/snmpd.po old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/po/it/snmpd.po b/luci-app-snmpd/po/it/snmpd.po old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/po/oc/snmpd.po b/luci-app-snmpd/po/oc/snmpd.po old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/po/templates/snmpd.pot b/luci-app-snmpd/po/templates/snmpd.pot old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/po/zh_Hans/snmpd.po b/luci-app-snmpd/po/zh_Hans/snmpd.po old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/root/etc/config/snmpd b/luci-app-snmpd/root/etc/config/snmpd old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/root/usr/share/luci/menu.d/luci-app-snmpd.json b/luci-app-snmpd/root/usr/share/luci/menu.d/luci-app-snmpd.json old mode 100755 new mode 100644 diff --git a/luci-app-snmpd/root/usr/share/rpcd/acl.d/luci-app-snmpd.json b/luci-app-snmpd/root/usr/share/rpcd/acl.d/luci-app-snmpd.json old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/Makefile b/luci-app-sqm-autorate/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/htdocs/luci-static/resources/view/network/sqm.js b/luci-app-sqm-autorate/htdocs/luci-static/resources/view/network/sqm.js old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ar/sqm.po b/luci-app-sqm-autorate/po/ar/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/bg/sqm.po b/luci-app-sqm-autorate/po/bg/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/bn_BD/sqm.po b/luci-app-sqm-autorate/po/bn_BD/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ca/sqm.po b/luci-app-sqm-autorate/po/ca/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/cs/sqm.po b/luci-app-sqm-autorate/po/cs/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/da/sqm.po b/luci-app-sqm-autorate/po/da/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/de/sqm.po b/luci-app-sqm-autorate/po/de/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/el/sqm.po b/luci-app-sqm-autorate/po/el/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/en/sqm.po b/luci-app-sqm-autorate/po/en/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/es/sqm.po b/luci-app-sqm-autorate/po/es/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/fi/sqm.po b/luci-app-sqm-autorate/po/fi/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/fr/sqm.po b/luci-app-sqm-autorate/po/fr/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/he/sqm.po b/luci-app-sqm-autorate/po/he/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/hi/sqm.po b/luci-app-sqm-autorate/po/hi/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/hu/sqm.po b/luci-app-sqm-autorate/po/hu/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/it/sqm.po b/luci-app-sqm-autorate/po/it/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ja/sqm.po b/luci-app-sqm-autorate/po/ja/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ko/sqm.po b/luci-app-sqm-autorate/po/ko/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/mr/sqm.po b/luci-app-sqm-autorate/po/mr/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ms/sqm.po b/luci-app-sqm-autorate/po/ms/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/nb_NO/sqm.po b/luci-app-sqm-autorate/po/nb_NO/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/pl/sqm.po b/luci-app-sqm-autorate/po/pl/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/pt/sqm.po b/luci-app-sqm-autorate/po/pt/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/pt_BR/sqm.po b/luci-app-sqm-autorate/po/pt_BR/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ro/sqm.po b/luci-app-sqm-autorate/po/ro/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/ru/sqm.po b/luci-app-sqm-autorate/po/ru/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/sk/sqm.po b/luci-app-sqm-autorate/po/sk/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/sv/sqm.po b/luci-app-sqm-autorate/po/sv/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/templates/sqm.pot b/luci-app-sqm-autorate/po/templates/sqm.pot old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/tr/sqm.po b/luci-app-sqm-autorate/po/tr/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/uk/sqm.po b/luci-app-sqm-autorate/po/uk/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/vi/sqm.po b/luci-app-sqm-autorate/po/vi/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/zh_Hans/sqm.po b/luci-app-sqm-autorate/po/zh_Hans/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/po/zh_Hant/sqm.po b/luci-app-sqm-autorate/po/zh_Hant/sqm.po old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/root/usr/share/luci/menu.d/luci-app-sqm.json b/luci-app-sqm-autorate/root/usr/share/luci/menu.d/luci-app-sqm.json old mode 100755 new mode 100644 diff --git a/luci-app-sqm-autorate/root/usr/share/rpcd/acl.d/luci-app-sqm.json b/luci-app-sqm-autorate/root/usr/share/rpcd/acl.d/luci-app-sqm.json old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/Makefile b/luci-app-sysupgrade/Makefile old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/luasrc/view/sysupgrade.htm b/luci-app-sysupgrade/luasrc/view/sysupgrade.htm old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/po/fr/sysupgrade.po b/luci-app-sysupgrade/po/fr/sysupgrade.po old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/po/fr/sysupgrade.po~ b/luci-app-sysupgrade/po/fr/sysupgrade.po~ old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/po/ru/sysupgrade.po b/luci-app-sysupgrade/po/ru/sysupgrade.po old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/po/templates/sysupgrade.pot b/luci-app-sysupgrade/po/templates/sysupgrade.pot old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/po/zh_Hans/sysupgrade.po b/luci-app-sysupgrade/po/zh_Hans/sysupgrade.po old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/po/zh_Hans/sysupgrade.po~ b/luci-app-sysupgrade/po/zh_Hans/sysupgrade.po~ old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/root/usr/share/luci/menu.d/luci-app-sysupgrade.json b/luci-app-sysupgrade/root/usr/share/luci/menu.d/luci-app-sysupgrade.json old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/root/usr/share/rpcd/acl.d/sysupgrade.json b/luci-app-sysupgrade/root/usr/share/rpcd/acl.d/sysupgrade.json old mode 100755 new mode 100644 diff --git a/luci-app-sysupgrade/root/www/luci-static/resources/sysupgrade.js b/luci-app-sysupgrade/root/www/luci-static/resources/sysupgrade.js old mode 100755 new mode 100644 diff --git a/luci-app-zerotier-master/.gitattributes b/luci-app-zerotier-master/.gitattributes new file mode 100755 index 000000000..dfe077042 --- /dev/null +++ b/luci-app-zerotier-master/.gitattributes @@ -0,0 +1,2 @@ +# Auto detect text files and perform LF normalization +* text=auto diff --git a/luci-app-zerotier-master/.gitignore b/luci-app-zerotier-master/.gitignore new file mode 100755 index 000000000..5b9bd8749 --- /dev/null +++ b/luci-app-zerotier-master/.gitignore @@ -0,0 +1,2 @@ + +*.bak diff --git a/luci-app-zerotier-master/Makefile b/luci-app-zerotier-master/Makefile new file mode 100755 index 000000000..d557df631 --- /dev/null +++ b/luci-app-zerotier-master/Makefile @@ -0,0 +1,19 @@ +# +# Copyright (C) 2008-2014 The LuCI Team +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI for Zerotier +LUCI_DEPENDS:=+zerotier +LUCI_PKGARCH:=all +PKG_VERSION:=1.0 +PKG_RELEASE:=17 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + + diff --git a/luci-app-zerotier-master/README.md b/luci-app-zerotier-master/README.md new file mode 100755 index 000000000..bd9822cdd --- /dev/null +++ b/luci-app-zerotier-master/README.md @@ -0,0 +1,4 @@ +# luci-app-zerotier + +你不在乎网络安全,可我在乎
+与lean原版相比使用了op自带的防火墙,并增添了流量权限控制 \ No newline at end of file diff --git a/luci-app-zerotier-master/luasrc/controller/zerotier.lua b/luci-app-zerotier-master/luasrc/controller/zerotier.lua new file mode 100755 index 000000000..04559fb42 --- /dev/null +++ b/luci-app-zerotier-master/luasrc/controller/zerotier.lua @@ -0,0 +1,24 @@ +module("luci.controller.zerotier",package.seeall) + +function index() + if not nixio.fs.access("/etc/config/zerotier")then +return +end + +entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false + +entry({"admin", "vpn", "zerotier"},firstchild(), _("ZeroTier")).dependent = false + +entry({"admin", "vpn", "zerotier", "general"},cbi("zerotier/settings"), _("Base Setting"), 1) +entry({"admin", "vpn", "zerotier", "log"},form("zerotier/info"), _("Interface Info"), 2) +entry({"admin", "vpn", "zerotier", "manual"},cbi("zerotier/manual"), _("Manual Config"), 3) + +entry({"admin","vpn","zerotier","status"},call("act_status")) +end + +function act_status() +local e={} + e.running=luci.sys.call("pgrep /usr/bin/zerotier-one >/dev/null")==0 + luci.http.prepare_content("application/json") + luci.http.write_json(e) +end diff --git a/luci-app-zerotier-master/luasrc/model/cbi/zerotier/info.lua b/luci-app-zerotier-master/luasrc/model/cbi/zerotier/info.lua new file mode 100755 index 000000000..9bc3824cf --- /dev/null +++ b/luci-app-zerotier-master/luasrc/model/cbi/zerotier/info.lua @@ -0,0 +1,15 @@ +local fs = require "nixio.fs" +local conffile = "/tmp/zero.info" + +f = SimpleForm("logview") + +t = f:field(TextValue, "conf") +t.rmempty = true +t.rows = 15 +function t.cfgvalue() + luci.sys.exec("ifconfig $(ifconfig | grep zt | awk '{print $1}') > /tmp/zero.info") + return fs.readfile(conffile) or "" +end +t.readonly="readonly" + +return f \ No newline at end of file diff --git a/luci-app-zerotier-master/luasrc/model/cbi/zerotier/manual.lua b/luci-app-zerotier-master/luasrc/model/cbi/zerotier/manual.lua new file mode 100755 index 000000000..13a72d7c0 --- /dev/null +++ b/luci-app-zerotier-master/luasrc/model/cbi/zerotier/manual.lua @@ -0,0 +1,25 @@ +local m, s, o +local fs = require "nixio.fs" +local jsonc = require "luci.jsonc" or nil +m = Map("zerotier") +s=m:section(NamedSection,"sample_config","zerotier") +s.anonymous=true +s.addremove=false +o = s:option(TextValue, "manualconfig") +o.rows = 20 +o.wrap = "soft" +o.rmempty = true +o.cfgvalue = function(self, section) + return fs.readfile("/etc/config/zero/local.conf") +end +o.write = function(self, section, value) + fs.writefile("/etc/config/zero/local.conf", value:gsub("\r\n", "\n")) +end +o.validate=function(self, value) + if jsonc == nil or jsonc.parse(value)~=nil then + return value + end + return nil +end +o.description='https://www.zerotier.com/manual/
https://github.com/zerotier/ZeroTierOne/blob/db813db7e875c257e42c41ab8091c3df1e9300a5/service/README.md' +return m \ No newline at end of file diff --git a/luci-app-zerotier-master/luasrc/model/cbi/zerotier/settings.lua b/luci-app-zerotier-master/luasrc/model/cbi/zerotier/settings.lua new file mode 100755 index 000000000..7131f6728 --- /dev/null +++ b/luci-app-zerotier-master/luasrc/model/cbi/zerotier/settings.lua @@ -0,0 +1,34 @@ + +a=Map("zerotier",translate("ZeroTier"),translate("Zerotier is an open source, cross-platform and easy to use virtual LAN")) +a:section(SimpleSection).template = "zerotier/zerotier_status" + +t=a:section(NamedSection,"sample_config","zerotier") +t.anonymous=true +t.addremove=false + +e=t:option(Flag,"enabled",translate("Enable")) +e.default=0 +e.rmempty=false + +e=t:option(DynamicList,"join",translate('ZeroTier Network ID')) +e.password=true +e.rmempty=false + +e=t:option(Flag,"nat",translate("Auto NAT Clients")) +e.default=0 +e.rmempty=false + +e = t:option(MultiValue, "access", translate("Zerotier access control")) +e.default="lanfwzt ztfwwan ztfwlan" +e.rmempty=false +e:value("lanfwzt",translate("lan access zerotier")) +e:value("wanfwzt",translate("wan access zerotier")) +e:value("ztfwwan",translate("remote access wan")) +e:value("ztfwlan",translate("remote access lan")) +e.widget = "checkbox" + +e=t:option(DummyValue,"opennewwindow" , + translate("")) +e.description = translate("Create or manage your zerotier network, and auth clients who could access") + +return a diff --git a/luci-app-zerotier-master/luasrc/view/zerotier/zerotier_status.htm b/luci-app-zerotier-master/luasrc/view/zerotier/zerotier_status.htm new file mode 100755 index 000000000..9d216c5d9 --- /dev/null +++ b/luci-app-zerotier-master/luasrc/view/zerotier/zerotier_status.htm @@ -0,0 +1,22 @@ + + +
+

+ <%:Collecting data...%> +

+
diff --git a/luci-app-zerotier-master/po/zh-cn/zerotier.po b/luci-app-zerotier-master/po/zh-cn/zerotier.po new file mode 100755 index 000000000..2fb491ed4 --- /dev/null +++ b/luci-app-zerotier-master/po/zh-cn/zerotier.po @@ -0,0 +1,28 @@ +msgid "" +msgstr "" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Gtranslator 2.91.7\n" +"Plural-Forms: nplurals=1; plural=0;\n" + +msgid "Zerotier is an open source, cross-platform and easy to use virtual LAN" +msgstr "Zerotier是一个开源,跨平台,而且适合内网穿透互联的傻瓜配置虚拟 VPN LAN" + +msgid "Auto NAT Clients" +msgstr "自动允许客户端NAT" + +msgid "Allow zerotier clients access your LAN network" +msgstr "允许Zerotier的拨入客户端访问路由器LAN资源(需要在 Zerotier管理页面设定到LAN网段的路由表)" + +msgid "Create or manage your zerotier network, and auth clients who could access" +msgstr "点击跳转到Zerotier官网管理平台,新建或者管理网络,并允许客户端接入访问你私人网路(新接入的节点默认不允许访问)" + +msgid "Interface Info" +msgstr "接口信息" + +msgid "Zerotier access control" +msgstr "Zerotier 准入控制" + +msgid "Manual Config" +msgstr "手动设置" diff --git a/luci-app-zerotier-master/root/etc/config/zero/local.conf b/luci-app-zerotier-master/root/etc/config/zero/local.conf new file mode 100755 index 000000000..2214f7cc1 --- /dev/null +++ b/luci-app-zerotier-master/root/etc/config/zero/local.conf @@ -0,0 +1,5 @@ +{ +"settings": { + "multipathMode": 2 + } + } \ No newline at end of file diff --git a/luci-app-zerotier-master/root/etc/init.d/zerotier b/luci-app-zerotier-master/root/etc/init.d/zerotier new file mode 100755 index 000000000..60cebbdc0 --- /dev/null +++ b/luci-app-zerotier-master/root/etc/init.d/zerotier @@ -0,0 +1,163 @@ +#!/bin/sh /etc/rc.common + +START=90 + +USE_PROCD=1 + +PROG=/usr/bin/zerotier-one +CONFIG_PATH=/var/lib/zerotier-one + +section_enabled() { + config_get_bool enabled "$1" 'enabled' 0 + [ $enabled -gt 0 ] +} +service_triggers() { + procd_add_reload_trigger zerotier +} +start_instance() { + local cfg="$1" + local port secret config_path + local ARGS="" + + if ! section_enabled "$cfg"; then + echo "disabled in config" + return 1 + fi + + [ -d /etc/config/zero ] || mkdir -p /etc/config/zero + config_path=/etc/config/zero + + config_get_bool port $cfg 'port' + config_get secret $cfg 'secret' + + # Remove existing link or folder + rm -rf $CONFIG_PATH + + # Create link from CONFIG_PATH to config_path + if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then + if [ ! -d "$config_path" ]; then + echo "ZeroTier config_path does not exist: $config_path" + return + fi + + ln -s $config_path $CONFIG_PATH + fi + + mkdir -p $CONFIG_PATH/networks.d + + if [ -n "$port" ]; then + ARGS="$ARGS -p$port" + fi + + if [ "$secret" = "generate" ]; then + echo "Generate secret - please wait..." + local sf="/tmp/zt.$cfg.secret" + + zerotier-idtool generate "$sf" > /dev/null + [ $? -ne 0 ] && return 1 + + secret="$(cat $sf)" + rm "$sf" + + uci set zerotier.$cfg.secret="$secret" + uci commit zerotier + fi + + if [ -n "$secret" ]; then + echo "$secret" > $CONFIG_PATH/identity.secret + # make sure there is not previous identity.public + rm -f $CONFIG_PATH/identity.public + fi + + add_join() { + # an (empty) config file will cause ZT to join a network + touch $CONFIG_PATH/networks.d/$1.conf + } + + config_list_foreach $cfg 'join' add_join + + procd_open_instance + procd_set_param command $PROG $ARGS $CONFIG_PATH + procd_set_param stderr 1 + procd_close_instance + ( + [ -f "/var/run/zerotier.wait.pid" ] && return + touch /var/run/zerotier.wait.pid + while [ "$(ifconfig | grep zt | awk '{print $1}')" = "" ] + do + sleep 1 + done + zt0=$(ifconfig | grep zt | awk '{print $1}') + echo "zt interface $zt0 is started!" + if [ -z "$(uci get network.zerotier)" ]; then + uci set network.zerotier=interface + uci set network.zerotier.proto='static' + fi + config_get nat $cfg 'nat' + if [ "$nat" == "1" ]; then + if [ -z "$(uci get firewall.ztzone)" ]; then + uci set firewall.ztzone=zone + uci set firewall.ztzone.input='ACCEPT' + uci set firewall.ztzone.output='ACCEPT' + uci set firewall.ztzone.forward='REJECT' + uci set firewall.ztzone.masq='1' + uci set firewall.ztzone.name='zerotier' + uci set firewall.ztzone.network='zerotier' + fi + else + uci delete firewall.ztzone + fi + config_get access $cfg 'access' + if [ "${access//ztfwlan/}" != "$access" ]; then + uci set firewall.ztfwlan=forwarding + uci set firewall.ztfwlan.dest='lan' + uci set firewall.ztfwlan.src='zerotier' + else + uci delete firewall.ztfwlan + fi + if [ "${access//ztfwwan/}" != "$access" ]; then + uci set firewall.ztfwwan=forwarding + uci set firewall.ztfwwan.dest='wan' + uci set firewall.ztfwwan.src='zerotier' + else + uci delete firewall.ztfwwan + fi + if [ "${access//lanfwzt/}" != "$access" ]; then + uci set firewall.lanfwzt=forwarding + uci set firewall.lanfwzt.dest='zerotier' + uci set firewall.lanfwzt.src='lan' + else + uci delete firewall.lanfwzt + fi + if [ "${access//wanfwzt/}" != "$access" ]; then + uci set firewall.wanfwzt=forwarding + uci set firewall.wanfwzt.dest='zerotier' + uci set firewall.wanfwzt.src='wan' + else + uci delete firewall.wanfwzt + fi + uci set network.zerotier.ifname="$zt0" + [ -n "$(uci changes network)" ] && uci commit network && /etc/init.d/network reload + [ -n "$(uci changes firewall)" ] && uci commit firewall && /etc/init.d/firewall reload + rm /var/run/zerotier.wait.pid + ) & +} + +start_service() { + config_load 'zerotier' + config_foreach start_instance 'zerotier' +} + +stop_instance() { + rm -f /tmp/zero.log + local cfg="$1" + + # Remove existing link or folder + rm -rf $CONFIG_PATH +} + +stop_service() { + config_load 'zerotier' + config_foreach stop_instance 'zerotier' +} + diff --git a/luci-app-zerotier-master/root/etc/uci-defaults/40_luci-zerotier b/luci-app-zerotier-master/root/etc/uci-defaults/40_luci-zerotier new file mode 100755 index 000000000..06f02e802 --- /dev/null +++ b/luci-app-zerotier-master/root/etc/uci-defaults/40_luci-zerotier @@ -0,0 +1,11 @@ +#!/bin/sh + +uci -q batch <<-EOF >/dev/null + delete ucitrack.@zerotier[-1] + add ucitrack zerotier + set ucitrack.@zerotier[-1].init=zerotier + commit ucitrack +EOF + +rm -f /tmp/luci-indexcache +exit 0 diff --git a/luci-app-zerotier-master/root/etc/zerotier/zerotier.log b/luci-app-zerotier-master/root/etc/zerotier/zerotier.log new file mode 100755 index 000000000..e69de29bb diff --git a/luci-base/po/oc/base.po b/luci-base/po/oc/base.po old mode 100755 new mode 100644 diff --git a/luci-base/po/templates/base.pot b/luci-base/po/templates/base.pot old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/Makefile b/luci-mod-dashboard/Makefile old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/css/custom.css b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/css/custom.css old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/devices.svg b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/devices.svg old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/internet.svg b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/internet.svg old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/not-internet.svg b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/not-internet.svg old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/router.svg b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/router.svg old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/wireless.svg b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/icons/wireless.svg old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/10_router.js old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/20_lan.js b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/20_lan.js old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/30_wifi.js b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/include/30_wifi.js old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/index.js b/luci-mod-dashboard/htdocs/luci-static/resources/view/dashboard/index.js old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/po/fr/dashboard.po b/luci-mod-dashboard/po/fr/dashboard.po old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/po/ru/dashboard.po b/luci-mod-dashboard/po/ru/dashboard.po old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/po/templates/dashboard.pot b/luci-mod-dashboard/po/templates/dashboard.pot old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/po/zh_Hans/dashboard.po b/luci-mod-dashboard/po/zh_Hans/dashboard.po old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/root/usr/share/luci/menu.d/luci-mod-dashboard.json b/luci-mod-dashboard/root/usr/share/luci/menu.d/luci-mod-dashboard.json old mode 100755 new mode 100644 diff --git a/luci-mod-dashboard/root/usr/share/rpcd/acl.d/luci-mod-dashboard.json b/luci-mod-dashboard/root/usr/share/rpcd/acl.d/luci-mod-dashboard.json old mode 100755 new mode 100644 diff --git a/luci-mod-network/Makefile b/luci-mod-network/Makefile old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/tools/network.js b/luci-mod-network/htdocs/luci-static/resources/tools/network.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js b/luci-mod-network/htdocs/luci-static/resources/view/network/dhcp.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js b/luci-mod-network/htdocs/luci-static/resources/view/network/diagnostics.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js b/luci-mod-network/htdocs/luci-static/resources/view/network/hosts.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js b/luci-mod-network/htdocs/luci-static/resources/view/network/interfaces.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js b/luci-mod-network/htdocs/luci-static/resources/view/network/routes.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js b/luci-mod-network/htdocs/luci-static/resources/view/network/switch.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js b/luci-mod-network/htdocs/luci-static/resources/view/network/wireless.js old mode 100755 new mode 100644 diff --git a/luci-mod-network/root/usr/share/luci/menu.d/luci-mod-network.json b/luci-mod-network/root/usr/share/luci/menu.d/luci-mod-network.json old mode 100755 new mode 100644 diff --git a/luci-mod-network/root/usr/share/rpcd/acl.d/luci-mod-network.json b/luci-mod-network/root/usr/share/rpcd/acl.d/luci-mod-network.json old mode 100755 new mode 100644 diff --git a/luci-proto-mbim/Makefile b/luci-proto-mbim/Makefile old mode 100755 new mode 100644 diff --git a/luci-proto-mbim/htdocs/luci-static/resources/protocol/mbim.js b/luci-proto-mbim/htdocs/luci-static/resources/protocol/mbim.js old mode 100755 new mode 100644 diff --git a/luci-theme-argon/LICENSE b/luci-theme-argon/LICENSE old mode 100755 new mode 100644 diff --git a/luci-theme-argon/Makefile b/luci-theme-argon/Makefile old mode 100755 new mode 100644 diff --git a/luci-theme-argon/README.md b/luci-theme-argon/README.md old mode 100755 new mode 100644 diff --git a/luci-theme-argon/README_ZH.md b/luci-theme-argon/README_ZH.md old mode 100755 new mode 100644 diff --git a/luci-theme-argon/Screenshots/screenshot_pc.jpg b/luci-theme-argon/Screenshots/screenshot_pc.jpg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/Screenshots/screenshot_phone.jpg b/luci-theme-argon/Screenshots/screenshot_phone.jpg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/background/README.md b/luci-theme-argon/htdocs/luci-static/argon/background/README.md old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/css/cascade.css b/luci-theme-argon/htdocs/luci-static/argon/css/cascade.css old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/css/dark.css b/luci-theme-argon/htdocs/luci-static/argon/css/dark.css old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/favicon.ico b/luci-theme-argon/htdocs/luci-static/argon/favicon.ico old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.eot b/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.eot old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.svg b/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.ttf b/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.ttf old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.woff b/luci-theme-argon/htdocs/luci-static/argon/fonts/TypoGraphica.woff old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.eot b/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.eot old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.svg b/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.ttf b/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.ttf old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.woff b/luci-theme-argon/htdocs/luci-static/argon/fonts/argon.woff old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/android-icon-192x192.png b/luci-theme-argon/htdocs/luci-static/argon/icon/android-icon-192x192.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/apple-icon-144x144.png b/luci-theme-argon/htdocs/luci-static/argon/icon/apple-icon-144x144.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/apple-icon-60x60.png b/luci-theme-argon/htdocs/luci-static/argon/icon/apple-icon-60x60.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/apple-icon-72x72.png b/luci-theme-argon/htdocs/luci-static/argon/icon/apple-icon-72x72.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/arrow.svg b/luci-theme-argon/htdocs/luci-static/argon/icon/arrow.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/browserconfig.xml b/luci-theme-argon/htdocs/luci-static/argon/icon/browserconfig.xml old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/favicon-16x16.png b/luci-theme-argon/htdocs/luci-static/argon/icon/favicon-16x16.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/favicon-32x32.png b/luci-theme-argon/htdocs/luci-static/argon/icon/favicon-32x32.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/favicon-96x96.png b/luci-theme-argon/htdocs/luci-static/argon/icon/favicon-96x96.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/manifest.json b/luci-theme-argon/htdocs/luci-static/argon/icon/manifest.json old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/ms-icon-144x144.png b/luci-theme-argon/htdocs/luci-static/argon/icon/ms-icon-144x144.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/icon/spinner.svg b/luci-theme-argon/htdocs/luci-static/argon/icon/spinner.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/img/argon.svg b/luci-theme-argon/htdocs/luci-static/argon/img/argon.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/img/bg1.jpg b/luci-theme-argon/htdocs/luci-static/argon/img/bg1.jpg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/img/blank.png b/luci-theme-argon/htdocs/luci-static/argon/img/blank.png old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/img/volume_high.svg b/luci-theme-argon/htdocs/luci-static/argon/img/volume_high.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/img/volume_off.svg b/luci-theme-argon/htdocs/luci-static/argon/img/volume_off.svg old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/js/jquery.min.js b/luci-theme-argon/htdocs/luci-static/argon/js/jquery.min.js old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/js/polyfill.min.js b/luci-theme-argon/htdocs/luci-static/argon/js/polyfill.min.js old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/less/cascade.less b/luci-theme-argon/htdocs/luci-static/argon/less/cascade.less old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/less/dark.less b/luci-theme-argon/htdocs/luci-static/argon/less/dark.less old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/less/fonts.less b/luci-theme-argon/htdocs/luci-static/argon/less/fonts.less old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/argon/less/pure-min.less b/luci-theme-argon/htdocs/luci-static/argon/less/pure-min.less old mode 100755 new mode 100644 diff --git a/luci-theme-argon/htdocs/luci-static/resources/menu-argon.js b/luci-theme-argon/htdocs/luci-static/resources/menu-argon.js old mode 100755 new mode 100644 diff --git a/luci-theme-argon/luasrc/view/themes/argon/footer_login.htm b/luci-theme-argon/luasrc/view/themes/argon/footer_login.htm old mode 100755 new mode 100644 diff --git a/luci-theme-argon/luasrc/view/themes/argon/header.htm b/luci-theme-argon/luasrc/view/themes/argon/header.htm old mode 100755 new mode 100644 diff --git a/luci-theme-argon/luasrc/view/themes/argon/header_login.htm b/luci-theme-argon/luasrc/view/themes/argon/header_login.htm old mode 100755 new mode 100644 diff --git a/luci-theme-argon/luasrc/view/themes/argon/out_footer_login.htm b/luci-theme-argon/luasrc/view/themes/argon/out_footer_login.htm old mode 100755 new mode 100644 diff --git a/luci-theme-argon/luasrc/view/themes/argon/out_header_login.htm b/luci-theme-argon/luasrc/view/themes/argon/out_header_login.htm old mode 100755 new mode 100644 diff --git a/luci-theme-argon/luasrc/view/themes/argon/sysauth.htm b/luci-theme-argon/luasrc/view/themes/argon/sysauth.htm old mode 100755 new mode 100644 diff --git a/luci-theme-argon/root/etc/uci-defaults/30_luci-theme-argon b/luci-theme-argon/root/etc/uci-defaults/30_luci-theme-argon old mode 100755 new mode 100644 diff --git a/luci-theme-openmptcprouter/Makefile b/luci-theme-openmptcprouter/Makefile old mode 100755 new mode 100644 diff --git a/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/html5.js b/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/html5.js old mode 100755 new mode 100644 diff --git a/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/mobile.css b/luci-theme-openmptcprouter/htdocs/luci-static/openmptcprouter/mobile.css old mode 100755 new mode 100644 diff --git a/luci-theme-openmptcprouter/htdocs/luci-static/resources/menu-openmptcprouter.js b/luci-theme-openmptcprouter/htdocs/luci-static/resources/menu-openmptcprouter.js old mode 100755 new mode 100644 diff --git a/macvlan/Makefile b/macvlan/Makefile old mode 100755 new mode 100644 diff --git a/macvlan/files/etc/config/macvlan b/macvlan/files/etc/config/macvlan old mode 100755 new mode 100644 diff --git a/macvlan/files/etc/uci-defaults/40_luci-app-macvlan b/macvlan/files/etc/uci-defaults/40_luci-app-macvlan old mode 100755 new mode 100644 diff --git a/mlvpn/Makefile b/mlvpn/Makefile old mode 100755 new mode 100644 diff --git a/mlvpn/files/etc/config/mlvpn b/mlvpn/files/etc/config/mlvpn old mode 100755 new mode 100644 diff --git a/mlvpn/files/etc/uci-defaults/4100-mlvpn b/mlvpn/files/etc/uci-defaults/4100-mlvpn old mode 100755 new mode 100644 diff --git a/mlvpn/patches/020-remove-cdefs.patch b/mlvpn/patches/020-remove-cdefs.patch old mode 100755 new mode 100644 diff --git a/modemmanager/Config.in b/modemmanager/Config.in old mode 100755 new mode 100644 diff --git a/modemmanager/Makefile b/modemmanager/Makefile old mode 100755 new mode 100644 diff --git a/modemmanager/README.md b/modemmanager/README.md old mode 100755 new mode 100644 diff --git a/modemmanager/files/10-report-down b/modemmanager/files/10-report-down old mode 100755 new mode 100644 diff --git a/modemmanager/files/25-modemmanager-net b/modemmanager/files/25-modemmanager-net old mode 100755 new mode 100644 diff --git a/modemmanager/files/25-modemmanager-tty b/modemmanager/files/25-modemmanager-tty old mode 100755 new mode 100644 diff --git a/modemmanager/files/25-modemmanager-usb b/modemmanager/files/25-modemmanager-usb old mode 100755 new mode 100644 diff --git a/modemmanager/files/25-modemmanager-wwan b/modemmanager/files/25-modemmanager-wwan old mode 100755 new mode 100644 diff --git a/modemmanager/files/modemmanager.common b/modemmanager/files/modemmanager.common old mode 100755 new mode 100644 diff --git a/modemmanager/files/modemmanager.init b/modemmanager/files/modemmanager.init old mode 100755 new mode 100644 diff --git a/modemmanager/files/modemmanager.proto b/modemmanager/files/modemmanager.proto old mode 100755 new mode 100644 diff --git a/mptcp/Makefile b/mptcp/Makefile old mode 100755 new mode 100644 diff --git a/mptcp/files/etc/hotplug.d/iface/30-mptcp b/mptcp/files/etc/hotplug.d/iface/30-mptcp old mode 100755 new mode 100644 diff --git a/mptcpd/Makefile b/mptcpd/Makefile old mode 100755 new mode 100644 diff --git a/mptcpd/patches/endian.patch b/mptcpd/patches/endian.patch old mode 100755 new mode 100644 diff --git a/mptcpd/patches/stub_error_h.patch b/mptcpd/patches/stub_error_h.patch old mode 100755 new mode 100644 diff --git a/msmtp/Makefile b/msmtp/Makefile old mode 100755 new mode 100644 diff --git a/net-tools/Makefile b/net-tools/Makefile old mode 100755 new mode 100644 diff --git a/net-tools/patches/mptcp-support.patch b/net-tools/patches/mptcp-support.patch old mode 100755 new mode 100644 diff --git a/netifd/Makefile b/netifd/Makefile old mode 100755 new mode 100644 diff --git a/netifd/files/etc/hotplug.d/iface/00-netstate b/netifd/files/etc/hotplug.d/iface/00-netstate old mode 100755 new mode 100644 diff --git a/netifd/files/etc/hotplug.d/net/20-smp-packet-steering b/netifd/files/etc/hotplug.d/net/20-smp-packet-steering old mode 100755 new mode 100644 diff --git a/netifd/files/etc/uci-defaults/14_migrate-dhcp-release b/netifd/files/etc/uci-defaults/14_migrate-dhcp-release old mode 100755 new mode 100644 diff --git a/netifd/files/etc/udhcpc.user b/netifd/files/etc/udhcpc.user old mode 100755 new mode 100644 diff --git a/netmaker-openwrt/.github/workflows/build_openwrt_ipk.yaml b/netmaker-openwrt/.github/workflows/build_openwrt_ipk.yaml deleted file mode 100755 index 86888ea0c..000000000 --- a/netmaker-openwrt/.github/workflows/build_openwrt_ipk.yaml +++ /dev/null @@ -1,62 +0,0 @@ -name: 'Build docker image' -on: - # Auto build on push to main branch - push: - paths-ignore: - - “README.md” - - ".gitignore" - - "LICENSE" - branches: - - main - # Auto build @ every day 6:00am - schedule: - - cron: '0 6 * * *' -jobs: - openwrt-builder-ipk: - name: 'Build ipk for openwrt branches' - strategy: - matrix: - branch: ["openwrt-18.06", "openwrt-19.07", "openwrt-21.02", "master"] - runs-on: ubuntu-latest - # Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest - defaults: - run: - shell: bash - steps: - - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." - - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" - - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." - - run: echo "Building ${{ matrix.branch }} branch." - - # Checkout the repository to the GitHub Actions runner - - name: 'Checkout the repository to the GitHub Actions runner' - uses: actions/checkout@v2 - - # Set up QEMU - - name: 'Set up QEMU' - uses: docker/setup-qemu-action@v1 - - # Login to DockerHub with username and token - - name: Login to DockerHub with username and token - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Build image and push to DockerHub - - name: 'Build image DockerHub' - run: | - echo "Building ${{ matrix.branch }} branch." - - # build ipk - docker run -t --rm -e OPENWRT_BRANCH="${{ matrix.branch }}" -v `pwd`:/src sbilly/openwrt-builder:latest /bin/bash /src/scripts/build_ipk.sh ${{ matrix.branch }} - - # Upload release - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.TOKEN }} - file: bin/*.ipk - tag: ${{ github.ref }} - overwrite: true - file_glob: true \ No newline at end of file diff --git a/netmaker-openwrt/netmaker/Makefile b/netmaker-openwrt/netmaker/Makefile index 55bba0f5b..903dd2beb 100755 --- a/netmaker-openwrt/netmaker/Makefile +++ b/netmaker-openwrt/netmaker/Makefile @@ -19,7 +19,7 @@ PKG_MIRROR_HASH:=skip PKG_LICENSE:=MIT PKG_LICENSE_FILES:=LICENSE -PKG_MAINTAINER:=neo +PKG_MAINTAINER:=sbilly PKG_BUILD_DEPENDS:=golang/host PKG_BUILD_PARALLEL:=1 @@ -31,7 +31,7 @@ GO_PKG_EXCLUDES:=excluded GO_PKG_LDFLAGS:=-s -w include $(INCLUDE_DIR)/package.mk -include $(TOPDIR)/feeds/openmptcprouter/golang/golang-package.mk +include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk define Package/netmaker $(call Package/netmaker/Default) diff --git a/nginx/Config.in b/nginx/Config.in new file mode 100644 index 000000000..68b037098 --- /dev/null +++ b/nginx/Config.in @@ -0,0 +1,247 @@ +# +# Copyright (C) 2010-2016 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +menu "Configuration" + depends on PACKAGE_nginx + +config NGINX_SSL + bool + prompt "Enable SSL module" + help + Enable HTTPS/SSL support. + default n + +config NGINX_DAV + bool + prompt "Enable WebDAV module" + help + Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE. + default n + +config NGINX_FLV + bool + prompt "Enable FLV module" + help + Provides the ability to seek within FLV (Flash) files using time-based offsets. + default n + +config NGINX_STUB_STATUS + bool + prompt "Enable stub status module" + help + Enable the stub status module which gives some status from the server. + default n + +config NGINX_HTTP_CHARSET + bool + prompt "Enable HTTP charset module" + default y + +config NGINX_HTTP_GZIP + bool + prompt "Enable HTTP gzip module" + default y + +config NGINX_HTTP_SSI + bool + prompt "Enable HTTP ssi module" + default y + +config NGINX_HTTP_USERID + bool + prompt "Enable HTTP userid module" + default y + +config NGINX_HTTP_ACCESS + bool + prompt "Enable HTTP access module" + default y + +config NGINX_HTTP_AUTH_BASIC + bool + prompt "Enable HTTP auth basic" + default y + +config NGINX_HTTP_AUTH_REQUEST + bool + prompt "Enable HTTP auth request module" + default n + +config NGINX_HTTP_AUTOINDEX + bool + prompt "Enable HTTP autoindex module" + default y + +config NGINX_HTTP_GEO + bool + prompt "Enable HTTP geo module" + default y + +config NGINX_HTTP_MAP + bool + prompt "Enable HTTP map module" + default y + +config NGINX_HTTP_SPLIT_CLIENTS + bool + prompt "Enable HTTP split clients" + default y + +config NGINX_HTTP_REFERER + bool + prompt "Enable HTTP referer module" + default y + +config NGINX_HTTP_REWRITE + bool + prompt "Enable HTTP rewrite module" + select NGINX_PCRE + default y + +config NGINX_HTTP_PROXY + bool + prompt "Enable HTTP proxy module" + default y + +config NGINX_HTTP_FASTCGI + bool + prompt "Enable HTTP fastcgi module" + default y + +config NGINX_HTTP_UWSGI + bool + prompt "Enable HTTP uwsgi module" + default y + +config NGINX_HTTP_SCGI + bool + prompt "Enable HTTP scgi module" + default y + +config NGINX_HTTP_MEMCACHED + bool + prompt "Enable HTTP memcached module" + default y + +config NGINX_HTTP_LIMIT_CONN + bool + prompt "Enable HTTP limit conn" + default y + +config NGINX_HTTP_LIMIT_REQ + bool + prompt "Enable HTTP limit req" + default y + +config NGINX_HTTP_EMPTY_GIF + bool + prompt "Enable HTTP empty gif" + default y + +config NGINX_HTTP_BROWSER + bool + prompt "Enable HTTP browser module" + default y + +config NGINX_HTTP_UPSTREAM_HASH + bool + prompt "Enable HTTP hash module" + default y + +config NGINX_HTTP_UPSTREAM_IP_HASH + bool + prompt "Enable HTTP IP hash module" + default y + +config NGINX_HTTP_UPSTREAM_LEAST_CONN + bool + prompt "Enable HTTP least conn module" + default y + +config NGINX_HTTP_UPSTREAM_KEEPALIVE + bool + prompt "Enable HTTP keepalive module" + default y + +config NGINX_HTTP_CACHE + bool + prompt "Enable HTTP cache" + default y + +config NGINX_HTTP_V2 + bool + prompt "Enable HTTP_V2 module" + default n + +config NGINX_PCRE + bool + prompt "Enable PCRE library usage" + default y + +config NGINX_NAXSI + bool + prompt "Enable NAXSI module" + default y + +config NGINX_LUA + bool + prompt "Enable Lua module" + default n + +config NGINX_HTTP_REAL_IP + bool + prompt "Enable HTTP real ip module" + default n + +config NGINX_HTTP_SECURE_LINK + bool + prompt "Enable HTTP secure link module" + default n + +config NGINX_HTTP_SUB + bool + prompt "Enable HTTP sub module" + default n + +config NGINX_HEADERS_MORE + bool + prompt "Enable Headers_more module" + help + Set and clear input and output headers...more than "add"! + default y + +config NGINX_HTTP_BROTLI + bool + prompt "Enable Brotli compression module" + help + Add support for brotli compression module. + default n + +config NGINX_STREAM_CORE_MODULE + bool + prompt "Enable stream support" + help + Add support for NGINX request streaming. + default y + +config NGINX_RTMP_MODULE + bool + prompt "Enable RTMP module" + depends on NGINX_SSL + help + Add support for NGINX-based Media Streaming Server module. + DASH enhanced - https://github.com/ut0mt8/nginx-rtmp-module + default n + +config NGINX_TS_MODULE + bool + prompt "Enable TS module" + help + Add support for MPEG-TS Live Module module. + default n + +endmenu diff --git a/nginx/Config_ssl.in b/nginx/Config_ssl.in old mode 100755 new mode 100644 index 738839354..9325fba51 --- a/nginx/Config_ssl.in +++ b/nginx/Config_ssl.in @@ -15,13 +15,6 @@ config NGINX_DAV Enable the HTTP and WebDAV methods PUT, DELETE, MKCOL, COPY and MOVE. default n -config NGINX_UBUS - bool - prompt "Enable UBUS module" - help - Enable UBUS api support directly from the server. - default y - config NGINX_FLV bool prompt "Enable FLV module" @@ -46,11 +39,6 @@ config NGINX_HTTP_GZIP prompt "Enable HTTP gzip module" default y -config NGINX_HTTP_GZIP_STATIC - bool - prompt "Enable HTTP gzip static module" - default y - config NGINX_HTTP_SSI bool prompt "Enable HTTP ssi module" @@ -180,7 +168,7 @@ config NGINX_HTTP_CACHE config NGINX_HTTP_V2 bool prompt "Enable HTTP_V2 module" - default y + default n config NGINX_PCRE bool @@ -195,7 +183,7 @@ config NGINX_NAXSI config NGINX_LUA bool prompt "Enable Lua module" - default y + default n config NGINX_HTTP_REAL_IP bool @@ -233,22 +221,6 @@ config NGINX_STREAM_CORE_MODULE Add support for NGINX request streaming. default n -config NGINX_STREAM_SSL_MODULE - bool - prompt "Enable stream support with SSL/TLS termination" - depends on NGINX_STREAM_CORE_MODULE - help - Add support for NGINX request streaming with SSL/TLS termination. - default n - -config NGINX_STREAM_SSL_PREREAD_MODULE - bool - prompt "Enable stream support with SSL/TLS pre-read" - depends on NGINX_STREAM_CORE_MODULE - help - Add support for NGINX request streaming using information from the ClientHello message without terminating SSL/TLS. - default n - config NGINX_RTMP_MODULE bool prompt "Enable RTMP module" diff --git a/nginx/Makefile b/nginx/Makefile old mode 100755 new mode 100644 index f9613504d..dc32fbb04 --- a/nginx/Makefile +++ b/nginx/Makefile @@ -8,30 +8,30 @@ include $(TOPDIR)/rules.mk PKG_NAME:=nginx -PKG_VERSION:=1.21.3 -PKG_RELEASE:=3 +PKG_VERSION:=1.16.1 +PKG_RELEASE:=2 PKG_SOURCE:=nginx-$(PKG_VERSION).tar.gz -PKG_SOURCE_URL:=https://nginx.org/download/ -PKG_HASH:=14774aae0d151da350417efc4afda5cce5035056e71894836797e1f6e2d1175a +PKG_SOURCE_URL:=http://nginx.org/download/ +PKG_HASH:=f11c2a6dd1d3515736f0324857957db2de98be862461b5a542a3ac6188dbe32b PKG_MAINTAINER:=Thomas Heil \ Ansuel Smith PKG_LICENSE:=2-clause BSD-like license -PKG_CPE_ID:=cpe:/a:nginx:nginx + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_VERSION) PKG_FIXUP:=autoreconf PKG_BUILD_PARALLEL:=1 PKG_INSTALL:=1 PKG_CONFIG_DEPENDS := \ + CONFIG_NGINX_SSL \ CONFIG_NGINX_DAV \ CONFIG_NGINX_FLV \ - CONFIG_NGINX_UBUS \ CONFIG_NGINX_STUB_STATUS \ CONFIG_NGINX_HTTP_CHARSET \ CONFIG_NGINX_HTTP_GZIP \ - CONFIG_NGINX_HTTP_GZIP_STATIC \ CONFIG_NGINX_HTTP_SSI \ CONFIG_NGINX_HTTP_USERID \ CONFIG_NGINX_HTTP_ACCESS \ @@ -67,15 +67,10 @@ PKG_CONFIG_DEPENDS := \ CONFIG_NGINX_HTTP_BROTLI \ CONFIG_NGINX_HEADERS_MORE \ CONFIG_NGINX_STREAM_CORE_MODULE \ - CONFIG_NGINX_STREAM_SSL_MODULE \ - CONFIG_NGINX_STREAM_SSL_PREREAD_MODULE \ CONFIG_NGINX_RTMP_MODULE \ CONFIG_NGINX_TS_MODULE \ - CONFIG_OPENSSL_ENGINE \ - CONFIG_OPENSSL_WITH_NPN include $(INCLUDE_DIR)/package.mk -include $(INCLUDE_DIR)/nls.mk define Package/nginx/default SECTION:=net @@ -83,50 +78,53 @@ define Package/nginx/default SUBMENU:=Web Servers/Proxies TITLE:=Nginx web server URL:=http://nginx.org/ - DEPENDS:=+libopenssl +libpthread - # TODO: add PROVIDES when removing nginx - # PROVIDES:=nginx + DEPENDS:=+NGINX_PCRE:libpcre +(NGINX_SSL||NGINX_HTTP_CACHE||NGINX_HTTP_AUTH_BASIC):libopenssl \ + +NGINX_HTTP_GZIP:zlib +NGINX_LUA:liblua +libpthread +NGINX_DAV:libexpat endef define Package/nginx/description nginx is an HTTP and reverse proxy server, as well as a mail proxy server, \ - written by Igor Sysoev. + written by Igor Sysoev. (Some module require SSL module enable to show up in \ + config menu) +endef + +define Package/nginx + $(Package/nginx/default) + VARIANT:=no-ssl endef define Package/nginx-ssl $(Package/nginx/default) TITLE += with SSL support + DEPENDS +=+libopenssl VARIANT:=ssl - DEPENDS+= +NGINX_PCRE:libpcre \ - +NGINX_PCRE:nginx-ssl-util +!NGINX_PCRE:nginx-ssl-util-nopcre \ - +NGINX_HTTP_GZIP:zlib +NGINX_LUA:liblua +NGINX_DAV:libxml2 \ - +NGINX_UBUS:libubus +NGINX_UBUS:libblobmsg-json +NGINX_UBUS:libjson-c - EXTRA_DEPENDS:=nginx-ssl-util$(if $(CONFIG_NGINX_PCRE),,-nopcre) (>=1.5-1) (<2) - CONFLICTS:=nginx-all-module + PROVIDES:=nginx endef Package/nginx-ssl/description = $(Package/nginx/description) \ - This variant is compiled with SSL support enabled. To enable additional module \ + This varian is compiled with SSL support enabled. To enable additional module \ select them in the nginx default configuration menu. define Package/nginx-all-module $(Package/nginx/default) TITLE += with ALL module selected - DEPENDS+=+libpcre +nginx-ssl-util +zlib +liblua +libxml2 +libubus \ - +libblobmsg-json +libjson-c - EXTRA_DEPENDS:=nginx-ssl-util (>=1.5-1) (<2) + DEPENDS:=+libpcre +libopenssl +zlib +liblua +libpthread +libexpat VARIANT:=all-module - PROVIDES += nginx-ssl + PROVIDES:=nginx endef Package/nginx-all-module/description = $(Package/nginx/description) \ - This variant is compiled with ALL module selected. + This varian is compiled with ALL module selected. + +define Package/nginx/config + source "$(SOURCE)/Config.in" +endef define Package/nginx-ssl/config source "$(SOURCE)/Config_ssl.in" endef -config_files=mime.types +config_files=nginx.conf mime.types define Package/nginx/conffiles /etc/nginx/ @@ -136,7 +134,7 @@ Package/nginx-ssl/conffiles = $(Package/nginx/conffiles) Package/nginx-all-module/conffiles = $(Package/nginx/conffiles) -ADDITIONAL_MODULES:= --with-http_ssl_module +ADDITIONAL_MODULES:= ifneq ($(BUILD_VARIANT),all-module) ifneq ($(CONFIG_NGINX_HTTP_CACHE),y) @@ -153,9 +151,6 @@ ifneq ($(BUILD_VARIANT),all-module) ifneq ($(CONFIG_NGINX_HTTP_GZIP),y) ADDITIONAL_MODULES += --without-http_gzip_module endif - ifeq ($(CONFIG_NGINX_HTTP_GZIP_STATIC),y) - ADDITIONAL_MODULES += --with-http_gzip_static_module - endif ifneq ($(CONFIG_NGINX_HTTP_SSI),y) ADDITIONAL_MODULES += --without-http_ssi_module endif @@ -196,13 +191,9 @@ ifneq ($(BUILD_VARIANT),all-module) endif ifneq ($(CONFIG_NGINX_HTTP_UWSGI),y) ADDITIONAL_MODULES += --without-http_uwsgi_module - else - config_files += uwsgi_params endif ifneq ($(CONFIG_NGINX_HTTP_SCGI),y) ADDITIONAL_MODULES += --without-http_scgi_module - else - config_files += scgi_params endif ifneq ($(CONFIG_NGINX_HTTP_MEMCACHED),y) ADDITIONAL_MODULES += --without-http_memcached_module @@ -231,6 +222,16 @@ ifneq ($(BUILD_VARIANT),all-module) ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE),y) ADDITIONAL_MODULES += --without-http_upstream_keepalive_module endif + + ifeq ($(BUILD_VARIANT),ssl) + ifneq ($(CONFIG_NGINX_SSL),y) + ADDITIONAL_MODULES += --with-http_ssl_module + endif + endif + + ifeq ($(CONFIG_NGINX_SSL),y) + ADDITIONAL_MODULES += --with-http_ssl_module + endif ifeq ($(CONFIG_NGINX_NAXSI),y) ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src endif @@ -249,9 +250,6 @@ ifneq ($(BUILD_VARIANT),all-module) ifeq ($(CONFIG_NGINX_DAV),y) ADDITIONAL_MODULES += --with-http_dav_module --add-module=$(PKG_BUILD_DIR)/nginx-dav-ext-module endif - ifeq ($(CONFIG_NGINX_UBUS),y) - ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-ubus-module - endif ifeq ($(CONFIG_NGINX_HTTP_AUTH_REQUEST),y) ADDITIONAL_MODULES += --with-http_auth_request_module endif @@ -270,12 +268,6 @@ ifneq ($(BUILD_VARIANT),all-module) ifeq ($(CONFIG_NGINX_STREAM_CORE_MODULE),y) ADDITIONAL_MODULES += --with-stream endif - ifeq ($(CONFIG_NGINX_STREAM_SSL_MODULE),y) - ADDITIONAL_MODULES += --with-stream_ssl_module - endif - ifeq ($(CONFIG_NGINX_STREAM_SSL_PREREAD_MODULE),y) - ADDITIONAL_MODULES += --with-stream_ssl_preread_module - endif ifeq ($(CONFIG_NGINX_HEADERS_MORE),y) ADDITIONAL_MODULES += --add-module=$(PKG_BUILD_DIR)/nginx-headers-more endif @@ -296,37 +288,44 @@ else CONFIG_NGINX_NAXSI:=y CONFIG_NGINX_LUA:=y CONFIG_NGINX_DAV:=y - CONFIG_NGINX_UBUS:=y - ADDITIONAL_MODULES += --with-ipv6 --with-http_stub_status_module --with-http_flv_module \ - --with-http_dav_module \ + ADDITIONAL_MODULES += --with-http_ssl_module --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src \ + --add-module=$(PKG_BUILD_DIR)/lua-nginx --with-ipv6 --with-http_stub_status_module --with-http_flv_module \ + --with-http_dav_module --add-module=$(PKG_BUILD_DIR)/nginx-dav-ext-module \ --with-http_auth_request_module --with-http_v2_module --with-http_realip_module \ - --with-http_secure_link_module --with-http_sub_module \ - --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module \ - --add-module=$(PKG_BUILD_DIR)/nginx-headers-more \ - --add-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src \ - --add-module=$(PKG_BUILD_DIR)/lua-nginx \ - --add-module=$(PKG_BUILD_DIR)/nginx-dav-ext-module \ + --with-http_secure_link_module --with-http_sub_module --add-module=$(PKG_BUILD_DIR)/nginx-headers-more \ + --with-stream \ --add-module=$(PKG_BUILD_DIR)/nginx-brotli --add-module=$(PKG_BUILD_DIR)/nginx-rtmp \ - --add-module=$(PKG_BUILD_DIR)/nginx-ts --add-module=$(PKG_BUILD_DIR)/nginx-ubus-module - config_files += koi-utf koi-win win-utf fastcgi_params uwsgi_params + --add-module=$(PKG_BUILD_DIR)/nginx-ts + config_files += koi-utf koi-win win-utf fastcgi_params endif -define Package/nginx-mod-luci +define Package/nginx-mod-luci/default TITLE:=Nginx on LuCI SECTION:=net CATEGORY:=Network SUBMENU:=Web Servers/Proxies TITLE:=Support file for Nginx URL:=http://nginx.org/ - DEPENDS:=+uwsgi +uwsgi-luci-support +nginx - # TODO: add PROVIDES when removing nginx-mod-luci-ssl - # PROVIDES:=nginx-mod-luci-ssl + DEPENDS:=+uwsgi-cgi +uwsgi-cgi-luci-support +endef + +define Package/nginx-mod-luci + $(Package/nginx-mod-luci/default) + DEPENDS += +nginx endef define Package/nginx-mod-luci/description Support file for LuCI in nginx. Include custom nginx configuration, autostart script for uwsgi. endef +define Package/nginx-mod-luci-ssl + $(Package/nginx-mod-luci/default) + TITLE += with HTTPS support + DEPENDS += +nginx-ssl +endef + +Package/nginx-mod-luci-ssl/description = $(define Package/nginx-mod-luci/description) \ + This also include redirect from http to https and cert autogeneration. TARGET_CFLAGS += -fvisibility=hidden -ffunction-sections -fdata-sections -DNGX_LUA_NO_BY_LUA_BLOCK TARGET_LDFLAGS += -Wl,--gc-sections @@ -336,14 +335,12 @@ ifeq ($(CONFIG_NGINX_LUA),y) LUA_LIB=$(STAGING_DIR)/usr/lib endif -CONFIGURE_VARS += CONFIG_BIG_ENDIAN=$(CONFIG_BIG_ENDIAN) - CONFIGURE_ARGS += \ --crossbuild=Linux::$(ARCH) \ --prefix=/usr \ --conf-path=/etc/nginx/nginx.conf \ $(ADDITIONAL_MODULES) \ - --error-log-path=stderr \ + --error-log-path=/var/log/nginx/error.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --http-log-path=/var/log/nginx/access.log \ @@ -356,16 +353,25 @@ CONFIGURE_ARGS += \ --without-http_upstream_zone_module define Package/nginx-mod-luci/install - $(INSTALL_DIR) $(1)/etc/nginx/conf.d - $(INSTALL_CONF) ./files-luci-support/luci.locations $(1)/etc/nginx/conf.d/ + $(INSTALL_DIR) $(1)/etc/nginx + $(INSTALL_BIN) ./files-luci-support/luci_uwsgi.conf $(1)/etc/nginx/luci_uwsgi.conf + $(INSTALL_BIN) ./files-luci-support/luci_nginx.conf $(1)/etc/nginx/luci_nginx.conf $(INSTALL_DIR) $(1)/etc/uci-defaults $(INSTALL_BIN) ./files-luci-support/60_nginx-luci-support $(1)/etc/uci-defaults/60_nginx-luci-support endef -define Package/nginx-ssl/install +define Package/nginx-mod-luci-ssl/install + $(Package/nginx-mod-luci/install) + $(INSTALL_DIR) $(1)/etc/nginx + $(INSTALL_BIN) ./files-luci-support/luci_nginx_ssl.conf $(1)/etc/nginx/luci_nginx_ssl.conf + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files-luci-support/70_nginx-luci-support-ssl $(1)/etc/uci-defaults/70_nginx-luci-support-ssl +endef + +define Package/nginx/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/nginx $(1)/usr/sbin/ - $(INSTALL_DIR) $(1)/etc/nginx/conf.d + $(INSTALL_DIR) $(1)/etc/nginx $(INSTALL_DATA) $(addprefix $(PKG_INSTALL_DIR)/etc/nginx/,$(config_files)) $(1)/etc/nginx/ $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/nginx.init $(1)/etc/init.d/nginx @@ -376,236 +382,151 @@ ifeq ($(CONFIG_NGINX_NAXSI),y) endif $(if $(CONFIG_NGINX_NAXSI),$($(INSTALL_BIN) $(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx)) $(if $(CONFIG_NGINX_NAXSI),$(chmod 0640 $(1)/etc/nginx/naxsi_core.rules)) - - $(INSTALL_DIR) $(1)/etc/hotplug.d/acme - $(INSTALL_DATA) ./files/acme.hotplug $(1)/etc/hotplug.d/acme/00-nginx endef -Package/nginx-all-module/install = $(Package/nginx-ssl/install) - -define Package/nginx-ssl/prerm -#!/bin/sh -[ -z "$${IPKG_INSTROOT}" ] || exit 0 -[ "$${PKG_UPGRADE}" = "1" ] && exit 0 -eval $$(/usr/bin/nginx-util get_env) -[ "$$(uci get "nginx.$${LAN_NAME}.$${MANAGE_SSL}")" = "self-signed" ] || exit 0 -rm -f "$$(uci get "nginx.$${LAN_NAME}.ssl_certificate")" -rm -f "$$(uci get "nginx.$${LAN_NAME}.ssl_certificate_key")" -exit 0 -endef - -Package/nginx-all-module/prerm = $(Package/nginx-ssl/prerm) - -define Download/nginx-headers-more - VERSION:=a9f7c7e86cc7441d04e2f11f01c2e3a9c4b0301d - SUBDIR:=nginx-headers-more - FILE:=headers-more-nginx-module-$$(VERSION).tar.xz - URL:=https://github.com/openresty/headers-more-nginx-module.git - MIRROR_HASH:=ce0b9996ecb2cff790831644d6ab1adc087aa2771d77d3931c06246d11bc59fd - PROTO:=git -endef - -define Prepare/nginx-headers-more - $(eval $(Download/nginx-headers-more)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/nginx-brotli - VERSION:=e505dce68acc190cc5a1e780a3b0275e39f160ca - SUBDIR:=nginx-brotli - FILE:=ngx-brotli-module-$$(VERSION).tar.xz - URL:=https://github.com/google/ngx_brotli.git - MIRROR_HASH:=04847f11ef808fed50f44b2af0ef3abf59ff0ffc06dfc7394d9ab51d53fef31f - PROTO:=git -endef - -define Prepare/nginx-brotli - $(eval $(Download/nginx-brotli)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/nginx-rtmp - VERSION:=f0ea62342a4eca504b311cd5df910d026c3ea4cf - SUBDIR:=nginx-rtmp - FILE:=ngx-rtmp-module-$$(VERSION).tar.xz - URL:=https://github.com/ut0mt8/nginx-rtmp-module.git - MIRROR_HASH:=d3f58066f0f858ed79f7f2b0c9b89de2ccc512c94ab3d0625f6dcff3df0b72c1 - PROTO:=git -endef - -define Prepare/nginx-rtmp - $(eval $(Download/nginx-rtmp)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/nginx-ts - VERSION:=ef2f874d95cc75747eb625a292524a702aefb0fd - SUBDIR:=nginx-ts - FILE:=ngx-ts-module-$$(VERSION).tar.xz - URL:=https://github.com/arut/nginx-ts-module.git - MIRROR_HASH:=73938950bb286d40d9e54b0994d1a63827340c1156c72eb04d7041b25b20ec18 - PROTO:=git -endef - -define Prepare/nginx-ts - $(eval $(Download/nginx-ts)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/nginx-naxsi - VERSION:=951123ad456bdf5ac94e8d8819342fe3d49bc002 - SUBDIR:=nginx-naxsi - FILE:=nginx-naxsi-module-$$(VERSION).tar.xz - URL:=https://github.com/nbs-system/naxsi.git - MIRROR_HASH:=c734cae19a596affadd62a2df1b58d3df8d1364093a4e80a7cd1ab4555963535 - PROTO:=git -endef - -define Prepare/nginx-naxsi - $(eval $(Download/nginx-naxsi)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/lua-nginx - VERSION:=e94f2e5d64daa45ff396e262d8dab8e56f5f10e0 - SUBDIR:=lua-nginx - FILE:=lua-nginx-module-$$(VERSION).tar.xz - URL:=https://github.com/openresty/lua-nginx-module.git - MIRROR_HASH:=27729921964f066d97e99c263da153b34622a2f4b811114e4c3ee61c6fc71395 - PROTO:=git -endef - -define Prepare/lua-nginx - $(eval $(Download/lua-nginx)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/nginx-dav-ext-module - VERSION:=f5e30888a256136d9c550bf1ada77d6ea78a48af - SUBDIR:=nginx-dav-ext-module - FILE:=nginx-dav-ext-module-$$(VERSION).tar.xz - URL:=https://github.com/arut/nginx-dav-ext-module.git - MIRROR_HASH:=70bb4c3907f4b783605500ba494e907aede11f8505702e370012abb3c177dc5b - PROTO:=git -endef - -define Prepare/nginx-dav-ext-module - $(eval $(Download/nginx-dav-ext-module)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Download/nginx-ubus-module - VERSION:=b2d7260dcb428b2fb65540edb28d7538602b4a26 - SUBDIR:=nginx-ubus-module - FILE:=nginx-ubus-module-$$(VERSION).tar.xz - URL:=https://github.com/Ansuel/nginx-ubus-module.git - MIRROR_HASH:=472cef416d25effcac66c85417ab6596e634a7a64d45b709bb090892d567553c - PROTO:=git -endef - -define Prepare/nginx-ubus-module - $(eval $(Download/nginx-ubus-module)) - xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) -endef - -define Build/Patch - $(if $(QUILT),rm -rf $(PKG_BUILD_DIR)/patches; mkdir -p $(PKG_BUILD_DIR)/patches) - $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/nginx,nginx/) -ifneq "$(or $(CONFIG_NGINX_DAV),$(QUILT))" "" - $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/dav-nginx,dav-nginx/) -endif -ifneq "$(or $(CONFIG_NGINX_LUA),$(QUILT))" "" - $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/lua-nginx,lua-nginx/) -endif -ifneq "$(or $(CONFIG_NGINX_RTMP_MODULE),$(QUILT))" "" - $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rtmp-nginx,rtmp-nginx/) -endif - $(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used) -endef - -define Quilt/Refresh/Package - $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/nginx,nginx/) - $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/dav-nginx,dav-nginx/) - $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/lua-nginx,lua-nginx/) - $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rtmp-nginx,rtmp-nginx/) -endef +Package/nginx-ssl/install = $(Package/nginx/install) +Package/nginx-all-module/install = $(Package/nginx/install) define Build/Prepare - rm -rf $(PKG_BUILD_DIR) - mkdir -p $(PKG_BUILD_DIR) - $(PKG_UNPACK) + $(Build/Prepare/Default) + $(Prepare/nginx-naxsi) + $(Prepare/lua-nginx) + $(Prepare/nginx-brotli) + $(Prepare/nginx-headers-more) + $(Prepare/nginx-rtmp) + $(Prepare/nginx-ts) + $(Prepare/nginx-dav-ext-module) +endef -ifeq ($(CONFIG_NGINX_NAXSI),y) - $(eval $(call Download,nginx-naxsi)) - $(Prepare/nginx-naxsi) -endif - -ifneq "$(or $(CONFIG_NGINX_LUA),$(QUILT))" "" - $(eval $(call Download,lua-nginx)) - $(Prepare/lua-nginx) -endif - -ifeq ($(CONFIG_NGINX_HTTP_BROTLI),y) - $(eval $(call Download,nginx-brotli)) - $(Prepare/nginx-brotli) -endif ifeq ($(CONFIG_NGINX_HEADERS_MORE),y) + define Download/nginx-headers-more + VERSION:=a9f7c7e86cc7441d04e2f11f01c2e3a9c4b0301d + SUBDIR:=nginx-headers-more + FILE:=headers-more-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/openresty/headers-more-nginx-module.git + MIRROR_HASH:=432609015719aaa7241e5166c7cda427acbe004f725887f78ef629d51bd9cb3f + PROTO:=git + endef $(eval $(call Download,nginx-headers-more)) - $(Prepare/nginx-headers-more) + + define Prepare/nginx-headers-more + $(eval $(Download/nginx-headers-more)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + endef endif -ifneq "$(or $(CONFIG_NGINX_RTMP_MODULE),$(QUILT))" "" - $(eval $(call Download,nginx-rtmp)) - $(Prepare/nginx-rtmp) + +ifeq ($(CONFIG_NGINX_HTTP_BROTLI),y) + define Download/nginx-brotli + VERSION:=e26248ee361c04e25f581b92b85d95681bdffb39 + SUBDIR:=nginx-brotli + FILE:=ngx-brotli-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/eustas/ngx_brotli.git + MIRROR_HASH:=76b891ba49f82f0cfbc9cba875646e26ee986b522373e0aa2698a9923a4adcdb + PROTO:=git + endef + $(eval $(call Download,nginx-brotli)) + + define Prepare/nginx-brotli + $(eval $(Download/nginx-brotli)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + endef endif + +ifeq ($(CONFIG_NGINX_RTMP_MODULE),y) + define Download/nginx-rtmp + VERSION:=f0ea62342a4eca504b311cd5df910d026c3ea4cf + SUBDIR:=nginx-rtmp + FILE:=ngx-rtmp-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/ut0mt8/nginx-rtmp-module.git + MIRROR_HASH:=9ba7625718d21f658c4878729271832a07bd989165f1d1c720b3a9b54cf738cc + PROTO:=git + endef + $(eval $(call Download,nginx-rtmp)) + + define Prepare/nginx-rtmp + $(eval $(Download/nginx-rtmp)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + endef +endif + + ifeq ($(CONFIG_NGINX_TS_MODULE),y) + define Download/nginx-ts + VERSION:=ef2f874d95cc75747eb625a292524a702aefb0fd + SUBDIR:=nginx-ts + FILE:=ngx-ts-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/arut/nginx-ts-module.git + MIRROR_HASH:=31ecc9968b928886b54884138eafe2fa747648bca5094d4c3132e8ae9509d1d3 + PROTO:=git + endef $(eval $(call Download,nginx-ts)) - $(Prepare/nginx-ts) + + define Prepare/nginx-ts + $(eval $(Download/nginx-ts)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + endef endif -ifneq "$(or $(CONFIG_NGINX_DAV),$(QUILT))" "" + +ifeq ($(CONFIG_NGINX_NAXSI),y) + define Download/nginx-naxsi + VERSION:=951123ad456bdf5ac94e8d8819342fe3d49bc002 + SUBDIR:=nginx-naxsi + FILE:=nginx-naxsi-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/nbs-system/naxsi.git + MIRROR_HASH:=7ab791f2ff38096f48013141bbfe20ba213d5e04dcac08ca82e0cac07d5c30f0 + PROTO:=git + endef + $(eval $(call Download,nginx-naxsi)) + + define Prepare/nginx-naxsi + $(eval $(Download/nginx-naxsi)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + endef +endif + + +ifeq ($(CONFIG_NGINX_LUA),y) + define Download/lua-nginx + VERSION:=e94f2e5d64daa45ff396e262d8dab8e56f5f10e0 + SUBDIR:=lua-nginx + FILE:=lua-nginx-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/openresty/lua-nginx-module.git + MIRROR_HASH:=ae439f9a8b3c34d7240735b844db72ee721af4791bbaff5692bca20e6785f541 + PROTO:=git + endef + $(eval $(call Download,lua-nginx)) + + define Prepare/lua-nginx + $(eval $(Download/lua-nginx)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + $(call PatchDir,$(PKG_BUILD_DIR),./patches-lua-nginx) + endef +endif + + +ifeq ($(CONFIG_NGINX_DAV),y) + define Download/nginx-dav-ext-module + VERSION:=430fd774fe838a04f1a5defbf1dd571d42300cf9 + SUBDIR:=nginx-dav-ext-module + FILE:=nginx-dav-ext-module-$(PKG_VERSION)-$$(VERSION).tar.gz + URL:=https://github.com/arut/nginx-dav-ext-module.git + MIRROR_HASH:=0566053a8756423ecab455fd9d218cec1e017598fcbb3d6415a06f816851611e + PROTO:=git + endef $(eval $(call Download,nginx-dav-ext-module)) - $(Prepare/nginx-dav-ext-module) + + define Prepare/nginx-dav-ext-module + $(eval $(Download/nginx-dav-ext-module)) + gzip -dc $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR) $(TAR_OPTIONS) + endef endif -ifeq ($(CONFIG_NGINX_UBUS),y) - $(eval $(call Download,nginx-ubus-module)) - $(Prepare/nginx-ubus-module) -endif - - $(Build/Patch) -endef - -$(eval $(call BuildPackage,nginx-ssl)) -$(eval $(call BuildPackage,nginx-all-module)) -$(eval $(call BuildPackage,nginx-mod-luci)) - -# TODO: remove after a transition period (together with pkg nginx-util): -# It is for smoothly substituting nginx and nginx-mod-luci-ssl (by nginx-ssl -# respectively nginx-mod-luci). Add above commented PROVIDES when removing. - -define Package/nginx - TITLE:=Dummy package for transition when upgrading. - DEPENDS:=+nginx-ssl - PKGARCH:=all -endef - -define Package/nginx/install - $(INSTALL_DIR) $(1)/usr/bin -endef - $(eval $(call BuildPackage,nginx)) - -define Package/nginx-mod-luci-ssl - TITLE:=Dummy package for transition when upgrading. - DEPENDS:=+nginx-mod-luci - PKGARCH:=all -endef - -define Package/nginx-mod-luci-ssl/install - $(INSTALL_DIR) $(1)/usr/bin -endef - -$(eval $(call BuildPackage,nginx-mod-luci-ssl)) +$(eval $(call BuildPackage,nginx-ssl)) +$(eval $(call BuildPackage,nginx-all-module)) +#$(eval $(call BuildPackage,nginx-mod-luci)) +#$(eval $(call BuildPackage,nginx-mod-luci-ssl)) diff --git a/nginx/files-luci-support/60_nginx-luci-support b/nginx/files-luci-support/60_nginx-luci-support old mode 100755 new mode 100644 index b2564444c..dd076d260 --- a/nginx/files-luci-support/60_nginx-luci-support +++ b/nginx/files-luci-support/60_nginx-luci-support @@ -1,41 +1,28 @@ #!/bin/sh -if nginx -V 2>&1 | grep -q ubus; then - if [ -z "$(cat /etc/nginx/conf.d/luci.locations | grep ubus)" ]; then - cat <> /etc/nginx/conf.d/luci.locations - -location /ubus { - ubus_interpreter; - ubus_socket_path /var/run/ubus/ubus.sock; - ubus_parallel_req 2; -} -EOT +if [ -f "/etc/nginx/luci_nginx.conf" ] && [ -f "/etc/nginx/nginx.conf" ]; then + if [ ! "$(cat '/etc/nginx/nginx.conf' | grep 'luci_uwsgi.conf')" ]; then + mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf_old + mv /etc/nginx/luci_nginx.conf /etc/nginx/nginx.conf + core_number=$(grep -c ^processor /proc/cpuinfo) + sed -i "3s/.*/worker_processes "$core_number";/" /etc/nginx/nginx.conf + if [ -n "$(pgrep uhttpd)" ]; then + /etc/init.d/uhttpd stop + /etc/init.d/uhttpd disable + fi + if [ -n "$(pgrep nginx)" ]; then + /etc/init.d/nginx restart + else + /etc/init.d/nginx start + fi + if [ -n "$(pgrep uwsgi)" ]; then + /etc/init.d/uwsgi restart + else + /etc/init.d/uwsgi start + fi + else + rm /etc/nginx/luci_nginx.conf fi fi -grep -q /var/run/ubus.sock /etc/nginx/conf.d/luci.locations && - sed -i 's#/var/run/ubus.sock#/var/run/ubus/ubus.sock#' /etc/nginx/conf.d/luci.locations - -if [ -x /etc/init.d/uhttpd ]; then - /etc/init.d/uhttpd disable - if [ -n "$(pgrep uhttpd)" ]; then - /etc/init.d/uhttpd stop - fi -fi - -/etc/init.d/nginx enable -if [ -n "$(pgrep nginx)" ]; then - /etc/init.d/nginx restart -else - /etc/init.d/nginx start -fi - -/etc/init.d/uwsgi enable -if [ -n "$(pgrep uwsgi)" ]; then - /etc/init.d/uwsgi restart -else - /etc/init.d/uwsgi start -fi - - exit 0 diff --git a/nginx/files-luci-support/70_nginx-luci-support-ssl b/nginx/files-luci-support/70_nginx-luci-support-ssl new file mode 100644 index 000000000..76ce3a819 --- /dev/null +++ b/nginx/files-luci-support/70_nginx-luci-support-ssl @@ -0,0 +1,48 @@ +#!/bin/sh + + +if [ -f "/etc/nginx/luci_nginx_ssl.conf" ] && [ -f "/etc/nginx/nginx.conf" ]; then + if [ ! "$(cat '/etc/nginx/nginx.conf' | grep 'return 301 https://$host$request_uri;')" ]; then + if [ -f "/etc/nginx/nginx.conf_old" ]; then + rm /etc/nginx/nginx.conf + else + mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf_old + fi + mv /etc/nginx/luci_nginx_ssl.conf /etc/nginx/nginx.conf + core_number=$(grep -c ^processor /proc/cpuinfo) + sed -i "3s/.*/worker_processes "$core_number";/" /etc/nginx/nginx.conf + if [ -n "$(pgrep nginx)" ]; then + /etc/init.d/nginx restart + else + /etc/init.d/nginx start + fi + else + rm /etc/nginx/luci_nginx_ssl.conf + fi +fi + + +if [ ! -f "/etc/nginx/nginx.key" ]; then + + NGINX_KEY=/etc/nginx/nginx.key + NGINX_CER=/etc/nginx/nginx.cer + OPENSSL_BIN=/usr/bin/openssl + PX5G_BIN=/usr/sbin/px5g + + # Prefer px5g for certificate generation (existence evaluated last) + GENKEY_CMD="" + UNIQUEID=$(dd if=/dev/urandom bs=1 count=4 | hexdump -e '1/1 "%02x"') + [ -x "$OPENSSL_BIN" ] && GENKEY_CMD="$OPENSSL_BIN req -x509 -nodes" + [ -x "$PX5G_BIN" ] && GENKEY_CMD="$PX5G_BIN selfsigned" + [ -n "$GENKEY_CMD" ] && { + $GENKEY_CMD \ + -days 730 -newkey rsa:2048 -keyout "${NGINX_KEY}.new" -out "${NGINX_CER}.new" \ + -subj /C="ZZ"/ST="Somewhere"/L="Unknown"/O="OpenWrt""$UNIQUEID"/CN="OpenWrt" + sync + mv "${NGINX_KEY}.new" "${NGINX_KEY}" + mv "${NGINX_CER}.new" "${NGINX_CER}" + } +fi + + +exit 0 diff --git a/nginx/files-luci-support/luci.locations b/nginx/files-luci-support/luci.locations deleted file mode 100755 index 374ee5d9f..000000000 --- a/nginx/files-luci-support/luci.locations +++ /dev/null @@ -1,17 +0,0 @@ -location /cgi-bin/luci { - index index.html; - include uwsgi_params; - uwsgi_param SERVER_ADDR $server_addr; - uwsgi_modifier1 9; - uwsgi_pass unix:////var/run/luci-webui.socket; -} -location ~ /cgi-bin/cgi-(backup|download|upload|exec) { - include uwsgi_params; - uwsgi_param SERVER_ADDR $server_addr; - uwsgi_modifier1 9; - uwsgi_pass unix:////var/run/luci-cgi_io.socket; -} - -location /luci-static { - error_log stderr crit; -} diff --git a/nginx/files-luci-support/luci_nginx.conf b/nginx/files-luci-support/luci_nginx.conf new file mode 100644 index 000000000..31af664a2 --- /dev/null +++ b/nginx/files-luci-support/luci_nginx.conf @@ -0,0 +1,51 @@ + +user nobody nogroup; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 0; + + client_body_buffer_size 10K; + client_header_buffer_size 1k; + client_max_body_size 1G; + large_client_header_buffers 2 1k; + + gzip on; + gzip_http_version 1.1; + gzip_vary on; + gzip_comp_level 1; + gzip_proxied any; + + root /www; + + server { + listen 80 default_server; + listen [::]:80 default_server; + server_name localhost; + + location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { + expires 365d; + } + + include luci_uwsgi.conf; + + } + + include /etc/nginx/conf.d/*.conf; +} diff --git a/nginx/files-luci-support/luci_nginx_ssl.conf b/nginx/files-luci-support/luci_nginx_ssl.conf new file mode 100644 index 000000000..318453b54 --- /dev/null +++ b/nginx/files-luci-support/luci_nginx_ssl.conf @@ -0,0 +1,66 @@ + +user root; +worker_processes 1; + +#error_log logs/error.log; +#error_log logs/error.log notice; +#error_log logs/error.log info; + +pid /var/run/nginx.pid; + + +events { + worker_connections 1024; +} + + +http { + include mime.types; + default_type application/octet-stream; + + sendfile on; + keepalive_timeout 0; + + client_body_buffer_size 10K; + client_header_buffer_size 1k; + client_max_body_size 1G; + large_client_header_buffers 2 1k; + + gzip on; + gzip_http_version 1.1; + gzip_vary on; + gzip_comp_level 1; + gzip_proxied any; + + root /www; + + server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + return 301 https://$host$request_uri; + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; + server_name localhost; + + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_prefer_server_ciphers on; + ssl_ciphers "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH:DHE+AESGCM:DHE:!RSA!aNULL:!eNULL:!LOW:!RC4:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS:!CAMELLIA:!SEED"; + ssl_session_tickets off; + + ssl_certificate /etc/nginx/nginx.cer; + ssl_certificate_key /etc/nginx/nginx.key; + + location ~* .(jpg|jpeg|png|gif|ico|css|js)$ { + expires 365d; + } + + include luci_uwsgi.conf; + + } + + include /etc/nginx/conf.d/*.conf; +} diff --git a/nginx/files-luci-support/luci_uwsgi.conf b/nginx/files-luci-support/luci_uwsgi.conf new file mode 100644 index 000000000..6211db74a --- /dev/null +++ b/nginx/files-luci-support/luci_uwsgi.conf @@ -0,0 +1,20 @@ +location /cgi-bin/luci { + index index.html; + uwsgi_param QUERY_STRING $query_string; + uwsgi_param REQUEST_METHOD $request_method; + uwsgi_param CONTENT_TYPE $content_type; + uwsgi_param CONTENT_LENGTH $content_length if_not_empty; + uwsgi_param REQUEST_URI $request_uri; + uwsgi_param PATH_INFO $document_uri; + uwsgi_param SERVER_PROTOCOL $server_protocol; + uwsgi_param REMOTE_ADDR $remote_addr; + uwsgi_param REMOTE_PORT $remote_port; + uwsgi_param SERVER_ADDR $server_addr; + uwsgi_param SERVER_PORT $server_port; + uwsgi_param SERVER_NAME $server_name; + uwsgi_modifier1 9; + uwsgi_pass unix:////var/run/uwsgi.sock; +} + +location /luci-static { +} diff --git a/nginx/files/acme.hotplug b/nginx/files/acme.hotplug deleted file mode 100755 index 74f1448d7..000000000 --- a/nginx/files/acme.hotplug +++ /dev/null @@ -1,3 +0,0 @@ -if [ "$ACTION" = renewed ]; then - /etc/init.d/nginx reload -fi diff --git a/nginx/files/nginx.init b/nginx/files/nginx.init old mode 100755 new mode 100644 index 300a8c657..40d389719 --- a/nginx/files/nginx.init +++ b/nginx/files/nginx.init @@ -5,69 +5,13 @@ START=80 USE_PROCD=1 -G_OPTS="daemon off;" - -NGINX_UTIL="/usr/bin/nginx-util" - -eval $("${NGINX_UTIL}" get_env) - -CONF="" - - -nginx_init() { - [ -z "${CONF}" ] || return # already called. - +start_service() { [ -d /var/log/nginx ] || mkdir -p /var/log/nginx [ -d /var/lib/nginx ] || mkdir -p /var/lib/nginx - rm -f "$(readlink "${UCI_CONF}")" - ${NGINX_UTIL} init_lan - - if [ -e "${UCI_CONF}" ] - then CONF="${UCI_CONF}" - else CONF="${NGINX_CONF}" - fi - - local message - message="$(/usr/sbin/nginx -t -c "${CONF}" -g "${G_OPTS}" 2>&1)" || - { - echo -e "${message}" | logger -t "nginx_init" -p "daemon.err" - logger -s -t "nginx_init" -p "daemon.err" "NOT using conf file!" - echo "show config to be used by: nginx -T -c '${CONF}'" >&2 - exit 1 - } - - logger -t "nginx_init" -p "daemon.info" "using ${CONF} (the test is ok)" -} - - -start_service() { - nginx_init - procd_open_instance - procd_set_param command /usr/sbin/nginx -c "${CONF}" -g "${G_OPTS}" - procd_set_param stdout 1 - procd_set_param stderr 1 - procd_set_param file "${CONF}" "${CONF_DIR}*.crt" "${CONF_DIR}*.key" \ - "${CONF_DIR}*.conf" "${CONF_DIR}*.locations" + procd_set_param command /usr/sbin/nginx -c /etc/nginx/nginx.conf -g 'daemon off;' + procd_set_param file /etc/nginx/nginx.conf procd_set_param respawn procd_close_instance } - - -reload_service() { - nginx_init - - if [ "$(cat "/proc/$(cat "/var/run/nginx.pid")/cmdline")" = \ - "nginx: master process /usr/sbin/nginx -c ${CONF} -g ${G_OPTS}" ] - then procd_send_signal nginx - else restart - fi -} - - -extra_command "relog" "Reopen log files (without reloading)" -relog() { - [ -d /var/log/nginx ] || mkdir -p /var/log/nginx - procd_send_signal nginx '*' USR1 -} diff --git a/nginx/patches/lua-nginx/100-no_by_lua_block.patch b/nginx/patches-lua-nginx/100-no_by_lua_block.patch old mode 100755 new mode 100644 similarity index 100% rename from nginx/patches/lua-nginx/100-no_by_lua_block.patch rename to nginx/patches-lua-nginx/100-no_by_lua_block.patch diff --git a/nginx/patches/nginx/101-feature_test_fix.patch b/nginx/patches/101-feature_test_fix.patch old mode 100755 new mode 100644 similarity index 89% rename from nginx/patches/nginx/101-feature_test_fix.patch rename to nginx/patches/101-feature_test_fix.patch index f09f3af8c..b867c88dd --- a/nginx/patches/nginx/101-feature_test_fix.patch +++ b/nginx/patches/101-feature_test_fix.patch @@ -49,7 +49,7 @@ ngx_feature_incs="#include " ngx_feature_path= ngx_feature_libs= -@@ -135,7 +135,7 @@ ngx_feature_test="int fd; struct stat sb +@@ -110,7 +110,7 @@ ngx_feature_test="int fd; struct stat sb CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE" ngx_feature="sendfile()" ngx_feature_name="NGX_HAVE_SENDFILE" @@ -58,7 +58,7 @@ ngx_feature_incs="#include #include " ngx_feature_path= -@@ -156,7 +156,7 @@ fi +@@ -131,7 +131,7 @@ fi CC_AUX_FLAGS="$cc_aux_flags -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64" ngx_feature="sendfile64()" ngx_feature_name="NGX_HAVE_SENDFILE64" @@ -67,7 +67,7 @@ ngx_feature_incs="#include #include " ngx_feature_path= -@@ -174,7 +174,7 @@ ngx_include="sys/prctl.h"; . auto/includ +@@ -149,7 +149,7 @@ ngx_include="sys/prctl.h"; . auto/includ ngx_feature="prctl(PR_SET_DUMPABLE)" ngx_feature_name="NGX_HAVE_PR_SET_DUMPABLE" @@ -78,7 +78,7 @@ ngx_feature_libs= --- a/auto/unix +++ b/auto/unix -@@ -805,7 +805,7 @@ ngx_feature_test="void *p; p = memalign( +@@ -840,7 +840,7 @@ ngx_feature_test="void *p; p = memalign( ngx_feature="mmap(MAP_ANON|MAP_SHARED)" ngx_feature_name="NGX_HAVE_MAP_ANON" @@ -87,7 +87,7 @@ ngx_feature_incs="#include " ngx_feature_path= ngx_feature_libs= -@@ -818,7 +818,7 @@ ngx_feature_test="void *p; +@@ -853,7 +853,7 @@ ngx_feature_test="void *p; ngx_feature='mmap("/dev/zero", MAP_SHARED)' ngx_feature_name="NGX_HAVE_MAP_DEVZERO" @@ -96,7 +96,7 @@ ngx_feature_incs="#include #include #include " -@@ -833,7 +833,7 @@ ngx_feature_test='void *p; int fd; +@@ -868,7 +868,7 @@ ngx_feature_test='void *p; int fd; ngx_feature="System V shared memory" ngx_feature_name="NGX_HAVE_SYSVSHM" @@ -105,7 +105,7 @@ ngx_feature_incs="#include #include " ngx_feature_path= -@@ -847,7 +847,7 @@ ngx_feature_test="int id; +@@ -882,7 +882,7 @@ ngx_feature_test="int id; ngx_feature="POSIX semaphores" ngx_feature_name="NGX_HAVE_POSIX_SEM" diff --git a/nginx/patches/nginx/102-sizeof_test_fix.patch b/nginx/patches/102-sizeof_test_fix.patch old mode 100755 new mode 100644 similarity index 100% rename from nginx/patches/nginx/102-sizeof_test_fix.patch rename to nginx/patches/102-sizeof_test_fix.patch diff --git a/nginx/patches/nginx/103-sys_nerr.patch b/nginx/patches/103-sys_nerr.patch old mode 100755 new mode 100644 similarity index 72% rename from nginx/patches/nginx/103-sys_nerr.patch rename to nginx/patches/103-sys_nerr.patch index c5101f695..5f5d106fe --- a/nginx/patches/nginx/103-sys_nerr.patch +++ b/nginx/patches/103-sys_nerr.patch @@ -8,5 +8,5 @@ +#define NGX_SYS_NERR 128 +#endif - static ngx_str_t ngx_unknown_error = ngx_string("Unknown error"); - + /* + * The strerror() messages are copied because: diff --git a/nginx/patches/nginx/200-config.patch b/nginx/patches/200-config.patch old mode 100755 new mode 100644 similarity index 100% rename from nginx/patches/nginx/200-config.patch rename to nginx/patches/200-config.patch diff --git a/nginx/patches/nginx/201-ignore-invalid-options.patch b/nginx/patches/201-ignore-invalid-options.patch old mode 100755 new mode 100644 similarity index 83% rename from nginx/patches/nginx/201-ignore-invalid-options.patch rename to nginx/patches/201-ignore-invalid-options.patch index d208bf507..28be2fb71 --- a/nginx/patches/nginx/201-ignore-invalid-options.patch +++ b/nginx/patches/201-ignore-invalid-options.patch @@ -1,6 +1,6 @@ --- a/auto/options +++ b/auto/options -@@ -400,8 +400,7 @@ $0: warning: the \"--with-sha1-asm\" opt +@@ -397,8 +397,7 @@ $0: warning: the \"--with-sha1-asm\" opt --test-build-solaris-sendfilev) NGX_TEST_BUILD_SOLARIS_SENDFILEV=YES ;; *) diff --git a/nginx/patches/300-max-processes.patch b/nginx/patches/300-max-processes.patch new file mode 100644 index 000000000..f7465d434 --- /dev/null +++ b/nginx/patches/300-max-processes.patch @@ -0,0 +1,11 @@ +--- a/src/os/unix/ngx_process.h ++++ b/src/os/unix/ngx_process.h +@@ -44,7 +44,7 @@ typedef struct { + } ngx_exec_ctx_t; + + +-#define NGX_MAX_PROCESSES 1024 ++#define NGX_MAX_PROCESSES 8 + + #define NGX_PROCESS_NORESPAWN -1 + #define NGX_PROCESS_JUST_SPAWN -2 diff --git a/nginx/patches/dav-nginx/100-drop-libxslt-dep.patch b/nginx/patches/dav-nginx/100-drop-libxslt-dep.patch deleted file mode 100755 index aa06f0464..000000000 --- a/nginx/patches/dav-nginx/100-drop-libxslt-dep.patch +++ /dev/null @@ -1,14 +0,0 @@ ---- a/nginx-dav-ext-module/config -+++ b/nginx-dav-ext-module/config -@@ -8,9 +8,8 @@ ngx_module_name=ngx_http_dav_ext_module - # building nginx with the xslt module, in which case libxslt will - # be linked anyway. In other cases libxslt is just redundant. - # If that's a big deal, libxml2 can be linked directly: --# ngx_module_libs=-lxml2 -- --ngx_module_libs=LIBXSLT -+ngx_module_libs=-lxml2 -+ngx_module_incs=$(pkg-config --cflags-only-I libxml-2.0 | sed 's/^-I//') - - ngx_module_srcs="$ngx_addon_dir/ngx_http_dav_ext_module.c" - diff --git a/nginx/patches/nginx/104-endianness_fix.patch b/nginx/patches/nginx/104-endianness_fix.patch deleted file mode 100755 index 4d8255e93..000000000 --- a/nginx/patches/nginx/104-endianness_fix.patch +++ /dev/null @@ -1,19 +0,0 @@ ---- a/auto/endianness -+++ b/auto/endianness -@@ -12,6 +12,16 @@ checking for system byte ordering - - END - -+if [ "${CONFIG_BIG_ENDIAN}" != "y" ]; then -+ echo " little endian" -+ have=NGX_HAVE_LITTLE_ENDIAN . auto/have -+else -+ echo " big endian" -+fi -+ -+return -+ -+ - - cat << END > $NGX_AUTOTEST.c - diff --git a/nginx/patches/rtmp-nginx/100-bigedian.patch b/nginx/patches/rtmp-nginx/100-bigedian.patch deleted file mode 100755 index c0a07bc7c..000000000 --- a/nginx/patches/rtmp-nginx/100-bigedian.patch +++ /dev/null @@ -1,1521 +0,0 @@ -From 5b06d1cad5f6711667038169b7ed759d749334da Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?Jan=20Bub=C3=ADk?= -Date: Wed, 13 May 2020 19:57:47 +0200 -Subject: [PATCH 1/3] arut's e0e278bc7fedd6f7465648d1d20df1a8422d60bf [removed - endian-dependent code] - ---- - ngx_rtmp.c | 4 ++ - ngx_rtmp.h | 12 +++-- - ngx_rtmp_amf.c | 6 +-- - ngx_rtmp_flv_module.c | 2 +- - ngx_rtmp_handler.c | 108 +++++++++++++++++++++--------------------- - 5 files changed, 68 insertions(+), 64 deletions(-) - ---- a/nginx-rtmp/ngx_rtmp.c -+++ b/nginx-rtmp/ngx_rtmp.c -@@ -825,22 +825,6 @@ ngx_rtmp_fire_event(ngx_rtmp_session_t * - } - - --void * --ngx_rtmp_rmemcpy(void *dst, const void* src, size_t n) --{ -- u_char *d, *s; -- -- d = dst; -- s = (u_char*)src + n - 1; -- -- while(s >= (u_char*)src) { -- *d++ = *s--; -- } -- -- return dst; --} -- -- - static ngx_int_t - ngx_rtmp_init_process(ngx_cycle_t *cycle) - { ---- a/nginx-rtmp/ngx_rtmp.h -+++ b/nginx-rtmp/ngx_rtmp.h -@@ -417,34 +417,33 @@ ngx_int_t ngx_rtmp_fire_event(ngx_rtmp_s - ngx_int_t ngx_rtmp_set_chunk_size(ngx_rtmp_session_t *s, ngx_uint_t size); - - --/* Bit reverse: we need big-endians in many places */ --void * ngx_rtmp_rmemcpy(void *dst, const void* src, size_t n); -- --#define ngx_rtmp_rcpymem(dst, src, n) \ -- (((u_char*)ngx_rtmp_rmemcpy(dst, src, n)) + (n)) -- -- --static ngx_inline uint16_t --ngx_rtmp_r16(uint16_t n) -+/* Bit agnosticism: we need network to host byte-order conversion in many places */ -+static ngx_inline uint64_t -+ntohll(uint64_t n) - { -- return (n << 8) | (n >> 8); -+#if (NGX_HAVE_LITTLE_ENDIAN) -+ return (uint64_t) ntohl((uint32_t) n) << 32 | -+ ntohl((uint32_t) (n >> 32)); -+#else -+ return n; -+#endif - } - -- - static ngx_inline uint32_t --ngx_rtmp_r32(uint32_t n) -+n3toh4(u_char* src) - { -- return (n << 24) | ((n << 8) & 0xff0000) | ((n >> 8) & 0xff00) | (n >> 24); -+ return ((uint32_t)src[0]<<16)|((uint32_t)src[1]<<8)|src[2]; - } - -- --static ngx_inline uint64_t --ngx_rtmp_r64(uint64_t n) -+static ngx_inline u_char* -+h4ton3(u_char* dst, uint32_t src) - { -- return (uint64_t) ngx_rtmp_r32((uint32_t) n) << 32 | -- ngx_rtmp_r32((uint32_t) (n >> 32)); --} -+ dst[0]=(u_char)(src>>16); -+ dst[1]=(u_char)(src>>8); -+ dst[2]=(u_char)src; - -+ return dst+3; -+} - - /* Receiving messages */ - ngx_int_t ngx_rtmp_receive_message(ngx_rtmp_session_t *s, ---- a/nginx-rtmp/ngx_rtmp_amf.c -+++ b/nginx-rtmp/ngx_rtmp_amf.c -@@ -10,23 +10,6 @@ - #include "ngx_rtmp.h" - #include - -- --static ngx_inline void* --ngx_rtmp_amf_reverse_copy(void *dst, void* src, size_t len) --{ -- size_t k; -- -- if (dst == NULL || src == NULL) { -- return NULL; -- } -- -- for(k = 0; k < len; ++k) { -- ((u_char*)dst)[k] = ((u_char*)src)[len - 1 - k]; -- } -- -- return dst; --} -- - #define NGX_RTMP_AMF_DEBUG_SIZE 72 - - #ifdef NGX_DEBUG -@@ -207,7 +190,7 @@ ngx_rtmp_amf_read_object(ngx_rtmp_amf_ct - return NGX_ERROR; - } - -- ngx_rtmp_amf_reverse_copy(&len, buf, 2); -+ len=ntohs(*(uint16_t*)&buf[0]); - - if (!len) - break; -@@ -258,7 +241,7 @@ ngx_rtmp_amf_read_array(ngx_rtmp_amf_ctx - if (ngx_rtmp_amf_get(ctx, buf, 4) != NGX_OK) - return NGX_ERROR; - -- ngx_rtmp_amf_reverse_copy(&len, buf, 4); -+ len=ntohl(*(uint32_t*)&buf[0]); - - for (n = 0; n < len; ++n) { - if (ngx_rtmp_amf_read(ctx, n < nelts ? &elts[n] : NULL, 1) != NGX_OK) -@@ -352,10 +335,9 @@ ngx_rtmp_amf_read(ngx_rtmp_amf_ctx_t *ct - - switch (type) { - case NGX_RTMP_AMF_NUMBER: -- if (ngx_rtmp_amf_get(ctx, buf, 8) != NGX_OK) { -+ if (ngx_rtmp_amf_get(ctx, data, 8) != NGX_OK) { - return NGX_ERROR; - } -- ngx_rtmp_amf_reverse_copy(data, buf, 8); - break; - - case NGX_RTMP_AMF_BOOLEAN: -@@ -368,7 +350,7 @@ ngx_rtmp_amf_read(ngx_rtmp_amf_ctx_t *ct - if (ngx_rtmp_amf_get(ctx, buf, 2) != NGX_OK) { - return NGX_ERROR; - } -- ngx_rtmp_amf_reverse_copy(&len, buf, 2); -+ len=ntohs(*(uint16_t*)buf); - - if (data == NULL) { - rc = ngx_rtmp_amf_get(ctx, data, len); -@@ -438,14 +420,14 @@ ngx_rtmp_amf_read(ngx_rtmp_amf_ctx_t *ct - if (ngx_rtmp_amf_get(ctx, buf, 2) != NGX_OK) { - return NGX_ERROR; - } -- ngx_rtmp_amf_reverse_copy(data, buf, 2); -+ *(uint16_t*)data=ntohs(*(uint16_t*)buf); - break; - - case NGX_RTMP_AMF_INT32: - if (ngx_rtmp_amf_get(ctx, buf, 4) != NGX_OK) { - return NGX_ERROR; - } -- ngx_rtmp_amf_reverse_copy(data, buf, 4); -+ *(uint32_t*)data=ntohs(*(uint32_t*)buf); - break; - - case NGX_RTMP_AMF_END: -@@ -476,9 +458,8 @@ ngx_rtmp_amf_write_object(ngx_rtmp_amf_c - - len = (uint16_t) elts[n].name.len; - -- if (ngx_rtmp_amf_put(ctx, -- ngx_rtmp_amf_reverse_copy(buf, -- &len, 2), 2) != NGX_OK) -+ *(uint16_t*)buf = htons(len); -+ if (ngx_rtmp_amf_put(ctx, buf, 2) != NGX_OK) - { - return NGX_ERROR; - } -@@ -509,9 +490,8 @@ ngx_rtmp_amf_write_array(ngx_rtmp_amf_ct - u_char buf[4]; - - len = nelts; -- if (ngx_rtmp_amf_put(ctx, -- ngx_rtmp_amf_reverse_copy(buf, -- &len, 4), 4) != NGX_OK) -+ *(uint32_t*)buf = htonl(len); -+ if (ngx_rtmp_amf_put(ctx, buf, 4) != NGX_OK) - { - return NGX_ERROR; - } -@@ -554,9 +534,7 @@ ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *c - - switch(type) { - case NGX_RTMP_AMF_NUMBER: -- if (ngx_rtmp_amf_put(ctx, -- ngx_rtmp_amf_reverse_copy(buf, -- data, 8), 8) != NGX_OK) -+ if (ngx_rtmp_amf_put(ctx, data, 8) != NGX_OK) - { - return NGX_ERROR; - } -@@ -573,9 +551,8 @@ ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *c - len = (uint16_t) ngx_strlen((u_char*) data); - } - -- if (ngx_rtmp_amf_put(ctx, -- ngx_rtmp_amf_reverse_copy(buf, -- &len, 2), 2) != NGX_OK) -+ *(uint16_t*)buf = htons(len); -+ if (ngx_rtmp_amf_put(ctx, buf, 2) != NGX_OK) - { - return NGX_ERROR; - } -@@ -621,18 +598,16 @@ ngx_rtmp_amf_write(ngx_rtmp_amf_ctx_t *c - break; - - case NGX_RTMP_AMF_INT16: -- if (ngx_rtmp_amf_put(ctx, -- ngx_rtmp_amf_reverse_copy(buf, -- data, 2), 2) != NGX_OK) -+ *(uint16_t*)buf = htons(*(uint16_t*)data); -+ if (ngx_rtmp_amf_put(ctx, buf, 2) != NGX_OK) - { - return NGX_ERROR; - } - break; - - case NGX_RTMP_AMF_INT32: -- if (ngx_rtmp_amf_put(ctx, -- ngx_rtmp_amf_reverse_copy(buf, -- data, 4), 4) != NGX_OK) -+ *(uint32_t*)buf = htonl(*(uint32_t*)data); -+ if (ngx_rtmp_amf_put(ctx, buf, 4) != NGX_OK) - { - return NGX_ERROR; - } ---- a/nginx-rtmp/ngx_rtmp_flv_module.c -+++ b/nginx-rtmp/ngx_rtmp_flv_module.c -@@ -102,7 +102,7 @@ ngx_rtmp_flv_fill_index(ngx_rtmp_amf_ctx - return NGX_ERROR; - } - -- ngx_rtmp_rmemcpy(&nelts, b->pos + ctx->offset, 4); -+ nelts=htonl(*(uint32_t*)(b->pos + ctx->offset)); - - idx->nelts = nelts; - idx->offset = ctx->offset + 4; -@@ -201,11 +201,7 @@ ngx_rtmp_flv_init_index(ngx_rtmp_session - static double - ngx_rtmp_flv_index_value(void *src) - { -- double v; -- -- ngx_rtmp_rmemcpy(&v, src, 8); -- -- return v; -+ return *(double*)src; - } - - -@@ -352,8 +348,7 @@ ngx_rtmp_flv_read_meta(ngx_rtmp_session_ - h.msid = NGX_RTMP_MSID; - h.csid = NGX_RTMP_CSID_AMF; - -- size = 0; -- ngx_rtmp_rmemcpy(&size, ngx_rtmp_flv_header + 1, 3); -+ size = n3toh4(ngx_rtmp_flv_header + 1); - - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "flv: metadata size=%D", size); -@@ -440,12 +435,9 @@ ngx_rtmp_flv_send(ngx_rtmp_session_t *s, - h.msid = NGX_RTMP_MSID; - h.type = ngx_rtmp_flv_header[0]; - -- size = 0; -- -- ngx_rtmp_rmemcpy(&size, ngx_rtmp_flv_header + 1, 3); -- ngx_rtmp_rmemcpy(&h.timestamp, ngx_rtmp_flv_header + 4, 3); -- -- ((u_char *) &h.timestamp)[3] = ngx_rtmp_flv_header[7]; -+ size = n3toh4(ngx_rtmp_flv_header + 1); -+ h.timestamp = n3toh4(ngx_rtmp_flv_header + 4); -+ h.timestamp |= ((uint32_t) ngx_rtmp_flv_header[7] << 24); - - ctx->offset += (sizeof(ngx_rtmp_flv_header) + size + 4); - ---- a/nginx-rtmp/ngx_rtmp_handler.c -+++ b/nginx-rtmp/ngx_rtmp_handler.c -@@ -200,7 +200,7 @@ ngx_rtmp_recv(ngx_event_t *rev) - ngx_rtmp_stream_t *st, *st0; - ngx_chain_t *in, *head; - ngx_buf_t *b; -- u_char *p, *pp, *old_pos; -+ u_char *p, *old_pos; - size_t size, fsize, old_size; - uint8_t fmt, ext; - uint32_t csid, timestamp; -@@ -308,14 +308,14 @@ ngx_rtmp_recv(ngx_event_t *rev) - if (b->last - p < 1) - continue; - csid = 64; -- csid += *(uint8_t*)p++; -+ csid += *p++; - - } else if (csid == 1) { - if (b->last - p < 2) - continue; - csid = 64; -- csid += *(uint8_t*)p++; -- csid += (uint32_t)256 * (*(uint8_t*)p++); -+ csid += *p++; -+ csid += ((uint32_t) *p++ << 8); - } - - ngx_log_debug2(NGX_LOG_DEBUG_RTMP, c->log, 0, -@@ -355,40 +355,37 @@ ngx_rtmp_recv(ngx_event_t *rev) - if (fmt <= 2 ) { - if (b->last - p < 3) - continue; -- /* timestamp: -- * big-endian 3b -> little-endian 4b */ -- pp = (u_char*)×tamp; -- pp[2] = *p++; -- pp[1] = *p++; -- pp[0] = *p++; -- pp[3] = 0; -+ -+ /* timestamp: big-endian 3 bytes */ -+ -+ timestamp = ((uint32_t) *p++ << 16); -+ timestamp |= ((uint32_t) *p++ << 8); -+ timestamp |= *p++; - - ext = (timestamp == 0x00ffffff); - - if (fmt <= 1) { - if (b->last - p < 4) - continue; -- /* size: -- * big-endian 3b -> little-endian 4b -- * type: -- * 1b -> 1b*/ -- pp = (u_char*)&h->mlen; -- pp[2] = *p++; -- pp[1] = *p++; -- pp[0] = *p++; -- pp[3] = 0; -- h->type = *(uint8_t*)p++; -+ -+ /* size: big-endian 3 bytes */ -+ -+ h->mlen = ((uint32_t) *p++ << 16); -+ h->mlen |= ((uint32_t) *p++ << 8); -+ h->mlen |= *p++; -+ -+ h->type = *p++; - - if (fmt == 0) { - if (b->last - p < 4) - continue; -- /* stream: -- * little-endian 4b -> little-endian 4b */ -- pp = (u_char*)&h->msid; -- pp[0] = *p++; -- pp[1] = *p++; -- pp[2] = *p++; -- pp[3] = *p++; -+ -+ /* stream: little-endian 4 bytes */ -+ -+ h->msid = *p++; -+ h->msid |= ((uint32_t) *p++ << 8); -+ h->msid |= ((uint32_t) *p++ << 16); -+ h->msid |= ((uint32_t) *p++ << 24); - } - } - } -@@ -397,13 +394,13 @@ ngx_rtmp_recv(ngx_event_t *rev) - if (ext) { - if (b->last - p < 4) - continue; -- pp = (u_char*)×tamp; -- /* extented time stamp: -- * big-endian 4b -> little-endian 4b */ -- pp[3] = *p++; -- pp[2] = *p++; -- pp[1] = *p++; -- pp[0] = *p++; -+ -+ /* timestamp: big-endian 4 bytes */ -+ -+ timestamp = ((uint32_t) *p++ << 24); -+ timestamp |= ((uint32_t) *p++ << 16); -+ timestamp |= ((uint32_t) *p++ << 8); -+ timestamp |= *p++; - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, c->log, 0, "RTMP extended timestamp %uD", (uint32_t)timestamp); - } - -@@ -584,7 +581,7 @@ ngx_rtmp_prepare_message(ngx_rtmp_sessio - ngx_rtmp_header_t *lh, ngx_chain_t *out) - { - ngx_chain_t *l; -- u_char *p, *pp; -+ u_char *p; - ngx_int_t hsize, thsize, nbufs; - uint32_t mlen, timestamp, ext_timestamp; - static uint8_t hdrsize[] = { 12, 8, 4, 1 }; -@@ -677,33 +674,36 @@ ngx_rtmp_prepare_message(ngx_rtmp_sessio - - /* message header */ - if (fmt <= 2) { -- pp = (u_char*)×tamp; -- *p++ = pp[2]; -- *p++ = pp[1]; -- *p++ = pp[0]; -+ -+ *p++ = (u_char) (timestamp >> 16); -+ *p++ = (u_char) (timestamp >> 8); -+ *p++ = (u_char) timestamp; -+ - if (fmt <= 1) { -- pp = (u_char*)&mlen; -- *p++ = pp[2]; -- *p++ = pp[1]; -- *p++ = pp[0]; -+ -+ *p++ = (u_char) (mlen >> 16); -+ *p++ = (u_char) (mlen >> 8); -+ *p++ = (u_char) mlen; -+ - *p++ = h->type; -+ - if (fmt == 0) { -- pp = (u_char*)&h->msid; -- *p++ = pp[0]; -- *p++ = pp[1]; -- *p++ = pp[2]; -- *p++ = pp[3]; -+ -+ *p++ = (u_char) h->msid; -+ *p++ = (u_char) (h->msid >> 8); -+ *p++ = (u_char) (h->msid >> 16); -+ *p++ = (u_char) (h->msid >> 24); - } - } - } - - /* extended header */ - if (ext_timestamp) { -- pp = (u_char*)&ext_timestamp; -- *p++ = pp[3]; -- *p++ = pp[2]; -- *p++ = pp[1]; -- *p++ = pp[0]; -+ -+ *p++ = (u_char) (ext_timestamp >> 24); -+ *p++ = (u_char) (ext_timestamp >> 16); -+ *p++ = (u_char) (ext_timestamp >> 8); -+ *p++ = (u_char) ext_timestamp; - - /* This CONTRADICTS the standard - * but that's the way flash client ---- a/nginx-rtmp/ngx_rtmp_send.c -+++ b/nginx-rtmp/ngx_rtmp_send.c -@@ -33,13 +33,13 @@ - *(__b->last++) = (u_char)(utype); - - #define NGX_RTMP_USER_OUT1(v) \ -- *(__b->last++) = ((u_char*)&v)[0]; -+ *(__b->last++) = (u_char) v; - - #define NGX_RTMP_USER_OUT4(v) \ -- *(__b->last++) = ((u_char*)&v)[3]; \ -- *(__b->last++) = ((u_char*)&v)[2]; \ -- *(__b->last++) = ((u_char*)&v)[1]; \ -- *(__b->last++) = ((u_char*)&v)[0]; -+ *(__b->last++) = (u_char) (v >> 24); \ -+ *(__b->last++) = (u_char) (v >> 16); \ -+ *(__b->last++) = (u_char) (v >> 8); \ -+ *(__b->last++) = (u_char) v; - - #define NGX_RTMP_USER_END(s) \ - ngx_rtmp_prepare_message(s, &__h, NULL, __l); \ ---- a/nginx-rtmp/hls/ngx_rtmp_hls_module.c -+++ b/nginx-rtmp/hls/ngx_rtmp_hls_module.c -@@ -296,7 +296,7 @@ static ngx_command_t ngx_rtmp_hls_comman - ngx_conf_set_enum_slot, - NGX_RTMP_APP_CONF_OFFSET, - offsetof(ngx_rtmp_hls_app_conf_t, allow_client_cache), -- &ngx_rtmp_hls_cache }, -+ &ngx_rtmp_hls_cache }, - - { ngx_string("hls_variant"), - NGX_RTMP_MAIN_CONF|NGX_RTMP_SRV_CONF|NGX_RTMP_APP_CONF|NGX_CONF_1MORE, -@@ -816,7 +816,7 @@ ngx_rtmp_hls_append_sps_pps(ngx_rtmp_ses - return NGX_ERROR; - } - -- ngx_rtmp_rmemcpy(&len, &rlen, 2); -+ len=ntohs(rlen); - - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "hls: header NAL length: %uz", (size_t) len); -@@ -2072,7 +2072,21 @@ ngx_rtmp_hls_video(ngx_rtmp_session_t *s - } - - len = 0; -- ngx_rtmp_rmemcpy(&len, &rlen, nal_bytes); -+ -+ switch (nal_bytes) { -+ case 1: -+ len=*(uint8_t*)&rlen; -+ break; -+ case 2: -+ len=ntohs(*(uint16_t*)&rlen); -+ break; -+ case 3: -+ len=n3toh4((u_char*)&rlen); -+ break; -+ case 4: -+ len=ntohl(rlen); -+ break; -+ }; - - if (len == 0) { - continue; ---- a/nginx-rtmp/ngx_rtmp_bitop.h -+++ b/nginx-rtmp/ngx_rtmp_bitop.h -@@ -40,7 +40,7 @@ uint64_t ngx_rtmp_bit_read_golomb(ngx_rt - ((uint32_t) ngx_rtmp_bit_read(br, 32)) - - #define ngx_rtmp_bit_read_64(br) \ -- ((uint64_t) ngx_rtmp_read(br, 64)) -+ ((uint64_t) ngx_rtmp_bit_read(br, 64)) - - - #endif /* _NGX_RTMP_BITOP_H_INCLUDED_ */ ---- a/nginx-rtmp/ngx_rtmp_eval.c -+++ b/nginx-rtmp/ngx_rtmp_eval.c -@@ -166,7 +166,7 @@ ngx_rtmp_eval(void *ctx, ngx_str_t *in, - state = ESCAPE; - continue; - } -- -+ /* fall through */ - case ESCAPE: - ngx_rtmp_eval_append(&b, &c, 1, log); - state = NORMAL; ---- a/nginx-rtmp/ngx_rtmp_handshake.c -+++ b/nginx-rtmp/ngx_rtmp_handshake.c -@@ -264,7 +264,8 @@ ngx_rtmp_handshake_create_challenge(ngx_ - b = s->hs_buf; - b->last = b->pos = b->start; - *b->last++ = '\x03'; -- b->last = ngx_rtmp_rcpymem(b->last, &s->epoch, 4); -+ *(uint32_t*)b->last=htonl(s->epoch); -+ b->last +=4; - b->last = ngx_cpymem(b->last, version, 4); - ngx_rtmp_fill_random_buffer(b); - ++b->pos; -@@ -292,8 +293,7 @@ ngx_rtmp_handshake_parse_challenge(ngx_r - return NGX_ERROR; - } - ++b->pos; -- s->peer_epoch = 0; -- ngx_rtmp_rmemcpy(&s->peer_epoch, b->pos, 4); -+ s->peer_epoch = ntohl(*(uint32_t*)b->pos); - - p = b->pos + 4; - ngx_log_debug5(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, ---- a/nginx-rtmp/ngx_rtmp_mp4_module.c -+++ b/nginx-rtmp/ngx_rtmp_mp4_module.c -@@ -528,9 +528,9 @@ ngx_rtmp_mp4_parse_mdhd(ngx_rtmp_session - } - - pos += 12; -- t->time_scale = ngx_rtmp_r32(*(uint32_t *) pos); -+ t->time_scale = ntohl(*(uint32_t *) pos); - pos += 4; -- t->duration = ngx_rtmp_r32(*(uint32_t *) pos); -+ t->duration = ntohl(*(uint32_t *) pos); - break; - - case 1: -@@ -539,9 +539,9 @@ ngx_rtmp_mp4_parse_mdhd(ngx_rtmp_session - } - - pos += 20; -- t->time_scale = ngx_rtmp_r32(*(uint32_t *) pos); -+ t->time_scale = ntohl(*(uint32_t *) pos); - pos += 4; -- t->duration = ngx_rtmp_r64(*(uint64_t *) pos); -+ t->duration = ntohll(*(uint64_t *) pos); - break; - - default: -@@ -616,11 +616,11 @@ ngx_rtmp_mp4_parse_video(ngx_rtmp_sessio - - pos += 24; - -- ctx->width = ngx_rtmp_r16(*(uint16_t *) pos); -+ ctx->width = ntohs(*(uint16_t *) pos); - - pos += 2; - -- ctx->height = ngx_rtmp_r16(*(uint16_t *) pos); -+ ctx->height = ntohs(*(uint16_t *) pos); - - pos += 52; - -@@ -660,19 +660,19 @@ ngx_rtmp_mp4_parse_audio(ngx_rtmp_sessio - - pos += 8; - -- version = ngx_rtmp_r16(*(uint16_t *) pos); -+ version = ntohs(*(uint16_t *) pos); - - pos += 8; - -- ctx->nchannels = ngx_rtmp_r16(*(uint16_t *) pos); -+ ctx->nchannels = ntohs(*(uint16_t *) pos); - - pos += 2; - -- ctx->sample_size = ngx_rtmp_r16(*(uint16_t *) pos); -+ ctx->sample_size = ntohs(*(uint16_t *) pos); - - pos += 6; - -- ctx->sample_rate = ngx_rtmp_r16(*(uint16_t *) pos); -+ ctx->sample_rate = ntohs(*(uint16_t *) pos); - - pos += 4; - -@@ -862,7 +862,7 @@ ngx_rtmp_mp4_parse_es(ngx_rtmp_session_t - return NGX_ERROR; - } - -- id = ngx_rtmp_r16(*(uint16_t *) pos); -+ id = ntohs(*(uint16_t *) pos); - pos += 2; - - flags = *(uint8_t *) pos; -@@ -1018,13 +1018,13 @@ ngx_rtmp_mp4_parse_stsc(ngx_rtmp_session - - t->chunks = (ngx_rtmp_mp4_chunks_t *) pos; - -- if (pos + sizeof(*t->chunks) + ngx_rtmp_r32(t->chunks->entry_count) * -+ if (pos + sizeof(*t->chunks) + ntohl(t->chunks->entry_count) * - sizeof(t->chunks->entries[0]) - <= last) - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: chunks entries=%uD", -- ngx_rtmp_r32(t->chunks->entry_count)); -+ ntohl(t->chunks->entry_count)); - return NGX_OK; - } - -@@ -1049,13 +1049,13 @@ ngx_rtmp_mp4_parse_stts(ngx_rtmp_session - - t->times = (ngx_rtmp_mp4_times_t *) pos; - -- if (pos + sizeof(*t->times) + ngx_rtmp_r32(t->times->entry_count) * -+ if (pos + sizeof(*t->times) + ntohl(t->times->entry_count) * - sizeof(t->times->entries[0]) - <= last) - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: times entries=%uD", -- ngx_rtmp_r32(t->times->entry_count)); -+ ntohl(t->times->entry_count)); - return NGX_OK; - } - -@@ -1080,13 +1080,13 @@ ngx_rtmp_mp4_parse_ctts(ngx_rtmp_session - - t->delays = (ngx_rtmp_mp4_delays_t *) pos; - -- if (pos + sizeof(*t->delays) + ngx_rtmp_r32(t->delays->entry_count) * -+ if (pos + sizeof(*t->delays) + ntohl(t->delays->entry_count) * - sizeof(t->delays->entries[0]) - <= last) - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: delays entries=%uD", -- ngx_rtmp_r32(t->delays->entry_count)); -+ ntohl(t->delays->entry_count)); - return NGX_OK; - } - -@@ -1111,13 +1111,13 @@ ngx_rtmp_mp4_parse_stss(ngx_rtmp_session - - t->keys = (ngx_rtmp_mp4_keys_t *) pos; - -- if (pos + sizeof(*t->keys) + ngx_rtmp_r32(t->keys->entry_count) * -+ if (pos + sizeof(*t->keys) + ntohl(t->keys->entry_count) * - sizeof(t->keys->entries[0]) - <= last) - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: keys entries=%uD", -- ngx_rtmp_r32(t->keys->entry_count)); -+ ntohl(t->keys->entry_count)); - return NGX_OK; - } - -@@ -1145,18 +1145,18 @@ ngx_rtmp_mp4_parse_stsz(ngx_rtmp_session - if (pos + sizeof(*t->sizes) <= last && t->sizes->sample_size) { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: sizes size=%uD", -- ngx_rtmp_r32(t->sizes->sample_size)); -+ ntohl(t->sizes->sample_size)); - return NGX_OK; - } - -- if (pos + sizeof(*t->sizes) + ngx_rtmp_r32(t->sizes->sample_count) * -+ if (pos + sizeof(*t->sizes) + ntohl(t->sizes->sample_count) * - sizeof(t->sizes->entries[0]) - <= last) - - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: sizes entries=%uD", -- ngx_rtmp_r32(t->sizes->sample_count)); -+ ntohl(t->sizes->sample_count)); - return NGX_OK; - } - -@@ -1181,14 +1181,14 @@ ngx_rtmp_mp4_parse_stz2(ngx_rtmp_session - - t->sizes2 = (ngx_rtmp_mp4_sizes2_t *) pos; - -- if (pos + sizeof(*t->sizes) + ngx_rtmp_r32(t->sizes2->sample_count) * -- ngx_rtmp_r32(t->sizes2->field_size) / 8 -+ if (pos + sizeof(*t->sizes) + ntohl(t->sizes2->sample_count) * -+ ntohl(t->sizes2->field_size) / 8 - <= last) - { - ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: sizes2 field_size=%uD entries=%uD", -- ngx_rtmp_r32(t->sizes2->field_size), -- ngx_rtmp_r32(t->sizes2->sample_count)); -+ ntohl(t->sizes2->field_size), -+ ntohl(t->sizes2->sample_count)); - return NGX_OK; - } - -@@ -1213,13 +1213,13 @@ ngx_rtmp_mp4_parse_stco(ngx_rtmp_session - - t->offsets = (ngx_rtmp_mp4_offsets_t *) pos; - -- if (pos + sizeof(*t->offsets) + ngx_rtmp_r32(t->offsets->entry_count) * -+ if (pos + sizeof(*t->offsets) + ntohl(t->offsets->entry_count) * - sizeof(t->offsets->entries[0]) - <= last) - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: offsets entries=%uD", -- ngx_rtmp_r32(t->offsets->entry_count)); -+ ntohl(t->offsets->entry_count)); - return NGX_OK; - } - -@@ -1244,13 +1244,13 @@ ngx_rtmp_mp4_parse_co64(ngx_rtmp_session - - t->offsets64 = (ngx_rtmp_mp4_offsets64_t *) pos; - -- if (pos + sizeof(*t->offsets64) + ngx_rtmp_r32(t->offsets64->entry_count) * -+ if (pos + sizeof(*t->offsets64) + ntohl(t->offsets64->entry_count) * - sizeof(t->offsets64->entries[0]) - <= last) - { - ngx_log_debug1(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: offsets64 entries=%uD", -- ngx_rtmp_r32(t->offsets64->entry_count)); -+ ntohl(t->offsets64->entry_count)); - return NGX_OK; - } - -@@ -1275,7 +1275,7 @@ ngx_rtmp_mp4_parse(ngx_rtmp_session_t *s - } - - hdr = (uint32_t *) pos; -- size = ngx_rtmp_r32(hdr[0]); -+ size = ntohl(hdr[0]); - tag = hdr[1]; - - if (pos + size > last) { -@@ -1318,11 +1318,11 @@ ngx_rtmp_mp4_next_time(ngx_rtmp_session_ - - cr = &t->cursor; - -- if (cr->time_pos >= ngx_rtmp_r32(t->times->entry_count)) { -+ if (cr->time_pos >= ntohl(t->times->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui time[%ui/%uD] overflow", - t->id, cr->time_pos, -- ngx_rtmp_r32(t->times->entry_count)); -+ ntohl(t->times->entry_count)); - - return NGX_ERROR; - } -@@ -1330,22 +1330,22 @@ ngx_rtmp_mp4_next_time(ngx_rtmp_session_ - te = &t->times->entries[cr->time_pos]; - - cr->last_timestamp = cr->timestamp; -- cr->timestamp += ngx_rtmp_r32(te->sample_delta); -+ cr->timestamp += ntohl(te->sample_delta); - - cr->not_first = 1; - - ngx_log_debug8(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui time[%ui] [%ui/%uD][%ui/%uD]=%uD t=%uD", - t->id, cr->pos, cr->time_pos, -- ngx_rtmp_r32(t->times->entry_count), -- cr->time_count, ngx_rtmp_r32(te->sample_count), -- ngx_rtmp_r32(te->sample_delta), -+ ntohl(t->times->entry_count), -+ cr->time_count, ntohl(te->sample_count), -+ ntohl(te->sample_delta), - cr->timestamp); - - cr->time_count++; - cr->pos++; - -- if (cr->time_count >= ngx_rtmp_r32(te->sample_count)) { -+ if (cr->time_count >= ntohl(te->sample_count)) { - cr->time_pos++; - cr->time_count = 0; - } -@@ -1370,8 +1370,8 @@ ngx_rtmp_mp4_seek_time(ngx_rtmp_session_ - - te = t->times->entries; - -- while (cr->time_pos < ngx_rtmp_r32(t->times->entry_count)) { -- dt = ngx_rtmp_r32(te->sample_delta) * ngx_rtmp_r32(te->sample_count); -+ while (cr->time_pos < ntohl(t->times->entry_count)) { -+ dt = ntohl(te->sample_delta) * ntohl(te->sample_count); - - if (cr->timestamp + dt >= timestamp) { - if (te->sample_delta == 0) { -@@ -1379,24 +1379,24 @@ ngx_rtmp_mp4_seek_time(ngx_rtmp_session_ - } - - cr->time_count = (timestamp - cr->timestamp) / -- ngx_rtmp_r32(te->sample_delta); -- cr->timestamp += ngx_rtmp_r32(te->sample_delta) * cr->time_count; -+ ntohl(te->sample_delta); -+ cr->timestamp += ntohl(te->sample_delta) * cr->time_count; - cr->pos += cr->time_count; - - break; - } - - cr->timestamp += dt; -- cr->pos += ngx_rtmp_r32(te->sample_count); -+ cr->pos += ntohl(te->sample_count); - cr->time_pos++; - te++; - } - -- if (cr->time_pos >= ngx_rtmp_r32(t->times->entry_count)) { -+ if (cr->time_pos >= ntohl(t->times->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek time[%ui/%uD] overflow", - t->id, cr->time_pos, -- ngx_rtmp_r32(t->times->entry_count)); -+ ntohl(t->times->entry_count)); - - return NGX_ERROR; - } -@@ -1405,10 +1405,10 @@ ngx_rtmp_mp4_seek_time(ngx_rtmp_session_ - "mp4: track#%ui seek time[%ui] [%ui/%uD][%ui/%uD]=%uD " - "t=%uD", - t->id, cr->pos, cr->time_pos, -- ngx_rtmp_r32(t->times->entry_count), -+ ntohl(t->times->entry_count), - cr->time_count, -- ngx_rtmp_r32(te->sample_count), -- ngx_rtmp_r32(te->sample_delta), -+ ntohl(te->sample_count), -+ ntohl(te->sample_delta), - cr->timestamp); - - return NGX_OK; -@@ -1433,44 +1433,44 @@ ngx_rtmp_mp4_update_offset(ngx_rtmp_sess - chunk = cr->chunk - 1; - - if (t->offsets) { -- if (chunk >= ngx_rtmp_r32(t->offsets->entry_count)) { -+ if (chunk >= ntohl(t->offsets->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui offset[%ui/%uD] overflow", - t->id, cr->chunk, -- ngx_rtmp_r32(t->offsets->entry_count)); -+ ntohl(t->offsets->entry_count)); - - return NGX_ERROR; - } - -- cr->offset = (off_t) ngx_rtmp_r32(t->offsets->entries[chunk]); -+ cr->offset = (off_t) ntohl(t->offsets->entries[chunk]); - cr->size = 0; - - ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui offset[%ui/%uD]=%O", - t->id, cr->chunk, -- ngx_rtmp_r32(t->offsets->entry_count), -+ ntohl(t->offsets->entry_count), - cr->offset); - - return NGX_OK; - } - - if (t->offsets64) { -- if (chunk >= ngx_rtmp_r32(t->offsets64->entry_count)) { -+ if (chunk >= ntohl(t->offsets64->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui offset64[%ui/%uD] overflow", - t->id, cr->chunk, -- ngx_rtmp_r32(t->offsets->entry_count)); -+ ntohl(t->offsets->entry_count)); - - return NGX_ERROR; - } - -- cr->offset = (off_t) ngx_rtmp_r64(t->offsets64->entries[chunk]); -+ cr->offset = (off_t) ntohll(t->offsets64->entries[chunk]); - cr->size = 0; - - ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui offset64[%ui/%uD]=%O", - t->id, cr->chunk, -- ngx_rtmp_r32(t->offsets->entry_count), -+ ntohl(t->offsets->entry_count), - cr->offset); - - return NGX_OK; -@@ -1493,11 +1493,11 @@ ngx_rtmp_mp4_next_chunk(ngx_rtmp_session - - cr = &t->cursor; - -- if (cr->chunk_pos >= ngx_rtmp_r32(t->chunks->entry_count)) { -+ if (cr->chunk_pos >= ntohl(t->chunks->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui chunk[%ui/%uD] overflow", - t->id, cr->chunk_pos, -- ngx_rtmp_r32(t->chunks->entry_count)); -+ ntohl(t->chunks->entry_count)); - - return NGX_ERROR; - } -@@ -1506,13 +1506,13 @@ ngx_rtmp_mp4_next_chunk(ngx_rtmp_session - - cr->chunk_count++; - -- if (cr->chunk_count >= ngx_rtmp_r32(ce->samples_per_chunk)) { -+ if (cr->chunk_count >= ntohl(ce->samples_per_chunk)) { - cr->chunk_count = 0; - cr->chunk++; - -- if (cr->chunk_pos + 1 < ngx_rtmp_r32(t->chunks->entry_count)) { -+ if (cr->chunk_pos + 1 < ntohl(t->chunks->entry_count)) { - nce = ce + 1; -- if (cr->chunk >= ngx_rtmp_r32(nce->first_chunk)) { -+ if (cr->chunk >= ntohl(nce->first_chunk)) { - cr->chunk_pos++; - ce = nce; - } -@@ -1527,10 +1527,10 @@ ngx_rtmp_mp4_next_chunk(ngx_rtmp_session - ngx_log_debug7(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui chunk[%ui/%uD][%uD..%ui][%ui/%uD]", - t->id, cr->chunk_pos, -- ngx_rtmp_r32(t->chunks->entry_count), -- ngx_rtmp_r32(ce->first_chunk), -+ ntohl(t->chunks->entry_count), -+ ntohl(ce->first_chunk), - cr->chunk, cr->chunk_count, -- ngx_rtmp_r32(ce->samples_per_chunk)); -+ ntohl(ce->samples_per_chunk)); - - - if (new_chunk) { -@@ -1558,12 +1558,12 @@ ngx_rtmp_mp4_seek_chunk(ngx_rtmp_session - ce = t->chunks->entries; - pos = 0; - -- while (cr->chunk_pos + 1 < ngx_rtmp_r32(t->chunks->entry_count)) { -+ while (cr->chunk_pos + 1 < ntohl(t->chunks->entry_count)) { - nce = ce + 1; - -- dpos = (ngx_rtmp_r32(nce->first_chunk) - -- ngx_rtmp_r32(ce->first_chunk)) * -- ngx_rtmp_r32(ce->samples_per_chunk); -+ dpos = (ntohl(nce->first_chunk) - -+ ntohl(ce->first_chunk)) * -+ ntohl(ce->samples_per_chunk); - - if (pos + dpos > cr->pos) { - break; -@@ -1578,20 +1578,20 @@ ngx_rtmp_mp4_seek_chunk(ngx_rtmp_session - return NGX_ERROR; - } - -- dchunk = (cr->pos - pos) / ngx_rtmp_r32(ce->samples_per_chunk); -+ dchunk = (cr->pos - pos) / ntohl(ce->samples_per_chunk); - -- cr->chunk = ngx_rtmp_r32(ce->first_chunk) + dchunk; -+ cr->chunk = ntohl(ce->first_chunk) + dchunk; - cr->chunk_pos = (ngx_uint_t) (ce - t->chunks->entries); - cr->chunk_count = (ngx_uint_t) (cr->pos - pos - dchunk * -- ngx_rtmp_r32(ce->samples_per_chunk)); -+ ntohl(ce->samples_per_chunk)); - - ngx_log_debug7(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek chunk[%ui/%uD][%uD..%ui][%ui/%uD]", - t->id, cr->chunk_pos, -- ngx_rtmp_r32(t->chunks->entry_count), -- ngx_rtmp_r32(ce->first_chunk), -+ ntohl(t->chunks->entry_count), -+ ntohl(ce->first_chunk), - cr->chunk, cr->chunk_count, -- ngx_rtmp_r32(ce->samples_per_chunk)); -+ ntohl(ce->samples_per_chunk)); - - return ngx_rtmp_mp4_update_offset(s, t); - } -@@ -1608,7 +1608,7 @@ ngx_rtmp_mp4_next_size(ngx_rtmp_session_ - - if (t->sizes) { - if (t->sizes->sample_size) { -- cr->size = ngx_rtmp_r32(t->sizes->sample_size); -+ cr->size = ntohl(t->sizes->sample_size); - - ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui size fix=%uz", -@@ -1619,32 +1619,32 @@ ngx_rtmp_mp4_next_size(ngx_rtmp_session_ - - cr->size_pos++; - -- if (cr->size_pos >= ngx_rtmp_r32(t->sizes->sample_count)) { -+ if (cr->size_pos >= ntohl(t->sizes->sample_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui size[%ui/%uD] overflow", - t->id, cr->size_pos, -- ngx_rtmp_r32(t->sizes->sample_count)); -+ ntohl(t->sizes->sample_count)); - - return NGX_ERROR; - } - -- cr->size = ngx_rtmp_r32(t->sizes->entries[cr->size_pos]); -+ cr->size = ntohl(t->sizes->entries[cr->size_pos]); - - ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui size[%ui/%uD]=%uz", - t->id, cr->size_pos, -- ngx_rtmp_r32(t->sizes->sample_count), -+ ntohl(t->sizes->sample_count), - cr->size); - - return NGX_OK; - } - - if (t->sizes2) { -- if (cr->size_pos >= ngx_rtmp_r32(t->sizes2->sample_count)) { -+ if (cr->size_pos >= ntohl(t->sizes2->sample_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui size[%ui/%uD] overflow", - t->id, cr->size_pos, -- ngx_rtmp_r32(t->sizes2->sample_count)); -+ ntohl(t->sizes2->sample_count)); - - return NGX_ERROR; - } -@@ -1672,7 +1672,7 @@ ngx_rtmp_mp4_seek_size(ngx_rtmp_session_ - - if (t->sizes) { - if (t->sizes->sample_size) { -- cr->size = ngx_rtmp_r32(t->sizes->sample_size); -+ cr->size = ntohl(t->sizes->sample_size); - - cr->offset += cr->size * cr->chunk_count; - -@@ -1683,37 +1683,37 @@ ngx_rtmp_mp4_seek_size(ngx_rtmp_session_ - return NGX_OK; - } - -- if (cr->pos >= ngx_rtmp_r32(t->sizes->sample_count)) { -+ if (cr->pos >= ntohl(t->sizes->sample_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek size[%ui/%uD] overflow", - t->id, cr->pos, -- ngx_rtmp_r32(t->sizes->sample_count)); -+ ntohl(t->sizes->sample_count)); - - return NGX_ERROR; - } - - for (pos = 1; pos <= cr->chunk_count; ++pos) { -- cr->offset += ngx_rtmp_r32(t->sizes->entries[cr->pos - pos]); -+ cr->offset += ntohl(t->sizes->entries[cr->pos - pos]); - } - - cr->size_pos = cr->pos; -- cr->size = ngx_rtmp_r32(t->sizes->entries[cr->size_pos]); -+ cr->size = ntohl(t->sizes->entries[cr->size_pos]); - - ngx_log_debug4(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek size[%ui/%uD]=%uz", - t->id, cr->size_pos, -- ngx_rtmp_r32(t->sizes->sample_count), -+ ntohl(t->sizes->sample_count), - cr->size); - - return NGX_OK; - } - - if (t->sizes2) { -- if (cr->size_pos >= ngx_rtmp_r32(t->sizes2->sample_count)) { -+ if (cr->size_pos >= ntohl(t->sizes2->sample_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek size2[%ui/%uD] overflow", - t->id, cr->size_pos, -- ngx_rtmp_r32(t->sizes->sample_count)); -+ ntohl(t->sizes->sample_count)); - - return NGX_ERROR; - } -@@ -1744,11 +1744,11 @@ ngx_rtmp_mp4_next_key(ngx_rtmp_session_t - cr->key_pos++; - } - -- if (cr->key_pos >= ngx_rtmp_r32(t->keys->entry_count)) { -+ if (cr->key_pos >= ntohl(t->keys->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui key[%ui/%uD] overflow", - t->id, cr->key_pos, -- ngx_rtmp_r32(t->keys->entry_count)); -+ ntohl(t->keys->entry_count)); - - cr->key = 0; - -@@ -1756,13 +1756,13 @@ ngx_rtmp_mp4_next_key(ngx_rtmp_session_t - } - - ke = &t->keys->entries[cr->key_pos]; -- cr->key = (cr->pos + 1 == ngx_rtmp_r32(*ke)); -+ cr->key = (cr->pos + 1 == ntohl(*ke)); - - ngx_log_debug6(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui key[%ui/%uD][%ui/%uD]=%s", - t->id, cr->key_pos, -- ngx_rtmp_r32(t->keys->entry_count), -- cr->pos, ngx_rtmp_r32(*ke), -+ ntohl(t->keys->entry_count), -+ cr->pos, ntohl(*ke), - cr->key ? "match" : "miss"); - - return NGX_OK; -@@ -1782,27 +1782,27 @@ ngx_rtmp_mp4_seek_key(ngx_rtmp_session_t - return NGX_OK; - } - -- while (cr->key_pos < ngx_rtmp_r32(t->keys->entry_count)) { -- if (ngx_rtmp_r32(t->keys->entries[cr->key_pos]) > cr->pos) { -+ while (cr->key_pos < ntohl(t->keys->entry_count)) { -+ if (ntohl(t->keys->entries[cr->key_pos]) > cr->pos) { - break; - } - - cr->key_pos++; - } - -- if (cr->key_pos >= ngx_rtmp_r32(t->keys->entry_count)) { -+ if (cr->key_pos >= ntohl(t->keys->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek key[%ui/%uD] overflow", - t->id, cr->key_pos, -- ngx_rtmp_r32(t->keys->entry_count)); -+ ntohl(t->keys->entry_count)); - return NGX_OK; - } - - ke = &t->keys->entries[cr->key_pos]; -- /*cr->key = (cr->pos + 1 == ngx_rtmp_r32(*ke));*/ -+ /*cr->key = (cr->pos + 1 == ntohl(*ke));*/ - - /* distance to the next keyframe */ -- dpos = ngx_rtmp_r32(*ke) - cr->pos - 1; -+ dpos = ntohl(*ke) - cr->pos - 1; - cr->key = 1; - - /* TODO: range version needed */ -@@ -1810,13 +1810,13 @@ ngx_rtmp_mp4_seek_key(ngx_rtmp_session_t - ngx_rtmp_mp4_next_time(s, t); - } - --/* cr->key = (cr->pos + 1 == ngx_rtmp_r32(*ke));*/ -+/* cr->key = (cr->pos + 1 == ntohl(*ke));*/ - - ngx_log_debug6(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek key[%ui/%uD][%ui/%uD]=%s", - t->id, cr->key_pos, -- ngx_rtmp_r32(t->keys->entry_count), -- cr->pos, ngx_rtmp_r32(*ke), -+ ntohl(t->keys->entry_count), -+ cr->pos, ntohl(*ke), - cr->key ? "match" : "miss"); - - return NGX_OK; -@@ -1835,11 +1835,11 @@ ngx_rtmp_mp4_next_delay(ngx_rtmp_session - return NGX_OK; - } - -- if (cr->delay_pos >= ngx_rtmp_r32(t->delays->entry_count)) { -+ if (cr->delay_pos >= ntohl(t->delays->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui delay[%ui/%uD] overflow", - t->id, cr->delay_pos, -- ngx_rtmp_r32(t->delays->entry_count)); -+ ntohl(t->delays->entry_count)); - - return NGX_OK; - } -@@ -1847,29 +1847,29 @@ ngx_rtmp_mp4_next_delay(ngx_rtmp_session - cr->delay_count++; - de = &t->delays->entries[cr->delay_pos]; - -- if (cr->delay_count >= ngx_rtmp_r32(de->sample_count)) { -+ if (cr->delay_count >= ntohl(de->sample_count)) { - cr->delay_pos++; - de++; - cr->delay_count = 0; - } - -- if (cr->delay_pos >= ngx_rtmp_r32(t->delays->entry_count)) { -+ if (cr->delay_pos >= ntohl(t->delays->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui delay[%ui/%uD] overflow", - t->id, cr->delay_pos, -- ngx_rtmp_r32(t->delays->entry_count)); -+ ntohl(t->delays->entry_count)); - - return NGX_OK; - } - -- cr->delay = ngx_rtmp_r32(de->sample_offset); -+ cr->delay = ntohl(de->sample_offset); - - ngx_log_debug6(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui delay[%ui/%uD][%ui/%uD]=%ui", - t->id, cr->delay_pos, -- ngx_rtmp_r32(t->delays->entry_count), -+ ntohl(t->delays->entry_count), - cr->delay_count, -- ngx_rtmp_r32(de->sample_count), cr->delay); -+ ntohl(de->sample_count), cr->delay); - - return NGX_OK; - } -@@ -1891,12 +1891,12 @@ ngx_rtmp_mp4_seek_delay(ngx_rtmp_session - pos = 0; - de = t->delays->entries; - -- while (cr->delay_pos < ngx_rtmp_r32(t->delays->entry_count)) { -- dpos = ngx_rtmp_r32(de->sample_count); -+ while (cr->delay_pos < ntohl(t->delays->entry_count)) { -+ dpos = ntohl(de->sample_count); - - if (pos + dpos > cr->pos) { - cr->delay_count = cr->pos - pos; -- cr->delay = ngx_rtmp_r32(de->sample_offset); -+ cr->delay = ntohl(de->sample_offset); - break; - } - -@@ -1905,11 +1905,11 @@ ngx_rtmp_mp4_seek_delay(ngx_rtmp_session - de++; - } - -- if (cr->delay_pos >= ngx_rtmp_r32(t->delays->entry_count)) { -+ if (cr->delay_pos >= ntohl(t->delays->entry_count)) { - ngx_log_debug3(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek delay[%ui/%uD] overflow", - t->id, cr->delay_pos, -- ngx_rtmp_r32(t->delays->entry_count)); -+ ntohl(t->delays->entry_count)); - - return NGX_OK; - } -@@ -1917,9 +1917,9 @@ ngx_rtmp_mp4_seek_delay(ngx_rtmp_session - ngx_log_debug6(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "mp4: track#%ui seek delay[%ui/%uD][%ui/%uD]=%ui", - t->id, cr->delay_pos, -- ngx_rtmp_r32(t->delays->entry_count), -+ ntohl(t->delays->entry_count), - cr->delay_count, -- ngx_rtmp_r32(de->sample_count), cr->delay); -+ ntohl(de->sample_count), cr->delay); - - return NGX_OK; - } -@@ -2348,7 +2348,7 @@ ngx_rtmp_mp4_init(ngx_rtmp_session_t *s, - return NGX_ERROR; - } - -- size = (size_t) ngx_rtmp_r32(hdr[0]); -+ size = (size_t) ntohl(hdr[0]); - shift = sizeof(hdr); - - if (size == 1) { -@@ -2362,7 +2362,7 @@ ngx_rtmp_mp4_init(ngx_rtmp_session_t *s, - return NGX_ERROR; - } - -- size = (size_t) ngx_rtmp_r64(extended_size); -+ size = (size_t) ntohll(extended_size); - shift += sizeof(extended_size); - - } else if (size == 0) { ---- a/nginx-rtmp/ngx_rtmp_receive.c -+++ b/nginx-rtmp/ngx_rtmp_receive.c -@@ -17,7 +17,6 @@ ngx_rtmp_protocol_message_handler(ngx_rt - ngx_rtmp_header_t *h, ngx_chain_t *in) - { - ngx_buf_t *b; -- u_char *p; - uint32_t val; - uint8_t limit; - -@@ -30,11 +29,7 @@ ngx_rtmp_protocol_message_handler(ngx_rt - return NGX_OK; - } - -- p = (u_char*)&val; -- p[0] = b->pos[3]; -- p[1] = b->pos[2]; -- p[2] = b->pos[1]; -- p[3] = b->pos[0]; -+ val=ntohl(*(uint32_t*)&b->pos[0]); - - switch(h->type) { - case NGX_RTMP_MSG_CHUNK_SIZE: -@@ -88,7 +83,6 @@ ngx_rtmp_user_message_handler(ngx_rtmp_s - ngx_chain_t *in) - { - ngx_buf_t *b; -- u_char *p; - uint16_t evt; - uint32_t val; - -@@ -101,21 +95,13 @@ ngx_rtmp_user_message_handler(ngx_rtmp_s - return NGX_OK; - } - -- p = (u_char*)&evt; -- -- p[0] = b->pos[1]; -- p[1] = b->pos[0]; -+ evt=ntohs(*(uint16_t*)&b->pos[0]); - - ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "RTMP recv user evt %s (%i)", - ngx_rtmp_user_message_type(evt), (ngx_int_t) evt); - -- p = (u_char *) &val; -- -- p[0] = b->pos[5]; -- p[1] = b->pos[4]; -- p[2] = b->pos[3]; -- p[3] = b->pos[2]; -+ val=ntohl(*(uint32_t*)&b->pos[2]); - - switch(evt) { - case NGX_RTMP_USER_STREAM_BEGIN: -@@ -164,12 +150,7 @@ ngx_rtmp_user_message_handler(ngx_rtmp_s - return NGX_OK; - } - -- p = (u_char *) &v.buflen; -- -- p[0] = b->pos[9]; -- p[1] = b->pos[8]; -- p[2] = b->pos[7]; -- p[3] = b->pos[6]; -+ v.buflen=ntohl(*(uint32_t*)&b->pos[6]); - - ngx_log_debug2(NGX_LOG_DEBUG_RTMP, s->connection->log, 0, - "receive: set_buflen msid=%uD buflen=%uD", -@@ -240,18 +221,20 @@ ngx_rtmp_fetch_uint8(ngx_chain_t **in, u - static ngx_int_t - ngx_rtmp_fetch_uint32(ngx_chain_t **in, uint32_t *ret, ngx_int_t n) - { -- u_char *r = (u_char *) ret; -+ u_char b; -+ uint32_t val=0; - ngx_int_t rc; - -- *ret = 0; -- - while (--n >= 0) { -- rc = ngx_rtmp_fetch(in, &r[n]); -+ rc = ngx_rtmp_fetch(in, &b); - if (rc != NGX_OK) { -+ *ret = 0; - return rc; - } -+ val = (val<<8)|b; - } - -+ *ret=val; - return NGX_OK; - } - ---- a/nginx-rtmp/ngx_rtmp_record_module.c -+++ b/nginx-rtmp/ngx_rtmp_record_module.c -@@ -454,7 +454,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_sessi - ngx_err_t err; - ngx_str_t path; - ngx_int_t mode, create_mode; -- u_char buf[8], *p; -+ u_char buf[8]; - off_t file_size; - uint32_t tag_size, mlen, timestamp; - -@@ -551,11 +551,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_sessi - goto done; - } - -- p = (u_char *) &tag_size; -- p[0] = buf[3]; -- p[1] = buf[2]; -- p[2] = buf[1]; -- p[3] = buf[0]; -+ tag_size=ntohl(*(uint32_t*)&buf[0]); - - if (tag_size == 0 || tag_size + 4 > file_size) { - file_size = 0; -@@ -569,11 +565,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_sessi - goto done; - } - -- p = (u_char *) &mlen; -- p[0] = buf[3]; -- p[1] = buf[2]; -- p[2] = buf[1]; -- p[3] = 0; -+ mlen=n3toh4(&buf[1]); - - if (tag_size != mlen + 11) { - ngx_log_error(NGX_LOG_CRIT, s->connection->log, ngx_errno, -@@ -582,11 +574,7 @@ ngx_rtmp_record_node_open(ngx_rtmp_sessi - goto done; - } - -- p = (u_char *) ×tamp; -- p[3] = buf[7]; -- p[0] = buf[6]; -- p[1] = buf[5]; -- p[2] = buf[4]; -+ timestamp=n3toh4(&buf[4])|((uint32_t)buf[7]<<24); - - done: - rctx->file.offset = file_size; -@@ -891,7 +879,7 @@ ngx_rtmp_record_write_frame(ngx_rtmp_ses - ngx_rtmp_header_t *h, ngx_chain_t *in, - ngx_int_t inc_nframes) - { -- u_char hdr[11], *p, *ph; -+ u_char hdr[11], *ph; - uint32_t timestamp, tag_size; - ngx_rtmp_record_app_conf_t *rracf; - -@@ -937,16 +925,10 @@ ngx_rtmp_record_write_frame(ngx_rtmp_ses - - *ph++ = (u_char)h->type; - -- p = (u_char*)&h->mlen; -- *ph++ = p[2]; -- *ph++ = p[1]; -- *ph++ = p[0]; -- -- p = (u_char*)×tamp; -- *ph++ = p[2]; -- *ph++ = p[1]; -- *ph++ = p[0]; -- *ph++ = p[3]; -+ ph = h4ton3(ph, h->mlen); -+ -+ ph = h4ton3(ph, timestamp); -+ *ph++ = (u_char)(timestamp>>24); - - *ph++ = 0; - *ph++ = 0; -@@ -985,12 +967,8 @@ ngx_rtmp_record_write_frame(ngx_rtmp_ses - - /* write tag size */ - ph = hdr; -- p = (u_char*)&tag_size; -- -- *ph++ = p[3]; -- *ph++ = p[2]; -- *ph++ = p[1]; -- *ph++ = p[0]; -+ *(uint32_t*)ph = htonl(tag_size); -+ ph += 4; - - if (ngx_write_file(&rctx->file, hdr, ph - hdr, - rctx->file.offset) diff --git a/omr-6in4/Makefile b/omr-6in4/Makefile old mode 100755 new mode 100644 diff --git a/omr-quota/Makefile b/omr-quota/Makefile old mode 100755 new mode 100644 diff --git a/omr-quota/files/etc/config/omr-quota b/omr-quota/files/etc/config/omr-quota old mode 100755 new mode 100644 diff --git a/omr-tracker/Makefile b/omr-tracker/Makefile old mode 100755 new mode 100644 diff --git a/omr-update/Makefile b/omr-update/Makefile old mode 100755 new mode 100644 diff --git a/openmptcprouter-full/Makefile b/openmptcprouter-full/Makefile old mode 100755 new mode 100644 index 546fdfba2..c9141b684 --- a/openmptcprouter-full/Makefile +++ b/openmptcprouter-full/Makefile @@ -39,12 +39,13 @@ MY_DEPENDS := \ luci-app-omr-tracker luci-app-omr-dscp \ luci-app-sqm-autorate sqm-scripts-extra \ luci-app-vnstat2 omr-quota luci-app-omr-quota \ - luci-app-mptcp luci-app-openmptcprouter luci-app-mail luci-app-upnp \ + luci-app-mptcp luci-app-openmptcprouter luci-app-omr-bypass luci-app-mail luci-app-upnp \ luci-app-wol luci-app-opkg \ luci-app-uhttpd \ luci-mod-rpc rpcd-mod-rpcsys rpcd-mod-file rpcd-mod-iwinfo \ luci-app-openvpn \ shadowsocks-libev-ss-server shadowsocks-libev-ss-tunnel \ + omr-6in4 ip6tables-mod-nat luci-proto-ipv6 6to4 6in4 6rd ip6tables \ !TARGET_mvebu:speedtestcpp \ iftop \ htop \ @@ -75,6 +76,7 @@ MY_DEPENDS := \ !TARGET_mvebu:kmod-usb-serial !TARGET_mvebu:kmod-usb-serial-option !TARGET_mvebu:kmod-usb-serial-wwan !TARGET_mvebu:usb-modeswitch !TARGET_mvebu:uqmi \ !TARGET_mvebu:umbim !TARGET_mvebu:kmod-mii !TARGET_mvebu:kmod-usb-net !TARGET_mvebu:kmod-usb-wdm !TARGET_mvebu:kmod-usb-net-qmi-wwan !TARGET_mvebu:kmod-usb-net-cdc-mbim !TARGET_mvebu:umbim \ !TARGET_mvebu:kmod-usb-net-huawei-cdc-ncm !TARGET_mvebu:kmod-usb-net-rndis !TARGET_mvebu:kmod-usb-net-cdc-ether !TARGET_mvebu:kmod-usb-net-ipheth !TARGET_mvebu:usbmuxd !TARGET_mvebu:libusbmuxd \ + kmod-rt2800-usb kmod-rtl8xxxu kmod-rtl8192cu kmod-net-rtl8192su !LINUX_6_1:kmod-rtl8812au-ct \ !TARGET_mvebu:luci-proto-qmi wpad-basic kmod-mt7601u kmod-rtl8187 TARGET_r4s:kmod-r8168 (TARGET_x86||TARGET_x86_64):kmod-usb-net-rtl8152 \ !TARGET_mvebu:luci-app-mlvpn !TARGET_mvebu:mlvpn 464xlat kmod-zram kmod-swconfig swconfig kmod-ipt-nat kmod-ipt-nat6 luci-app-https-dns-proxy kmod-tcp-nanqinlang (TARGET_x86_64||aarch64):kmod-tcp-bbr2 iptables-mod-ipopt igmpproxy ss iptraf-ng \ luci-app-acl block-mount blockd fstools luci-app-shutdown libwebp luci-proto-gre tcptraceroute luci-proto-mbim kmod-rtl8xxxu kmod-ath9k-htc luci-app-ttyd luci-mod-dashboard (TARGET_x86||TARGET_x86_64):rtl8192eu-firmware kmod-usb2 libustream-openssl (TARGET_x86||TARGET_x86_64):kmod-ixgbevf (TARGET_x86||TARGET_x86_64):kmod-igbvf \ diff --git a/openmptcprouter-mini/Makefile b/openmptcprouter-mini/Makefile old mode 100755 new mode 100644 diff --git a/openmptcprouter/Makefile b/openmptcprouter/Makefile old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/firewall.gre-tunnel b/openmptcprouter/files/etc/firewall.gre-tunnel old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/firewall.omr-server b/openmptcprouter/files/etc/firewall.omr-server old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/firewall.ttl b/openmptcprouter/files/etc/firewall.ttl old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/hotplug.d/iface/00-nego b/openmptcprouter/files/etc/hotplug.d/iface/00-nego old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/iproute2/rt_dsfield b/openmptcprouter/files/etc/iproute2/rt_dsfield old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/sysctl.d/default.conf b/openmptcprouter/files/etc/sysctl.d/default.conf old mode 100755 new mode 100644 diff --git a/openmptcprouter/files/etc/wgetrc4 b/openmptcprouter/files/etc/wgetrc4 old mode 100755 new mode 100644 diff --git a/protobuf/Makefile b/protobuf/Makefile old mode 100755 new mode 100644 diff --git a/serdisplib/Makefile b/serdisplib/Makefile old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/Makefile b/shadowsocks-libev/Makefile old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/README.md b/shadowsocks-libev/README.md old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/files/firewall.ss-rules b/shadowsocks-libev/files/firewall.ss-rules old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/files/shadowsocks-libev.config b/shadowsocks-libev/files/shadowsocks-libev.config old mode 100755 new mode 100644 index 1f79bcb83..9423ef9bc --- a/shadowsocks-libev/files/shadowsocks-libev.config +++ b/shadowsocks-libev/files/shadowsocks-libev.config @@ -25,7 +25,7 @@ config ss_redir hi2 option mptcp 1 option ipv6_first 1 option no_delay 1 - + config ss_rules 'ss_rules' option disabled 0 option redir_tcp 'hi1' @@ -47,32 +47,4 @@ config ss_tunnel 'dns' option mode 'tcp_and_udp' option server 'sss0' option local_port '5353' - option tunnel_address '8.8.8.8:53' - -config ss_redir hi3 - option server 'sss0' - option local_address '0.0.0.0' - option local_port '1100' - option mode 'tcp_and_udp' - option timeout '1000' - option fast_open 1 - option verbose 0 - option syslog 1 - option reuse_port 1 - option mptcp 1 - option ipv6_first 1 - option no_delay 1 - -config ss_redir hi4 - option server 'sss0' - option local_address '0.0.0.0' - option local_port '1100' - option mode 'tcp_and_udp' - option timeout '1000' - option fast_open 1 - option verbose 0 - option syslog 1 - option reuse_port 1 - option mptcp 1 - option ipv6_first 1 - option no_delay 1 \ No newline at end of file + option tunnel_address '8.8.8.8:53' \ No newline at end of file diff --git a/shadowsocks-libev/files/shadowsocks-libev.init b/shadowsocks-libev/files/shadowsocks-libev.init old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/files/shadowsocks.conf b/shadowsocks-libev/files/shadowsocks.conf old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/patches/010-ECONNRESET.patch b/shadowsocks-libev/patches/010-ECONNRESET.patch old mode 100755 new mode 100644 diff --git a/shadowsocks-libev/patches/020-FIX.patch b/shadowsocks-libev/patches/020-FIX.patch old mode 100755 new mode 100644 diff --git a/shadowsocks-v2ray-plugin/Makefile b/shadowsocks-v2ray-plugin/Makefile old mode 100755 new mode 100644 index df483b94d..f4cb4c2dc --- a/shadowsocks-v2ray-plugin/Makefile +++ b/shadowsocks-v2ray-plugin/Makefile @@ -25,7 +25,7 @@ GO_PKG:=github.com/shadowsocks/v2ray-plugin PKG_USE_MIPS16:=0 include $(INCLUDE_DIR)/package.mk -include $(TOPDIR)/feeds/openmptcprouter/golang/golang-package.mk +include ../golang/golang-package.mk define Package/v2ray-plugin SECTION:=net diff --git a/shortcut-fe/fast-classifier/Makefile b/shortcut-fe/fast-classifier/Makefile new file mode 100755 index 000000000..09c1174dd --- /dev/null +++ b/shortcut-fe/fast-classifier/Makefile @@ -0,0 +1,109 @@ +# +# Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. +# Permission to use, copy, modify, and/or distribute this software for +# any purpose with or without fee is hereby granted, provided that the +# above copyright notice and this permission notice appear in all copies. +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=fast-classifier +PKG_RELEASE:=6 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/fast-classifier/Default + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + DEPENDS:=+kmod-ipt-conntrack +kmod-shortcut-fe + TITLE:=Kernel driver for FAST Classifier + FILES:=$(PKG_BUILD_DIR)/fast-classifier.ko + KCONFIG:= \ + CONFIG_NF_CONNTRACK_EVENTS=y \ + CONFIG_NF_CONNTRACK_CHAIN_EVENTS=y \ + CONFIG_NF_CONNTRACK_MARK=y \ + CONFIG_XFRM=y + CONFLICTS:=kmod-shortcut-fe-drv kmod-shortcut-fe-cm +endef + +define KernelPackage/fast-classifier + $(call KernelPackage/fast-classifier/Default) +endef + +define KernelPackage/fast-classifier-noload + $(call KernelPackage/fast-classifier/Default) +endef + +define KernelPackage/fast-classifier/Default/description +FAST Classifier talks to SFE to make decisions about offloading connections +endef + +define KernelPackage/fast-classifier/description +$(call KernelPackage/fast-classifier/Default/description) +endef + +define KernelPackage/fast-classifier-noload/description +$(call KernelPackage/fast-classifier/Default/description) + +This package does not load fast-classifier at boot by default +endef + +define Package/fast-classifier-example + TITLE:=Example user space program for fast-classifier + DEPENDS:=+libnl +kmod-fast-classifier +endef + +define Package/fast-classifier-example/description +Example user space program that communicates with fast +classifier kernel module +endef + +HAVE_ECM:=$(CONFIG_PACKAGE_kmod-qca-nss-ecm-premium)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-noload)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-premium-noload)$(CONFIG_PACKAGE_kmod-qca-nss-ecm-standard) + +define Build/Compile/kmod + +$(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_MAKE_FLAGS) \ + M="$(PKG_BUILD_DIR)" \ + CONFIG_FAST_CLASSIFIER=m \ + EXTRA_CFLAGS+="-DSFE_SUPPORT_IPV6" \ + $(if $(HAVE_ECM),EXTRA_CFLAGS+="-DCONFIG_SFE_ECM" CONFIG_SFE_ECM=y,) \ + modules +endef + +define Build/Compile/example + $(TARGET_CC) -o $(PKG_BUILD_DIR)/userspace_fast_classifier \ + -I $(PKG_BUILD_DIR) \ + -I$(STAGING_DIR)/usr/include/libnl \ + -I$(STAGING_DIR)/usr/include/libnl3 \ + -lnl-genl-3 -lnl-3 \ + $(PKG_BUILD_DIR)/nl_classifier_test.c +endef + +define Build/Compile + $(Build/Compile/kmod) + $(if $(CONFIG_PACKAGE_fast-classifier-example),$(Build/Compile/example)) +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_BUILD_DIR)/fast-classifier.h $(1)/usr/include/ +endef + +define Package/fast-classifier-example/install + $(INSTALL_DIR) $(1)/sbin + $(CP) $(PKG_BUILD_DIR)/userspace_fast_classifier $(1)/sbin/ +endef + +$(eval $(call KernelPackage,fast-classifier)) +#$(eval $(call KernelPackage,fast-classifier-noload)) +#$(eval $(call BuildPackage,fast-classifier-example)) diff --git a/shortcut-fe/fast-classifier/src/Makefile b/shortcut-fe/fast-classifier/src/Makefile new file mode 100755 index 000000000..58dd06e01 --- /dev/null +++ b/shortcut-fe/fast-classifier/src/Makefile @@ -0,0 +1,10 @@ +obj-$(CONFIG_FAST_CLASSIFIER) += fast-classifier.o + +ifeq ($(SFE_SUPPORT_IPV6),) +SFE_SUPPORT_IPV6=y +endif +ccflags-$(SFE_SUPPORT_IPV6) += -DSFE_SUPPORT_IPV6 + +ccflags-y += -I$(obj)/../shortcut-fe + +obj ?= . diff --git a/shortcut-fe/fast-classifier/src/fast-classifier.c b/shortcut-fe/fast-classifier/src/fast-classifier.c new file mode 100755 index 000000000..944dfae38 --- /dev/null +++ b/shortcut-fe/fast-classifier/src/fast-classifier.c @@ -0,0 +1,2002 @@ +/* + * fast-classifier.c + * Shortcut forwarding engine connection manager. + * fast-classifier + * + * Copyright (c) 2013-2018 The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include "fast-classifier.h" + +typedef enum fast_classifier_exception { + FAST_CL_EXCEPTION_PACKET_BROADCAST, + FAST_CL_EXCEPTION_PACKET_MULTICAST, + FAST_CL_EXCEPTION_NO_IIF, + FAST_CL_EXCEPTION_NO_CT, + FAST_CL_EXCEPTION_CT_NO_TRACK, + FAST_CL_EXCEPTION_CT_NO_CONFIRM, + FAST_CL_EXCEPTION_CT_IS_ALG, + FAST_CL_EXCEPTION_IS_IPV4_MCAST, + FAST_CL_EXCEPTION_IS_IPV6_MCAST, + FAST_CL_EXCEPTION_TCP_NOT_ASSURED, + FAST_CL_EXCEPTION_TCP_NOT_ESTABLISHED, + FAST_CL_EXCEPTION_UNKNOW_PROTOCOL, + FAST_CL_EXCEPTION_NO_SRC_DEV, + FAST_CL_EXCEPTION_NO_SRC_XLATE_DEV, + FAST_CL_EXCEPTION_NO_DEST_DEV, + FAST_CL_EXCEPTION_NO_DEST_XLATE_DEV, + FAST_CL_EXCEPTION_NO_BRIDGE, + FAST_CL_EXCEPTION_LOCAL_OUT, + FAST_CL_EXCEPTION_WAIT_FOR_ACCELERATION, + FAST_CL_EXCEPTION_UPDATE_PROTOCOL_FAIL, + FAST_CL_EXCEPTION_CT_DESTROY_MISS, + FAST_CL_EXCEPTION_MAX +} fast_classifier_exception_t; + +static char *fast_classifier_exception_events_string[FAST_CL_EXCEPTION_MAX] = { + "PACKET_BROADCAST", + "PACKET_MULTICAST", + "NO_IIF", + "NO_CT", + "CT_NO_TRACK", + "CT_NO_CONFIRM", + "CT_IS_ALG", + "IS_IPV4_MCAST", + "IS_IPV6_MCAST", + "TCP_NOT_ASSURED", + "TCP_NOT_ESTABLISHED", + "UNKNOW_PROTOCOL", + "NO_SRC_DEV", + "NO_SRC_XLATE_DEV", + "NO_DEST_DEV", + "NO_DEST_XLATE_DEV", + "NO_BRIDGE", + "LOCAL_OUT", + "WAIT_FOR_ACCELERATION", + "UPDATE_PROTOCOL_FAIL", + "CT_DESTROY_MISS", +}; + +/* + * Per-module structure. + */ +struct fast_classifier { + spinlock_t lock; /* Lock for SMP correctness */ + + /* + * Control state. + */ + struct kobject *sys_fast_classifier; /* sysfs linkage */ + + /* + * Callback notifiers. + */ + struct notifier_block dev_notifier; /* Device notifier */ + struct notifier_block inet_notifier; /* IPv4 notifier */ + struct notifier_block inet6_notifier; /* IPv6 notifier */ + u32 exceptions[FAST_CL_EXCEPTION_MAX]; +}; + +static struct fast_classifier __sc; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)) +static struct nla_policy fast_classifier_genl_policy[FAST_CLASSIFIER_A_MAX + 1] = { + [FAST_CLASSIFIER_A_TUPLE] = { + .type = NLA_UNSPEC, + .len = sizeof(struct fast_classifier_tuple) + }, +}; +#endif /*KERNEL_VERSION(5, 2, 0)*/ + +static struct genl_multicast_group fast_classifier_genl_mcgrp[] = { + { + .name = FAST_CLASSIFIER_GENL_MCGRP, + }, +}; + +static int fast_classifier_offload_genl_msg(struct sk_buff *skb, struct genl_info *info); +static int fast_classifier_nl_genl_msg_DUMP(struct sk_buff *skb, struct netlink_callback *cb); + +static struct genl_ops fast_classifier_gnl_ops[] = { + { + .cmd = FAST_CLASSIFIER_C_OFFLOAD, + .flags = 0, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)) + .policy = fast_classifier_genl_policy, +#endif /*KERNEL_VERSION(5, 2, 0)*/ + .doit = fast_classifier_offload_genl_msg, + .dumpit = NULL, + }, + { + .cmd = FAST_CLASSIFIER_C_OFFLOADED, + .flags = 0, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)) + .policy = fast_classifier_genl_policy, +#endif /*KERNEL_VERSION(5, 2, 0)*/ + .doit = NULL, + .dumpit = fast_classifier_nl_genl_msg_DUMP, + }, + { + .cmd = FAST_CLASSIFIER_C_DONE, + .flags = 0, +#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0)) + .policy = fast_classifier_genl_policy, +#endif /*KERNEL_VERSION(5, 2, 0)*/ + .doit = NULL, + .dumpit = fast_classifier_nl_genl_msg_DUMP, + }, +}; + +static struct genl_family fast_classifier_gnl_family = { +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 10, 0)) + .id = GENL_ID_GENERATE, +#endif /*KERNEL_VERSION(4, 10, 0)*/ + .hdrsize = FAST_CLASSIFIER_GENL_HDRSIZE, + .name = FAST_CLASSIFIER_GENL_NAME, + .version = FAST_CLASSIFIER_GENL_VERSION, + .maxattr = FAST_CLASSIFIER_A_MAX, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) + .ops = fast_classifier_gnl_ops, + .n_ops = ARRAY_SIZE(fast_classifier_gnl_ops), + .mcgrps = fast_classifier_genl_mcgrp, + .n_mcgrps = ARRAY_SIZE(fast_classifier_genl_mcgrp), +#endif /*KERNEL_VERSION(4, 10, 0)*/ +}; + +static atomic_t offload_msgs = ATOMIC_INIT(0); +static atomic_t offload_no_match_msgs = ATOMIC_INIT(0); +static atomic_t offloaded_msgs = ATOMIC_INIT(0); +static atomic_t done_msgs = ATOMIC_INIT(0); + +static atomic_t offloaded_fail_msgs = ATOMIC_INIT(0); +static atomic_t done_fail_msgs = ATOMIC_INIT(0); + +/* + * Accelerate incoming packets destined for bridge device + * If a incoming packet is ultimatly destined for + * a bridge device we will first see the packet coming + * from the phyiscal device, we can skip straight to + * processing the packet like it came from the bridge + * for some more performance gains + * + * This only works when the hook is above the bridge. We + * only implement ingress for now, because for egress we + * want to have the bridge devices qdiscs be used. + */ +static bool skip_to_bridge_ingress; + +/* + * fast_classifier_incr_exceptions() + * increase an exception counter. + */ +static inline void fast_classifier_incr_exceptions(fast_classifier_exception_t except) +{ + struct fast_classifier *sc = &__sc; + + spin_lock_bh(&sc->lock); + sc->exceptions[except]++; + spin_unlock_bh(&sc->lock); +} + +/* + * fast_classifier_recv() + * Handle packet receives. + * + * Returns 1 if the packet is forwarded or 0 if it isn't. + */ +int fast_classifier_recv(struct sk_buff *skb) +{ + struct net_device *dev; + struct net_device *master_dev = NULL; + int ret = 0; + + /* + * We know that for the vast majority of packets we need the transport + * layer header so we may as well start to fetch it now! + */ + prefetch(skb->data + 32); + barrier(); + + dev = skb->dev; + + /* + * Process packet like it arrived on the bridge device + */ + if (skip_to_bridge_ingress && + (dev->priv_flags & IFF_BRIDGE_PORT)) { + master_dev = sfe_dev_get_master(dev); + if (!master_dev) { + DEBUG_WARN("master dev is NULL %s\n", dev->name); + goto rx_exit; + } + dev = master_dev; + } + + /* + * We're only interested in IPv4 and IPv6 packets. + */ + if (likely(htons(ETH_P_IP) == skb->protocol)) { + struct in_device *in_dev; + + /* + * Does our input device support IP processing? + */ + in_dev = (struct in_device *)dev->ip_ptr; + if (unlikely(!in_dev)) { + DEBUG_TRACE("no IP processing for device: %s\n", dev->name); + goto rx_exit; + } + + /* + * Does it have an IP address? If it doesn't then we can't do anything + * interesting here! + */ + if (unlikely(!in_dev->ifa_list)) { + DEBUG_TRACE("no IP address for device: %s\n", dev->name); + goto rx_exit; + } + + ret = sfe_ipv4_recv(dev, skb); + + } else if (likely(htons(ETH_P_IPV6) == skb->protocol)) { + struct inet6_dev *in_dev; + + /* + * Does our input device support IPv6 processing? + */ + in_dev = (struct inet6_dev *)dev->ip6_ptr; + if (unlikely(!in_dev)) { + DEBUG_TRACE("no IPv6 processing for device: %s\n", dev->name); + goto rx_exit; + } + + /* + * Does it have an IPv6 address? If it doesn't then we can't do anything + * interesting here! + */ + if (unlikely(list_empty(&in_dev->addr_list))) { + DEBUG_TRACE("no IPv6 address for device: %s\n", dev->name); + goto rx_exit; + } + + ret = sfe_ipv6_recv(dev, skb); + + } else { + DEBUG_TRACE("not IP packet\n"); + } + +rx_exit: + if (master_dev) { + dev_put(master_dev); + } + + return ret; +} + +/* + * fast_classifier_find_dev_and_mac_addr() + * Find the device and MAC address for a given IPv4 address. + * + * Returns true if we find the device and MAC address, otherwise false. + * + * We look up the rtable entry for the address and, from its neighbour + * structure, obtain the hardware address. This means this function also + * works if the neighbours are routers too. + */ +static bool fast_classifier_find_dev_and_mac_addr(struct sk_buff *skb, sfe_ip_addr_t *addr, struct net_device **dev, u8 *mac_addr, bool is_v4) +{ + struct neighbour *neigh; + struct rtable *rt; + struct rt6_info *rt6; + struct dst_entry *dst; + struct net_device *mac_dev; + + /* + * If we have skb provided, use it as the original code is unable + * to lookup routes that are policy routed. + */ + if (unlikely(skb)) { + dst = skb_dst(skb); + goto skip_dst_lookup; + } + + /* + * Look up the rtable entry for the IP address then get the hardware + * address from its neighbour structure. This means this works when the + * neighbours are routers too. + */ + if (likely(is_v4)) { + rt = ip_route_output(&init_net, addr->ip, 0, 0, 0); + if (unlikely(IS_ERR(rt))) { + goto ret_fail; + } + + dst = (struct dst_entry *)rt; + } +#ifdef SFE_SUPPORT_IPV6 + else { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0)) + rt6 = rt6_lookup(&init_net, (struct in6_addr *)addr->ip6, 0, 0, NULL, 0); +#else + rt6 = rt6_lookup(&init_net, (struct in6_addr *)addr->ip6, 0, 0, 0); +#endif /*KERNEL_VERSION(4, 17, 0)*/ + if (!rt6) { + goto ret_fail; + } + + dst = (struct dst_entry *)rt6; + } +#endif + +skip_dst_lookup: + rcu_read_lock(); + neigh = sfe_dst_get_neighbour(dst, addr); + if (unlikely(!neigh)) { + rcu_read_unlock(); + if (likely(!skb)) + dst_release(dst); + + goto ret_fail; + } + + if (unlikely(!(neigh->nud_state & NUD_VALID))) { + rcu_read_unlock(); + neigh_release(neigh); + if (likely(!skb)) + dst_release(dst); + + goto ret_fail; + } + + mac_dev = neigh->dev; + if (!mac_dev) { + rcu_read_unlock(); + neigh_release(neigh); + if (likely(!skb)) + dst_release(dst); + + goto ret_fail; + } + + memcpy(mac_addr, neigh->ha, (size_t)mac_dev->addr_len); + + dev_hold(mac_dev); + *dev = mac_dev; + rcu_read_unlock(); + neigh_release(neigh); + if (likely(!skb)) + dst_release(dst); + + return true; + +ret_fail: + if (is_v4) { + DEBUG_TRACE("failed to find MAC address for IP: %pI4\n", addr); + + } else { + DEBUG_TRACE("failed to find MAC address for IP: %pI6\n", addr); + } + + return false; +} + +static DEFINE_SPINLOCK(sfe_connections_lock); + +struct sfe_connection { + struct hlist_node hl; + struct sfe_connection_create *sic; + struct nf_conn *ct; + int hits; + int offload_permit; + int offloaded; + bool is_v4; + unsigned char smac[ETH_ALEN]; + unsigned char dmac[ETH_ALEN]; +}; + +static int sfe_connections_size; + +#define FC_CONN_HASH_ORDER 13 +static DEFINE_HASHTABLE(fc_conn_ht, FC_CONN_HASH_ORDER); + +static u32 fc_conn_hash(sfe_ip_addr_t *saddr, sfe_ip_addr_t *daddr, + unsigned short sport, unsigned short dport, bool is_v4) +{ + u32 idx, cnt = ((is_v4 ? sizeof(saddr->ip) : sizeof(saddr->ip6))/sizeof(u32)); + u32 hash = 0; + + for (idx = 0; idx < cnt; idx++) { + hash ^= ((u32 *)saddr)[idx] ^ ((u32 *)daddr)[idx]; + } + + return hash ^ (sport | (dport << 16)); +} + +/* + * fast_classifier_update_protocol() + * Update sfe_ipv4_create struct with new protocol information before we offload + */ +static int fast_classifier_update_protocol(struct sfe_connection_create *p_sic, struct nf_conn *ct) +{ + #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) + struct net *net=NULL ; + struct nf_tcp_net *tn=NULL; + #endif + switch (p_sic->protocol) { + case IPPROTO_TCP: + p_sic->src_td_window_scale = ct->proto.tcp.seen[0].td_scale; + p_sic->src_td_max_window = ct->proto.tcp.seen[0].td_maxwin; + p_sic->src_td_end = ct->proto.tcp.seen[0].td_end; + p_sic->src_td_max_end = ct->proto.tcp.seen[0].td_maxend; + p_sic->dest_td_window_scale = ct->proto.tcp.seen[1].td_scale; + p_sic->dest_td_max_window = ct->proto.tcp.seen[1].td_maxwin; + p_sic->dest_td_end = ct->proto.tcp.seen[1].td_end; + p_sic->dest_td_max_end = ct->proto.tcp.seen[1].td_maxend; +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) + net = nf_ct_net(ct); + tn = nf_tcp_pernet(net); + if ((tn&&tn->tcp_no_window_check) +#else + if (nf_ct_tcp_no_window_check +#endif + + || (ct->proto.tcp.seen[0].flags & IP_CT_TCP_FLAG_BE_LIBERAL) + || (ct->proto.tcp.seen[1].flags & IP_CT_TCP_FLAG_BE_LIBERAL)) { + p_sic->flags |= SFE_CREATE_FLAG_NO_SEQ_CHECK; + } + + /* + * If the connection is shutting down do not manage it. + * state can not be SYN_SENT, SYN_RECV because connection is assured + * Not managed states: FIN_WAIT, CLOSE_WAIT, LAST_ACK, TIME_WAIT, CLOSE. + */ + spin_lock(&ct->lock); + if (ct->proto.tcp.state != TCP_CONNTRACK_ESTABLISHED) { + spin_unlock(&ct->lock); + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_TCP_NOT_ESTABLISHED); + DEBUG_TRACE("connection in termination state: %#x, s: %pI4:%u, d: %pI4:%u\n", + ct->proto.tcp.state, &p_sic->src_ip, ntohs(p_sic->src_port), + &p_sic->dest_ip, ntohs(p_sic->dest_port)); + return 0; + } + spin_unlock(&ct->lock); + break; + + case IPPROTO_UDP: + break; + + default: + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_UNKNOW_PROTOCOL); + DEBUG_TRACE("unhandled protocol %d\n", p_sic->protocol); + return 0; + } + + return 1; +} + +/* fast_classifier_send_genl_msg() + * Function to send a generic netlink message + */ +static void fast_classifier_send_genl_msg(int msg, struct fast_classifier_tuple *fc_msg) +{ + struct sk_buff *skb; + int rc; + int buf_len; + int total_len; + void *msg_head; + + /* + * Calculate our packet payload size. + * Start with our family header. + */ + buf_len = fast_classifier_gnl_family.hdrsize; + + /* + * Add the nla_total_size of each attribute we're going to nla_put(). + */ + buf_len += nla_total_size(sizeof(*fc_msg)); + + /* + * Lastly we need to add space for the NL message header since + * genlmsg_new only accounts for the GENL header and not the + * outer NL header. To do this, we use a NL helper function which + * calculates the total size of a netlink message given a payload size. + * Note this value does not include the GENL header, but that's + * added automatically by genlmsg_new. + */ + total_len = nlmsg_total_size(buf_len); + skb = genlmsg_new(total_len, GFP_ATOMIC); + if (!skb) + return; + + msg_head = genlmsg_put(skb, 0, 0, &fast_classifier_gnl_family, 0, msg); + if (!msg_head) { + nlmsg_free(skb); + return; + } + + rc = nla_put(skb, FAST_CLASSIFIER_A_TUPLE, sizeof(struct fast_classifier_tuple), fc_msg); + if (rc != 0) { + genlmsg_cancel(skb, msg_head); + nlmsg_free(skb); + return; + } + +#if (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 19 , 0)) + rc = genlmsg_end(skb, msg_head); + if (rc < 0) { + genlmsg_cancel(skb, msg_head); + nlmsg_free(skb); + return; + } +#else + genlmsg_end(skb, msg_head); + +#endif + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) + rc = genlmsg_multicast(&fast_classifier_gnl_family, skb, 0, 0, GFP_ATOMIC); +#else + rc = genlmsg_multicast(skb, 0, fast_classifier_genl_mcgrp[0].id, GFP_ATOMIC); +#endif + switch (msg) { + case FAST_CLASSIFIER_C_OFFLOADED: + if (rc == 0) { + atomic_inc(&offloaded_msgs); + } else { + atomic_inc(&offloaded_fail_msgs); + } + break; + case FAST_CLASSIFIER_C_DONE: + if (rc == 0) { + atomic_inc(&done_msgs); + } else { + atomic_inc(&done_fail_msgs); + } + break; + default: + DEBUG_ERROR("fast-classifer: Unknown message type sent!\n"); + break; + } + + DEBUG_TRACE("Notify NL message %d ", msg); + if (fc_msg->ethertype == AF_INET) { + DEBUG_TRACE("sip=%pI4 dip=%pI4 ", &fc_msg->src_saddr, &fc_msg->dst_saddr); + } else { + DEBUG_TRACE("sip=%pI6 dip=%pI6 ", &fc_msg->src_saddr, &fc_msg->dst_saddr); + } + DEBUG_TRACE("protocol=%d sport=%d dport=%d smac=%pM dmac=%pM\n", + fc_msg->proto, fc_msg->sport, fc_msg->dport, fc_msg->smac, fc_msg->dmac); +} + +/* + * fast_classifier_find_conn() + * find a connection object in the hash table + * @pre the sfe_connection_lock must be held before calling this function + */ +static struct sfe_connection * +fast_classifier_find_conn(sfe_ip_addr_t *saddr, sfe_ip_addr_t *daddr, + unsigned short sport, unsigned short dport, + unsigned char proto, bool is_v4) +{ + struct sfe_connection_create *p_sic; + struct sfe_connection *conn; + u32 key; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)) + struct hlist_node *node; +#endif + + key = fc_conn_hash(saddr, daddr, sport, dport, is_v4); + + sfe_hash_for_each_possible(fc_conn_ht, conn, node, hl, key) { + if (conn->is_v4 != is_v4) { + continue; + } + + p_sic = conn->sic; + + if (p_sic->protocol == proto && + p_sic->src_port == sport && + p_sic->dest_port == dport && + sfe_addr_equal(&p_sic->src_ip, saddr, is_v4) && + sfe_addr_equal(&p_sic->dest_ip, daddr, is_v4)) { + return conn; + } + } + + DEBUG_TRACE("connection not found\n"); + return NULL; +} + +/* + * fast_classifier_sb_find_conn() + * find a connection object in the hash table according to information of packet + * if not found, reverse the tuple and try again. + * @pre the sfe_connection_lock must be held before calling this function + */ +static struct sfe_connection * +fast_classifier_sb_find_conn(sfe_ip_addr_t *saddr, sfe_ip_addr_t *daddr, + unsigned short sport, unsigned short dport, + unsigned char proto, bool is_v4) +{ + struct sfe_connection_create *p_sic; + struct sfe_connection *conn; + u32 key; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)) + struct hlist_node *node; +#endif + + key = fc_conn_hash(saddr, daddr, sport, dport, is_v4); + + sfe_hash_for_each_possible(fc_conn_ht, conn, node, hl, key) { + if (conn->is_v4 != is_v4) { + continue; + } + + p_sic = conn->sic; + + if (p_sic->protocol == proto && + p_sic->src_port == sport && + p_sic->dest_port_xlate == dport && + sfe_addr_equal(&p_sic->src_ip, saddr, is_v4) && + sfe_addr_equal(&p_sic->dest_ip_xlate, daddr, is_v4)) { + return conn; + } + } + + /* + * Reverse the tuple and try again + */ + key = fc_conn_hash(daddr, saddr, dport, sport, is_v4); + + sfe_hash_for_each_possible(fc_conn_ht, conn, node, hl, key) { + if (conn->is_v4 != is_v4) { + continue; + } + + p_sic = conn->sic; + + if (p_sic->protocol == proto && + p_sic->src_port == dport && + p_sic->dest_port_xlate == sport && + sfe_addr_equal(&p_sic->src_ip, daddr, is_v4) && + sfe_addr_equal(&p_sic->dest_ip_xlate, saddr, is_v4)) { + return conn; + } + } + + DEBUG_TRACE("connection not found\n"); + return NULL; +} + +/* + * fast_classifier_add_conn() + * add a connection object in the hash table if no duplicate + * @conn connection to add + * @return conn if successful, NULL if duplicate + */ +static struct sfe_connection * +fast_classifier_add_conn(struct sfe_connection *conn) +{ + struct sfe_connection_create *sic = conn->sic; + u32 key; + + spin_lock_bh(&sfe_connections_lock); + if (fast_classifier_find_conn(&sic->src_ip, &sic->dest_ip, sic->src_port, + sic->dest_port, sic->protocol, conn->is_v4)) { + spin_unlock_bh(&sfe_connections_lock); + return NULL; + } + + key = fc_conn_hash(&sic->src_ip, &sic->dest_ip, + sic->src_port, sic->dest_port, conn->is_v4); + + hash_add(fc_conn_ht, &conn->hl, key); + sfe_connections_size++; + spin_unlock_bh(&sfe_connections_lock); + + DEBUG_TRACE(" -> adding item to sfe_connections, new size: %d\n", sfe_connections_size); + + if (conn->is_v4) { + DEBUG_TRACE("new offloadable: key: %u proto: %d src_ip: %pI4 dst_ip: %pI4, src_port: %d, dst_port: %d\n", + key, sic->protocol, &(sic->src_ip), &(sic->dest_ip), sic->src_port, sic->dest_port); + } else { + DEBUG_TRACE("new offloadable: key: %u proto: %d src_ip: %pI6 dst_ip: %pI6, src_port: %d, dst_port: %d\n", + key, sic->protocol, &(sic->src_ip), &(sic->dest_ip), sic->src_port, sic->dest_port); + } + + return conn; +} + +/* + * fast_classifier_offload_genl_msg() + * Called from user space to offload a connection + */ +static int +fast_classifier_offload_genl_msg(struct sk_buff *skb, struct genl_info *info) +{ + struct nlattr *na; + struct fast_classifier_tuple *fc_msg; + struct sfe_connection *conn; + + na = info->attrs[FAST_CLASSIFIER_A_TUPLE]; + fc_msg = nla_data(na); + + if (fc_msg->ethertype == AF_INET) { + DEBUG_TRACE("want to offload: %d-%d, %pI4, %pI4, %d, %d SMAC=%pM DMAC=%pM\n", + fc_msg->ethertype, + fc_msg->proto, + &fc_msg->src_saddr, + &fc_msg->dst_saddr, + fc_msg->sport, + fc_msg->dport, + fc_msg->smac, + fc_msg->dmac); + } else { + DEBUG_TRACE("want to offload: %d-%d, %pI6, %pI6, %d, %d SMAC=%pM DMAC=%pM\n", + fc_msg->ethertype, + fc_msg->proto, + &fc_msg->src_saddr, + &fc_msg->dst_saddr, + fc_msg->sport, + fc_msg->dport, + fc_msg->smac, + fc_msg->dmac); + } + + spin_lock_bh(&sfe_connections_lock); + conn = fast_classifier_sb_find_conn((sfe_ip_addr_t *)&fc_msg->src_saddr, + (sfe_ip_addr_t *)&fc_msg->dst_saddr, + fc_msg->sport, + fc_msg->dport, + fc_msg->proto, + (fc_msg->ethertype == AF_INET)); + if (!conn) { + spin_unlock_bh(&sfe_connections_lock); + DEBUG_TRACE("REQUEST OFFLOAD NO MATCH\n"); + atomic_inc(&offload_no_match_msgs); + return 0; + } + + conn->offload_permit = 1; + spin_unlock_bh(&sfe_connections_lock); + atomic_inc(&offload_msgs); + + DEBUG_TRACE("INFO: calling sfe rule creation!\n"); + return 0; +} + +/* + * fast_classifier_nl_genl_msg_DUMP() + * ignore fast_classifier_messages OFFLOADED and DONE + */ +static int fast_classifier_nl_genl_msg_DUMP(struct sk_buff *skb, + struct netlink_callback *cb) +{ + return 0; +} + +/* auto offload connection once we have this many packets*/ +static int offload_at_pkts = 128; + +/* + * fast_classifier_post_routing() + * Called for packets about to leave the box - either locally generated or forwarded from another interface + */ +static unsigned int fast_classifier_post_routing(struct sk_buff *skb, bool is_v4) +{ + int ret; + struct sfe_connection_create sic; + struct sfe_connection_create *p_sic; + struct net_device *in; + struct nf_conn *ct; + enum ip_conntrack_info ctinfo; + struct net_device *dev; + struct net_device *src_dev; + struct net_device *dest_dev; + struct net_device *src_dev_tmp; + struct net_device *dest_dev_tmp; + struct net_device *src_br_dev = NULL; + struct net_device *dest_br_dev = NULL; + struct nf_conntrack_tuple orig_tuple; + struct nf_conntrack_tuple reply_tuple; + struct sfe_connection *conn; + struct sk_buff *tmp_skb = NULL; + + /* + * Don't process broadcast or multicast packets. + */ + if (unlikely(skb->pkt_type == PACKET_BROADCAST)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_PACKET_BROADCAST); + DEBUG_TRACE("broadcast, ignoring\n"); + return NF_ACCEPT; + } + if (unlikely(skb->pkt_type == PACKET_MULTICAST)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_PACKET_MULTICAST); + DEBUG_TRACE("multicast, ignoring\n"); + return NF_ACCEPT; + } + + /* + * Don't process packets that are not being forwarded. + */ + in = dev_get_by_index(&init_net, skb->skb_iif); + if (!in) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_IIF); + DEBUG_TRACE("packet not forwarding\n"); + return NF_ACCEPT; + } + + dev_put(in); + + /* + * Don't process packets that aren't being tracked by conntrack. + */ + ct = nf_ct_get(skb, &ctinfo); + if (unlikely(!ct)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_CT); + DEBUG_TRACE("no conntrack connection, ignoring\n"); + return NF_ACCEPT; + } + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) + /* + * Don't process untracked connections. + */ + if (unlikely(nf_ct_is_untracked(ct))) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_CT_NO_TRACK); + DEBUG_TRACE("untracked connection\n"); + return NF_ACCEPT; + } +#endif /*KERNEL_VERSION(4, 12, 0)*/ + + /* + * Unconfirmed connection may be dropped by Linux at the final step, + * So we don't process unconfirmed connections. + */ + if (!nf_ct_is_confirmed(ct)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_CT_NO_CONFIRM); + DEBUG_TRACE("unconfirmed connection\n"); + return NF_ACCEPT; + } + + /* + * Don't process connections that require support from a 'helper' (typically a NAT ALG). + */ + if (unlikely(nfct_help(ct))) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_CT_IS_ALG); + DEBUG_TRACE("connection has helper\n"); + return NF_ACCEPT; + } + + memset(&sic, 0, sizeof(sic)); + + /* + * Look up the details of our connection in conntrack. + * + * Note that the data we get from conntrack is for the "ORIGINAL" direction + * but our packet may actually be in the "REPLY" direction. + */ + orig_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; + reply_tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple; + sic.protocol = (s32)orig_tuple.dst.protonum; + + sic.flags = 0; + + /* + * Get addressing information, non-NAT first + */ + if (likely(is_v4)) { + u32 dscp; + + sic.src_ip.ip = (__be32)orig_tuple.src.u3.ip; + sic.dest_ip.ip = (__be32)orig_tuple.dst.u3.ip; + + if (ipv4_is_multicast(sic.src_ip.ip) || ipv4_is_multicast(sic.dest_ip.ip)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_IS_IPV4_MCAST); + DEBUG_TRACE("multicast address\n"); + return NF_ACCEPT; + } + + /* + * NAT'ed addresses - note these are as seen from the 'reply' direction + * When NAT does not apply to this connection these will be identical to the above. + */ + sic.src_ip_xlate.ip = (__be32)reply_tuple.dst.u3.ip; + sic.dest_ip_xlate.ip = (__be32)reply_tuple.src.u3.ip; + + dscp = ipv4_get_dsfield(ip_hdr(skb)) >> XT_DSCP_SHIFT; + if (dscp) { + sic.dest_dscp = dscp; + sic.src_dscp = sic.dest_dscp; + sic.flags |= SFE_CREATE_FLAG_REMARK_DSCP; + } + } else { + u32 dscp; + + sic.src_ip.ip6[0] = *((struct sfe_ipv6_addr *)&orig_tuple.src.u3.in6); + sic.dest_ip.ip6[0] = *((struct sfe_ipv6_addr *)&orig_tuple.dst.u3.in6); + + if (ipv6_addr_is_multicast((struct in6_addr *)sic.src_ip.ip6) || + ipv6_addr_is_multicast((struct in6_addr *)sic.dest_ip.ip6)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_IS_IPV6_MCAST); + DEBUG_TRACE("multicast address\n"); + return NF_ACCEPT; + } + + /* + * NAT'ed addresses - note these are as seen from the 'reply' direction + * When NAT does not apply to this connection these will be identical to the above. + */ + sic.src_ip_xlate.ip6[0] = *((struct sfe_ipv6_addr *)&reply_tuple.dst.u3.in6); + sic.dest_ip_xlate.ip6[0] = *((struct sfe_ipv6_addr *)&reply_tuple.src.u3.in6); + + dscp = ipv6_get_dsfield(ipv6_hdr(skb)) >> XT_DSCP_SHIFT; + if (dscp) { + sic.dest_dscp = dscp; + sic.src_dscp = sic.dest_dscp; + sic.flags |= SFE_CREATE_FLAG_REMARK_DSCP; + } + } + + switch (sic.protocol) { + case IPPROTO_TCP: + sic.src_port = orig_tuple.src.u.tcp.port; + sic.dest_port = orig_tuple.dst.u.tcp.port; + sic.src_port_xlate = reply_tuple.dst.u.tcp.port; + sic.dest_port_xlate = reply_tuple.src.u.tcp.port; + + /* + * Don't try to manage a non-established connection. + */ + if (!test_bit(IPS_ASSURED_BIT, &ct->status)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_TCP_NOT_ASSURED); + DEBUG_TRACE("non-established connection\n"); + return NF_ACCEPT; + } + + break; + + case IPPROTO_UDP: + sic.src_port = orig_tuple.src.u.udp.port; + sic.dest_port = orig_tuple.dst.u.udp.port; + sic.src_port_xlate = reply_tuple.dst.u.udp.port; + sic.dest_port_xlate = reply_tuple.src.u.udp.port; + + /* + * Somehow, SFE is not playing nice with IPSec traffic. + * Do not accelerate for now. + */ + if (ntohs(sic.dest_port) == 4500 || ntohs(sic.dest_port) == 500) { + if (likely(is_v4)) + DEBUG_TRACE("quarkysg:: IPsec bypass: %pI4:%d(%pI4:%d) to %pI4:%d(%pI4:%d)\n", + &sic.src_ip.ip, ntohs(sic.src_port), &sic.src_ip_xlate.ip, ntohs(sic.src_port_xlate), + &sic.dest_ip.ip, ntohs(sic.dest_port), &sic.dest_ip_xlate.ip, ntohs(sic.dest_port_xlate)); + else + DEBUG_TRACE("quarkysg:: IPsec bypass: %pI6:%d to %pI6:%d\n", + &sic.src_ip.ip6, ntohs(sic.src_port), &sic.dest_ip.ip6, ntohs(sic.dest_port)); + return NF_ACCEPT; + } + break; + + default: + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_UNKNOW_PROTOCOL); + DEBUG_TRACE("unhandled protocol %d\n", sic.protocol); + return NF_ACCEPT; + } + +#ifdef CONFIG_XFRM + sic.original_accel = 1; + sic.reply_accel = 1; +#endif + + /* + * Get QoS information + */ + if (skb->priority) { + sic.dest_priority = skb->priority; + sic.src_priority = sic.dest_priority; + sic.flags |= SFE_CREATE_FLAG_REMARK_PRIORITY; + } + + if (is_v4) { + DEBUG_TRACE("POST_ROUTE: checking new connection: %d src_ip: %pI4 dst_ip: %pI4, src_port: %d, dst_port: %d\n", + sic.protocol, &sic.src_ip, &sic.dest_ip, sic.src_port, sic.dest_port); + } else { + DEBUG_TRACE("POST_ROUTE: checking new connection: %d src_ip: %pI6 dst_ip: %pI6, src_port: %d, dst_port: %d\n", + sic.protocol, &sic.src_ip, &sic.dest_ip, sic.src_port, sic.dest_port); + } + + /* + * If we already have this connection in our list, skip it + * XXX: this may need to be optimized + */ + spin_lock_bh(&sfe_connections_lock); + + conn = fast_classifier_find_conn(&sic.src_ip, &sic.dest_ip, sic.src_port, sic.dest_port, sic.protocol, is_v4); + if (conn) { + conn->hits++; + + if (!conn->offloaded) { + if (conn->offload_permit || conn->hits >= offload_at_pkts) { + DEBUG_TRACE("OFFLOADING CONNECTION, TOO MANY HITS\n"); + + if (fast_classifier_update_protocol(conn->sic, conn->ct) == 0) { + spin_unlock_bh(&sfe_connections_lock); + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_UPDATE_PROTOCOL_FAIL); + DEBUG_TRACE("UNKNOWN PROTOCOL OR CONNECTION CLOSING, SKIPPING\n"); + return NF_ACCEPT; + } + + DEBUG_TRACE("INFO: calling sfe rule creation!\n"); + spin_unlock_bh(&sfe_connections_lock); + + ret = is_v4 ? sfe_ipv4_create_rule(conn->sic) : sfe_ipv6_create_rule(conn->sic); + if ((ret == 0) || (ret == -EADDRINUSE)) { + struct fast_classifier_tuple fc_msg; + + if (is_v4) { + fc_msg.ethertype = AF_INET; + fc_msg.src_saddr.in = *((struct in_addr *)&sic.src_ip); + fc_msg.dst_saddr.in = *((struct in_addr *)&sic.dest_ip_xlate); + } else { + fc_msg.ethertype = AF_INET6; + fc_msg.src_saddr.in6 = *((struct in6_addr *)&sic.src_ip); + fc_msg.dst_saddr.in6 = *((struct in6_addr *)&sic.dest_ip_xlate); + } + + fc_msg.proto = sic.protocol; + fc_msg.sport = sic.src_port; + fc_msg.dport = sic.dest_port_xlate; + memcpy(fc_msg.smac, conn->smac, ETH_ALEN); + memcpy(fc_msg.dmac, conn->dmac, ETH_ALEN); + fast_classifier_send_genl_msg(FAST_CLASSIFIER_C_OFFLOADED, &fc_msg); + conn->offloaded = 1; + } + + return NF_ACCEPT; + } + } + + spin_unlock_bh(&sfe_connections_lock); + if (conn->offloaded) { + is_v4 ? sfe_ipv4_update_rule(conn->sic) : sfe_ipv6_update_rule(conn->sic); + } + + DEBUG_TRACE("FOUND, SKIPPING\n"); + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_WAIT_FOR_ACCELERATION); + return NF_ACCEPT; + } + + spin_unlock_bh(&sfe_connections_lock); + + /* + * Get the net device and MAC addresses that correspond to the various source and + * destination host addresses. + */ + if (!fast_classifier_find_dev_and_mac_addr(NULL, &sic.src_ip, &src_dev_tmp, sic.src_mac, is_v4)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_SRC_DEV); + return NF_ACCEPT; + } + src_dev = src_dev_tmp; + + if (!fast_classifier_find_dev_and_mac_addr(NULL, &sic.src_ip_xlate, &dev, sic.src_mac_xlate, is_v4)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_SRC_XLATE_DEV); + goto done1; + } + dev_put(dev); + + if (unlikely(!is_v4)) + tmp_skb = skb; + + if (!fast_classifier_find_dev_and_mac_addr(tmp_skb, &sic.dest_ip, &dev, sic.dest_mac, is_v4)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_DEST_DEV); + goto done1; + } + dev_put(dev); + + if (!fast_classifier_find_dev_and_mac_addr(skb, &sic.dest_ip_xlate, &dest_dev_tmp, sic.dest_mac_xlate, is_v4)) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_DEST_XLATE_DEV); + goto done1; + } + dest_dev = dest_dev_tmp; + + /* + * Our devices may actually be part of a bridge interface. If that's + * the case then find the bridge interface instead. + */ + if (src_dev->priv_flags & IFF_BRIDGE_PORT) { + src_br_dev = sfe_dev_get_master(src_dev); + if (!src_br_dev) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_BRIDGE); + DEBUG_TRACE("no bridge found for: %s\n", src_dev->name); + goto done2; + } + src_dev = src_br_dev; + } + + if (dest_dev->priv_flags & IFF_BRIDGE_PORT) { + dest_br_dev = sfe_dev_get_master(dest_dev); + if (!dest_br_dev) { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_NO_BRIDGE); + DEBUG_TRACE("no bridge found for: %s\n", dest_dev->name); + goto done3; + } + dest_dev = dest_br_dev; + } + + sic.src_dev = src_dev; + sic.dest_dev = dest_dev; + + sic.src_mtu = src_dev->mtu; + sic.dest_mtu = dest_dev->mtu; + + if (skb->mark) { + DEBUG_TRACE("SKB MARK NON ZERO %x\n", skb->mark); + } + sic.mark = skb->mark; + + conn = kmalloc(sizeof(*conn), GFP_ATOMIC); + if (!conn) { + printk(KERN_CRIT "ERROR: no memory for sfe\n"); + goto done4; + } + conn->hits = 0; + conn->offload_permit = 0; + conn->offloaded = 0; + conn->is_v4 = is_v4; + DEBUG_TRACE("Source MAC=%pM\n", sic.src_mac); + memcpy(conn->smac, sic.src_mac, ETH_ALEN); + memcpy(conn->dmac, sic.dest_mac_xlate, ETH_ALEN); + + p_sic = kmalloc(sizeof(*p_sic), GFP_ATOMIC); + if (!p_sic) { + printk(KERN_CRIT "ERROR: no memory for sfe\n"); + kfree(conn); + goto done4; + } + + memcpy(p_sic, &sic, sizeof(sic)); + conn->sic = p_sic; + conn->ct = ct; + + if (!fast_classifier_add_conn(conn)) { + kfree(conn->sic); + kfree(conn); + } + + /* + * If we had bridge ports then release them too. + */ +done4: + if (dest_br_dev) { + dev_put(dest_br_dev); + } +done3: + if (src_br_dev) { + dev_put(src_br_dev); + } +done2: + dev_put(dest_dev_tmp); +done1: + dev_put(src_dev_tmp); + + return NF_ACCEPT; +} + +/* + * fast_classifier_ipv4_post_routing_hook() + * Called for packets about to leave the box - either locally generated or forwarded from another interface + */ +fast_classifier_ipv4_post_routing_hook(hooknum, ops, skb, in_unused, out, okfn) +{ + return fast_classifier_post_routing(skb, true); +} + +/* + * fast_classifier_ipv6_post_routing_hook() + * Called for packets about to leave the box - either locally generated or forwarded from another interface + */ +fast_classifier_ipv6_post_routing_hook(hooknum, ops, skb, in_unused, out, okfn) +{ + return fast_classifier_post_routing(skb, false); +} + +/* + * fast_classifier_update_mark() + * updates the mark for a fast-classifier connection + */ +static void fast_classifier_update_mark(struct sfe_connection_mark *mark, bool is_v4) +{ + struct sfe_connection *conn; + + spin_lock_bh(&sfe_connections_lock); + + conn = fast_classifier_find_conn(&mark->src_ip, &mark->dest_ip, + mark->src_port, mark->dest_port, + mark->protocol, is_v4); + if (conn) { + conn->sic->mark = mark->mark; + } + + spin_unlock_bh(&sfe_connections_lock); +} + +#ifdef CONFIG_NF_CONNTRACK_EVENTS +/* + * fast_classifier_conntrack_event() + * Callback event invoked when a conntrack connection's state changes. + */ +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS +static int fast_classifier_conntrack_event(struct notifier_block *this, + unsigned long events, void *ptr) +#else +static int fast_classifier_conntrack_event(unsigned int events, struct nf_ct_event *item) +#endif +{ +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS + struct nf_ct_event *item = ptr; +#endif + struct sfe_connection_destroy sid; + struct nf_conn *ct = item->ct; + struct nf_conntrack_tuple orig_tuple; + struct sfe_connection *conn; + struct fast_classifier_tuple fc_msg; + int offloaded = 0; + bool is_v4; + + /* + * If we don't have a conntrack entry then we're done. + */ + if (unlikely(!ct)) { + DEBUG_WARN("no ct in conntrack event callback\n"); + return NOTIFY_DONE; + } + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0)) + /* + * If this is an untracked connection then we can't have any state either. + */ + if (unlikely(nf_ct_is_untracked(ct))) { + DEBUG_TRACE("ignoring untracked conn\n"); + return NOTIFY_DONE; + } +#endif /*KERNEL_VERSION(4, 12, 0)*/ + + orig_tuple = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; + sid.protocol = (s32)orig_tuple.dst.protonum; + + /* + * Extract information from the conntrack connection. We're only interested + * in nominal connection information (i.e. we're ignoring any NAT information). + */ + if (likely(nf_ct_l3num(ct) == AF_INET)) { + sid.src_ip.ip = (__be32)orig_tuple.src.u3.ip; + sid.dest_ip.ip = (__be32)orig_tuple.dst.u3.ip; + is_v4 = true; + } else if (likely(nf_ct_l3num(ct) == AF_INET6)) { + sid.src_ip.ip6[0] = *((struct sfe_ipv6_addr *)&orig_tuple.src.u3.in6); + sid.dest_ip.ip6[0] = *((struct sfe_ipv6_addr *)&orig_tuple.dst.u3.in6); + is_v4 = false; + } else { + DEBUG_TRACE("ignoring non-IPv4 and non-IPv6 connection\n"); + return NOTIFY_DONE; + } + + switch (sid.protocol) { + case IPPROTO_TCP: + sid.src_port = orig_tuple.src.u.tcp.port; + sid.dest_port = orig_tuple.dst.u.tcp.port; + break; + + case IPPROTO_UDP: + sid.src_port = orig_tuple.src.u.udp.port; + sid.dest_port = orig_tuple.dst.u.udp.port; + break; + + default: + DEBUG_TRACE("unhandled protocol: %d\n", sid.protocol); + return NOTIFY_DONE; + } + + /* + * Check for an updated mark + */ + if ((events & (1 << IPCT_MARK)) && (ct->mark != 0)) { + struct sfe_connection_mark mark; + + mark.protocol = sid.protocol; + mark.src_ip = sid.src_ip; + mark.dest_ip = sid.dest_ip; + mark.src_port = sid.src_port; + mark.dest_port = sid.dest_port; + mark.mark = ct->mark; + + is_v4 ? sfe_ipv4_mark_rule(&mark) : sfe_ipv6_mark_rule(&mark); + fast_classifier_update_mark(&mark, is_v4); + } + + /* + * We're only interested in destroy events at this point + */ + if (unlikely(!(events & (1 << IPCT_DESTROY)))) { + DEBUG_TRACE("ignoring non-destroy event\n"); + return NOTIFY_DONE; + } + + if (is_v4) { + DEBUG_TRACE("Try to clean up: proto: %d src_ip: %pI4 dst_ip: %pI4, src_port: %d, dst_port: %d\n", + sid.protocol, &sid.src_ip, &sid.dest_ip, ntohs(sid.src_port), ntohs(sid.dest_port)); + } else { + DEBUG_TRACE("Try to clean up: proto: %d src_ip: %pI6 dst_ip: %pI6, src_port: %d, dst_port: %d\n", + sid.protocol, &sid.src_ip, &sid.dest_ip, ntohs(sid.src_port), ntohs(sid.dest_port)); + } + + spin_lock_bh(&sfe_connections_lock); + + conn = fast_classifier_find_conn(&sid.src_ip, &sid.dest_ip, sid.src_port, sid.dest_port, sid.protocol, is_v4); + if (conn && conn->offloaded) { + if (is_v4) { + fc_msg.ethertype = AF_INET; + fc_msg.src_saddr.in = *((struct in_addr *)&conn->sic->src_ip); + fc_msg.dst_saddr.in = *((struct in_addr *)&conn->sic->dest_ip_xlate); + } else { + fc_msg.ethertype = AF_INET6; + fc_msg.src_saddr.in6 = *((struct in6_addr *)&conn->sic->src_ip); + fc_msg.dst_saddr.in6 = *((struct in6_addr *)&conn->sic->dest_ip_xlate); + } + + fc_msg.proto = conn->sic->protocol; + fc_msg.sport = conn->sic->src_port; + fc_msg.dport = conn->sic->dest_port_xlate; + memcpy(fc_msg.smac, conn->smac, ETH_ALEN); + memcpy(fc_msg.dmac, conn->dmac, ETH_ALEN); + offloaded = 1; + } + + if (conn) { + DEBUG_TRACE("Free connection\n"); + + hash_del(&conn->hl); + sfe_connections_size--; + kfree(conn->sic); + kfree(conn); + } else { + fast_classifier_incr_exceptions(FAST_CL_EXCEPTION_CT_DESTROY_MISS); + } + + spin_unlock_bh(&sfe_connections_lock); + + is_v4 ? sfe_ipv4_destroy_rule(&sid) : sfe_ipv6_destroy_rule(&sid); + + if (offloaded) { + fast_classifier_send_genl_msg(FAST_CLASSIFIER_C_DONE, &fc_msg); + } + + return NOTIFY_DONE; +} + +/* + * Netfilter conntrack event system to monitor connection tracking changes + */ +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS +static struct notifier_block fast_classifier_conntrack_notifier = { + .notifier_call = fast_classifier_conntrack_event, +}; +#else +static struct nf_ct_event_notifier fast_classifier_conntrack_notifier = { + .fcn = fast_classifier_conntrack_event, +}; +#endif +#endif + +/* + * Structure to establish a hook into the post routing netfilter point - this + * will pick up local outbound and packets going from one interface to another. + * + * Note: see include/linux/netfilter_ipv4.h for info related to priority levels. + * We want to examine packets after NAT translation and any ALG processing. + */ +static struct nf_hook_ops fast_classifier_ops_post_routing[] __read_mostly = { + SFE_IPV4_NF_POST_ROUTING_HOOK(__fast_classifier_ipv4_post_routing_hook), + SFE_IPV6_NF_POST_ROUTING_HOOK(__fast_classifier_ipv6_post_routing_hook), +}; + +/* + * fast_classifier_sync_rule() + * Synchronize a connection's state. + */ +static void fast_classifier_sync_rule(struct sfe_connection_sync *sis) +{ + struct nf_conntrack_tuple_hash *h; + struct nf_conntrack_tuple tuple; + struct nf_conn *ct; + SFE_NF_CONN_ACCT(acct); + + /* + * Create a tuple so as to be able to look up a connection + */ + memset(&tuple, 0, sizeof(tuple)); + tuple.src.u.all = (__be16)sis->src_port; + tuple.dst.dir = IP_CT_DIR_ORIGINAL; + tuple.dst.protonum = (u8)sis->protocol; + tuple.dst.u.all = (__be16)sis->dest_port; + + if (sis->is_v6) { + tuple.src.u3.in6 = *((struct in6_addr *)sis->src_ip.ip6); + tuple.dst.u3.in6 = *((struct in6_addr *)sis->dest_ip.ip6); + tuple.src.l3num = AF_INET6; + + DEBUG_TRACE("update connection - p: %d, s: %pI6:%u, d: %pI6:%u\n", + (int)tuple.dst.protonum, + &tuple.src.u3.in6, (unsigned int)ntohs(tuple.src.u.all), + &tuple.dst.u3.in6, (unsigned int)ntohs(tuple.dst.u.all)); + } else { + tuple.src.u3.ip = sis->src_ip.ip; + tuple.dst.u3.ip = sis->dest_ip.ip; + tuple.src.l3num = AF_INET; + + DEBUG_TRACE("update connection - p: %d, s: %pI4:%u, d: %pI4:%u\n", + (int)tuple.dst.protonum, + &tuple.src.u3.ip, (unsigned int)ntohs(tuple.src.u.all), + &tuple.dst.u3.ip, (unsigned int)ntohs(tuple.dst.u.all)); + } + + /* + * Update packet count for ingress on bridge device + */ + if (skip_to_bridge_ingress) { + struct rtnl_link_stats64 nlstats; + nlstats.tx_packets = 0; + nlstats.tx_bytes = 0; + + if (sis->src_dev && IFF_EBRIDGE && + (sis->src_new_packet_count || sis->src_new_byte_count)) { + nlstats.rx_packets = sis->src_new_packet_count; + nlstats.rx_bytes = sis->src_new_byte_count; + spin_lock_bh(&sfe_connections_lock); + br_dev_update_stats(sis->src_dev, &nlstats); + spin_unlock_bh(&sfe_connections_lock); + } + if (sis->dest_dev && IFF_EBRIDGE && + (sis->dest_new_packet_count || sis->dest_new_byte_count)) { + nlstats.rx_packets = sis->dest_new_packet_count; + nlstats.rx_bytes = sis->dest_new_byte_count; + spin_lock_bh(&sfe_connections_lock); + br_dev_update_stats(sis->dest_dev, &nlstats); + spin_unlock_bh(&sfe_connections_lock); + } + } + + /* + * Look up conntrack connection + */ + h = nf_conntrack_find_get(&init_net, SFE_NF_CT_DEFAULT_ZONE, &tuple); + if (unlikely(!h)) { + DEBUG_TRACE("no connection found\n"); + return; + } + + ct = nf_ct_tuplehash_to_ctrack(h); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) + NF_CT_ASSERT(ct->timeout.data == (unsigned long)ct); +#endif /*KERNEL_VERSION(4, 9, 0)*/ + + /* + * Only update if this is not a fixed timeout + */ + if (!test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status)) { + spin_lock_bh(&ct->lock); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) + ct->timeout += sis->delta_jiffies; +#else + ct->timeout.expires += sis->delta_jiffies; +#endif /*KERNEL_VERSION(4, 9, 0)*/ + spin_unlock_bh(&ct->lock); + } + + acct = nf_conn_acct_find(ct); + if (acct) { + spin_lock_bh(&ct->lock); + atomic64_add(sis->src_new_packet_count, &SFE_ACCT_COUNTER(acct)[IP_CT_DIR_ORIGINAL].packets); + atomic64_add(sis->src_new_byte_count, &SFE_ACCT_COUNTER(acct)[IP_CT_DIR_ORIGINAL].bytes); + atomic64_add(sis->dest_new_packet_count, &SFE_ACCT_COUNTER(acct)[IP_CT_DIR_REPLY].packets); + atomic64_add(sis->dest_new_byte_count, &SFE_ACCT_COUNTER(acct)[IP_CT_DIR_REPLY].bytes); + spin_unlock_bh(&ct->lock); + } + + switch (sis->protocol) { + case IPPROTO_TCP: + spin_lock_bh(&ct->lock); + if (ct->proto.tcp.seen[0].td_maxwin < sis->src_td_max_window) { + ct->proto.tcp.seen[0].td_maxwin = sis->src_td_max_window; + } + if ((s32)(ct->proto.tcp.seen[0].td_end - sis->src_td_end) < 0) { + ct->proto.tcp.seen[0].td_end = sis->src_td_end; + } + if ((s32)(ct->proto.tcp.seen[0].td_maxend - sis->src_td_max_end) < 0) { + ct->proto.tcp.seen[0].td_maxend = sis->src_td_max_end; + } + if (ct->proto.tcp.seen[1].td_maxwin < sis->dest_td_max_window) { + ct->proto.tcp.seen[1].td_maxwin = sis->dest_td_max_window; + } + if ((s32)(ct->proto.tcp.seen[1].td_end - sis->dest_td_end) < 0) { + ct->proto.tcp.seen[1].td_end = sis->dest_td_end; + } + if ((s32)(ct->proto.tcp.seen[1].td_maxend - sis->dest_td_max_end) < 0) { + ct->proto.tcp.seen[1].td_maxend = sis->dest_td_max_end; + } + spin_unlock_bh(&ct->lock); + break; + } + + /* + * Release connection + */ + nf_ct_put(ct); +} + +/* + * fast_classifier_device_event() + */ +static int fast_classifier_device_event(struct notifier_block *this, unsigned long event, void *ptr) +{ + struct net_device *dev = SFE_DEV_EVENT_PTR(ptr); + + if (dev && (event == NETDEV_DOWN)) { + sfe_ipv4_destroy_all_rules_for_dev(dev); + sfe_ipv6_destroy_all_rules_for_dev(dev); + } + + return NOTIFY_DONE; +} + +/* + * fast_classifier_inet_event() + */ +static int fast_classifier_inet_event(struct notifier_block *this, unsigned long event, void *ptr) +{ + struct net_device *dev = ((struct in_ifaddr *)ptr)->ifa_dev->dev; + + if (dev && (event == NETDEV_DOWN)) { + sfe_ipv4_destroy_all_rules_for_dev(dev); + } + + return NOTIFY_DONE; +} + +/* + * fast_classifier_inet6_event() + */ +static int fast_classifier_inet6_event(struct notifier_block *this, unsigned long event, void *ptr) +{ + struct net_device *dev = ((struct inet6_ifaddr *)ptr)->idev->dev; + + if (dev && (event == NETDEV_DOWN)) { + sfe_ipv6_destroy_all_rules_for_dev(dev); + } + + return NOTIFY_DONE; +} + +/* + * fast_classifier_get_offload_at_pkts() + */ +static ssize_t fast_classifier_get_offload_at_pkts(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return snprintf(buf, (ssize_t)PAGE_SIZE, "%d\n", offload_at_pkts); +} + +/* + * fast_classifier_set_offload_at_pkts() + */ +static ssize_t fast_classifier_set_offload_at_pkts(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + long new; + int ret; + + ret = kstrtol(buf, 0, &new); + if (ret == -EINVAL || ((int)new != new)) + return -EINVAL; + + offload_at_pkts = new; + + return size; +} + +/* + * fast_classifier_get_debug_info() + */ +static ssize_t fast_classifier_get_debug_info(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + size_t len = 0; + struct sfe_connection *conn; + u32 i; +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 9, 0)) + struct hlist_node *node; +#endif + + spin_lock_bh(&sfe_connections_lock); + len += scnprintf(buf, PAGE_SIZE - len, "size=%d offload=%d offload_no_match=%d" + " offloaded=%d done=%d offloaded_fail=%d done_fail=%d\n", + sfe_connections_size, + atomic_read(&offload_msgs), + atomic_read(&offload_no_match_msgs), + atomic_read(&offloaded_msgs), + atomic_read(&done_msgs), + atomic_read(&offloaded_fail_msgs), + atomic_read(&done_fail_msgs)); + sfe_hash_for_each(fc_conn_ht, i, node, conn, hl) { + len += scnprintf(buf + len, PAGE_SIZE - len, + (conn->is_v4 ? "o=%d, p=%d [%pM]:%pI4:%u %pI4:%u:[%pM] m=%08x h=%d\n" : "o=%d, p=%d [%pM]:%pI6:%u %pI6:%u:[%pM] m=%08x h=%d\n"), + conn->offloaded, + conn->sic->protocol, + conn->sic->src_mac, + &conn->sic->src_ip, + ntohs(conn->sic->src_port), + &conn->sic->dest_ip, + ntohs(conn->sic->dest_port), + conn->sic->dest_mac_xlate, + conn->sic->mark, + conn->hits); + } + spin_unlock_bh(&sfe_connections_lock); + + return len; +} + +/* + * fast_classifier_get_skip_bridge_ingress() + */ +static ssize_t fast_classifier_get_skip_bridge_ingress(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + return snprintf(buf, (ssize_t)PAGE_SIZE, "%d\n", skip_to_bridge_ingress); +} + +/* + * fast_classifier_set_skip_bridge_ingress() + */ +static ssize_t fast_classifier_set_skip_bridge_ingress(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t size) +{ + long new; + int ret; + + ret = kstrtol(buf, 0, &new); + if (ret == -EINVAL || ((int)new != new)) + return -EINVAL; + + skip_to_bridge_ingress = new ? 1 : 0; + + return size; +} + +/* + * fast_classifier_get_exceptions + * dump exception counters + */ +static ssize_t fast_classifier_get_exceptions(struct device *dev, + struct device_attribute *attr, + char *buf) +{ + int idx, len; + struct fast_classifier *sc = &__sc; + + spin_lock_bh(&sc->lock); + for (len = 0, idx = 0; idx < FAST_CL_EXCEPTION_MAX; idx++) { + if (sc->exceptions[idx]) { + len += snprintf(buf + len, (ssize_t)(PAGE_SIZE - len), "%s = %d\n", fast_classifier_exception_events_string[idx], sc->exceptions[idx]); + } + } + spin_unlock_bh(&sc->lock); + + return len; +} + +/* + * sysfs attributes. + */ +static const struct device_attribute fast_classifier_offload_at_pkts_attr = + __ATTR(offload_at_pkts, S_IWUSR | S_IRUGO, fast_classifier_get_offload_at_pkts, fast_classifier_set_offload_at_pkts); +static const struct device_attribute fast_classifier_debug_info_attr = + __ATTR(debug_info, S_IRUGO, fast_classifier_get_debug_info, NULL); +static const struct device_attribute fast_classifier_skip_bridge_ingress = + __ATTR(skip_to_bridge_ingress, S_IWUSR | S_IRUGO, fast_classifier_get_skip_bridge_ingress, fast_classifier_set_skip_bridge_ingress); +static const struct device_attribute fast_classifier_exceptions_attr = + __ATTR(exceptions, S_IRUGO, fast_classifier_get_exceptions, NULL); + +/* + * fast_classifier_init() + */ +static int __init fast_classifier_init(void) +{ + struct fast_classifier *sc = &__sc; + int result = -1; +#ifdef CONFIG_SFE_ECM + int (*fast_recv)(struct sk_buff *skb); +#endif + + printk(KERN_ALERT "fast-classifier: starting up\n"); + DEBUG_INFO("SFE CM init\n"); + + hash_init(fc_conn_ht); + + /* + * Create sys/fast_classifier + */ + sc->sys_fast_classifier = kobject_create_and_add("fast_classifier", NULL); + if (!sc->sys_fast_classifier) { + DEBUG_ERROR("failed to register fast_classifier\n"); + goto exit1; + } + + result = sysfs_create_file(sc->sys_fast_classifier, &fast_classifier_offload_at_pkts_attr.attr); + if (result) { + DEBUG_ERROR("failed to register offload at pkgs: %d\n", result); + goto exit2; + } + + result = sysfs_create_file(sc->sys_fast_classifier, &fast_classifier_debug_info_attr.attr); + if (result) { + DEBUG_ERROR("failed to register debug dev: %d\n", result); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_offload_at_pkts_attr.attr); + goto exit2; + } + + result = sysfs_create_file(sc->sys_fast_classifier, &fast_classifier_skip_bridge_ingress.attr); + if (result) { + DEBUG_ERROR("failed to register skip bridge on ingress: %d\n", result); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_offload_at_pkts_attr.attr); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_debug_info_attr.attr); + goto exit2; + } + + result = sysfs_create_file(sc->sys_fast_classifier, &fast_classifier_exceptions_attr.attr); + if (result) { + DEBUG_ERROR("failed to register exceptions file: %d\n", result); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_offload_at_pkts_attr.attr); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_debug_info_attr.attr); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_skip_bridge_ingress.attr); + goto exit2; + } + + sc->dev_notifier.notifier_call = fast_classifier_device_event; + sc->dev_notifier.priority = 1; + register_netdevice_notifier(&sc->dev_notifier); + + sc->inet_notifier.notifier_call = fast_classifier_inet_event; + sc->inet_notifier.priority = 1; + register_inetaddr_notifier(&sc->inet_notifier); + + sc->inet6_notifier.notifier_call = fast_classifier_inet6_event; + sc->inet6_notifier.priority = 1; + register_inet6addr_notifier(&sc->inet6_notifier); + + /* + * Register our netfilter hooks. + */ + result = nf_register_net_hooks(&init_net, fast_classifier_ops_post_routing, ARRAY_SIZE(fast_classifier_ops_post_routing)); + if (result < 0) { + DEBUG_ERROR("can't register nf post routing hook: %d\n", result); + goto exit3; + } + +#ifdef CONFIG_NF_CONNTRACK_EVENTS + /* + * Register a notifier hook to get fast notifications of expired connections. + */ +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS + result = nf_conntrack_register_chain_notifier(&init_net, &fast_classifier_conntrack_notifier); +#else + result = nf_conntrack_register_notifier(&init_net, &fast_classifier_conntrack_notifier); +#endif + if (result < 0) { + DEBUG_ERROR("can't register nf notifier hook: %d\n", result); + goto exit4; + } +#endif + + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 10, 0)) + result = genl_register_family(&fast_classifier_gnl_family); + if (result) { + DEBUG_ERROR("failed to register genl family: %d\n", result); + goto exit5; + } +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0)) + result = genl_register_family_with_ops_groups(&fast_classifier_gnl_family, + fast_classifier_gnl_ops, + fast_classifier_genl_mcgrp); + if (result) { + DEBUG_ERROR("failed to register genl ops: %d\n", result); + goto exit5; + } +#else + result = genl_register_family(&fast_classifier_gnl_family); + if (result) { + printk(KERN_CRIT "unable to register genl family\n"); + goto exit5; + } + + result = genl_register_ops(&fast_classifier_gnl_family, fast_classifier_gnl_ops); + if (result) { + printk(KERN_CRIT "unable to register ops\n"); + goto exit6; + } + + result = genl_register_mc_group(&fast_classifier_gnl_family, + fast_classifier_genl_mcgrp); + if (result) { + printk(KERN_CRIT "unable to register multicast group\n"); + goto exit6; + } +#endif + + printk(KERN_ALERT "fast-classifier: registered\n"); + + spin_lock_init(&sc->lock); + + /* + * Hook the receive path in the network stack. + */ +#ifdef CONFIG_SFE_ECM + rcu_read_lock(); + fast_recv = rcu_dereference(athrs_fast_nat_recv); + rcu_read_unlock(); + if (!fast_recv) { + BUG_ON(athrs_fast_nat_recv); + } +#else + BUG_ON(athrs_fast_nat_recv); +#endif + RCU_INIT_POINTER(athrs_fast_nat_recv, fast_classifier_recv); + + /* + * Hook the shortcut sync callback. + */ + sfe_ipv4_register_sync_rule_callback(fast_classifier_sync_rule); + sfe_ipv6_register_sync_rule_callback(fast_classifier_sync_rule); + return 0; + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)) +exit6: + genl_unregister_family(&fast_classifier_gnl_family); +#endif + +exit5: +#ifdef CONFIG_NF_CONNTRACK_EVENTS +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS + nf_conntrack_unregister_chain_notifier(&init_net, &fast_classifier_conntrack_notifier); +#else + nf_conntrack_unregister_notifier(&init_net, &fast_classifier_conntrack_notifier); +#endif + +exit4: +#endif + nf_unregister_net_hooks(&init_net, fast_classifier_ops_post_routing, ARRAY_SIZE(fast_classifier_ops_post_routing)); + +exit3: + unregister_inetaddr_notifier(&sc->inet_notifier); + unregister_inet6addr_notifier(&sc->inet6_notifier); + unregister_netdevice_notifier(&sc->dev_notifier); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_offload_at_pkts_attr.attr); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_debug_info_attr.attr); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_skip_bridge_ingress.attr); + sysfs_remove_file(sc->sys_fast_classifier, &fast_classifier_exceptions_attr.attr); + +exit2: + kobject_put(sc->sys_fast_classifier); + +exit1: + return result; +} + +/* + * fast_classifier_exit() + */ +static void __exit fast_classifier_exit(void) +{ + struct fast_classifier *sc = &__sc; + int result = -1; + + DEBUG_INFO("SFE CM exit\n"); + printk(KERN_ALERT "fast-classifier: shutting down\n"); + + /* + * Unregister our sync callback. + */ + sfe_ipv4_register_sync_rule_callback(NULL); + sfe_ipv6_register_sync_rule_callback(NULL); + + /* + * Unregister our receive callback. + */ + RCU_INIT_POINTER(athrs_fast_nat_recv, NULL); + + /* + * Wait for all callbacks to complete. + */ + rcu_barrier(); + + /* + * Destroy all connections. + */ + sfe_ipv4_destroy_all_rules_for_dev(NULL); + sfe_ipv6_destroy_all_rules_for_dev(NULL); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)) + result = genl_unregister_ops(&fast_classifier_gnl_family, fast_classifier_gnl_ops); + if (result != 0) { + printk(KERN_CRIT "Unable to unreigster genl_ops\n"); + } +#endif + + result = genl_unregister_family(&fast_classifier_gnl_family); + if (result != 0) { + printk(KERN_CRIT "Unable to unregister genl_family\n"); + } + +#ifdef CONFIG_NF_CONNTRACK_EVENTS +#ifdef CONFIG_NF_CONNTRACK_CHAIN_EVENTS + nf_conntrack_unregister_chain_notifier(&init_net, &fast_classifier_conntrack_notifier); +#else + nf_conntrack_unregister_notifier(&init_net, &fast_classifier_conntrack_notifier); +#endif +#endif + nf_unregister_net_hooks(&init_net, fast_classifier_ops_post_routing, ARRAY_SIZE(fast_classifier_ops_post_routing)); + + unregister_inet6addr_notifier(&sc->inet6_notifier); + unregister_inetaddr_notifier(&sc->inet_notifier); + unregister_netdevice_notifier(&sc->dev_notifier); + + kobject_put(sc->sys_fast_classifier); +} + +module_init(fast_classifier_init) +module_exit(fast_classifier_exit) + +MODULE_DESCRIPTION("Shortcut Forwarding Engine - Connection Manager"); +MODULE_LICENSE("Dual BSD/GPL"); + diff --git a/shortcut-fe/fast-classifier/src/fast-classifier.h b/shortcut-fe/fast-classifier/src/fast-classifier.h new file mode 100755 index 000000000..6b7a18cf6 --- /dev/null +++ b/shortcut-fe/fast-classifier/src/fast-classifier.h @@ -0,0 +1,57 @@ +/* + * User space header to send message to the fast classifier + * + * Copyright (c) 2013,2016 The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include + +#define FAST_CLASSIFIER_GENL_VERSION (1) +#define FAST_CLASSIFIER_GENL_NAME "FC" +#define FAST_CLASSIFIER_GENL_MCGRP "FC_MCGRP" +#define FAST_CLASSIFIER_GENL_HDRSIZE (0) + +enum { + FAST_CLASSIFIER_A_UNSPEC, + FAST_CLASSIFIER_A_TUPLE, + __FAST_CLASSIFIER_A_MAX, +}; + +#define FAST_CLASSIFIER_A_MAX (__FAST_CLASSIFIER_A_MAX - 1) + +enum { + FAST_CLASSIFIER_C_UNSPEC, + FAST_CLASSIFIER_C_OFFLOAD, + FAST_CLASSIFIER_C_OFFLOADED, + FAST_CLASSIFIER_C_DONE, + __FAST_CLASSIFIER_C_MAX, +}; + +#define FAST_CLASSIFIER_C_MAX (__FAST_CLASSIFIER_C_MAX - 1) + +struct fast_classifier_tuple { + unsigned short ethertype; + unsigned char proto; + union { + struct in_addr in; + struct in6_addr in6; + } src_saddr; + union { + struct in_addr in; + struct in6_addr in6; + } dst_saddr; + unsigned short sport; + unsigned short dport; + unsigned char smac[ETH_ALEN]; + unsigned char dmac[ETH_ALEN]; +}; diff --git a/shortcut-fe/fast-classifier/src/nl_classifier_test.c b/shortcut-fe/fast-classifier/src/nl_classifier_test.c new file mode 100755 index 000000000..639417964 --- /dev/null +++ b/shortcut-fe/fast-classifier/src/nl_classifier_test.c @@ -0,0 +1,281 @@ +/* + * Copyright (c) 2016 The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include +#include + +#define NL_CLASSIFIER_GENL_VERSION 1 +#define NL_CLASSIFIER_GENL_FAMILY "FC" +#define NL_CLASSIFIER_GENL_GROUP "FC_MCGRP" +#define NL_CLASSIFIER_GENL_HDRSIZE 0 + +enum NL_CLASSIFIER_CMD { + NL_CLASSIFIER_CMD_UNSPEC, + NL_CLASSIFIER_CMD_ACCEL, + NL_CLASSIFIER_CMD_ACCEL_OK, + NL_CLASSIFIER_CMD_CONNECTION_CLOSED, + NL_CLASSIFIER_CMD_MAX, +}; + +enum NL_CLASSIFIER_ATTR { + NL_CLASSIFIER_ATTR_UNSPEC, + NL_CLASSIFIER_ATTR_TUPLE, + NL_CLASSIFIER_ATTR_MAX, +}; + +union nl_classifier_tuple_ip { + struct in_addr in; + struct in6_addr in6; +}; + +struct nl_classifier_tuple { + unsigned short af; + unsigned char proto; + union nl_classifier_tuple_ip src_ip; + union nl_classifier_tuple_ip dst_ip; + unsigned short sport; + unsigned short dport; + unsigned char smac[6]; + unsigned char dmac[6]; +}; + +struct nl_classifier_instance { + struct nl_sock *sock; + int family_id; + int group_id; + int stop; +}; + +struct nl_classifier_instance nl_cls_inst; + +static struct nla_policy nl_classifier_genl_policy[(NL_CLASSIFIER_ATTR_MAX+1)] = { + [NL_CLASSIFIER_ATTR_TUPLE] = { .type = NLA_UNSPEC }, +}; + +void nl_classifier_dump_nl_tuple(struct nl_classifier_tuple *tuple) +{ + char ip_str[64]; + + printf("protocol = %s\n", (tuple->proto == IPPROTO_UDP) ? "udp" : ((tuple->proto == IPPROTO_TCP) ? "tcp" : "unknown")); + printf("source ip = %s\n", inet_ntop(tuple->af, &tuple->src_ip, ip_str, sizeof(ip_str))); + printf("destination ip = %s\n", inet_ntop(tuple->af, &tuple->dst_ip, ip_str, sizeof(ip_str))); + printf("source port = %d\n", ntohs(tuple->sport)); + printf("destination port = %d\n", ntohs(tuple->dport)); +} + +int nl_classifier_msg_recv(struct nl_msg *msg, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(msg); + struct genlmsghdr *gnlh = nlmsg_data(nlh); + struct nlattr *attrs[(NL_CLASSIFIER_ATTR_MAX+1)]; + + genlmsg_parse(nlh, NL_CLASSIFIER_GENL_HDRSIZE, attrs, NL_CLASSIFIER_ATTR_MAX, nl_classifier_genl_policy); + + switch (gnlh->cmd) { + case NL_CLASSIFIER_CMD_ACCEL_OK: + printf("Acceleration successful:\n"); + nl_classifier_dump_nl_tuple(nla_data(attrs[NL_CLASSIFIER_ATTR_TUPLE])); + return NL_OK; + case NL_CLASSIFIER_CMD_CONNECTION_CLOSED: + printf("Connection is closed:\n"); + nl_classifier_dump_nl_tuple(nla_data(attrs[NL_CLASSIFIER_ATTR_TUPLE])); + return NL_OK; + default: + printf("nl classifier received unknow message %d\n", gnlh->cmd); + } + + return NL_SKIP; +} + +void nl_classifier_offload(struct nl_classifier_instance *inst, + unsigned char proto, unsigned long *src_saddr, + unsigned long *dst_saddr, unsigned short sport, + unsigned short dport, int af) +{ + struct nl_msg *msg; + int ret; + struct nl_classifier_tuple classifier_msg; + + memset(&classifier_msg, 0, sizeof(classifier_msg)); + classifier_msg.af = af; + classifier_msg.proto = proto; + memcpy(&classifier_msg.src_ip, src_saddr, (af == AF_INET ? 4 : 16)); + memcpy(&classifier_msg.dst_ip, dst_saddr, (af == AF_INET ? 4 : 16)); + classifier_msg.sport = sport; + classifier_msg.dport = dport; + + msg = nlmsg_alloc(); + if (!msg) { + printf("Unable to allocate message\n"); + return; + } + + genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, inst->family_id, + NL_CLASSIFIER_GENL_HDRSIZE, NLM_F_REQUEST, + NL_CLASSIFIER_CMD_ACCEL, NL_CLASSIFIER_GENL_VERSION); + nla_put(msg, NL_CLASSIFIER_ATTR_TUPLE, sizeof(classifier_msg), &classifier_msg); + + ret = nl_send_auto(inst->sock, msg); + if (ret < 0) { + printf("send netlink message failed.\n"); + nlmsg_free(msg); + return; + } + + nlmsg_free(msg); + printf("nl classifier offload connection successful\n"); +} + +int nl_classifier_init(struct nl_classifier_instance *inst) +{ + int ret; + + inst->sock = nl_socket_alloc(); + if (!inst->sock) { + printf("Unable to allocation socket.\n"); + return -1; + } + genl_connect(inst->sock); + + inst->family_id = genl_ctrl_resolve(inst->sock, NL_CLASSIFIER_GENL_FAMILY); + if (inst->family_id < 0) { + printf("Unable to resolve family %s\n", NL_CLASSIFIER_GENL_FAMILY); + goto init_failed; + } + + inst->group_id = genl_ctrl_resolve_grp(inst->sock, NL_CLASSIFIER_GENL_FAMILY, NL_CLASSIFIER_GENL_GROUP); + if (inst->group_id < 0) { + printf("Unable to resolve mcast group %s\n", NL_CLASSIFIER_GENL_GROUP); + goto init_failed; + } + + ret = nl_socket_add_membership(inst->sock, inst->group_id); + if (ret < 0) { + printf("Unable to add membership\n"); + goto init_failed; + } + + nl_socket_disable_seq_check(inst->sock); + nl_socket_modify_cb(inst->sock, NL_CB_VALID, NL_CB_CUSTOM, nl_classifier_msg_recv, NULL); + + printf("nl classifier init successful\n"); + return 0; + +init_failed: + if (inst->sock) { + nl_close(inst->sock); + nl_socket_free(inst->sock); + inst->sock = NULL; + } + return -1; +} + +void nl_classifier_exit(struct nl_classifier_instance *inst) +{ + if (inst->sock) { + nl_close(inst->sock); + nl_socket_free(inst->sock); + inst->sock = NULL; + } + printf("nl classifier exit successful\n"); +} + +int nl_classifier_parse_arg(int argc, char *argv[], unsigned char *proto, unsigned long *src_saddr, + unsigned long *dst_saddr, unsigned short *sport, unsigned short *dport, int *af) +{ + int ret; + unsigned short port; + + if (argc < 7) { + printf("help: nl_classifier \n"); + return -1; + } + + if (0 == strncmp(argv[1], "v4", 2)) { + *af = AF_INET; + } else if (0 == strncmp(argv[1], "v6", 2)) { + *af = AF_INET6; + } else { + printf("Address family is not supported"); + return -1; + } + + if (0 == strncmp(argv[2], "udp", 3)) { + *proto = IPPROTO_UDP; + } else if (0 == strncmp(argv[2], "tcp", 3)) { + *proto = IPPROTO_TCP; + } else { + printf("Protocol is not supported"); + return -1; + } + + ret = inet_pton(*af, argv[3], src_saddr); + if (ret <= 0) { + printf("source ip has wrong format\n"); + return -1; + } + + ret = inet_pton(*af, argv[4], dst_saddr); + if (ret <= 0) { + printf("destination ip has wrong format\n"); + return -1; + } + + port = strtol(argv[5], NULL, 0); + *sport = htons(port); + port = strtol(argv[6], NULL, 0); + *dport = htons(port); + + printf("nl classifier parse arguments successful\n"); + return 0; +} + +int main(int argc, char *argv[]) +{ + struct nl_classifier_instance *inst = &nl_cls_inst; + unsigned char proto; + unsigned long src_addr[4]; + unsigned long dst_addr[4]; + unsigned short sport; + unsigned short dport; + int af; + int ret; + + ret = nl_classifier_parse_arg(argc, argv, &proto, src_addr, dst_addr, &sport, &dport, &af); + if (ret < 0) { + printf("Failed to parse arguments\n"); + return ret; + } + + ret = nl_classifier_init(inst); + if (ret < 0) { + printf("Unable to init generic netlink\n"); + return ret; + } + + nl_classifier_offload(inst, proto, src_addr, dst_addr, sport, dport, af); + + /* main loop to listen on message */ + while (!inst->stop) { + nl_recvmsgs_default(inst->sock); + } + + nl_classifier_exit(inst); + + return 0; +} diff --git a/shortcut-fe/fast-classifier/src/userspace_example.c b/shortcut-fe/fast-classifier/src/userspace_example.c new file mode 100755 index 000000000..4f4113d99 --- /dev/null +++ b/shortcut-fe/fast-classifier/src/userspace_example.c @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2013,2016 The Linux Foundation. All rights reserved. + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all copies. + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT + * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include +#include + +#include + +static struct nl_sock *sock; +static struct nl_sock *sock_event; +static int family; +static int grp_id; + +static struct nla_policy fast_classifier_genl_policy[FAST_CLASSIFIER_A_MAX + 1] = { + [FAST_CLASSIFIER_A_TUPLE] = { .type = NLA_UNSPEC }, +}; + +void dump_fc_tuple(struct fast_classifier_tuple *fc_msg) +{ + char src_str[INET_ADDRSTRLEN]; + char dst_str[INET_ADDRSTRLEN]; + + printf("TUPLE: %d, %s, %s, %d, %d" + " SMAC=%02x:%02x:%02x:%02x:%02x:%02x", + " DMAC=%02x:%02x:%02x:%02x:%02x:%02x\n", + fc_msg->proto, + inet_ntop(AF_INET, + &fc_msg->src_saddr.in.s_addr, + src_str, + INET_ADDRSTRLEN), + inet_ntop(AF_INET, + &fc_msg->dst_saddr.in.s_addr, + dst_str, + INET_ADDRSTRLEN), + fc_msg->sport, fc_msg->dport, + fc_msg->smac[0], fc_msg->smac[1], fc_msg->smac[2], + fc_msg->smac[3], fc_msg->smac[4], fc_msg->smac[5], + fc_msg->dmac[0], fc_msg->dmac[1], fc_msg->dmac[2], + fc_msg->dmac[3], fc_msg->dmac[4], fc_msg->dmac[5]); +} + +static int parse_cb(struct nl_msg *msg, void *arg) +{ + struct nlmsghdr *nlh = nlmsg_hdr(msg); + struct genlmsghdr *gnlh = nlmsg_data(nlh); + struct nlattr *attrs[FAST_CLASSIFIER_A_MAX]; + + genlmsg_parse(nlh, 0, attrs, FAST_CLASSIFIER_A_MAX, fast_classifier_genl_policy); + + switch (gnlh->cmd) { + case FAST_CLASSIFIER_C_OFFLOADED: + printf("Got a offloaded message\n"); + dump_fc_tuple(nla_data(attrs[FAST_CLASSIFIER_A_TUPLE])); + return NL_OK; + case FAST_CLASSIFIER_C_DONE: + printf("Got a done message\n"); + dump_fc_tuple(nla_data(attrs[FAST_CLASSIFIER_A_TUPLE])); + return NL_OK; + } + + return NL_SKIP; +} + +int fast_classifier_init(void) +{ + int err; + + sock = nl_socket_alloc(); + if (!sock) { + printf("Unable to allocation socket.\n"); + return -1; + } + genl_connect(sock); + + sock_event = nl_socket_alloc(); + if (!sock_event) { + nl_close(sock); + nl_socket_free(sock); + printf("Unable to allocation socket.\n"); + return -1; + } + genl_connect(sock_event); + + family = genl_ctrl_resolve(sock, FAST_CLASSIFIER_GENL_NAME); + if (family < 0) { + nl_close(sock_event); + nl_close(sock); + nl_socket_free(sock); + nl_socket_free(sock_event); + printf("Unable to resolve family\n"); + return -1; + } + + grp_id = genl_ctrl_resolve_grp(sock, FAST_CLASSIFIER_GENL_NAME, + FAST_CLASSIFIER_GENL_MCGRP); + if (grp_id < 0) { + printf("Unable to resolve mcast group\n"); + return -1; + } + + err = nl_socket_add_membership(sock_event, grp_id); + if (err < 0) { + printf("Unable to add membership\n"); + return -1; + } + + nl_socket_disable_seq_check(sock_event); + nl_socket_modify_cb(sock_event, NL_CB_VALID, NL_CB_CUSTOM, parse_cb, NULL); + + return 0; +} + +void fast_classifier_close(void) +{ + nl_close(sock_event); + nl_close(sock); + nl_socket_free(sock_event); + nl_socket_free(sock); +} + +void fast_classifier_ipv4_offload(unsigned char proto, unsigned long src_saddr, + unsigned long dst_saddr, unsigned short sport, + unsigned short dport) +{ + struct nl_msg *msg; + int ret; +#ifdef DEBUG + char src_str[INET_ADDRSTRLEN]; + char dst_str[INET_ADDRSTRLEN]; +#endif + struct fast_classifier_tuple fc_msg; + +#ifdef DEBUG + printf("DEBUG: would offload: %d, %s, %s, %d, %d\n", proto, + inet_ntop(AF_INET, &src_saddr, src_str, INET_ADDRSTRLEN), + inet_ntop(AF_INET, &dst_saddr, dst_str, INET_ADDRSTRLEN), + sport, dport); +#endif + + fc_msg.proto = proto; + fc_msg.src_saddr.in.s_addr = src_saddr; + fc_msg.dst_saddr.in.s_addr = dst_saddr; + fc_msg.sport = sport; + fc_msg.dport = dport; + fc_msg.smac[0] = 'a'; + fc_msg.smac[1] = 'b'; + fc_msg.smac[2] = 'c'; + fc_msg.smac[3] = 'd'; + fc_msg.smac[4] = 'e'; + fc_msg.smac[5] = 'f'; + fc_msg.dmac[0] = 'f'; + fc_msg.dmac[1] = 'e'; + fc_msg.dmac[2] = 'd'; + fc_msg.dmac[3] = 'c'; + fc_msg.dmac[4] = 'b'; + fc_msg.dmac[5] = 'a'; + + if (fast_classifier_init() < 0) { + printf("Unable to init generic netlink\n"); + exit(1); + } + + msg = nlmsg_alloc(); + if (!msg) { + nl_socket_free(sock); + printf("Unable to allocate message\n"); + return; + } + + genlmsg_put(msg, NL_AUTO_PID, NL_AUTO_SEQ, family, + FAST_CLASSIFIER_GENL_HDRSIZE, NLM_F_REQUEST, + FAST_CLASSIFIER_C_OFFLOAD, FAST_CLASSIFIER_GENL_VERSION); + nla_put(msg, 1, sizeof(fc_msg), &fc_msg); + + ret = nl_send_auto_complete(sock, msg); + + nlmsg_free(msg); + if (ret < 0) { + printf("nlmsg_free failed"); + nl_close(sock); + nl_socket_free(sock); + return; + } + + ret = nl_wait_for_ack(sock); + if (ret < 0) { + printf("wait for ack failed"); + nl_close(sock); + nl_socket_free(sock); + return; + } +} + +void fast_classifier_listen_for_messages(void) +{ + printf("waiting for netlink events\n"); + + while (1) { + nl_recvmsgs_default(sock_event); + } +} + +int main(int argc, char *argv[]) +{ + if (fast_classifier_init() < 0) { + printf("Unable to init generic netlink\n"); + exit(1); + } + + fast_classifier_ipv4_offload('a', 0, 0, 0, 0); + + /* this never returns */ + fast_classifier_listen_for_messages(); + + fast_classifier_close(); + + return 0; +} diff --git a/shortcut-fe/Makefile b/shortcut-fe/shortcut-fe/Makefile similarity index 95% rename from shortcut-fe/Makefile rename to shortcut-fe/shortcut-fe/Makefile index c84bfa964..df295ca0f 100755 --- a/shortcut-fe/Makefile +++ b/shortcut-fe/shortcut-fe/Makefile @@ -24,7 +24,7 @@ define KernelPackage/shortcut-fe SECTION:=kernel CATEGORY:=Kernel modules SUBMENU:=Network Support - DEPENDS:=@KERNEL_5_4 @IPV6 +kmod-nf-conntrack + DEPENDS:=@IPV6 +kmod-nf-conntrack TITLE:=Kernel driver for SFE FILES:= \ $(PKG_BUILD_DIR)/shortcut-fe.ko \ @@ -53,7 +53,7 @@ define KernelPackage/shortcut-fe-cm SECTION:=kernel CATEGORY:=Kernel modules SUBMENU:=Network Support - DEPENDS:=@KERNEL_5_4 +kmod-ipt-conntrack +kmod-shortcut-fe + DEPENDS:=+kmod-ipt-conntrack +kmod-shortcut-fe TITLE:=Kernel driver for SFE FILES:=$(PKG_BUILD_DIR)/shortcut-fe-cm.ko KCONFIG:= \ @@ -79,7 +79,7 @@ endef ifneq ($(CONFIG_PACKAGE_kmod-shortcut-fe)$(CONFIG_PACKAGE_kmod-shortcut-fe-cm),) define Build/InstallDev - $(INSTALL_DIR) $(1)/usr/include + $(INSTALL_DIR) $(1)/usr/include $(INSTALL_DIR) $(1)/usr/include/shortcut-fe $(CP) -rf $(PKG_BUILD_DIR)/sfe.h $(1)/usr/include/shortcut-fe $(CP) -rf $(PKG_BUILD_DIR)/sfe.h $(1)/usr/include diff --git a/shortcut-fe/files/etc/init.d/shortcut-fe b/shortcut-fe/shortcut-fe/files/etc/init.d/shortcut-fe similarity index 100% rename from shortcut-fe/files/etc/init.d/shortcut-fe rename to shortcut-fe/shortcut-fe/files/etc/init.d/shortcut-fe diff --git a/shortcut-fe/files/usr/bin/sfe_dump b/shortcut-fe/shortcut-fe/files/usr/bin/sfe_dump similarity index 100% rename from shortcut-fe/files/usr/bin/sfe_dump rename to shortcut-fe/shortcut-fe/files/usr/bin/sfe_dump diff --git a/shortcut-fe/src/Kconfig b/shortcut-fe/shortcut-fe/src/Kconfig similarity index 100% rename from shortcut-fe/src/Kconfig rename to shortcut-fe/shortcut-fe/src/Kconfig diff --git a/shortcut-fe/src/Makefile b/shortcut-fe/shortcut-fe/src/Makefile similarity index 100% rename from shortcut-fe/src/Makefile rename to shortcut-fe/shortcut-fe/src/Makefile diff --git a/shortcut-fe/src/sfe.h b/shortcut-fe/shortcut-fe/src/sfe.h similarity index 100% rename from shortcut-fe/src/sfe.h rename to shortcut-fe/shortcut-fe/src/sfe.h diff --git a/shortcut-fe/src/sfe_backport.h b/shortcut-fe/shortcut-fe/src/sfe_backport.h similarity index 100% rename from shortcut-fe/src/sfe_backport.h rename to shortcut-fe/shortcut-fe/src/sfe_backport.h diff --git a/shortcut-fe/src/sfe_cm.c b/shortcut-fe/shortcut-fe/src/sfe_cm.c similarity index 100% rename from shortcut-fe/src/sfe_cm.c rename to shortcut-fe/shortcut-fe/src/sfe_cm.c diff --git a/shortcut-fe/src/sfe_cm.h b/shortcut-fe/shortcut-fe/src/sfe_cm.h similarity index 100% rename from shortcut-fe/src/sfe_cm.h rename to shortcut-fe/shortcut-fe/src/sfe_cm.h diff --git a/shortcut-fe/src/sfe_ipv4.c b/shortcut-fe/shortcut-fe/src/sfe_ipv4.c similarity index 100% rename from shortcut-fe/src/sfe_ipv4.c rename to shortcut-fe/shortcut-fe/src/sfe_ipv4.c diff --git a/shortcut-fe/src/sfe_ipv6.c b/shortcut-fe/shortcut-fe/src/sfe_ipv6.c similarity index 100% rename from shortcut-fe/src/sfe_ipv6.c rename to shortcut-fe/shortcut-fe/src/sfe_ipv6.c diff --git a/shortcut-fe/simulated-driver/Makefile b/shortcut-fe/simulated-driver/Makefile new file mode 100755 index 000000000..60034b89c --- /dev/null +++ b/shortcut-fe/simulated-driver/Makefile @@ -0,0 +1,60 @@ +# +# Copyright (c) 2015,2016 The Linux Foundation. All rights reserved. +# Permission to use, copy, modify, and/or distribute this software for +# any purpose with or without fee is hereby granted, provided that the +# above copyright notice and this permission notice appear in all copies. +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=shortcut-fe-simulated-driver +PKG_RELEASE:=1 + +PKG_SOURCE_URL:=https://git.codelinaro.org/clo/qsdk/oss/lklm/shortcut-fe.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_DATE:=2021-03-17 +PKG_SOURCE_VERSION:=697977d8d0ccf0ab596e5692d08608a75dd7f33d +PKG_MIRROR_HASH:=659fa82a431e15af797a6c7069faeee02810453ad8b576c51c29f95a1761a045 + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/shortcut-fe-drv + SECTION:=kernel + CATEGORY:=Kernel modules + SUBMENU:=Network Support + DEPENDS:=@TARGET_ipq806x||TARGET_ipq807x +kmod-shortcut-fe + KCONFIG:= \ + CONFIG_NET_CLS_ACT=y \ + CONFIG_XFRM=y + TITLE:=Simulated sfe driver for ECM + FILES:=$(PKG_BUILD_DIR)/simulated-driver/shortcut-fe-drv.ko +endef + +define KernelPackage/shortcut-fe-drv/Description +Simulated sfe driver which act as an adapter to convert message +between a connection manager and the SFE core engine. +endef + +define Build/Compile + $(MAKE) $(PKG_JOBS) -C "$(LINUX_DIR)" \ + $(KERNEL_MAKE_FLAGS) \ + $(PKG_MAKE_FLAGS) \ + M="$(PKG_BUILD_DIR)/simulated-driver" \ + EXTRA_CFLAGS="-DSFE_SUPPORT_IPV6" \ + modules +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include/shortcut-fe + $(CP) -rf $(PKG_BUILD_DIR)/simulated-driver/sfe_drv.h $(1)/usr/include/shortcut-fe +endef + +$(eval $(call KernelPackage,shortcut-fe-drv)) diff --git a/shortcut-fe/simulated-driver/patches/200-nss-qdisc-support.patch b/shortcut-fe/simulated-driver/patches/200-nss-qdisc-support.patch new file mode 100755 index 000000000..638ad8a84 --- /dev/null +++ b/shortcut-fe/simulated-driver/patches/200-nss-qdisc-support.patch @@ -0,0 +1,11 @@ +--- ./simulated-driver/sfe_drv.c.orig 2020-06-16 12:49:47.680153371 +0800 ++++ ./simulated-driver/sfe_drv.c 2020-06-16 12:50:18.540153371 +0800 +@@ -1167,7 +1167,7 @@ int sfe_drv_recv(struct sk_buff *skb) + * If ingress Qdisc configured, and packet not processed by ingress Qdisc yet + * We can not accelerate this packet. + */ +- if (dev->ingress_queue && !(skb->tc_verd & TC_NCLS)) { ++ if (dev->ingress_queue && !(skb->tc_verd_qca_nss & TC_NCLS)) { + return 0; + } + #endif diff --git a/simple-obfs/LICENSE b/simple-obfs/LICENSE old mode 100755 new mode 100644 diff --git a/simple-obfs/Makefile b/simple-obfs/Makefile old mode 100755 new mode 100644 diff --git a/speedtestc/Makefile b/speedtestc/Makefile old mode 100755 new mode 100644 diff --git a/speedtestcpp/Makefile b/speedtestcpp/Makefile old mode 100755 new mode 100644 diff --git a/systemtap/Makefile b/systemtap/Makefile old mode 100755 new mode 100644 diff --git a/systemtap/patches/0001-Do-not-let-configure-write-a-python-location-into-th.patch b/systemtap/patches/0001-Do-not-let-configure-write-a-python-location-into-th.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/0001-Install-python-modules-to-correct-library-dir.patch b/systemtap/patches/0001-Install-python-modules-to-correct-library-dir.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/0001-staprun-address-ncurses-6.3-failures.patch b/systemtap/patches/0001-staprun-address-ncurses-6.3-failures.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch b/systemtap/patches/0001-staprun-stapbpf-don-t-support-installing-a-non-root.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/basename.patch b/systemtap/patches/basename.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/conversion.patch b/systemtap/patches/conversion.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/include-fix.patch b/systemtap/patches/include-fix.patch old mode 100755 new mode 100644 diff --git a/systemtap/patches/types.patch b/systemtap/patches/types.patch old mode 100755 new mode 100644 diff --git a/tcptraceroute/Makefile b/tcptraceroute/Makefile old mode 100755 new mode 100644 diff --git a/tcptraceroute/patches/001-configure_cross_compile.patch b/tcptraceroute/patches/001-configure_cross_compile.patch old mode 100755 new mode 100644 diff --git a/tracebox/Makefile b/tracebox/Makefile old mode 100755 new mode 100644 diff --git a/tracebox/files/usr/share/tracebox/omr-mptcp-trace.lua b/tracebox/files/usr/share/tracebox/omr-mptcp-trace.lua old mode 100755 new mode 100644 diff --git a/tracebox/patches/101-build-fixes.patch b/tracebox/patches/101-build-fixes.patch old mode 100755 new mode 100644 diff --git a/tracebox/patches/102-configure.patch b/tracebox/patches/102-configure.patch old mode 100755 new mode 100644 diff --git a/tracebox/patches/103-configure.patch b/tracebox/patches/103-configure.patch old mode 100755 new mode 100644 diff --git a/tracebox/patches/104-ns_name_compress.patch b/tracebox/patches/104-ns_name_compress.patch old mode 100755 new mode 100644 diff --git a/tracebox/patches/202-fix-lua-include-hpp.patch b/tracebox/patches/202-fix-lua-include-hpp.patch old mode 100755 new mode 100644 diff --git a/tracebox/patches/204-fix-lua-namespace-crafter.patch b/tracebox/patches/204-fix-lua-namespace-crafter.patch old mode 100755 new mode 100644 diff --git a/tsping/Makefile b/tsping/Makefile old mode 100755 new mode 100644 diff --git a/v2ray-core/Config.in b/v2ray-core/Config.in old mode 100755 new mode 100644 diff --git a/v2ray-core/LICENSE b/v2ray-core/LICENSE old mode 100755 new mode 100644 diff --git a/v2ray-core/Makefile b/v2ray-core/Makefile old mode 100755 new mode 100644 diff --git a/v2ray-core/files/etc/firewall.v2ray-rules b/v2ray-core/files/etc/firewall.v2ray-rules old mode 100755 new mode 100644 diff --git a/v2ray-core/files/etc/uci-defaults/3010-omr-v2ray b/v2ray-core/files/etc/uci-defaults/3010-omr-v2ray old mode 100755 new mode 100644 diff --git a/v2ray-ext/Makefile b/v2ray-ext/Makefile old mode 100755 new mode 100644 index 2983d536f..f1fd155fb --- a/v2ray-ext/Makefile +++ b/v2ray-ext/Makefile @@ -25,7 +25,7 @@ GO_PKG:=v2ray.com/ext GO_PKG_SOURCE_ONLY:=1 include $(INCLUDE_DIR)/package.mk -include $(TOPDIR)/feeds/openmptcprouter/golang/golang-package.mk +include ../golang/golang-package.mk define Package/v2ray-ext-dev $(call GoPackage/GoSubMenu)