diff --git a/package/libjson-c/Makefile b/package/libjson-c/Makefile new file mode 100644 index 000000000..08d4f2d63 --- /dev/null +++ b/package/libjson-c/Makefile @@ -0,0 +1,50 @@ +# +# Copyright (C) 2006-2010 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:=json-c +PKG_VERSION:=0.9 +PKG_RELEASE:=2 + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz +PKG_SOURCE_URL:=http://oss.metaparadigm.com/json-c/ +PKG_MD5SUM:=3a13d264528dcbaf3931b0cede24abae + +PKG_FIXUP:=libtool +PKG_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk + +TARGET_CFLAGS += $(FPIC) + +define Package/libjson + SECTION:=libs + CATEGORY:=Libraries + TITLE:=javascript object notation + URL:=http://oss.metaparadigm.com/json-c/ +endef + +define Package/libjson/description + This package contains a library for javascript object notation backends. +endef + +define Build/InstallDev + $(INSTALL_DIR) $(1)/usr/include + $(CP) $(PKG_INSTALL_DIR)/usr/include/json $(1)/usr/include/ + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson.{a,so*} $(1)/usr/lib/ + $(INSTALL_DIR) $(1)/usr/lib/pkgconfig + $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/json.pc $(1)/usr/lib/pkgconfig/ +endef + +define Package/libjson/install + $(INSTALL_DIR) $(1)/usr/lib + $(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson.so.* $(1)/usr/lib/ +endef + +$(eval $(call BuildPackage,libjson)) diff --git a/package/libubox/Makefile b/package/libubox/Makefile new file mode 100644 index 000000000..ccfe8382b --- /dev/null +++ b/package/libubox/Makefile @@ -0,0 +1,47 @@ +include $(TOPDIR)/rules.mk + +PKG_NAME:=libubox +PKG_VERSION:=2011-02-11 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE_PROTO:=git +PKG_SOURCE_URL:=git://nbd.name/luci2/libubox.git +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_VERSION:=83037e345dd702f2a013322139ef0b7bab7e170f +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz +CMAKE_INSTALL:=1 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/libubox + SECTION:=libs + CATEGORY:=Libraries + TITLE:=Basic utility library + DEPENDS:= +endef + + +define Package/libblobmsg-json + SECTION:=libs + CATEGORY:=Libraries + TITLE:=blobmsg <-> json conversion library + DEPENDS:=+libjson +endef + + +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + +define Package/libubox/install + $(INSTALL_DIR) $(1)/lib/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libubox.so $(1)/lib/ +endef + +define Package/libblobmsg-json/install + $(INSTALL_DIR) $(1)/lib/ + $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libblobmsg_json.so $(1)/lib/ +endef + +$(eval $(call BuildPackage,libubox)) +$(eval $(call BuildPackage,libblobmsg-json)) + diff --git a/package/relayd/Makefile b/package/relayd/Makefile new file mode 100644 index 000000000..1881da928 --- /dev/null +++ b/package/relayd/Makefile @@ -0,0 +1,41 @@ +# +# Copyright (C) 2010-2011 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:=relayd +PKG_VERSION:=2011-02-07 +PKG_RELEASE=$(PKG_SOURCE_VERSION) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 +PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) +PKG_SOURCE_URL:=git://nbd.name/relayd.git +PKG_SOURCE_PROTO:=git +PKG_SOURCE_VERSION:=aeb49d61c2a737dc9a89e0558388c25208e5e919 + +include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/cmake.mk + +define Package/relayd + SECTION:=net + CATEGORY:=Network + TITLE:=Transparent routing / relay daemon + DEPENDS:=+libubox +endef + +TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include + +define Package/relayd/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/relayd $(1)/usr/sbin/relayd + $(INSTALL_DIR) $(1)/etc/hotplug.d/iface + $(INSTALL_DATA) ./files/relay.hotplug $(1)/etc/hotplug.d/iface/30-relay + $(INSTALL_DIR) $(1)/lib/network + $(INSTALL_DATA) ./files/relay.sh $(1)/lib/network/relay.sh +endef + +$(eval $(call BuildPackage,relayd)) diff --git a/package/relayd/files/relay.hotplug b/package/relayd/files/relay.hotplug new file mode 100644 index 000000000..b992fca08 --- /dev/null +++ b/package/relayd/files/relay.hotplug @@ -0,0 +1,36 @@ +#!/bin/sh + +# Break recursion +[ "$PROTO" = "relay" ] && exit 0 + +include /lib/network +scan_interfaces + +restart_relayd() { + local cfg="$1" + + local proto + config_get proto "$1" proto + [ "$proto" = "relay" ] || return 0 + + local net networks + config_get networks "$cfg" network + for net in $networks; do + [ "$net" = "$INTERFACE" ] && { + env -i /sbin/ifup "$cfg" & + return 0 + } + done + + local ifn ifnames + config_get ifnames "$cfg" ifname + for ifn in $ifnames; do + [ "$ifn" = "$DEVICE" ] && { + env -i /sbin/ifup "$cfg" & + return 0 + } + done +} + +config_foreach restart_relayd interface + diff --git a/package/relayd/files/relay.sh b/package/relayd/files/relay.sh new file mode 100644 index 000000000..3e5e84c87 --- /dev/null +++ b/package/relayd/files/relay.sh @@ -0,0 +1,93 @@ +# relay.sh - Abstract relayd protocol backend +# Copyright (c) 2011 OpenWrt.org + +# Hook into scan_interfaces() to synthesize a .device option +# This is needed for /sbin/ifup to properly dispatch control +# to setup_interface_relay() even if no .ifname is set in +# the configuration. +scan_relay() { + config_set "$1" device "relay-$1" +} + +# No coldplugging needed, relayd will be restarted if one of +# the member interfaces goes up or down +#coldplug_interface_relay() { +# setup_interface_relay "relay-$1" "$1" +#} + +setup_interface_relay() { + local iface="$1" + local cfg="$2" + local link="relay-$cfg" + + local args="" + local ifaces="" + + resolve_ifname() { + grep -qs "^ *$1:" /proc/net/dev && { + append args "-I $1" + append ifaces "$1" + } + } + + resolve_network() { + local ifn + config_get ifn "$1" ifname + resolve_ifname "$ifn" + } + + local net networks + config_get networks "$cfg" network + for net in $networks; do + resolve_network "$net" + done + + local ifn ifnames + config_get ifnames "$cfg" ifname + for ifn in $ifnames; do + resolve_ifname "$ifn" + done + + local gateway + config_get gateway "$cfg" gateway + [ -n "$gateway" ] && append args "-G $gateway" + + local expiry # = 30 + config_get expiry "$cfg" expiry + [ -n "$expiry" ] && append args "-t $expiry" + + local retry # = 5 + config_get retry "$cfg" retry + [ -n "$retry" ] && append args "-p $retry" + + local table # = 16800 + config_get table "$cfg" table + [ -n "$table" ] && append args "-T $table" + + local fwd_bcast # = 1 + config_get_bool fwd_bcast "$cfg" forward_bcast 1 + [ $fwd_bcast -eq 1 ] && append args "-B" + + local fwd_dhcp # = 1 + config_get_bool fwd_dhcp "$cfg" forward_dhcp 1 + [ $fwd_dhcp -eq 1 ] && append args "-D" + + start-stop-daemon -b -S -m -p /var/run/$link.pid \ + -x /usr/sbin/relayd -- $args + + uci_set_state network "$cfg" device "$ifaces" + + env -i ACTION="ifup" DEVICE="$link" INTERFACE="$cfg" PROTO="relay" \ + /sbin/hotplug-call iface +} + +stop_interface_relay() { + local cfg="$1" + local link="relay-$cfg" + + env -i ACTION="ifdown" DEVICE="$link" INTERFACE="$cfg" PROTO="relay" \ + /sbin/hotplug-call iface + + service_kill relayd "/var/run/$link.pid" +} +