diff options
author | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-09-16 18:12:49 +0200 |
---|---|---|
committer | Ludovic Pouzenc <ludovic@pouzenc.fr> | 2018-09-16 18:12:49 +0200 |
commit | 7611c941f53bf2154aca8a1ea8799a72d7d5b388 (patch) | |
tree | a1cb7baf840c74b86c791b5304d3c26f24752b2f /package/network | |
parent | 436eab21c3d6186debd8af26291ebb36c926fd77 (diff) | |
download | mtk-20170518-7611c941f53bf2154aca8a1ea8799a72d7d5b388.zip mtk-20170518-7611c941f53bf2154aca8a1ea8799a72d7d5b388.tar.gz mtk-20170518-7611c941f53bf2154aca8a1ea8799a72d7d5b388.tar.bz2 |
package/network/ipv6: probably from OpenWRT
Diffstat (limited to 'package/network')
-rw-r--r-- | package/network/ipv6/map/Makefile | 5 | ||||
-rwxr-xr-x | package/network/ipv6/map/files/map.sh | 38 | ||||
-rw-r--r-- | package/network/ipv6/map/src/mapcalc.c | 17 | ||||
-rw-r--r-- | package/network/ipv6/odhcp6c/Makefile | 18 | ||||
-rwxr-xr-x | package/network/ipv6/odhcp6c/files/dhcpv6.script | 19 | ||||
-rwxr-xr-x | package/network/ipv6/odhcp6c/files/dhcpv6.sh | 6 |
6 files changed, 66 insertions, 37 deletions
diff --git a/package/network/ipv6/map/Makefile b/package/network/ipv6/map/Makefile index 0f64ebe..ed358de 100644 --- a/package/network/ipv6/map/Makefile +++ b/package/network/ipv6/map/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2014 OpenWrt.org +# Copyright (C) 2014-2015 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,8 +8,9 @@ include $(TOPDIR)/rules.mk PKG_NAME:=map -PKG_VERSION:=1 +PKG_VERSION:=3 PKG_RELEASE:=2 +PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk diff --git a/package/network/ipv6/map/files/map.sh b/package/network/ipv6/map/files/map.sh index fceeb8a..945accd 100755 --- a/package/network/ipv6/map/files/map.sh +++ b/package/network/ipv6/map/files/map.sh @@ -52,6 +52,7 @@ proto_map_setup() { fi fi + echo "rule=$rule" > /tmp/map-$cfg.rules RULE_DATA=$(mapcalc ${tunlink:-\*} $rule) if [ "$?" != 0 ]; then proto_notify_error "$cfg" "INVALID_MAP_RULE" @@ -59,6 +60,7 @@ proto_map_setup() { return fi + echo "$RULE_DATA" >> /tmp/map-$cfg.rules eval $RULE_DATA if [ -z "$RULE_BMR" ]; then @@ -122,19 +124,28 @@ proto_map_setup() { [ "$zone" != "-" ] && json_add_string zone "$zone" json_add_array firewall - for portset in $(eval "echo \$RULE_${k}_PORTSETS"); do - for proto in icmp tcp udp; do - json_add_object "" - json_add_string type nat - json_add_string target SNAT - json_add_string family inet - json_add_string proto "$proto" - json_add_boolean connlimit_ports 1 - json_add_string snat_ip $(eval "echo \$RULE_${k}_IPV4ADDR") - json_add_string snat_port "$portset" - json_close_object - done - done + if [ -z "$(eval "echo \$RULE_${k}_PORTSETS")" ]; then + json_add_object "" + json_add_string type nat + json_add_string target SNAT + json_add_string family inet + json_add_string snat_ip $(eval "echo \$RULE_${k}_IPV4ADDR") + json_close_object + else + for portset in $(eval "echo \$RULE_${k}_PORTSETS"); do + for proto in icmp tcp udp; do + json_add_object "" + json_add_string type nat + json_add_string target SNAT + json_add_string family inet + json_add_string proto "$proto" + json_add_boolean connlimit_ports 1 + json_add_string snat_ip $(eval "echo \$RULE_${k}_IPV4ADDR") + json_add_string snat_port "$portset" + json_close_object + done + done + fi if [ "$type" = "map-t" ]; then json_add_object "" json_add_string type rule @@ -179,6 +190,7 @@ proto_map_setup() { proto_map_teardown() { local cfg="$1" ifdown "${cfg}_local" + rm -f /tmp/map-$cfg.rules } proto_map_init_config() { diff --git a/package/network/ipv6/map/src/mapcalc.c b/package/network/ipv6/map/src/mapcalc.c index 03f8165..b4b3d73 100644 --- a/package/network/ipv6/map/src/mapcalc.c +++ b/package/network/ipv6/map/src/mapcalc.c @@ -2,7 +2,7 @@ * mapcalc - MAP parameter calculation * * Author: Steven Barth <cyrus@openwrt.org> - * Copyright (c) 2014 cisco Systems, Inc. + * Copyright (c) 2014-2015 cisco Systems, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 @@ -271,8 +271,10 @@ int main(int argc, char *argv[]) if (ealen < 0 && pdlen >= 0) ealen = pdlen - prefix6len; - if (psidlen < 0) + if (psidlen <= 0) { psidlen = ealen - (32 - prefix4len); + psid = -1; + } if (psid < 0 && psidlen <= 16 && psidlen >= 0 && pdlen >= 0 && ealen >= psidlen) { bmemcpys64(&psid16, &pd, prefix6len + ealen - psidlen, psidlen); @@ -343,14 +345,17 @@ int main(int argc, char *argv[]) } - if (psidlen == 0) { - printf("RULE_%d_PORTSETS=0-65535\n", rulecnt); - } else if (psid >= 0) { + if (psidlen > 0 && psid >= 0) { printf("RULE_%d_PORTSETS='", rulecnt); for (int k = (offset) ? 1 : 0; k < (1 << offset); ++k) { int start = (k << (16 - offset)) | (psid >> offset); int end = start + (1 << (16 - offset - psidlen)) - 1; - printf("%d-%d ", start, end); + + if (start == 0) + start = 1; + + if (start <= end) + printf("%d-%d ", start, end); } printf("'\n"); } diff --git a/package/network/ipv6/odhcp6c/Makefile b/package/network/ipv6/odhcp6c/Makefile index 3ec58e1..b2a4e89 100644 --- a/package/network/ipv6/odhcp6c/Makefile +++ b/package/network/ipv6/odhcp6c/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2012 OpenWrt.org +# Copyright (C) 2012-2014 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,15 +8,16 @@ include $(TOPDIR)/rules.mk PKG_NAME:=odhcp6c -PKG_VERSION:=2014-07-21 +PKG_VERSION:=2014-12-10 PKG_RELEASE=$(PKG_SOURCE_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) -PKG_SOURCE_URL:=git://github.com/sbyx/odhcp6c.git +PKG_SOURCE_URL:=https://github.com/sbyx/odhcp6c.git PKG_SOURCE_PROTO:=git -PKG_SOURCE_VERSION:=67b311ab81736b35858664219d345844ab08fcc7 +PKG_SOURCE_VERSION:=722226c4f1d45c8bf4ac9189523738abcf7d648f PKG_MAINTAINER:=Steven Barth <steven@midlink.org> +PKG_LICENSE:=GPL-2.0 include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/cmake.mk @@ -29,10 +30,6 @@ ifneq ($(CONFIG_PACKAGE_odhcp6c_ext_cer_id),0) CMAKE_OPTIONS += -DEXT_CER_ID=$(CONFIG_PACKAGE_odhcp6c_ext_cer_id) endif -ifneq ($(CONFIG_PACKAGE_odhcp6c_ext_s46),0) - CMAKE_OPTIONS += -DEXT_S46=$(CONFIG_PACKAGE_odhcp6c_ext_s46) -endif - define Package/odhcp6c SECTION:=net CATEGORY:=Network @@ -50,11 +47,6 @@ define Package/odhcp6c/config int "CER-ID Extension ID (0 = disabled)" depends on PACKAGE_odhcp6c default 0 - - config PACKAGE_odhcp6c_ext_s46 - int "Softwire MAP Extension ID (0 = disabled)" - depends on PACKAGE_odhcp6c - default 0 endef define Package/odhcp6c/install diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.script b/package/network/ipv6/odhcp6c/files/dhcpv6.script index 5ab9a1e..1acad19 100755 --- a/package/network/ipv6/odhcp6c/files/dhcpv6.script +++ b/package/network/ipv6/odhcp6c/files/dhcpv6.script @@ -26,6 +26,15 @@ setup_interface () { for prefix in $PREFIXES; do proto_add_ipv6_prefix "$prefix" + local entry="${prefix#*/}" + entry="${entry#*,}" + entry="${entry#*,}" + local valid="${entry%%,*}" + + if [ -z "$RA_ADDRESSES" -a -z "$RA_ROUTES" -a \ + -z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then + RA_ROUTES="::/0,$SERVER,$valid,4096" + fi done [ -n "$USERPREFIX" ] && proto_add_ipv6_prefix "$USERPREFIX" @@ -51,6 +60,11 @@ setup_interface () { local valid="${entry%%,*}" proto_add_ipv6_address "$addr" "$mask" "$preferred" "$valid" 1 + + if [ -z "$RA_ADDRESSES" -a -z "$RA_ROUTES" -a \ + -z "$RA_DNS" -a "$FAKE_ROUTES" = 1 ]; then + RA_ROUTES="::/0,$SERVER,$valid,4096" + fi done for entry in $RA_ROUTES; do @@ -141,9 +155,12 @@ case "$2" in teardown_interface "$1" setup_interface "$1" ;; - informed|updated|rebound|ra-updated) + informed|updated|rebound) setup_interface "$1" ;; + ra-updated) + [ -n "$ADDRESSES$RA_ADDRESSES$PREFIXES$USERPREFIX" ] && setup_interface "$1" + ;; started|stopped|unbound) teardown_interface "$1" ;; diff --git a/package/network/ipv6/odhcp6c/files/dhcpv6.sh b/package/network/ipv6/odhcp6c/files/dhcpv6.sh index 0690bd1..5914abe 100755 --- a/package/network/ipv6/odhcp6c/files/dhcpv6.sh +++ b/package/network/ipv6/odhcp6c/files/dhcpv6.sh @@ -26,14 +26,15 @@ proto_dhcpv6_init_config() { proto_config_add_string "vendorclass" proto_config_add_boolean delegate proto_config_add_int "soltimeout" + proto_config_add_boolean fakeroutes } proto_dhcpv6_setup() { local config="$1" local iface="$2" - local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout - json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout + local reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout fakeroutes + json_get_vars reqaddress reqprefix clientid reqopts noslaaconly forceprefix norelease ip6prefix iface_dslite iface_map ifaceid sourcerouting userclass vendorclass delegate zone_dslite zone_map zone soltimeout fakeroutes # Configure @@ -72,6 +73,7 @@ proto_dhcpv6_setup() { [ -n "$zone_dslite" ] && proto_export "ZONE_DSLITE=$zone_dslite" [ -n "$zone_map" ] && proto_export "ZONE_MAP=$zone_map" [ -n "$zone" ] && proto_export "ZONE=$zone" + [ "$fakeroutes" != "0" ] && proto_export "FAKE_ROUTES=1" proto_export "INTERFACE=$config" proto_run_command "$config" odhcp6c \ |