hnetd: Added use of minimalist-pcproxy(/miniupnpd) for PCP, if present.
include $(TOPDIR)/rules.mk
PKG_NAME:=hnetd
-PKG_SOURCE_VERSION:=a7fb081a9b98a150f2fda913886c6c0ef0725048
-PKG_VERSION:=2014-05-04-$(PKG_SOURCE_VERSION)
+PKG_SOURCE_VERSION:=c6da40c19d0e550cd1e2dd1a459ef6cab9b15cae
+PKG_VERSION:=2014-06-02-$(PKG_SOURCE_VERSION)
PKG_RELEASE:=1
PKG_SOURCE_PROTO:=git
define Package/hnet-full
SECTION:=net
CATEGORY:=Network
- TITLE:=HNCP Homenet metapackage (hnetd + ohybridproxy + babels)
+ TITLE:=HNCP Homenet metapackage
URL:=https://github.com/sbyx/hnetd
- DEPENDS:=+odhcpd +odhcp6c +netifd +hnetd +ohybridproxy +babels
- DEPENDS+=+@IPV6
+ DEPENDS:=+hnetd
+ # Routing
+ DEPENDS+=+babels
+ # Service discovery
+ DEPENDS+=+ohybridproxy
+ # Distributed PCP support
+ DEPENDS+=+miniupnpd +minimalist-pcproxy
endef
define Package/hnetd/description
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/hnetd.init $(1)/etc/init.d/hnetd
$(INSTALL_BIN) ./files/ohp-script $(1)/usr/sbin/hnetd-ohp-script
+ $(INSTALL_BIN) ./files/pcp-script $(1)/usr/sbin/hnetd-pcp-script
$(INSTALL_BIN) $(PKG_BUILD_DIR)/generic/hnetd-routing $(1)/usr/sbin/hnetd-routing
$(INSTALL_DIR) $(1)/etc/uci-defaults
$(INSTALL_BIN) ./files/hnetd.defaults $(1)/etc/uci-defaults/x-hnetd.defaults
DNSMASQ_SCRIPT=/etc/init.d/dnsmasq
OHP_SCRIPT=/usr/sbin/hnetd-ohp-script
OHP_BINARY=/usr/sbin/ohybridproxy
+PCP_SCRIPT=/usr/sbin/hnetd-pcp-script
+PCP_BINARY=/usr/sbin/minimalist-pcproxy
start_service() {
mkdir -p $DNSMASQ_DIR
then
mkdir -p $DNSMASQ_DIR
procd_append_param command -d $DNSMASQ_SCRIPT
- procd_append_param command -f $DNSMASQ_DIR/hnet.conf
+ procd_append_param command -f $DNSMASQ_DIR/hnet.conf
procd_append_param command -o $OHP_SCRIPT
HOSTNAME=`cat /proc/sys/kernel/hostname`
if [ -n "$HOSTNAME" ]
procd_append_param command -n "$HOSTNAME"
fi
fi
+
+ # Enable PCP, if it's present
+ if [ -f $PCP_BINARY -a -f $PCP_SCRIPT ]
+ then
+ procd_append_param command -c $PCP_SCRIPT
+ fi
+
# State file
procd_append_param command -s /tmp/hnetd.pa_state
--- /dev/null
+#!/bin/sh
+#-*-sh-*-
+#
+# $Id: pcp-script $
+#
+# Author: Markus Stenberg <mstenber@cisco.com>
+#
+# Copyright (c) 2014 cisco Systems, Inc.
+#
+# Created: Fri Jan 17 11:46:30 2014 mstenber
+# Last modified: Fri May 30 13:27:57 2014 mstenber
+# Edit time: 16 min
+#
+
+# Copied from ohp-script.. Same idea. Just prod minimalist-pcproxy as
+# needed, hoping the miniupnpd is taken care of by the system.
+
+PCP=minimalist-pcproxy
+
+start() {
+ $PCP $* &
+}
+
+stop() {
+ killall -9 $PCP
+}
+
+
+CMD=$1
+# For debugging purposes
+LOGNAME=`basename $0`
+echo "$*" | logger -t "$LOGNAME"
+case $CMD in
+ start)
+ shift
+ stop
+ start $*
+ ;;
+ stop)
+ stop
+ ;;
+ *)
+ echo "Only start [config]/stop supported"
+ exit 1
+ ;;
+esac
--- /dev/null
+#
+# Copyright (C) 2014 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:=minimalist-pcproxy
+PKG_SOURCE_VERSION:=c8d47ff42c4354f502830faeae13bd8f269401af
+PKG_VERSION:=2014-06-02-$(PKG_SOURCE_VERSION)
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=git://github.com/fingon/minimalist-pcproxy.git
+PKG_MAINTAINER:=Markus Stenberg <fingon@iki.fi>
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/minimalist-pcproxy
+ SECTION:=net
+ CATEGORY:=Network
+ TITLE:=Lightweight PCP proxy
+ URL:=https://github.com/fingon/minimalist-pcproxy
+ DEPENDS:=+libubox +@IPV6
+endef
+
+define Package/minimalist-pcproxy/description
+This package contains a daemon which can be used to forward
+PCP (Port Control Protocol - RFC6887) requests requests to PCP remote servers.
+
+In and of itself, it is not very useful, but combined with hnetd+miniupnpd
+it allows for control of NAT forwarding and firewall pinholes from multiple
+hops away.
+endef
+
+define Package/minimalist-pcproxy/install
+ $(INSTALL_DIR) $(1)/usr/sbin/
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/minimalist-pcproxy $(1)/usr/sbin/
+ $(INSTALL_DIR) $(1)/etc/uci-defaults
+ $(INSTALL_BIN) ./files/minimalist-pcproxy.defaults $(1)/etc/uci-defaults/x-minimalist-pcproxy.defaults
+endef
+
+define Package/minimalist-pcproxy/postinst
+!/bin/sh
+[ -n "$${IPKG_INSTROOT}" ] || {
+ (. /etc/uci-defaults/x-minimalist-pcproxy.defaults) && rm -f /etc/uci-defaults/x-minimalist-pcproxy.defaults
+}
+exit 0
+endef
+
+$(eval $(call BuildPackage,minimalist-pcproxy))
--- /dev/null
+#!/bin/sh
+
+if [ `uci get -q upnpd.config._pcproxy_configured` = "1" ]
+then
+ exit
+fi
+
+uci batch <<EOF
+set upnpd.config.enable_upnp=0
+set upnpd.config.pcp_allow_thirdparty=1
+set upnpd.config.internal_iface=loopback
+set upnpd.config.ipv6_listening_ip=::1
+set upnpd.config._pcproxy_configured=1
+commit upnpd
+EOF