omcproxy: fix compilation on little-endian CPUs

This commit is contained in:
CN_SZTL 2019-08-16 13:47:10 +08:00
parent c0e02c9bad
commit a8b6c28650
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
4 changed files with 77 additions and 65 deletions

10
package/network/services/omcproxy/Makefile Executable file → Normal file
View File

@ -8,13 +8,13 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=omcproxy
PKG_RELEASE:=8
PKG_RELEASE:=5
PKG_SOURCE_URL:=https://github.com/sbyx/omcproxy.git
PKG_SOURCE_PROTO:=git
PKG_SOURCE_URL=$(PROJECT_GIT)/project/omcproxy.git
PKG_SOURCE_DATE:=2018-12-14
PKG_SOURCE_VERSION:=722151f04348cf1b759613c087bced52fb45790a
PKG_MIRROR_HASH:=4d218923c149e2dc9010b8932ea92ab7e06f30df06814ffedaba7e081f2d4640
PKG_SOURCE_DATE:=2017-02-14
PKG_SOURCE_VERSION:=1fe6f48f8a5067685cbcf6427baf1b3e8b889da1
PKG_MIRROR_HASH:=b5a5e09149bd08a945ada8a29a30c3e42834524747d7fd0911717f5a0ec59c72
PKG_MAINTAINER:=Steven Barth <cyrus@openwrt.org>
PKG_LICENSE:=Apache-2.0

View File

97
package/network/services/omcproxy/files/omcproxy.init Executable file → Normal file
View File

@ -1,74 +1,55 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2018 OpenWrt.org
# Copyright (C) 2010-2014 OpenWrt.org
START=99
USE_PROCD=1
PROG=/usr/sbin/omcproxy
# Uncomment to enable verbosity
#OPTIONS="-v"
# Uncomment to enable verbosity
#OPTIONS="-v"
PROXIES=""
omcproxy_add_proxy() {
local proxy scope uplink updevice downlinks
local uplink downlink scope proxy
config_get uplink $1 uplink
[ -n "$uplink" ] || return
config_get downlink $1 downlink
config_get scope $1 scope
network_get_device updevice "$uplink" || {
procd_append_param error "$uplink is not up"
return;
}
proxy=""
config_get downlinks $1 downlink
for downlink in $downlinks; do
local device
network_get_device updev $uplink
[ -n "$updev" ] || return 0
network_get_device device "$downlink" || {
procd_append_param error "$downlink is not up"
continue;
}
for network in $downlink; do
network_get_device downdev $network
[ -n "$downdev" ] && proxy="$proxy,$downdev"
proxy="$proxy,$device"
# Disable in-kernel querier while ours is active, default is 1.
[ -f /sys/class/net/$device/bridge/multicast_querier ] && \
echo 0 > /sys/class/net/$device/bridge/multicast_querier
# Disable in-kernel querier while ours is active
[ -f /sys/class/net/$downdev/bridge/multicast_querier ] && \
echo 0 > /sys/class/net/$downdev/bridge/multicast_querier
done
[ -n "$proxy" ] || return 0
config_get scope $1 scope
[ -n "$scope" ] && proxy="$proxy,scope=$scope"
PROXIES="$PROXIES $updevice$proxy"
PROXIES="$PROXIES $updev$proxy"
}
omcproxy_add_network_triggers() {
local uplink downlinks
omcproxy_add_trigger() {
local uplink downlink
config_get uplink $1 uplink
config_get downlinks $1 downlink
config_get downlink $1 downlink
for link in $uplink $downlinks; do
local duplicate=0
for l in $LINKS; do
[ "$l" = "$link" ] && duplicate=1
done
[ "$duplicate" = 0 ] && {
LINKS="$LINKS $link"
procd_add_interface_trigger "interface.*" $link /etc/init.d/omcproxy restart
}
for network in $uplink $downlink; do
procd_add_interface_trigger "interface.*" $network /etc/init.d/omcproxy restart
done
}
omcproxy_add_firewall_rules() {
local uplink downlinks
omcproxy_add_firewall() {
config_get uplink $1 uplink
config_get downlinks $1 downlink
config_get downlink $1 downlink
upzone=$(fw3 -q network $uplink 2>/dev/null)
[ -n "$upzone" ] || return 0
@ -76,7 +57,6 @@ omcproxy_add_firewall_rules() {
json_add_object ""
json_add_string type rule
json_add_string src "$upzone"
json_add_string family ipv4
json_add_string proto igmp
json_add_string target ACCEPT
json_close_object
@ -96,8 +76,8 @@ omcproxy_add_firewall_rules() {
json_add_string target ACCEPT
json_close_object
for downlink in $downlinks; do
downzone=$(fw3 -q network $downlink 2>/dev/null)
for network in $downlink; do
downzone=$(fw3 -q network $network 2>/dev/null)
[ -n "$downzone" ] || continue
json_add_object ""
@ -105,7 +85,7 @@ omcproxy_add_firewall_rules() {
json_add_string src "$upzone"
json_add_string dest "$downzone"
json_add_string family ipv4
json_add_string proto udp
json_add_string proto any
json_add_string dest_ip "224.0.0.0/4"
json_add_string target ACCEPT
json_close_object
@ -115,7 +95,7 @@ omcproxy_add_firewall_rules() {
json_add_string src "$upzone"
json_add_string dest "$downzone"
json_add_string family ipv6
json_add_string proto udp
json_add_string proto any
json_add_string dest_ip "ff00::/8"
json_add_string target ACCEPT
json_close_object
@ -123,18 +103,15 @@ omcproxy_add_firewall_rules() {
}
service_triggers() {
LINKS=""
procd_add_reload_trigger "omcproxy"
config_foreach omcproxy_add_network_triggers proxy
}
start_service() {
. /lib/functions/network.sh
include /lib/functions
config_load omcproxy
config_foreach omcproxy_add_proxy proxy
[ -n "$PROXIES" ] || return 0
procd_open_instance
@ -143,24 +120,24 @@ start_service() {
procd_append_param command $PROXIES
procd_set_param respawn
procd_open_trigger
config_foreach omcproxy_add_trigger proxy
procd_close_trigger
procd_open_data
json_add_array firewall
config_foreach omcproxy_add_firewall_rules proxy
config_foreach omcproxy_add_firewall proxy
json_close_array
procd_close_data
procd_close_instance
# Increase maximum IPv4 group memberships per socket, default is 100.
# Increase maximum IPv4 group memberships per socket
echo 128 > /proc/sys/net/ipv4/igmp_max_memberships
}
service_started() {
procd_set_config_changed firewall
}
stop_service() {
procd_set_config_changed firewall
}

View File

@ -0,0 +1,35 @@
From 721064f2eb1dabe5bda63dcaff249b73ab891e6c Mon Sep 17 00:00:00 2001
From: Eneas U de Queiroz <cote2004-github@yahoo.com>
Date: Fri, 14 Dec 2018 15:13:41 -0200
Subject: [PATCH] mrib.c: don't use cpu_to_be32 outside of function
cpu_to_be32 is not a constant, so it can't be used outside of a
function.
Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
--- a/src/mrib.c
+++ b/src/mrib.c
@@ -21,6 +21,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <endian.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <unistd.h>
@@ -54,7 +55,13 @@ struct mrib_iface {
struct uloop_timeout timer;
};
-static uint32_t ipv4_rtr_alert = cpu_to_be32(0x94040000);
+/* we can't use cpu_to_be32 outside a function */
+#if __BYTE_ORDER == __BIG_ENDIAN
+static uint32_t ipv4_rtr_alert = 0x94040000;
+#else
+static uint32_t ipv4_rtr_alert = 0x00000494;
+#endif
+
static struct {
struct ip6_hbh hdr;
struct ip6_opt_router rt;