1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-24 05:11:46 +02:00

[backfire] backport relayd, libubox and libjson-c

git-svn-id: svn://svn.openwrt.org/openwrt/branches/backfire@25718 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
jow 2011-02-26 00:12:42 +00:00
parent c367f85aae
commit 1e09ab8b72
5 changed files with 267 additions and 0 deletions

View File

@ -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))

47
package/libubox/Makefile Normal file
View File

@ -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))

41
package/relayd/Makefile Normal file
View File

@ -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))

View File

@ -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

View File

@ -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"
}