Merge pull request #21184 from commodo/numpy
authorAlexandru Ardelean <alex@shruggie.ro>
Sat, 27 May 2023 06:25:45 +0000 (09:25 +0300)
committerGitHub <noreply@github.com>
Sat, 27 May 2023 06:25:45 +0000 (09:25 +0300)
numpy: bump version to 1.24.3

21 files changed:
.github/workflows/multi-arch-test-build.yml
net/curl/Makefile
net/https-dns-proxy/Makefile
net/https-dns-proxy/files/https-dns-proxy.init
net/https-dns-proxy/patches/010-cmakelists-remove-cflags.patch
net/https-dns-proxy/patches/020-cmakelists-add-version.patch [deleted file]
net/https-dns-proxy/patches/020-src-options.c-add-version.patch [new file with mode: 0644]
net/mstpd/Config.in [deleted file]
net/mstpd/Makefile [deleted file]
net/mstpd/files/etc/init.d/mstpd.init [deleted file]
net/mstpd/files/sbin/bridge-stp [deleted file]
net/mstpd/patches/010-bsd.patch [deleted file]
net/nginx/Makefile
net/nginx/patches/dav-nginx/100-drop-libxslt-dep.patch [deleted file]
net/nginx/patches/lua-nginx/100-no_by_lua_block.patch [deleted file]
net/nginx/patches/nginx-mod-dav-ext/100-drop-libxslt-dep.patch [new file with mode: 0644]
net/nginx/patches/nginx-mod-lua/100-no_by_lua_block.patch [new file with mode: 0644]
net/nginx/patches/nginx-mod-rtmp/100-bigedian.patch [new file with mode: 0644]
net/nginx/patches/rtmp-nginx/100-bigedian.patch [deleted file]
net/tailscale/Makefile
net/tailscale/patches/010-fake_iptables.patch

index 60ff51063bf1132cc4d50fe074375efd119b3415..9cac7c9b395370c737607863a9bb3a13b7c6f9d7 100644 (file)
@@ -3,6 +3,10 @@ name: Test Build
 on:
   pull_request:
 
+concurrency:
+  group: ${{ github.workflow }}-${{ github.ref }}
+  cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
 jobs:
   build:
     name: Test ${{ matrix.arch }}
index d167cebfc0d8fe4ea554109def30ee91455cb2e2..392679b9bf8dc6d5441bacc8f0b1f8195f791233 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/nls.mk
 
 PKG_NAME:=curl
-PKG_VERSION:=8.1.0
+PKG_VERSION:=8.1.1
 PKG_RELEASE:=1
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
@@ -17,7 +17,7 @@ PKG_SOURCE_URL:=https://github.com/curl/curl/releases/download/curl-$(subst .,_,
        https://dl.uxnr.de/mirror/curl/ \
        https://curl.askapache.com/download/ \
        https://curl.se/download/
-PKG_HASH:=6bd80ad4f07187015911216ee7185b90d285ac5162aed1bded144f9f93232a3c
+PKG_HASH:=08a948e061929645597c1ef7194e07b308b22084ff03fa7400b465e6c05149e5
 
 PKG_LICENSE:=MIT
 PKG_LICENSE_FILES:=COPYING
index f7d7cc1bfd90b974d9121ffe8cb7c521ffcb688d..af172e4afe17d41c00c6034eadff4246c8881b77 100644 (file)
@@ -1,14 +1,14 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=https-dns-proxy
-PKG_VERSION:=2022-10-15
-PKG_RELEASE:=12
+PKG_VERSION:=2023-05-25
+PKG_RELEASE:=1
 
 PKG_SOURCE_PROTO:=git
 PKG_SOURCE_URL:=https://github.com/aarond10/https_dns_proxy/
 PKG_SOURCE_DATE:=$(PKG_VERSION)
-PKG_SOURCE_VERSION:=f52a85f3edabecfbab41d9244c63a1c6b8aaf49b
-PKG_MIRROR_HASH:=dd8a55255e8859a462fcfd736577fec40731b39a4783325640518745009b0dee
+PKG_SOURCE_VERSION:=d03e11572562f008f68df217a7378628f1bb7b79
+PKG_MIRROR_HASH:=5af3683c48bc9e493ca2761a6f7ee756431692a695d6008f61b8b92431036dca
 PKG_MAINTAINER:=Stan Grishin <stangri@melmac.ca>
 PKG_LICENSE:=MIT
 PKG_LICENSE_FILES:=LICENSE
index f6e32cba7372c8a7e12414d5dcdbc7bea7d5fa92..1495592e0f576b8d6b9f3dba582ddd347ecd293f 100755 (executable)
@@ -3,7 +3,7 @@
 # shellcheck disable=SC1091,SC3043,SC3060
 
 # shellcheck disable=SC2034
-START=80
+START=95
 # shellcheck disable=SC2034
 USE_PROCD=1
 
index a765a5bbd7d7f991089d86dffee3d5cc2f98cb04..cd60c6dc017699b2829dbcd462153640c6620a59 100644 (file)
@@ -4,10 +4,10 @@
    set(CMAKE_INSTALL_BINDIR bin)
  endif()
  
--set(CMAKE_C_FLAGS "-Wall -Wextra --pedantic -Wno-strict-aliasing -Wno-variadic-macros")
+-set(CMAKE_C_FLAGS "${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 "${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")
  
diff --git a/net/https-dns-proxy/patches/020-cmakelists-add-version.patch b/net/https-dns-proxy/patches/020-cmakelists-add-version.patch
deleted file mode 100644 (file)
index 8debfe9..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-From 2ca80486ba6a4e5acbdf0ff581d9754af17fa33b Mon Sep 17 00:00:00 2001
-From: baranyaib90 <5031516+baranyaib90@users.noreply.github.com>
-Date: Mon, 24 Oct 2022 22:53:37 +0200
-Subject: [PATCH] Allow external setting of GIT_VERSION
-
----
- CMakeLists.txt | 34 ++++++++++++++++++----------------
- 1 file changed, 18 insertions(+), 16 deletions(-)
-
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -36,22 +36,24 @@ endif()
- # VERSION
--find_package(Git)
--if(Git_FOUND)
--  execute_process(
--    COMMAND "${GIT_EXECUTABLE}" show --date=format:%Y.%m.%d --format=%ad-%h --no-patch
--    WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
--    OUTPUT_VARIABLE GIT_VERSION
--    OUTPUT_STRIP_TRAILING_WHITESPACE)
--  message(STATUS "Version: ${GIT_VERSION}")
-+if(NOT GIT_VERSION)
-+  find_package(Git)
-+  if(Git_FOUND)
-+    execute_process(
-+      COMMAND "${GIT_EXECUTABLE}" show --date=format:%Y.%m.%d --format=%ad-%h --no-patch
-+      WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
-+      OUTPUT_VARIABLE GIT_VERSION
-+      OUTPUT_STRIP_TRAILING_WHITESPACE)
-+    message(STATUS "Version: ${GIT_VERSION}")
--  # May not update version in some cases (example: git commit --amend)
--  set_property(GLOBAL APPEND
--    PROPERTY CMAKE_CONFIGURE_DEPENDS
--    "${CMAKE_SOURCE_DIR}/.git/index")
--else()
--  set(GIT_VERSION "UNKNOWN")
--  message(WARNING "Could not find git command! Version is set to: ${GIT_VERSION}")
-+    # May not update version in some cases (example: git commit --amend)
-+    set_property(GLOBAL APPEND
-+      PROPERTY CMAKE_CONFIGURE_DEPENDS
-+      "${CMAKE_SOURCE_DIR}/.git/index")
-+  else()
-+    set(GIT_VERSION "UNKNOWN")
-+    message(WARNING "Could not find git command! Version is set to: ${GIT_VERSION}")
-+  endif()
- endif()
- # LIBRARY DEPENDENCIES
diff --git a/net/https-dns-proxy/patches/020-src-options.c-add-version.patch b/net/https-dns-proxy/patches/020-src-options.c-add-version.patch
new file mode 100644 (file)
index 0000000..8bb2d93
--- /dev/null
@@ -0,0 +1,11 @@
+--- a/src/options.c
++++ b/src/options.c
+@@ -22,7 +22,7 @@ const char * options_sw_version() {
+ #ifdef SW_VERSION
+   return SW_VERSION;
+ #else
+-  return "2023.01.01-atLeast";  // update date sometimes, like 1-2 times a year
++  return "2023-05-25-1";  // update date sometimes, like 1-2 times a year
+ #endif
+ }
diff --git a/net/mstpd/Config.in b/net/mstpd/Config.in
deleted file mode 100644 (file)
index 84d5147..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-menu "Configuration"
-       depends on PACKAGE_mstpd
-
-config MSTPD_RTNL_RCV_BUFSIZE
-       int "Netlink receive buffer size"
-       default 262144
-
-config MSTPD_RTNL_SND_BUFSIZE
-       int "Netlink send buffer size"
-       default 262144
-
-endmenu
diff --git a/net/mstpd/Makefile b/net/mstpd/Makefile
deleted file mode 100644 (file)
index 3bea93c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#
-# Copyright (C) 2019 Alexandru Ardelean <ardeleanalex@gmail.com>
-#
-# This is free software, licensed under the GNU General Public License v2.
-# See /LICENSE for more information.
-#
-
-include $(TOPDIR)/rules.mk
-
-PKG_NAME:=mstpd
-PKG_VERSION:=0.1.0
-PKG_RELEASE:=1
-
-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_SOURCE_URL:=https://codeload.github.com/mstpd/mstpd/tar.gz/$(PKG_VERSION)?
-PKG_HASH:=03d1ff4ca189d54322562cb2891888768af719d2c73ceafa5f1ca96133dffeb2
-
-PKG_MAINTAINER:=Alexandru Ardelean <ardeleanalex@gmail.com>
-PKG_LICENSE:=GPL-2.0-or-later
-PKG_LICENSE_FILES:=LICENSE
-
-PKG_FIXUP:=autoreconf
-
-include $(INCLUDE_DIR)/package.mk
-
-define Package/mstpd
-  SECTION:=net
-  CATEGORY:=Network
-  TITLE:=Multiple Spanning Tree Protocol daemon
-  URL:=https://github.com/mstpd/mstpd
-endef
-
-define Package/mstpd/description
-  Multiple Spanning Tree Protocol daemon.
-  Implements MSTP which is not implemented yet in the Linux kernel.
-endef
-
-define Package/mstpd/config
-  source "$(SOURCE)/Config.in"
-endef
-
-TARGET_CFLAGS += \
-       -DRTNL_RCV_BUFSIZE=$(CONFIG_MSTPD_RTNL_RCV_BUFSIZE) \
-       -DRTNL_SND_BUFSIZE=$(CONFIG_MSTPD_RTNL_SND_BUFSIZE)
-
-MAKE_VARS+=MODE=prod
-
-define Package/mstpd/install
-       $(INSTALL_DIR) $(1)/usr/sbin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/mstpd $(1)/usr/sbin
-       $(INSTALL_BIN) $(PKG_BUILD_DIR)/mstpctl $(1)/usr/sbin
-       $(INSTALL_DIR) $(1)/etc/init.d/
-       $(INSTALL_BIN) ./files/etc/init.d/mstpd.init $(1)/etc/init.d/mstpd
-       $(INSTALL_DIR) $(1)/sbin
-       $(INSTALL_BIN) ./files/sbin/bridge-stp $(1)/sbin
-endef
-
-$(eval $(call BuildPackage,mstpd))
diff --git a/net/mstpd/files/etc/init.d/mstpd.init b/net/mstpd/files/etc/init.d/mstpd.init
deleted file mode 100644 (file)
index bade419..0000000
+++ /dev/null
@@ -1,124 +0,0 @@
-#!/bin/sh /etc/rc.common
-
-# shellcheck disable=SC2034    # foo appears unused. Verify it or export it.
-
-START=25
-STOP=99
-
-MSTPCTL="/usr/sbin/mstpctl"
-MSTPD="/usr/sbin/mstpd"
-
-USE_PROCD=1
-
-mstpd_get_bridges() {
-       "$MSTPCTL" showbridge | grep -v "^ " | cut -d " " -f 1 2>/dev/null
-}
-
-# mstpd log levels 
-#   LOG_LEVEL_NONE  0
-#   LOG_LEVEL_ERROR 1
-#   LOG_LEVEL_INFO  2
-#   LOG_LEVEL_DEBUG 3
-#   LOG_LEVEL_STATE_MACHINE_TRANSITION 4
-#   LOG_LEVEL_MAX   100
-
-config_bridge_port_mstpd() {
-       local config="$1"
-       local index=$2 # FIXME: maybe remove index later
-       local name=$3
-
-       [ -n "$index" -a -n "$name" ] || return 0
-
-       config_get br_index "$config" br_index
-       [ -n "$br_index" ] || return 0
-       [ "$index" = "$br_index" ] || return 0
-
-       config_get port_name "$config" name
-       [ -n "$port_name" ] || return 0
-
-       for opt in bpduguard; do
-               config_get $opt "$config" $opt
-               eval optval=\$$opt
-               [ -z "$optval" ] || "$MSTPCTL" "set$opt" "$name" "$port_name" "$optval"
-       done
-}
-
-config_bridge_mstpd() {
-       local config="$1"
-       local optval=
-       local name=
-       local enable=
-       local mstid=0 #  for the moment, using only MSTID
-
-       config_get index "$config" index
-       [ -n "$index" ] || return 1
-
-       # Get bridge name
-       config_get name "$config" name
-       [ -n "$name" ] || return 0
-
-       config_get enable "$config" enable
-       if [ "$enable" != "1" ] ; then
-               return 0
-       fi
-
-       list_contains MSTPD_PREINSTALLED_BRIDGES "$name" || \
-               "$MSTPCTL" addbridge "$name"
-       # All options here have 'set$opt' equivalent calls in mstpd,
-       #  hence this trick with the loop
-       for opt in maxage fdelay maxhops hello ageing forcevers txholdcount; do
-               config_get $opt "$config" "$opt"
-               eval optval=\$$opt
-               [ -z "$optval" ] || "$MSTPCTL" set$opt "$name" "$optval"
-       done
-       config_get treeprio "$config" treeprio
-       [ -z "$treeprio" ] || $MSTPCTL settreeprio "$name" "$mstid" "$treeprio"
-       config_foreach config_bridge_port_mstpd bridge_port "$index" "$name"
-       CONFIGURED_BRIDGES="$CONFIGURED_BRIDGES $name"
-       export CONFIGURED_BRIDGES
-}
-
-start_service() {
-       procd_open_instance
-       procd_set_param command $MSTPD
-       procd_append_param command -v 2
-       procd_append_param command -d # don't daemonize, procd will handle that for us
-       procd_append_param command -s # print to syslog
-
-       # set auto respawn behavior
-       procd_set_param respawn
-
-       # reload config on respawn
-       procd_open_trigger
-       procd_add_raw_trigger "instance.start" 2000 "/etc/init.d/mstpd" "reload"
-       procd_close_trigger
-
-       procd_close_instance
-}
-
-service_running() {
-       pgrep mstpd >/dev/null 2>&1
-}
-
-reload_service() {
-       if ! running ; then
-               start
-               return
-       fi
-
-       unset CONFIGURED_BRIDGES
-       MSTPD_PREINSTALLED_BRIDGES="$(mstpd_get_bridges)"
-       export MSTPD_PREINSTALLED_BRIDGES
-
-       config_load 'mstpd'
-       config_foreach config_bridge_mstpd bridge
-
-       for bridge in $(mstpd_get_bridges) ; do
-               list_contains CONFIGURED_BRIDGES "$bridge" || \
-                       $MSTPCTL delbridge "$bridge"
-       done
-       # return 0 (success) here, otherwise, and endless restart loop will occur from procd
-       # because the last return code may be mstpctl failing
-       return 0
-}
-
diff --git a/net/mstpd/files/sbin/bridge-stp b/net/mstpd/files/sbin/bridge-stp
deleted file mode 100644 (file)
index 7b2cbc0..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-# Dummy file ; don't do anything ;
-# Returning success here, tells the kernel to allow
-# a userspace module to handle STP states
-#
-# Meanwhile, procd will start mstpd, and all will be well
-
-exit 0
diff --git a/net/mstpd/patches/010-bsd.patch b/net/mstpd/patches/010-bsd.patch
deleted file mode 100644 (file)
index 120a0db..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
---- a/hmac_md5.c
-+++ b/hmac_md5.c
-@@ -356,10 +356,10 @@ caddr_t         digest;     /* caller di
-      */
-     /* start out by storing key in pads */
--    bzero(k_ipad, sizeof k_ipad);
--    bzero(k_opad, sizeof k_opad);
--    bcopy(key, k_ipad, key_len);
--    bcopy( key, k_opad, key_len);
-+    memset(k_ipad, 0, sizeof k_ipad);
-+    memset(k_opad, 0, sizeof k_opad);
-+    memcpy(k_ipad, key, key_len);
-+    memcpy(k_opad, key, key_len);
-     /* XOR key with ipad and opad values */
-     for(i = 0; i < 64; ++i)
index bb0b9441e8fac78791d7ebe1caf98cdfa036531c..061d82346ee9d60c83a00486830d220648b717f0 100644 (file)
@@ -25,6 +25,22 @@ PKG_BUILD_PARALLEL:=1
 PKG_INSTALL:=1
 PKG_BUILD_FLAGS:=gc-sections
 
+# 3rd-party modules
+PKG_MOD_EXTRA := \
+       lua \
+       rtmp \
+       dav-ext \
+       naxsi \
+       brotli \
+       headers-more \
+       ts \
+       ubus
+# official and 3rd-party modules
+PKG_MOD_ALL := \
+       $(PKG_MOD_EXTRA) \
+       stream
+PKG_MOD_PATCHED := $(shell find patches -mindepth 1 -maxdepth 1 -type d -name 'nginx-mod-*' | sed -E 's,^patches/nginx-mod-,,')
+
 PKG_CONFIG_DEPENDS := \
        CONFIG_NGINX_DAV \
        CONFIG_NGINX_FLV \
@@ -63,7 +79,8 @@ PKG_CONFIG_DEPENDS := \
        CONFIG_NGINX_HTTP_REAL_IP \
        CONFIG_NGINX_HTTP_SECURE_LINK \
        CONFIG_OPENSSL_ENGINE \
-       CONFIG_OPENSSL_WITH_NPN
+       CONFIG_OPENSSL_WITH_NPN \
+       $(foreach m,$(PKG_MOD_EXTRA),CONFIG_PACKAGE_$(m))
 
 include $(INCLUDE_DIR)/package.mk
 include $(INCLUDE_DIR)/nls.mk
@@ -84,6 +101,10 @@ define Package/nginx/description
  written by Igor Sysoev.
 endef
 
+define Package/nginx/conffiles
+/etc/nginx/
+endef
+
 define Package/nginx-ssl
   $(Package/nginx/default)
   TITLE += with SSL support
@@ -99,195 +120,60 @@ Package/nginx-ssl/description = $(Package/nginx/description) \
   This variant is compiled with SSL support enabled. To enable additional module \
   select them in the nginx default configuration menu.
 
+define Package/nginx-ssl/config
+  source "$(SOURCE)/Config_ssl.in"
+endef
+
+Package/nginx-ssl/conffiles = $(Package/nginx/conffiles)
+
+IsEnabled = $(or $(filter full,$(BUILD_VARIANT)),$(CONFIG_$(1)))
+IsDisabled = $(if $(call IsEnabled,$(1)),,1)
+
+config_files := mime.types \
+       $(if $(call IsEnabled,NGINX_HTTP_CHARSET),koi-utf koi-win win-utf) \
+       $(if $(call IsEnabled,NGINX_HTTP_FASTCGI),fastcgi_params) \
+       $(if $(call IsEnabled,NGINX_HTTP_UWSGI),uwsgi_params) \
+       $(if $(call IsEnabled,NGINX_HTTP_SCGI),scgi_params)
+
+define Package/nginx-ssl/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_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
+endef
+
+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
+
 define Package/nginx-full
   $(Package/nginx/default)
   TITLE += with ALL module selected
   DEPENDS+=+libpcre +nginx-ssl-util +zlib +libxml2 \
-  +nginx-mod-ubus +nginx-mod-naxsi +nginx-mod-lua \
-  +nginx-mod-dav-ext +nginx-mod-stream +nginx-mod-headers-more \
-  +nginx-mod-brotli +nginx-mod-rtmp +nginx-mod-ts
+    $(foreach m,$(PKG_MOD_ALL),+nginx-mod-$(m))
   EXTRA_DEPENDS:=nginx-ssl-util (>=1.5-1) (<2)
-  VARIANT:=all-module
+  VARIANT:=full
   PROVIDES += nginx-ssl
 endef
 
 Package/nginx-full/description = $(Package/nginx/description) \
   This variant is compiled with ALL module selected.
 
-define Package/nginx-ssl/config
-  source "$(SOURCE)/Config_ssl.in"
-endef
-
-config_files=mime.types
+Package/nginx-full/install = $(Package/nginx-ssl/install)
 
-define Package/nginx/conffiles
-/etc/nginx/
-endef
+Package/nginx-full/prerm = $(Package/nginx-ssl/prerm)
 
-Package/nginx-ssl/conffiles = $(Package/nginx/conffiles)
 Package/nginx-full/conffiles = $(Package/nginx/conffiles)
 
-ADDITIONAL_MODULES:= --with-http_ssl_module
-
-ifneq ($(BUILD_VARIANT),all-module)
-  ifneq ($(CONFIG_NGINX_HTTP_CACHE),y)
-    ADDITIONAL_MODULES += --without-http-cache
-  endif
-  ifneq ($(CONFIG_NGINX_PCRE),y)
-    ADDITIONAL_MODULES += --without-pcre
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_CHARSET),y)
-    ADDITIONAL_MODULES += --without-http_charset_module
-  else
-    config_files += koi-utf koi-win win-utf
-  endif
-  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
-  ifneq ($(CONFIG_NGINX_HTTP_USERID),y)
-    ADDITIONAL_MODULES += --without-http_userid_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_ACCESS),y)
-    ADDITIONAL_MODULES += --without-http_access_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_AUTH_BASIC),y)
-    ADDITIONAL_MODULES += --without-http_auth_basic_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_AUTOINDEX),y)
-    ADDITIONAL_MODULES += --without-http_autoindex_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_GEO),y)
-    ADDITIONAL_MODULES += --without-http_geo_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_MAP),y)
-    ADDITIONAL_MODULES += --without-http_map_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_SPLIT_CLIENTS),y)
-    ADDITIONAL_MODULES += --without-http_split_clients_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_REFERER),y)
-    ADDITIONAL_MODULES += --without-http_referer_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_REWRITE),y)
-    ADDITIONAL_MODULES += --without-http_rewrite_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_PROXY),y)
-    ADDITIONAL_MODULES += --without-http_proxy_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_FASTCGI),y)
-    ADDITIONAL_MODULES += --without-http_fastcgi_module
-  else
-    config_files += fastcgi_params
-  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
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_LIMIT_CONN),y)
-    ADDITIONAL_MODULES += --without-http_limit_conn_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_LIMIT_REQ),y)
-    ADDITIONAL_MODULES += --without-http_limit_req_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_EMPTY_GIF),y)
-    ADDITIONAL_MODULES += --without-http_empty_gif_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_BROWSER),y)
-    ADDITIONAL_MODULES += --without-http_browser_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_HASH),y)
-    ADDITIONAL_MODULES += --without-http_upstream_hash_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_IP_HASH),y)
-    ADDITIONAL_MODULES += --without-http_upstream_ip_hash_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_LEAST_CONN),y)
-    ADDITIONAL_MODULES += --without-http_upstream_least_conn_module
-  endif
-  ifneq ($(CONFIG_NGINX_HTTP_UPSTREAM_KEEPALIVE),y)
-    ADDITIONAL_MODULES += --without-http_upstream_keepalive_module
-  endif
-  ifeq ($(CONFIG_IPV6),y)
-    ADDITIONAL_MODULES += --with-ipv6
-  endif
-  ifeq ($(CONFIG_NGINX_STUB_STATUS),y)
-    ADDITIONAL_MODULES += --with-http_stub_status_module
-  endif
-  ifeq ($(CONFIG_NGINX_FLV),y)
-    ADDITIONAL_MODULES += --with-http_flv_module
-  endif
-  ifeq ($(CONFIG_NGINX_DAV),y)
-    ADDITIONAL_MODULES += --with-http_dav_module
-  endif
-  ifeq ($(CONFIG_NGINX_HTTP_AUTH_REQUEST),y)
-    ADDITIONAL_MODULES += --with-http_auth_request_module
-  endif
-  ifeq ($(CONFIG_NGINX_HTTP_V2),y)
-    ADDITIONAL_MODULES += --with-http_v2_module
-  endif
-  ifeq ($(CONFIG_NGINX_HTTP_REAL_IP),y)
-    ADDITIONAL_MODULES += --with-http_realip_module
-  endif
-  ifeq ($(CONFIG_NGINX_HTTP_SECURE_LINK),y)
-    ADDITIONAL_MODULES += --with-http_secure_link_module
-  endif
-  ifeq ($(CONFIG_NGINX_HTTP_SUB),y)
-       ADDITIONAL_MODULES += --with-http_sub_module
-  endif
-else
-  ADDITIONAL_MODULES += --with-ipv6 --with-http_stub_status_module --with-http_flv_module \
-       --with-http_dav_module \
-       --with-http_auth_request_module --with-http_v2_module --with-http_realip_module \
-       --with-http_secure_link_module --with-http_sub_module \
-  config_files += koi-utf koi-win win-utf fastcgi_params uwsgi_params
-endif
-
-ifneq ($(CONFIG_PACKAGE_nginx-mod-naxsi),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_src
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-lua),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/lua-nginx
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-dav-ext),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-dav-ext-module
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-stream),)
-  ADDITIONAL_MODULES += --with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-ubus),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-ubus-module
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-headers-more),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-headers-more
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-brotli),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-brotli
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-rtmp),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-rtmp
-endif
-ifneq ($(CONFIG_PACKAGE_nginx-mod-ts),)
-  ADDITIONAL_MODULES += --add-dynamic-module=$(PKG_BUILD_DIR)/nginx-ts
-endif
-ifeq ($(CONFIG_NGINX_GEOIP_MODULE),y)
-  ADDITIONAL_MODULES += --with-http_geoip_module=dynamic
-endif
-
 define Package/nginx-mod-luci
   TITLE:=Nginx on LuCI
   SECTION:=net
@@ -295,7 +181,7 @@ define Package/nginx-mod-luci
   SUBMENU:=Web Servers/Proxies
   TITLE:=Support file for Nginx
   URL:=http://nginx.org/
-  DEPENDS:=+uwsgi +uwsgi-luci-support +nginx +nginx-mod-ubus
+  DEPENDS:=+uwsgi +uwsgi-luci-support +nginx-ssl +nginx-mod-ubus
   # TODO: add PROVIDES when removing nginx-mod-luci-ssl
   # PROVIDES:=nginx-mod-luci-ssl
 endef
@@ -304,119 +190,6 @@ define Package/nginx-mod-luci/description
  Support file for LuCI in nginx. Include custom nginx configuration, autostart script for uwsgi.
 endef
 
-NGINX_MODULES :=
-
-# $(1) module name
-# $(2) module additional dependency
-# $(3) module so name (stripped of the finaly _module.so)
-# $(4) module description
-define module
-  define Package/nginx-mod-$(strip $(1))
-       $(call Package/nginx/default)
-       DEPENDS:=+nginx-ssl $(2)
-       TITLE:=Nginx $(1) module
-  endef
-
-  define Package/nginx-mod-$(strip $(1))/description
-   $(4)
-  endef
-
-  define Package/nginx-mod-$(strip $(1))/install
-       $(INSTALL_DIR) $$(1)/usr/lib/nginx/modules
-       $(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/lib/nginx/modules/$(3)_module.so $$(1)/usr/lib/nginx/modules
-  endef
-
-  NGINX_MODULES += nginx-mod-$(strip $(1))
-endef
-
-define brotli
-  define Package/nginx-mod-brotli
-       $(call Package/nginx/default)
-       DEPENDS:=+nginx-ssl
-       TITLE:=Nginx Brotli module
-  endef
-
-  define Package/nginx-mod-brotli/description
-   Add support for brotli compression module.
-  endef
-
-  define Package/nginx-mod-brotli/install
-       $(INSTALL_DIR) $$(1)/usr/lib/nginx/modules
-       $(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/lib/nginx/modules/ngx_http_brotli_filter_module.so $$(1)/usr/lib/nginx/modules
-       $(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/lib/nginx/modules/ngx_http_brotli_static_module.so $$(1)/usr/lib/nginx/modules
-  endef
-
-  NGINX_MODULES += nginx-mod-brotli
-endef
-
-define naxsi
-  define Package/nginx-mod-naxsi
-       $(call Package/nginx/default)
-       DEPENDS:=+nginx-ssl
-       TITLE:=Nginx naxsi module
-  endef
-
-  define Package/nginx-mod-naxsi/description
-   Enable NAXSI module.
-  endef
-
-  define Package/nginx-mod-naxsi/install
-       $(INSTALL_DIR) $$(1)/usr/lib/nginx/modules
-       $(INSTALL_BIN) $$(PKG_INSTALL_DIR)/usr/lib/nginx/modules/ngx_http_naxsi_module.so $$(1)/usr/lib/nginx/modules
-
-       $(INSTALL_DIR) $$(1)/etc/nginx
-       $(INSTALL_BIN) $$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $$(1)/etc/nginx
-       chmod 0640 $$(1)/etc/nginx/naxsi_core.rules
-
-       $(INSTALL_BIN) $$(PKG_BUILD_DIR)/nginx-naxsi/naxsi_config/naxsi_core.rules $$(1)/etc/nginx
-       chmod 0640 $$(1)/etc/nginx/naxsi_core.rules
-  endef
-
-  NGINX_MODULES += nginx-mod-naxsi
-endef
-
-$(eval $(call module,lua, +luajit,ngx_http_lua, Enable Lua module))
-$(eval $(call module,stream, +@NGINX_STREAM_CORE_MODULE,ngx_stream, Add support for NGINX request streaming.))
-$(eval $(call module,ubus, +libubus +libjson-c +libblobmsg-json +@NGINX_UBUS,ngx_http_ubus, Enable UBUS api support directly from the server.))
-$(eval $(call module,dav-ext, +@NGINX_DAV +libxml2,ngx_http_dav_ext, Enable the WebDAV methods PROPFIND OPTIONS LOCK UNLOCK.))
-$(eval $(call module,headers-more,,ngx_http_headers_more_filter, Set and clear input and output headers...more than "add"!))
-$(eval $(call module,rtmp,,ngx_rtmp, Add support for NGINX-based Media Streaming Server module. \
-               DASH enhanced - https://github.com/ut0mt8/nginx-rtmp-module))
-$(eval $(call module, ts,,ngx_http_ts, Add support for MPEG-TS Live Module module.))
-$(eval $(call brotli))
-$(eval $(call naxsi))
-
-PKG_CONFIG_DEPENDS += $(patsubst %,CONFIG_PACKAGE_%,$(NGINX_MODULES))
-
-TARGET_CFLAGS += -DNGX_LUA_NO_BY_LUA_BLOCK
-
-ifneq ($(CONFIG_PACKAGE_nginx-mod-lua),)
-  CONFIGURE_VARS += LUAJIT_INC=$(STAGING_DIR)/usr/include/luajit-* \
-                                       LUAJIT_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 \
-                       --modules-path=/usr/lib/nginx/modules \
-                       --with-compat \
-                       $(ADDITIONAL_MODULES) \
-                       --error-log-path=stderr \
-                       --pid-path=/var/run/nginx.pid \
-                       --lock-path=/var/lock/nginx.lock \
-                       --http-log-path=/var/log/nginx/access.log \
-                       --http-client-body-temp-path=/var/lib/nginx/body \
-                       --http-proxy-temp-path=/var/lib/nginx/proxy \
-                       --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
-                       --with-cc="$(TARGET_CC)" \
-                       --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
-                       --with-ld-opt="$(TARGET_LDFLAGS)" \
-                       --without-http_upstream_zone_module \
-                       --without-pcre2
-
 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/
@@ -424,162 +197,98 @@ define Package/nginx-mod-luci/install
        $(INSTALL_BIN) ./files-luci-support/60_nginx-luci-support $(1)/etc/uci-defaults/60_nginx-luci-support
 endef
 
-define Package/nginx-ssl/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_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
-endef
-
-Package/nginx-full/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-full/prerm = $(Package/nginx-ssl/prerm)
-
-define Download/nginx-headers-more
+define Download/nginx-mod-headers-more
   VERSION:=bea1be3bbf6af28f6aa8cf0c01c07ee1637e2bd0
-  SUBDIR:=nginx-headers-more
-  FILE:=headers-more-nginx-module-$$(VERSION).tar.xz
   URL:=https://github.com/openresty/headers-more-nginx-module.git
   MIRROR_HASH:=3617bbf7a935208a1d8d5f86a8f9b770f6987e4d2b5663a9ab1b777217e3066b
   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
+define Download/nginx-mod-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
+define Download/nginx-mod-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
+define Download/nginx-mod-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
+define Download/nginx-mod-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
+define Download/nginx-mod-lua
   VERSION:=68acad14e4a8f42e31d4a4bb5ed44d6f5b55fc1c
-  SUBDIR:=lua-nginx
-  FILE:=lua-nginx-module-$$(VERSION).tar.xz
   URL:=https://github.com/openresty/lua-nginx-module.git
   MIRROR_HASH:=366f24e1ba6221e34f6ba20ab29146438438f88c89fd71f9500d169b3f5aedf0
   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
+define Download/nginx-mod-dav-ext
   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
+define Download/nginx-mod-ubus
   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)
+define Module/Download
+  define Download/nginx-mod-$(1) +=
+
+    SUBDIR:=nginx-mod-$(1)
+    FILE:=nginx-mod-$(1)-$$$$(VERSION).tar.xz
+  endef
+endef
+$(foreach m,$(PKG_MOD_EXTRA),$(eval $(call Module/Download,$(m))))
+
+define Module/nginx-mod-naxsi/install
+       $(INSTALL_DIR) $(1)/etc/nginx
+       $(INSTALL_CONF) $(PKG_BUILD_DIR)/nginx-mod-naxsi/naxsi_config/naxsi_core.rules $(1)/etc/nginx
+endef
+
+define Quilt/Refresh/Package
+       $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/nginx,nginx/)
+       $(foreach m,$(PKG_MOD_PATCHED),
+               $(call Quilt/RefreshDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/nginx-mod-$(m),nginx-mod-$(m)/)
+       )
 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_PACKAGE_nginx-mod-dav-ext),$(QUILT))" ""
-       $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/dav-nginx,dav-nginx/)
-endif
-ifneq "$(or $(CONFIG_PACKAGE_nginx-mod-lua),$(QUILT))" ""
-       $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/lua-nginx,lua-nginx/)
-endif
-ifneq "$(or $(CONFIG_PACKAGE_nginx-mod-rtmp),$(QUILT))" ""
-       $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/rtmp-nginx,rtmp-nginx/)
-endif
+       $(foreach m,$(PKG_MOD_PATCHED),$(if $(or $(CONFIG_PACKAGE_nginx-mod-$(m)),$(QUILT)),
+               $(call PatchDir,$(PKG_BUILD_DIR),$(PATCH_DIR)/nginx-mod-$(m),nginx-mod-$(m)/)
+       ))
        $(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/)
+define Module/Build/Prepare
+       $(eval $(call Download,nginx-mod-$(1)))
+       $(eval $(Download/nginx-mod-$(1)))
+       mkdir -p $(PKG_BUILD_DIR)/nginx-mod-$(1)
+       xzcat $(DL_DIR)/$(FILE) | tar -C $(PKG_BUILD_DIR)/nginx-mod-$(1) $(TAR_OPTIONS) --strip-components 1
 endef
 
 define Build/Prepare
@@ -587,54 +296,132 @@ define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        $(PKG_UNPACK)
 
-ifneq ($(CONFIG_PACKAGE_nginx-mod-naxsi),)
-  $(eval $(call Download,nginx-naxsi))
-  $(Prepare/nginx-naxsi)
-endif
+       $(foreach m,$(filter-out $(PKG_MOD_PATCHED),$(PKG_MOD_EXTRA)),$(if $(CONFIG_PACKAGE_nginx-mod-$(m)),
+               $(call Module/Build/Prepare,$(m))
+       ))
+       $(foreach m,$(PKG_MOD_PATCHED),$(if $(or $(CONFIG_PACKAGE_nginx-mod-$(m)),$(QUILT)),
+               $(call Module/Build/Prepare,$(m))
+       ))
+       $(Build/Patch)
+endef
 
-ifneq "$(or $(CONFIG_PACKAGE_nginx-mod-lua),$(QUILT))" ""
-  $(eval $(call Download,lua-nginx))
-  $(Prepare/lua-nginx)
-endif
+# $(1) module name
+# $(2) module additional dependency
+# $(3) module so name (stripped of the finaly _module.so)
+# $(4) module description
+define BuildModule
+  define Package/nginx-mod-$(1)
+    $(call Package/nginx/default)
+    DEPENDS:=+nginx-ssl $(2)
+    TITLE:=Nginx $(1) module
+  endef
 
-ifneq ($(CONFIG_PACKAGE_nginx-mod-brotli),)
-  $(eval $(call Download,nginx-brotli))
-  $(Prepare/nginx-brotli)
-endif
+  define Package/nginx-mod-$(1)/description
+    $(strip $(4))
+  endef
 
-ifneq ($(CONFIG_PACKAGE_nginx-mod-headers-more),)
-  $(eval $(call Download,nginx-headers-more))
-  $(Prepare/nginx-headers-more)
-endif
+  define Package/nginx-mod-$(1)/install
+       $(INSTALL_DIR) $$(1)/usr/lib/nginx/modules
+       $(foreach m,$(3),
+         $(CP) $$(PKG_INSTALL_DIR)/usr/lib/nginx/modules/$(m)_module.so $$(1)/usr/lib/nginx/modules
+       )
+       $(call Module/nginx-mod-$(1)/install,$$(1))
+  endef
 
-ifneq "$(or $(CONFIG_PACKAGE_nginx-mod-rtmp),$(QUILT))" ""
-  $(eval $(call Download,nginx-rtmp))
-  $(Prepare/nginx-rtmp)
-endif
+  $$(eval $$(call BuildPackage,nginx-mod-$(1)))
+endef
 
-ifneq ($(CONFIG_PACKAGE_nginx-mod-ts),)
-  $(eval $(call Download,nginx-ts))
-  $(Prepare/nginx-ts)
-endif
+TARGET_CFLAGS += -DNGX_LUA_NO_BY_LUA_BLOCK
 
-ifneq "$(or $(CONFIG_PACKAGE_nginx-mod-dav-ext),$(QUILT))" ""
-  $(eval $(call Download,nginx-dav-ext-module))
-  $(Prepare/nginx-dav-ext-module)
+ifneq ($(CONFIG_PACKAGE_nginx-mod-lua),)
+  CONFIGURE_VARS += LUAJIT_INC=$(STAGING_DIR)/usr/include/luajit-* \
+                                       LUAJIT_LIB=$(STAGING_DIR)/usr/lib
 endif
 
-ifneq ($(CONFIG_PACKAGE_nginx-mod-ubus),)
-  $(eval $(call Download,nginx-ubus-module))
-  $(Prepare/nginx-ubus-module)
-endif
+CONFIGURE_VARS += CONFIG_BIG_ENDIAN=$(CONFIG_BIG_ENDIAN)
 
-       $(Build/Patch)
-endef
+CONFIGURE_ARGS += \
+       --crossbuild=Linux::$(ARCH) \
+       --prefix=/usr \
+       --conf-path=/etc/nginx/nginx.conf \
+       --modules-path=/usr/lib/nginx/modules \
+       --error-log-path=stderr \
+       --pid-path=/var/run/nginx.pid \
+       --lock-path=/var/lock/nginx.lock \
+       --http-log-path=/var/log/nginx/access.log \
+       --http-client-body-temp-path=/var/lib/nginx/body \
+       --http-proxy-temp-path=/var/lib/nginx/proxy \
+       --http-fastcgi-temp-path=/var/lib/nginx/fastcgi \
+       --with-cc="$(TARGET_CC)" \
+       --with-cc-opt="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
+       --with-ld-opt="$(TARGET_LDFLAGS)" \
+       --without-http_upstream_zone_module \
+       --without-pcre2 \
+       --with-compat \
+       --with-http_ssl_module \
+       $(if $(call IsDisabled,NGINX_HTTP_CACHE),--without-http-cache) \
+       $(if $(call IsDisabled,NGINX_PCRE),--without-pcre) \
+       $(if $(call IsDisabled,NGINX_HTTP_CHARSET),--without-http_charset_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_GZIP),--without-http_gzip_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_SSI),--without-http_ssi_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_USERID),--without-http_userid_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_ACCESS),--without-http_access_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_AUTH_BASIC),--without-http_auth_basic_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_AUTOINDEX),--without-http_autoindex_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_GEO),--without-http_geo_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_MAP),--without-http_map_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_SPLIT_CLIENTS),--without-http_split_clients_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_REFERER),--without-http_referer_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_REWRITE),--without-http_rewrite_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_PROXY),--without-http_proxy_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_FASTCGI),--without-http_fastcgi_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_UWSGI),--without-http_uwsgi_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_SCGI),--without-http_scgi_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_MEMCACHED),--without-http_memcached_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_LIMIT_CONN),--without-http_limit_conn_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_LIMIT_REQ),--without-http_limit_req_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_EMPTY_GIF),--without-http_empty_gif_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_BROWSER),--without-http_browser_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_UPSTREAM_HASH),--without-http_upstream_hash_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_UPSTREAM_IP_HASH),--without-http_upstream_ip_hash_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_UPSTREAM_LEAST_CONN),--without-http_upstream_least_conn_module) \
+       $(if $(call IsDisabled,NGINX_HTTP_UPSTREAM_KEEPALIVE),--without-http_upstream_keepalive_module) \
+       $(if $(call IsEnabled,IPV6),--with-ipv6) \
+       $(if $(call IsEnabled,NGINX_HTTP_GZIP_STATIC),--with-http_gzip_static_module) \
+       $(if $(call IsEnabled,NGINX_STUB_STATUS),--with-http_stub_status_module) \
+       $(if $(call IsEnabled,NGINX_FLV),--with-http_flv_module) \
+       $(if $(call IsEnabled,NGINX_DAV),--with-http_dav_module) \
+       $(if $(call IsEnabled,NGINX_HTTP_AUTH_REQUEST),--with-http_auth_request_module) \
+       $(if $(call IsEnabled,NGINX_HTTP_V2),--with-http_v2_module) \
+       $(if $(call IsEnabled,NGINX_HTTP_REAL_IP),--with-http_realip_module) \
+       $(if $(call IsEnabled,NGINX_HTTP_SECURE_LINK),--with-http_secure_link_module) \
+       $(if $(call IsEnabled,NGINX_HTTP_SUB),--with-http_sub_module) \
+       $(if $(CONFIG_PACKAGE_nginx-mod-stream),--with-stream=dynamic --with-stream_ssl_module --with-stream_ssl_preread_module) \
+       $(if $(CONFIG_PACKAGE_nginx-mod-naxsi),--add-dynamic-module=$(PKG_BUILD_DIR)/nginx-mod-naxsi/naxsi_src) \
+       $(foreach m,$(filter-out naxsi,$(PKG_MOD_EXTRA)), \
+               $(if $(CONFIG_PACKAGE_nginx-mod-$(m)),--add-dynamic-module=$(PKG_BUILD_DIR)/nginx-mod-$(m)))
 
 $(eval $(call BuildPackage,nginx-ssl))
 $(eval $(call BuildPackage,nginx-full))
 $(eval $(call BuildPackage,nginx-mod-luci))
-
-$(foreach m,$(NGINX_MODULES),$(eval $(call BuildPackage,$(m))))
+$(eval $(call BuildModule,stream,+@NGINX_STREAM_CORE_MODULE, \
+       ngx_stream, Add support for NGINX request streaming.))
+$(eval $(call BuildModule,lua,+luajit,ngx_http_lua, \
+       Enable Lua module))
+$(eval $(call BuildModule,ubus,+libubus +libjson-c +libblobmsg-json +@NGINX_UBUS, \
+       ngx_http_ubus,Enable UBUS api support directly from the server.))
+$(eval $(call BuildModule,dav-ext,+@NGINX_DAV +libxml2,ngx_http_dav_ext, \
+       Enable the WebDAV methods PROPFIND OPTIONS LOCK UNLOCK.))
+$(eval $(call BuildModule,headers-more,,ngx_http_headers_more_filter, \
+       Set and clear input and output headers...more than "add"!))
+$(eval $(call BuildModule,rtmp,,ngx_rtmp, \
+       Add support for NGINX-based Media Streaming Server module. DASH enhanced))
+$(eval $(call BuildModule,ts,,ngx_http_ts, \
+       Add support for MPEG-TS Live Module module.))
+$(eval $(call BuildModule,brotli,,ngx_http_brotli_filter ngx_http_brotli_static, \
+       Add support for brotli compression module.))
+$(eval $(call BuildModule,naxsi,,ngx_http_naxsi, \
+       Enable NAXSI module.))
 
 # 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
diff --git a/net/nginx/patches/dav-nginx/100-drop-libxslt-dep.patch b/net/nginx/patches/dav-nginx/100-drop-libxslt-dep.patch
deleted file mode 100644 (file)
index aa06f04..0000000
+++ /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/net/nginx/patches/lua-nginx/100-no_by_lua_block.patch b/net/nginx/patches/lua-nginx/100-no_by_lua_block.patch
deleted file mode 100644 (file)
index 1b4d1fe..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
---- a/lua-nginx/src/ngx_http_lua_module.c
-+++ b/lua-nginx/src/ngx_http_lua_module.c
-@@ -207,12 +207,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       offsetof(ngx_http_lua_loc_conf_t, log_socket_errors),
-       NULL },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("init_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_init_by_lua_block,
-       NGX_HTTP_MAIN_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_init_by_inline },
-+#endif
-     { ngx_string("init_by_lua"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
-@@ -228,12 +230,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_init_by_file },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("init_worker_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_init_worker_by_lua_block,
-       NGX_HTTP_MAIN_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_init_worker_by_inline },
-+#endif
-     { ngx_string("init_worker_by_lua"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
-@@ -249,12 +253,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_init_worker_by_file },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("exit_worker_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_exit_worker_by_lua_block,
-       NGX_HTTP_MAIN_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_exit_worker_by_inline },
-+#endif
-     { ngx_string("exit_worker_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
-@@ -264,6 +270,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       (void *) ngx_http_lua_exit_worker_by_file },
- #if defined(NDK) && NDK
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* set_by_lua_block $res { inline Lua code } */
-     { ngx_string("set_by_lua_block"),
-       NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -272,6 +279,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_filter_set_by_lua_inline },
-+#endif
-     /* set_by_lua $res <inline script> [$arg1 [$arg2 [...]]] */
-     { ngx_string("set_by_lua"),
-@@ -292,6 +300,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       (void *) ngx_http_lua_filter_set_by_lua_file },
- #endif
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* server_rewrite_by_lua_block { <inline script> } */
-     { ngx_string("server_rewrite_by_lua_block"),
-         NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-@@ -299,6 +308,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-         NGX_HTTP_SRV_CONF_OFFSET,
-         0,
-         (void *) ngx_http_lua_server_rewrite_handler_inline },
-+#endif
-     /* server_rewrite_by_lua_file filename; */
-     { ngx_string("server_rewrite_by_lua_file"),
-@@ -317,6 +327,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_rewrite_handler_inline },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* rewrite_by_lua_block { <inline script> } */
-     { ngx_string("rewrite_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -325,6 +336,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_rewrite_handler_inline },
-+#endif
-     /* access_by_lua "<inline script>" */
-     { ngx_string("access_by_lua"),
-@@ -335,6 +347,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_access_handler_inline },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* access_by_lua_block { <inline script> } */
-     { ngx_string("access_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -343,6 +356,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_access_handler_inline },
-+#endif
-     /* content_by_lua "<inline script>" */
-     { ngx_string("content_by_lua"),
-@@ -352,6 +366,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_content_handler_inline },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* content_by_lua_block { <inline script> } */
-     { ngx_string("content_by_lua_block"),
-       NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-@@ -359,6 +374,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_content_handler_inline },
-+#endif
-     /* log_by_lua <inline script> */
-     { ngx_string("log_by_lua"),
-@@ -369,6 +385,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_log_handler_inline },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* log_by_lua_block { <inline script> } */
-     { ngx_string("log_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -377,6 +394,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_log_handler_inline },
-+#endif
-     { ngx_string("rewrite_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -433,6 +451,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_header_filter_inline },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* header_filter_by_lua_block { <inline script> } */
-     { ngx_string("header_filter_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -441,6 +460,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_header_filter_inline },
-+#endif
-     { ngx_string("header_filter_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -458,6 +478,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_body_filter_inline },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     /* body_filter_by_lua_block { <inline script> } */
-     { ngx_string("body_filter_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -466,6 +487,7 @@ static ngx_command_t ngx_http_lua_cmds[]
-       NGX_HTTP_LOC_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_body_filter_inline },
-+#endif
-     { ngx_string("body_filter_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
-@@ -475,12 +497,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_body_filter_file },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("balancer_by_lua_block"),
-       NGX_HTTP_UPS_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_balancer_by_lua_block,
-       NGX_HTTP_SRV_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_balancer_handler_inline },
-+#endif
-     { ngx_string("balancer_by_lua_file"),
-       NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
-@@ -585,12 +609,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       offsetof(ngx_http_lua_loc_conf_t, ssl_ciphers),
-       NULL },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("ssl_client_hello_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_ssl_client_hello_by_lua_block,
-       NGX_HTTP_SRV_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_ssl_client_hello_handler_inline },
-+#endif
-     { ngx_string("ssl_client_hello_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
-@@ -599,12 +625,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_ssl_client_hello_handler_file },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("ssl_certificate_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_ssl_cert_by_lua_block,
-       NGX_HTTP_SRV_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_ssl_cert_handler_inline },
-+#endif
-     { ngx_string("ssl_certificate_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
-@@ -613,12 +641,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_ssl_cert_handler_file },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("ssl_session_store_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_ssl_sess_store_by_lua_block,
-       NGX_HTTP_SRV_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_ssl_sess_store_handler_inline },
-+#endif
-     { ngx_string("ssl_session_store_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
-@@ -627,12 +657,14 @@ static ngx_command_t ngx_http_lua_cmds[]
-       0,
-       (void *) ngx_http_lua_ssl_sess_store_handler_file },
-+#ifndef NGX_LUA_NO_BY_LUA_BLOCK
-     { ngx_string("ssl_session_fetch_by_lua_block"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
-       ngx_http_lua_ssl_sess_fetch_by_lua_block,
-       NGX_HTTP_SRV_CONF_OFFSET,
-       0,
-       (void *) ngx_http_lua_ssl_sess_fetch_handler_inline },
-+#endif
-     { ngx_string("ssl_session_fetch_by_lua_file"),
-       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
diff --git a/net/nginx/patches/nginx-mod-dav-ext/100-drop-libxslt-dep.patch b/net/nginx/patches/nginx-mod-dav-ext/100-drop-libxslt-dep.patch
new file mode 100644 (file)
index 0000000..689898d
--- /dev/null
@@ -0,0 +1,14 @@
+--- a/nginx-mod-dav-ext/config
++++ b/nginx-mod-dav-ext/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/net/nginx/patches/nginx-mod-lua/100-no_by_lua_block.patch b/net/nginx/patches/nginx-mod-lua/100-no_by_lua_block.patch
new file mode 100644 (file)
index 0000000..b51c5e4
--- /dev/null
@@ -0,0 +1,250 @@
+--- a/nginx-mod-lua/src/ngx_http_lua_module.c
++++ b/nginx-mod-lua/src/ngx_http_lua_module.c
+@@ -207,12 +207,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       offsetof(ngx_http_lua_loc_conf_t, log_socket_errors),
+       NULL },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("init_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_init_by_lua_block,
+       NGX_HTTP_MAIN_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_init_by_inline },
++#endif
+     { ngx_string("init_by_lua"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+@@ -228,12 +230,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_init_by_file },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("init_worker_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_init_worker_by_lua_block,
+       NGX_HTTP_MAIN_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_init_worker_by_inline },
++#endif
+     { ngx_string("init_worker_by_lua"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+@@ -249,12 +253,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_init_worker_by_file },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("exit_worker_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_exit_worker_by_lua_block,
+       NGX_HTTP_MAIN_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_exit_worker_by_inline },
++#endif
+     { ngx_string("exit_worker_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+@@ -264,6 +270,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       (void *) ngx_http_lua_exit_worker_by_file },
+ #if defined(NDK) && NDK
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* set_by_lua_block $res { inline Lua code } */
+     { ngx_string("set_by_lua_block"),
+       NGX_HTTP_SRV_CONF|NGX_HTTP_SIF_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -272,6 +279,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_filter_set_by_lua_inline },
++#endif
+     /* set_by_lua $res <inline script> [$arg1 [$arg2 [...]]] */
+     { ngx_string("set_by_lua"),
+@@ -292,6 +300,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       (void *) ngx_http_lua_filter_set_by_lua_file },
+ #endif
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* server_rewrite_by_lua_block { <inline script> } */
+     { ngx_string("server_rewrite_by_lua_block"),
+         NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+@@ -299,6 +308,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+         NGX_HTTP_SRV_CONF_OFFSET,
+         0,
+         (void *) ngx_http_lua_server_rewrite_handler_inline },
++#endif
+     /* server_rewrite_by_lua_file filename; */
+     { ngx_string("server_rewrite_by_lua_file"),
+@@ -317,6 +327,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_rewrite_handler_inline },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* rewrite_by_lua_block { <inline script> } */
+     { ngx_string("rewrite_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -325,6 +336,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_rewrite_handler_inline },
++#endif
+     /* access_by_lua "<inline script>" */
+     { ngx_string("access_by_lua"),
+@@ -335,6 +347,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_access_handler_inline },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* access_by_lua_block { <inline script> } */
+     { ngx_string("access_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -343,6 +356,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_access_handler_inline },
++#endif
+     /* content_by_lua "<inline script>" */
+     { ngx_string("content_by_lua"),
+@@ -352,6 +366,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_content_handler_inline },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* content_by_lua_block { <inline script> } */
+     { ngx_string("content_by_lua_block"),
+       NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+@@ -359,6 +374,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_content_handler_inline },
++#endif
+     /* log_by_lua <inline script> */
+     { ngx_string("log_by_lua"),
+@@ -369,6 +385,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_log_handler_inline },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* log_by_lua_block { <inline script> } */
+     { ngx_string("log_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -377,6 +394,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_log_handler_inline },
++#endif
+     { ngx_string("rewrite_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -433,6 +451,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_header_filter_inline },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* header_filter_by_lua_block { <inline script> } */
+     { ngx_string("header_filter_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -441,6 +460,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_header_filter_inline },
++#endif
+     { ngx_string("header_filter_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -458,6 +478,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_body_filter_inline },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     /* body_filter_by_lua_block { <inline script> } */
+     { ngx_string("body_filter_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -466,6 +487,7 @@ static ngx_command_t ngx_http_lua_cmds[]
+       NGX_HTTP_LOC_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_body_filter_inline },
++#endif
+     { ngx_string("body_filter_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_HTTP_LIF_CONF
+@@ -475,12 +497,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_body_filter_file },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("balancer_by_lua_block"),
+       NGX_HTTP_UPS_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_balancer_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_balancer_handler_inline },
++#endif
+     { ngx_string("balancer_by_lua_file"),
+       NGX_HTTP_UPS_CONF|NGX_CONF_TAKE1,
+@@ -585,12 +609,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       offsetof(ngx_http_lua_loc_conf_t, ssl_ciphers),
+       NULL },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("ssl_client_hello_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_ssl_client_hello_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_ssl_client_hello_handler_inline },
++#endif
+     { ngx_string("ssl_client_hello_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+@@ -599,12 +625,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_ssl_client_hello_handler_file },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("ssl_certificate_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_ssl_cert_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_ssl_cert_handler_inline },
++#endif
+     { ngx_string("ssl_certificate_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_CONF_TAKE1,
+@@ -613,12 +641,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_ssl_cert_handler_file },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("ssl_session_store_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_ssl_sess_store_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_ssl_sess_store_handler_inline },
++#endif
+     { ngx_string("ssl_session_store_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
+@@ -627,12 +657,14 @@ static ngx_command_t ngx_http_lua_cmds[]
+       0,
+       (void *) ngx_http_lua_ssl_sess_store_handler_file },
++#ifndef NGX_LUA_NO_BY_LUA_BLOCK
+     { ngx_string("ssl_session_fetch_by_lua_block"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_NOARGS,
+       ngx_http_lua_ssl_sess_fetch_by_lua_block,
+       NGX_HTTP_SRV_CONF_OFFSET,
+       0,
+       (void *) ngx_http_lua_ssl_sess_fetch_handler_inline },
++#endif
+     { ngx_string("ssl_session_fetch_by_lua_file"),
+       NGX_HTTP_MAIN_CONF|NGX_CONF_TAKE1,
diff --git a/net/nginx/patches/nginx-mod-rtmp/100-bigedian.patch b/net/nginx/patches/nginx-mod-rtmp/100-bigedian.patch
new file mode 100644 (file)
index 0000000..b7b78fc
--- /dev/null
@@ -0,0 +1,1521 @@
+From 5b06d1cad5f6711667038169b7ed759d749334da Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Jan=20Bub=C3=ADk?= <jan.bubik@technodat.cz>
+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-mod-rtmp/ngx_rtmp.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp.h
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_amf.c
++++ b/nginx-mod-rtmp/ngx_rtmp_amf.c
+@@ -10,23 +10,6 @@
+ #include "ngx_rtmp.h"
+ #include <string.h>
+-
+-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-mod-rtmp/ngx_rtmp_flv_module.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_handler.c
++++ b/nginx-mod-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*)&timestamp;
+-                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*)&timestamp;
+-               /* 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*)&timestamp;
+-        *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-mod-rtmp/ngx_rtmp_send.c
++++ b/nginx-mod-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-mod-rtmp/hls/ngx_rtmp_hls_module.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_bitop.h
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_eval.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_handshake.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_mp4_module.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_receive.c
++++ b/nginx-mod-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-mod-rtmp/ngx_rtmp_record_module.c
++++ b/nginx-mod-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 *) &timestamp;
+-        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*)&timestamp;
+-    *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/net/nginx/patches/rtmp-nginx/100-bigedian.patch b/net/nginx/patches/rtmp-nginx/100-bigedian.patch
deleted file mode 100644 (file)
index c0a07bc..0000000
+++ /dev/null
@@ -1,1521 +0,0 @@
-From 5b06d1cad5f6711667038169b7ed759d749334da Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?Jan=20Bub=C3=ADk?= <jan.bubik@technodat.cz>
-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 <string.h>
--
--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*)&timestamp;
--                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*)&timestamp;
--               /* 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*)&timestamp;
--        *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 *) &timestamp;
--        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*)&timestamp;
--    *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)
index e71978a8e1f569e3bfa45efd47065997f7725b39..0199bd150ed81fd1005c83787102378bc579a3d8 100644 (file)
@@ -8,12 +8,12 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=tailscale
-PKG_VERSION:=1.40.1
+PKG_VERSION:=1.42.0
 PKG_RELEASE:=1
 
 PKG_SOURCE:=tailscale-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=https://codeload.github.com/tailscale/tailscale/tar.gz/v$(PKG_VERSION)?
-PKG_HASH:=9c0a9648c921f695fc501536e69c8b4998d318256c8049de538f72fbe1491c18
+PKG_HASH:=09de9bacda98de8d733cff162572b7eac857d13db783776ba2a2450a44ecc5e9
 
 PKG_MAINTAINER:=Jan Pavlinec <jan.pavlinec1@gmail.com>
 PKG_LICENSE:=BSD-3-Clause
index 2874f53b0798c0d69d306ad9244c88d17e26f17e..ca7086ed8e6e515bb7896f3b50fe608804b03f9c 100644 (file)
@@ -7,8 +7,8 @@
 +replace github.com/coreos/go-iptables => ./patched/go-iptables
 +
  require (
-       filippo.io/mkcert v1.4.3
-       github.com/Microsoft/go-winio v0.6.0
+       filippo.io/mkcert v1.4.4
+       github.com/Microsoft/go-winio v0.6.1
 --- a/patched/go-iptables/iptables/iptables.go
 +++ b/patched/go-iptables/iptables/iptables.go
 @@ -149,12 +149,39 @@ func New(opts ...option) (*IPTables, err