Initial commit

This commit is contained in:
domenico
2025-06-24 15:51:28 +02:00
commit 22031d9dab
6862 changed files with 1462554 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
#
# Copyright (C) 2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=omcproxy
PKG_RELEASE:=5
PKG_SOURCE_URL:=https://github.com/sbyx/omcproxy.git
PKG_SOURCE_PROTO:=git
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
include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/cmake.mk
define Package/omcproxy
SECTION:=net
CATEGORY:=Network
DEPENDS:=+libubox +libubus
TITLE:=IGMPv3 and MLDv2 Multicast Proxy
endef
CMAKE_OPTIONS += -DWITH_LIBUBOX=1
define Package/omcproxy/install
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/omcproxy.config $(1)/etc/config/omcproxy
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/omcproxy.init $(1)/etc/init.d/omcproxy
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/omcproxy $(1)/usr/sbin/
endef
$(eval $(call BuildPackage,omcproxy))

View File

@@ -0,0 +1,9 @@
config proxy
option scope global
option uplink wan
list downlink lan
config proxy
option scope global
option uplink wan6
list downlink lan

View File

@@ -0,0 +1,143 @@
#!/bin/sh /etc/rc.common
# Copyright (C) 2010-2014 OpenWrt.org
START=99
USE_PROCD=1
PROG=/usr/sbin/omcproxy
# Uncomment to enable verbosity
#OPTIONS="-v"
PROXIES=""
omcproxy_add_proxy() {
local uplink downlink scope proxy
config_get uplink $1 uplink
config_get downlink $1 downlink
config_get scope $1 scope
proxy=""
network_get_device updev $uplink
[ -n "$updev" ] || return 0
for network in $downlink; do
network_get_device downdev $network
[ -n "$downdev" ] && proxy="$proxy,$downdev"
# 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
[ -n "$scope" ] && proxy="$proxy,scope=$scope"
PROXIES="$PROXIES $updev$proxy"
}
omcproxy_add_trigger() {
local uplink downlink
config_get uplink $1 uplink
config_get downlink $1 downlink
for network in $uplink $downlink; do
procd_add_interface_trigger "interface.*" $network /etc/init.d/omcproxy restart
done
}
omcproxy_add_firewall() {
config_get uplink $1 uplink
config_get downlink $1 downlink
upzone=$(fw3 -q network $uplink 2>/dev/null)
[ -n "$upzone" ] || return 0
json_add_object ""
json_add_string type rule
json_add_string src "$upzone"
json_add_string proto igmp
json_add_string target ACCEPT
json_close_object
json_add_object ""
json_add_string type rule
json_add_string family ipv6
json_add_string src "$upzone"
json_add_string proto icmp
json_add_string src_ip fe80::/10
json_add_array icmp_type
json_add_string "" 130/0
json_add_string "" 131/0
json_add_string "" 132/0
json_add_string "" 143/0
json_close_array
json_add_string target ACCEPT
json_close_object
for network in $downlink; do
downzone=$(fw3 -q network $network 2>/dev/null)
[ -n "$downzone" ] || continue
json_add_object ""
json_add_string type rule
json_add_string src "$upzone"
json_add_string dest "$downzone"
json_add_string family ipv4
json_add_string proto any
json_add_string dest_ip "224.0.0.0/4"
json_add_string target ACCEPT
json_close_object
json_add_object ""
json_add_string type rule
json_add_string src "$upzone"
json_add_string dest "$downzone"
json_add_string family ipv6
json_add_string proto any
json_add_string dest_ip "ff00::/8"
json_add_string target ACCEPT
json_close_object
done
}
service_triggers() {
procd_add_reload_trigger "omcproxy"
}
start_service() {
include /lib/functions
config_load omcproxy
config_foreach omcproxy_add_proxy proxy
[ -n "$PROXIES" ] || return 0
procd_open_instance
procd_set_param command $PROG
[ -n "$OPTIONS" ] && procd_append_param command $OPTIONS
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 proxy
json_close_array
procd_close_data
procd_close_instance
# Increase maximum IPv4 group memberships per socket
echo 128 > /proc/sys/net/ipv4/igmp_max_memberships
}
service_started() {
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;