From 7376de0ff13251ab9951530d111a28bca88b7d9d Mon Sep 17 00:00:00 2001 From: florian Date: Wed, 17 Aug 2011 10:13:19 +0000 Subject: [PATCH] [package] siproxd: update to 0.8.1 Upgrade siproxd, fix init script, link statically with libosip2 (size) and add description. Signed-off-by: Luka Perkov git-svn-id: svn://svn.openwrt.org/openwrt/packages@28029 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- net/siproxd/Makefile | 26 +- net/siproxd/files/siproxd.config | 4 +- net/siproxd/files/siproxd.init | 274 ++++++++++-------- .../010-fix-bogus-libltdl-dependency.patch | 18 +- 4 files changed, 181 insertions(+), 141 deletions(-) diff --git a/net/siproxd/Makefile b/net/siproxd/Makefile index 828463fe4..adaa16519 100644 --- a/net/siproxd/Makefile +++ b/net/siproxd/Makefile @@ -1,5 +1,5 @@ # -# Copyright (C) 2006-2010 OpenWrt.org +# Copyright (C) 2006-2011 OpenWrt.org # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. @@ -8,12 +8,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=siproxd -PKG_VERSION:=0.7.1 -PKG_RELEASE:=3 - +PKG_VERSION:=0.8.1 +PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/siproxd -PKG_MD5SUM:=45e5a44803181e2bf3361d562060c904 +PKG_MD5SUM:=1a6f9d13aeb2d650375c9a346ac6cbaf + +PKG_BUILD_DEPENDS:=libosip2 PKG_FIXUP:=libtool PKG_INSTALL:=1 @@ -24,17 +25,24 @@ define Package/siproxd SECTION:=net CATEGORY:=Network SUBMENU:=Telephony - DEPENDS:=+libltdl +libosip2 +libpthread + DEPENDS:=+libltdl +libpthread TITLE:=SIP (Session Initiation Protocol) proxy URL:=http://siproxd.sourceforge.net/ endef +define Package/siproxd/description + Siproxd is a proxy/masquerading daemon for the SIP protocol. +endef + define Package/siproxd/conffiles /etc/config/siproxd endef CONFIGURE_ARGS+= \ + --enable-static-libosip2 \ --with-libosip-prefix="$(STAGING_DIR)/usr" \ + --disable-doc \ + --disable-shared MAKE_FLAGS+= \ SUBDIRS="src scripts contrib" \ @@ -42,11 +50,9 @@ MAKE_FLAGS+= \ define Package/siproxd/install $(INSTALL_DIR) $(1)/usr/sbin - $(CP) $(PKG_INSTALL_DIR)/usr/sbin/siproxd $(1)/usr/sbin/ - $(INSTALL_DIR) $(1)/usr/lib/siproxd - $(CP) $(PKG_INSTALL_DIR)/usr/lib/siproxd/plugin_*.so* $(1)/usr/lib/siproxd/ + $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/siproxd $(1)/usr/sbin $(INSTALL_DIR) $(1)/etc/config - $(INSTALL_DATA) ./files/siproxd.config $(1)/etc/config/siproxd + $(INSTALL_CONF) ./files/siproxd.config $(1)/etc/config/siproxd $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/siproxd.init $(1)/etc/init.d/siproxd endef diff --git a/net/siproxd/files/siproxd.config b/net/siproxd/files/siproxd.config index 3904b91be..b65148c7e 100644 --- a/net/siproxd/files/siproxd.config +++ b/net/siproxd/files/siproxd.config @@ -1,3 +1,3 @@ config siproxd general - option if_inbound 'lan' - option if_outbound 'wan' + option if_inbound lan + option if_outbound wan diff --git a/net/siproxd/files/siproxd.init b/net/siproxd/files/siproxd.init index 03fb58b2c..17709271b 100644 --- a/net/siproxd/files/siproxd.init +++ b/net/siproxd/files/siproxd.init @@ -1,132 +1,164 @@ #!/bin/sh /etc/rc.common # Copyright (C) 2008 Alina Friedrichsen +# Copyright (C) 2011 OpenWrt.org START=50 +siproxd_bin="/usr/sbin/siproxd" +siproxd_conf_dir="/var/etc/" +siproxd_conf_prefix="$siproxd_conf_dir"siproxd- +siproxd_registration_dir="/var/lib/siproxd/" +siproxd_pid_dir="/var/run/" + +start_instance() +{ + local cfg="$1" + config_get if_inbound "$cfg" if_inbound + config_get if_outbound "$cfg" if_outbound + config_get host_outbound "$cfg" host_outbound + config_get hosts_allow_reg "$cfg" hosts_allow_reg + config_get hosts_allow_sip "$cfg" hosts_allow_sip + config_get hosts_deny_sip "$cfg" hosts_deny_sip + config_get sip_listen_port "$cfg" sip_listen_port 5060 + config_get_bool daemonize "$cfg" daemonize 1 + config_get silence_log "$cfg" silence_log 4 + config_get user "$cfg" user nobody + config_get chrootjail "$cfg" chrootjail + config_get registration_file "$cfg" registration_file "$siproxd_registration_dir"siproxd_registrations-"$cfg" + config_get autosave_registrations "$cfg" autosave_registrations 300 + config_get pid_file "$cfg" pid_file "$siproxd_pid_dir"siproxd-"$cfg".pid + config_get_bool rtp_proxy_enable "$cfg" rtp_proxy_enable 1 + config_get rtp_port_low "$cfg" rtp_port_low 7070 + config_get rtp_port_high "$cfg" rtp_port_high 7089 + config_get rtp_timeout "$cfg" rtp_timeout 300 + config_get rtp_dscp "$cfg" rtp_dscp 46 + config_get default_expires "$cfg" default_expires 600 + config_get proxy_auth_realm "$cfg" proxy_auth_realm + config_get proxy_auth_passwd "$cfg" proxy_auth_passwd + config_get proxy_auth_pwfile "$cfg" proxy_auth_pwfile + config_get debug_level "$cfg" debug_level 0x00000000 + config_get debug_port "$cfg" debug_port 0 + config_get mask_host "$cfg" mask_host + config_get masked_host "$cfg" masked_host + config_get ua_string "$cfg" ua_string Siproxd-UA + config_get use_rport "$cfg" use_rport 0 + config_get outbound_proxy_host "$cfg" outbound_proxy_host + config_get outbound_proxy_port "$cfg" outbound_proxy_port + config_get outbound_domain_name "$cfg" outbound_domain_name + config_get outbound_domain_host "$cfg" outbound_domain_host + config_get outbound_domain_port "$cfg" outbound_domain_port + + if [ ! -d "$siproxd_conf_dir" ]; then + mkdir -p "$siproxd_conf_dir" + chmod 0755 "$siproxd_conf_dir" + fi + if [ -f "$siproxd_conf_prefix$cfg" ]; then + rm "$siproxd_conf_prefix$cfg" + fi + if [ -n "$if_inbound" ]; then + echo if_inbound = "$if_inbound" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$if_outbound" ]; then + echo if_outbound = "$if_outbound" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$host_outbound" ]; then + echo host_outbound = "$host_outbound" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$hosts_allow_reg" ]; then + echo hosts_allow_reg = "$hosts_allow_reg" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$hosts_allow_sip" ]; then + echo hosts_allow_sip = "$hosts_allow_sip" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$hosts_deny_sip" ]; then + echo hosts_deny_sip = "$hosts_deny_sip" >> "$siproxd_conf_prefix$cfg" + fi + echo sip_listen_port = "$sip_listen_port" >> "$siproxd_conf_prefix$cfg" + echo daemonize = "$daemonize" >> "$siproxd_conf_prefix$cfg" + echo silence_log = "$silence_log" >> "$siproxd_conf_prefix$cfg" + echo user = "$user" >> "$siproxd_conf_prefix$cfg" + if [ -n "$chrootjail" ]; then + if [ ! -d "$chrootjail" ]; then + mkdir -p "$chrootjail" + chmod 0755 "$chrootjail" + fi + echo chrootjail = "$chrootjail" >> "$siproxd_conf_prefix$cfg" + fi + if [ ! -d "$siproxd_registration_dir" ]; then + mkdir -p "$siproxd_registration_dir" + chmod 0755 "$siproxd_registration_dir" + fi + echo registration_file = "$registration_file" >> "$siproxd_conf_prefix$cfg" + echo autosave_registrations = "$autosave_registrations" >> "$siproxd_conf_prefix$cfg" + if [ ! -d "$siproxd_pid_dir" ]; then + mkdir -p "$siproxd_pid_dir" + chmod 0755 "$siproxd_pid_dir" + fi + echo pid_file = "$pid_file" >> "$siproxd_conf_prefix$cfg" + echo rtp_proxy_enable = "$rtp_proxy_enable" >> "$siproxd_conf_prefix$cfg" + echo rtp_port_low = "$rtp_port_low" >> "$siproxd_conf_prefix$cfg" + echo rtp_port_high = "$rtp_port_high" >> "$siproxd_conf_prefix$cfg" + echo rtp_timeout = "$rtp_timeout" >> "$siproxd_conf_prefix$cfg" + echo rtp_dscp = "$rtp_dscp" >> "$siproxd_conf_prefix$cfg" + echo default_expires = "$default_expires" >> "$siproxd_conf_prefix$cfg" + if [ -n "$proxy_auth_realm" ]; then + echo proxy_auth_realm = "$proxy_auth_realm" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$proxy_auth_passwd" ]; then + echo proxy_auth_passwd = "$proxy_auth_passwd" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$proxy_auth_pwfile" ]; then + echo proxy_auth_pwfile = "$proxy_auth_pwfile" >> "$siproxd_conf_prefix$cfg" + fi + echo debug_level = "$debug_level" >> "$siproxd_conf_prefix$cfg" + echo debug_port = "$debug_port" >> "$siproxd_conf_prefix$cfg" + if [ -n "$mask_host" ]; then + echo mask_host = "$mask_host" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$masked_host" ]; then + echo masked_host = "$masked_host" >> "$siproxd_conf_prefix$cfg" + fi + echo ua_string = "$ua_string" >> "$siproxd_conf_prefix$cfg" + echo use_rport = "$use_rport" >> "$siproxd_conf_prefix$cfg" + if [ -n "$outbound_proxy_host" ]; then + echo oubound_proxy_host = "$outbound_proxy_host" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$outbound_proxy_port" ]; then + echo outbound_proxy_port = "$outbound_proxy_port" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$outbound_domain_name" ]; then + echo outbound_domain_name = "$outbound_domain_name" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$outbound_domain_host" ]; then + echo outbound_domain_host = "$outbound_domain_host" >> "$siproxd_conf_prefix$cfg" + fi + if [ -n "$outbound_domain_port" ]; then + echo outbound_domain_port = "$outbound_domain_port" >> "$siproxd_conf_prefix$cfg" + fi + + $siproxd_bin --config "$siproxd_conf_prefix$cfg" +} + +stop_instance() +{ + local cfg="$1" + + [ -f "$siproxd_pid_dir"siproxd-"$cfg".pid ] && { + start-stop-daemon -K -q -n ${siproxd_bin##*/} \ + -p "$siproxd_pid_dir"siproxd-"$cfg".pid -s TERM + + rm "$siproxd_pid_dir"siproxd-"$cfg".pid + } +} start() { - local ifname - local cfgt - - option_cb() { - local varname="$1" - local value="$2" - local cfg="$CONFIG_SECTION" - local cfgt - local item - local c - - config_get cfgt "$cfg" TYPE - - if [ "$cfgt" == siproxd ]; then - if [ "$varname" == config_file ]; then - CONFIG_FILE="$value" - elif [ "$varname" == if_inbound ]; then - IF_INBOUND="$value" - elif [ "$varname" == if_outbound ]; then - IF_OUTBOUND="$value" - elif [ "$varname" == mask_host ]; then - c=0 - for item in $value - do - if [ "$((c % 2))" -eq 0 ]; then - printf '%s\n' "mask_host = $item" >> /var/etc/siproxd.conf - else - printf '%s\n' "masked_host = $item" >> /var/etc/siproxd.conf - fi - c=$((c + 1)) - done - elif [ "$varname" == outbound_domain ]; then - c=0 - for item in $value - do - if [ "$((c % 3))" -eq 0 ]; then - printf '%s\n' "outbound_domain_name = $item" >> /var/etc/siproxd.conf - elif [ "$((c % 3))" -eq 1 ]; then - printf '%s\n' "outbound_domain_host = $item" >> /var/etc/siproxd.conf - else - printf '%s\n' "outbound_domain_port = $item" >> /var/etc/siproxd.conf - fi - c=$((c + 1)) - done - elif [ "$varname" == pi_shortdial_entry ]; then - for item in $value - do - printf '%s\n' "pi_shortdial_entry = $item" >> /var/etc/siproxd.conf - done - else - if [ "$varname" == hosts_allow_reg -o "$varname" == hosts_allow_sip -o "$varname" == hosts_deny_sip ]; then - value=$(printf '%s' "$value" | tr -s '\t ' ',') - fi - [ "$varname" == sip_listen_port ] && SIP_LISTEN_PORT="" - [ "$varname" == daemonize ] && DAEMONIZE="" - [ "$varname" == silence_log ] && SILENCE_LOG="" - [ "$varname" == log_calls ] && LOG_CALLS="" - [ "$varname" == user ] && USER="" - [ "$varname" == registration_file ] && REGISTRATION_FILE="" - [ "$varname" == pid_file ] && PID_FILE="" - [ "$varname" == rtp_proxy_enable ] && RTP_PROXY_ENABLE="" - [ "$varname" == rtp_port_low ] && RTP_PORT_LOW="" - [ "$varname" == rtp_port_high ] && RTP_PORT_HIGH="" - [ "$varname" == rtp_timeout ] && RTP_TIMEOUT="" - [ "$varname" == default_expires ] && DEFAULT_EXPIRES="" - [ "$varname" == debug_level ] && DEBUG_LEVEL="" - [ "$varname" == debug_port ] && DEBUG_PORT="" - printf '%s\n' "$varname = $value" >> /var/etc/siproxd.conf - fi - fi - } - - mkdir -p /var/etc - > /var/etc/siproxd.conf - mkdir -p /var/lib/siproxd - chmod 777 /var/lib/siproxd - mkdir -p /var/run/siproxd - chmod 777 /var/run/siproxd - CONFIG_FILE=/var/etc/siproxd.conf - SIP_LISTEN_PORT=5060 - DAEMONIZE=1 - SILENCE_LOG=0 - LOG_CALLS=1 - USER=nobody - REGISTRATION_FILE=/var/lib/siproxd/siproxd_registrations - PID_FILE=/var/run/siproxd/siproxd.pid - RTP_PROXY_ENABLE=1 - RTP_PORT_LOW=7070 - RTP_PORT_HIGH=7089 - RTP_TIMEOUT=300 - DEFAULT_EXPIRES=600 - DEBUG_LEVEL=0x00000000 - DEBUG_PORT=0 config_load siproxd - [ -n "$SIP_LISTEN_PORT" ] && printf '%s\n' "sip_listen_port = $SIP_LISTEN_PORT" >> /var/etc/siproxd.conf - [ -n "$DAEMONIZE" ] && printf '%s\n' "daemonize = $DAEMONIZE" >> /var/etc/siproxd.conf - [ -n "$SILENCE_LOG" ] && printf '%s\n' "silence_log = $SILENCE_LOG" >> /var/etc/siproxd.conf - [ -n "$LOG_CALLS" ] && printf '%s\n' "log_calls = $LOG_CALLS" >> /var/etc/siproxd.conf - [ -n "$USER" ] && printf '%s\n' "user = $USER" >> /var/etc/siproxd.conf - [ -n "$REGISTRATION_FILE" ] && printf '%s\n' "registration_file = $REGISTRATION_FILE" >> /var/etc/siproxd.conf - [ -n "$PID_FILE" ] && printf '%s\n' "pid_file = $PID_FILE" >> /var/etc/siproxd.conf - [ -n "$RTP_PROXY_ENABLE" ] && printf '%s\n' "rtp_proxy_enable = $RTP_PROXY_ENABLE" >> /var/etc/siproxd.conf - [ -n "$RTP_PORT_LOW" ] && printf '%s\n' "rtp_port_low = $RTP_PORT_LOW" >> /var/etc/siproxd.conf - [ -n "$RTP_PORT_HIGH" ] && printf '%s\n' "rtp_port_high = $RTP_PORT_HIGH" >> /var/etc/siproxd.conf - [ -n "$RTP_TIMEOUT" ] && printf '%s\n' "rtp_timeout = $RTP_TIMEOUT" >> /var/etc/siproxd.conf - [ -n "$DEFAULT_EXPIRES" ] && printf '%s\n' "default_expires = $DEFAULT_EXPIRES" >> /var/etc/siproxd.conf - [ -n "$DEBUG_LEVEL" ] && printf '%s\n' "debug_level = $DEBUG_LEVEL" >> /var/etc/siproxd.conf - [ -n "$DEBUG_PORT" ] && printf '%s\n' "debug_port = $DEBUG_PORT" >> /var/etc/siproxd.conf - reset_cb - include /lib/network - scan_interfaces - config_load /var/state/network - if [ -n "$IF_INBOUND" ]; then - config_get IF_INBOUND "$IF_INBOUND" ifname - printf '%s\n' "if_inbound = $IF_INBOUND" >> /var/etc/siproxd.conf - fi - if [ -n "$IF_OUTBOUND" ]; then - config_get IF_OUTBOUND "$IF_OUTBOUND" ifname - printf '%s\n' "if_outbound = $IF_OUTBOUND" >> /var/etc/siproxd.conf - fi - /usr/sbin/siproxd --config "$CONFIG_FILE" + config_foreach start_instance siproxd } stop() { - killall siproxd + config_load siproxd + config_foreach stop_instance siproxd + # for case when pid file was not written + # because of permission issues + pkill ${siproxd_bin##*/} } diff --git a/net/siproxd/patches/010-fix-bogus-libltdl-dependency.patch b/net/siproxd/patches/010-fix-bogus-libltdl-dependency.patch index 521de7238..20f3b6b5d 100644 --- a/net/siproxd/patches/010-fix-bogus-libltdl-dependency.patch +++ b/net/siproxd/patches/010-fix-bogus-libltdl-dependency.patch @@ -1,24 +1,26 @@ --- a/src/Makefile.am +++ b/src/Makefile.am -@@ -26,8 +26,7 @@ AM_CFLAGS = -Wall -D_GNU_SOURCE \ - # Siproxd itself +@@ -77,8 +77,8 @@ plugin_regex_la_LDFLAGS = -module -avoid + # else Cygwin goes beserk when building...) # sbin_PROGRAMS = siproxd -siproxd_LDFLAGS=-export-dynamic --siproxd_LDADD = $(LIBLTDL) +-siproxd_LDADD = $(LIBLTDL) $(DLOPENPLUGINS) +siproxd_LDFLAGS=-export-dynamic -lltdl ++siproxd_LDADD = $(DLOPENPLUGINS) siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \ sip_utils.c sip_layer.c log.c readconf.c rtpproxy.c \ rtpproxy_relay.c accessctl.c route_processing.c \ --- a/src/Makefile.in +++ b/src/Makefile.in -@@ -259,8 +259,7 @@ target_vendor = @target_vendor@ - AM_CFLAGS = -Wall -D_GNU_SOURCE \ - -DBUILDSTR="\"`cat .buildno`\"" - +@@ -326,8 +326,8 @@ plugin_prefix_la_LDFLAGS = -module -avoi + # + plugin_regex_la_SOURCES = plugin_regex.c + plugin_regex_la_LDFLAGS = -module -avoid-version -shrext '.so' -siproxd_LDFLAGS = -export-dynamic --siproxd_LDADD = $(LIBLTDL) +-siproxd_LDADD = $(LIBLTDL) $(DLOPENPLUGINS) +siproxd_LDFLAGS = -export-dynamic -lltdl ++siproxd_LDADD = $(DLOPENPLUGINS) siproxd_SOURCES = siproxd.c proxy.c register.c sock.c utils.c \ sip_utils.c sip_layer.c log.c readconf.c rtpproxy.c \ rtpproxy_relay.c accessctl.c route_processing.c \