From: Florian Fainelli Date: Mon, 26 Jan 2009 17:58:13 +0000 (+0000) Subject: Add stun server and client X-Git-Url: http://git.openwrt.org/?p=openwrt%2Fsvn-archive%2Farchive.git;a=commitdiff_plain;h=5f94068dc1ca6b4e13669057e7f74ccef61ed78d;ds=sidebyside Add stun server and client SVN-Revision: 14206 --- diff --git a/net/stun/Makefile b/net/stun/Makefile new file mode 100644 index 0000000000..d30d6fe3aa --- /dev/null +++ b/net/stun/Makefile @@ -0,0 +1,83 @@ +# +# Copyright (C) 2008 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id: $ + +include $(TOPDIR)/rules.mk + +PKG_NAME:=stund +PKG_VERSION:=0.96 + +PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION)_Aug13.tgz +PKG_SOURCE_URL:=@SF/stun +PKG_MD5SUM:=3273abb1a6f299f4e611b658304faefa + +PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) + +include $(INCLUDE_DIR)/package.mk + +define Package/stun/Default + SECTION:=net + CATEGORY:=Network + DEPENDS:=+uclibcxx + URL:=http://sourceforge.net/projects/stun +endef + +define Package/stun/Default/description + The STUN protocol (Simple Traversal of UDP through NATs) is described in the + IETF RFC 3489, available at http://www.ietf.org/rfc/rfc3489.txt. It's used to + help clients behind NAT to tunnel incoming calls through. This server is the + counterpart to help the client identify the NAT and have it open the proper + ports for it. +endef + +define Package/stund +$(call Package/stun/Default) + TITLE:=STUN server +endef + +define Package/stund/description +$(call Package/stun/Default/description) +endef + +define Package/stun-client +$(call Package/stun/Default) + TITLE:=STUN test client +endef + +define Package/stun-client/description +$(call Package/stun/Default/description) +endef + +define Build/Compile + $(MAKE) -C $(PKG_BUILD_DIR) \ + CXX="$(TARGET_CXX)" \ + CFLAGS="$(TARGET_CFLAGS)" \ + DESTDIR="$(PKG_INSTALL_DIR)" \ + CXXFLAGS="$$$$CXXFLAGS -fno-builtin -fno-rtti -nostdinc++" \ + CPPFLAGS="$$$$CPPFLAGS -I$(STAGING_DIR)/usr/include/uClibc++ -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \ + LDFLAGS="$$$$LDFLAGS -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -L$(TOOLCHAIN_DIR)/usr/lib \ + -nodefaultlibs -luClibc++ -lgcc" \ + all +endef + + +define Package/stund/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/server $(1)/usr/sbin/stund + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/stund.init $(1)/etc/init.d/ + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/stund.config $(1)/etc/config/stund +endef + +define Package/stun-client/install + $(INSTALL_DIR) $(1)/usr/sbin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/client $(1)/usr/sbin/stun-client +endef + +$(eval $(call BuildPackage,stund)) +$(eval $(call BuildPackage,stun-client)) diff --git a/net/stun/files/stund.config b/net/stun/files/stund.config new file mode 100644 index 0000000000..0a0bc079d4 --- /dev/null +++ b/net/stun/files/stund.config @@ -0,0 +1,5 @@ +config stund + option primaryip '' + option secondaryip '' + option primaryport '3478' + option secondaryport '3479' diff --git a/net/stun/files/stund.init b/net/stun/files/stund.init new file mode 100644 index 0000000000..2960567456 --- /dev/null +++ b/net/stun/files/stund.init @@ -0,0 +1,18 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2009 OpenWrt.org +START=70 + +start() { + config_load "6stund" + + config_get PRIMIP primaryip + config_get SECIP secondaryip + config_get PRIMPORT primaryport + config_get SECPORT secondaryport + + /usr/sbin/stund -b -h $PRIMIP -a $SECIP -p $PRIMPORT -o $SECPORT +} + +stop() { + killall -9 stund +} diff --git a/net/stun/patches/001-fix_non_i386.patch b/net/stun/patches/001-fix_non_i386.patch new file mode 100644 index 0000000000..070b5517c2 --- /dev/null +++ b/net/stun/patches/001-fix_non_i386.patch @@ -0,0 +1,27 @@ +#! /bin/sh /usr/share/dpatch/dpatch-run +## fix_non_i386.dpatch by Kilian Krause +## +## All lines beginning with `## DP:' are a description of the patch. +## DP: Remove i386-only code analogous to twinkle +@DPATCH@ +diff -urNad stun-0.96~/stun.cxx stun-0.96/stun.cxx +--- stun-0.96~/stun.cxx 2005-08-14 00:39:03.000000000 +0000 ++++ stun-0.96/stun.cxx 2006-01-03 00:54:33.000000000 +0000 +@@ -669,16 +669,8 @@ + tick = hightick; + tick <<= 32; + tick |= lowtick; +-#elif defined(__GNUC__) && ( defined(__i686__) || defined(__i386__) ) +- asm("rdtsc" : "=A" (tick)); +-#elif defined (__SUNPRO_CC) || defined( __sparc__ ) +- tick = gethrtime(); +-#elif defined(__MACH__) +- int fd=open("/dev/random",O_RDONLY); +- read(fd,&tick,sizeof(tick)); +- closesocket(fd); + #else +-# error Need some way to seed the random number generator ++ tick = time(NULL); + #endif + int seed = int(tick); + #ifdef WIN32