# HG changeset patch # User Michael Schloh von Bennewitz # Date 1231458356 -3600 # Node ID d42d557c7a5a09328056e31d0aceb0b1a06c65f5 # Parent 64165e101f088d35c70f7953f00066ee1019b00b Import package vendor original specs for necessary manipulations. diff -r 64165e101f08 -r d42d557c7a5a stun/rc.stun --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stun/rc.stun Fri Jan 09 00:45:56 2009 +0100 @@ -0,0 +1,49 @@ +#!@l_prefix@/bin/openpkg rc +## +## rc.stun -- Run-Commands +## + +%config + stun_enable="$openpkg_rc_def" + stun_bind_addr1="127.0.0.1" + stun_bind_addr2="127.0.0.2" + stun_bind_port1="3478" + stun_bind_port2="3479" + +%common + stun_pidfile="@l_prefix@/var/stun/stun.pid" + stun_signal () { + [ -f $stun_pidfile ] && kill -$1 `cat $stun_pidfile` + } + +%status -u @l_susr@ -o + stun_usable="unknown" + stun_active="no" + rcService stun enable yes && \ + stun_signal 0 && stun_active="yes" + echo "stun_enable=\"$stun_enable\"" + echo "stun_usable=\"$stun_usable\"" + echo "stun_active=\"$stun_active\"" + +%start -u @l_susr@ + rcService stun enable yes || exit 0 + rcService stun active yes && exit 0 + @l_prefix@/sbin/stund -b \ + -h "${stun_bind_addr1}" \ + -a "${stun_bind_addr2}" \ + -p "${stun_bind_port1}" \ + -o "${stun_bind_port2}" \ + -P "${stun_pidfile}" + +%stop -u @l_susr@ + rcService stun enable yes || exit 0 + rcService stun active no && exit 0 + stun_signal TERM + sleep 2 + rm -f $stun_pidfile >/dev/null 2>&1 || true + +%restart -u @l_susr@ + rcService stun enable yes || exit 0 + rcService stun active no && exit 0 + rc stun stop start + diff -r 64165e101f08 -r d42d557c7a5a stun/stun.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stun/stun.patch Fri Jan 09 00:45:56 2009 +0100 @@ -0,0 +1,85 @@ +Index: client.cxx +--- client.cxx.orig 2005-08-14 02:43:10 +0200 ++++ client.cxx 2005-11-16 10:28:17 +0100 +@@ -178,13 +178,13 @@ + retval[nic] = 0x02; + break; + case StunTypeDependentFilter: +- cout << "Independedt Mapping, Address Dependendent Filter"; ++ cout << "Independedt Mapping, Address Dependent Filter"; + if ( presPort ) cout << ", preserves ports"; else cout << ", random port"; + if ( hairpin ) cout << ", will hairpin"; else cout << ", no hairpin"; + retval[nic] = 0x04; + break; + case StunTypePortDependedFilter: +- cout << "Indepndent Mapping, Port Dependent Filter"; ++ cout << "Independent Mapping, Port Dependent Filter"; + if ( presPort ) cout << ", preserves ports"; else cout << ", random port"; + if ( hairpin ) cout << ", will hairpin"; else cout << ", no hairpin"; + retval[nic] = 0x06; +Index: server.cxx +--- server.cxx.orig 2005-08-13 22:19:29 +0200 ++++ server.cxx 2005-11-16 10:33:51 +0100 +@@ -23,7 +23,7 @@ + usage() + { + cerr << "Usage: " << endl +- << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-m mediaport]" << endl ++ << " ./server [-v] [-h] [-h IP_Address] [-a IP_Address] [-p port] [-o port] [-b] [-m mediaport] [-P pidfile]" << endl + << " " << endl + << " If the IP addresses of your NIC are 10.0.1.150 and 10.0.1.151, run this program with" << endl + << " ./server -v -h 10.0.1.150 -a 10.0.1.151" << endl +@@ -32,7 +32,7 @@ + << " -a sets the secondary IP" << endl + << " -p sets the primary port and defaults to 3478" << endl + << " -o sets the secondary port and defaults to 3479" << endl +- << " -b makes the program run in the backgroud" << endl ++ << " -b makes the program run in the background" << endl + << " -m sets up a STERN server starting at port m" << endl + << " -v runs in verbose mode" << endl + // in makefile too +@@ -55,6 +55,7 @@ + StunAddress4 altAddr; + bool verbose=false; + bool background=false; ++ char *myPidFile = 0; + + myAddr.addr = 0; + altAddr.addr = 0; +@@ -135,6 +136,16 @@ + } + myMediaPort = UInt16(strtol( argv[arg], NULL, 10)); + } ++ else if ( !strcmp( argv[arg] , "-P" ) ) ++ { ++ arg++; ++ if ( argc <= arg ) ++ { ++ usage(); ++ exit(-1); ++ } ++ myPidFile = argv[arg]; ++ } + else + { + usage(); +@@ -213,6 +224,19 @@ + + if (pid == 0) //child or not using background + { ++ /* write a daemon pidfile */ ++ if (myPidFile) { ++ pid_t pid; ++ FILE *fp; ++ pid = getpid(); ++ if ((fp = fopen(myPidFile, "w")) == NULL) { ++ fprintf(stderr, "stund: Can't write pidfile '%s'", myPidFile); ++ exit(1); ++ } ++ fprintf(fp, "%ld\n", (long)pid); ++ fclose(fp); ++ } ++ + StunServerInfo info; + bool ok = stunInitServer(info, myAddr, altAddr, myMediaPort, verbose); + diff -r 64165e101f08 -r d42d557c7a5a stun/stun.spec --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/stun/stun.spec Fri Jan 09 00:45:56 2009 +0100 @@ -0,0 +1,124 @@ +## +## stun.spec -- OpenPKG RPM Package Specification +## Copyright (c) 2000-2008 OpenPKG Foundation e.V. +## +## Permission to use, copy, modify, and distribute this software for +## any purpose with or without fee is hereby granted, provided that +## the above copyright notice and this permission notice appear in all +## copies. +## +## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +## SUCH DAMAGE. +## + +# package version +%define V_dist 0.96_Aug13 +%define V_opkg 0.96 + +# package information +Name: stun +Summary: STUN Client & Server +URL: http://www.vovida.org/applications/downloads/stun/ +Vendor: Vovida +Packager: OpenPKG Foundation e.V. +Distribution: OpenPKG Community +Class: EVAL +Group: VoIP +License: Open Source +Version: %{V_opkg} +Release: 20080101 + +# list of sources +Source0: http://switch.dl.sourceforge.net/stun/stund_%{V_dist}.tgz +Source1: rc.stun +Patch0: stun.patch + +# build information +Prefix: %{l_prefix} +BuildRoot: %{l_buildroot} +BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc +PreReq: OpenPKG, openpkg >= 20060823 +AutoReq: no +AutoReqProv: no + +%description + The STUN (Simple Traversal of UDP through NATs (Network Address + Translation)) server is an implementation of the STUN protocol that + enables STUN functionality in SIP-based systems. The STUN server + tar ball also include a client API to enable STUN functionality in + SIP endpoints. In addition there is a command line UNIX client and + a graphical windows client that check what type of NAT the user is + using. STUN is an application-layer protocol that can determine the + public IP and nature of a NAT device that sits between the STUN + client and STUN server. The current version of the code supports + most of RFC 3489 except the ability to get OTPs from the server. + +%track + prog stun = { + version = %{V_dist} + url = http://prdownloads.sourceforge.net/stun/ + regex = stund_(.+?)\.tgz + } + +%prep + %setup -q -n stund + %patch -p0 + +%build + %{l_make} %{l_mflags} \ + CXX="%{l_cxx}" \ + CXXFLAGS="%{l_cxxflags -O}" \ + LDFLAGS="" + +%install + rm -rf $RPM_BUILD_ROOT + %{l_shtool} mkdir -f -p -m 755 \ + $RPM_BUILD_ROOT%{l_prefix}/bin \ + $RPM_BUILD_ROOT%{l_prefix}/sbin \ + $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \ + $RPM_BUILD_ROOT%{l_prefix}/var/stun + %{l_shtool} install -c -s -m 755 \ + client $RPM_BUILD_ROOT%{l_prefix}/bin/stun + %{l_shtool} install -c -s -m 755 \ + server $RPM_BUILD_ROOT%{l_prefix}/sbin/stund + %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{SOURCE rc.stun} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ + %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std} + +%files -f files + +%clean + rm -rf $RPM_BUILD_ROOT + +%post + if [ $1 -eq 1 ]; then + # display final hints on initial installation + ( echo "Before starting the STUN daemon, please set the configuration" + echo "variables \"stun_bind_addr{1,2}\" in $RPM_INSTALL_PREFIX/etc/rc.conf" + echo "to two *different* IP addresses bound to your host. STUN requires this." + ) | %{l_rpmtool} msg -b -t notice + fi + + # after upgrade, restart service + [ $1 -eq 2 ] || exit 0 + eval `%{l_rc} stun status 2>/dev/null` + [ ".$stun_active" = .yes ] && %{l_rc} stun restart + exit 0 + +%preun + # before erase, stop service and remove log files + [ $1 -eq 0 ] || exit 0 + %{l_rc} stun stop 2>/dev/null + rm -f $RPM_INSTALL_PREFIX/var/stun/stun.pid >/dev/null 2>&1 || true + exit 0 +