# HG changeset patch # User Michael Schloh von Bennewitz # Date 1316606656 -7200 # Node ID 67e813202d5307f1da9a44bb0788ff02d6c11c18 # Parent 8f552d1cd6717580fabfbc14768674a1e6a9c6ed Introduce severe but necessary corrections and update to new vendor version. diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.cfg --- a/opensips/opensips.cfg Wed Sep 21 14:02:13 2011 +0200 +++ b/opensips/opensips.cfg Wed Sep 21 14:04:16 2011 +0200 @@ -2,197 +2,380 @@ ## opensips.cfg -- OpenSIPS server configuration ## + +# General configuration help available at: +# http://siprouter.teigre.com/doc/gettingstarted/ + +# Specific routing help available at: +# http://www.opensips.org/index.php?n=Resources.DocsCoreRoutes + +# Information on debug and log levels +# http://www.voice-system.ro/docs/ser-syslog/ + +# Die Konfigbloecke sind: +# Global Configuration Parameters +# Extension Module Loading +# Extension Module Configuration +# Main Request Routing Logic +# Secondary Request Routing Logic +# Branch Request Routing Logic +# Reply Request Routing Logic +# Failure Request Routing Logic +# Local Request Routing Logic +# Error Request Routing Logic # -# GLOBAL CONFIGURATION PARAMETERS +# Logging: +# L_ALERT (-3) - used if the error requires immediate action. +# L_CRIT (-2) - used if the error is a critical situation. +# L_ERR (-1) - used if the error doesn't cause system malfunctioning. +# L_WARN (1) - used to write warning messages. +# L_NOTICE (2) - used to report unusual situations. +# L_INFO (3) - used to write informational messages. +# L_DBG (4) - used to write messages for debugging. + + # - +# Global Configuration Parameters +# # process configuration -debug=1 +debug=4 log_stderror=no fork=yes -check_via=no -dns=no -rev_dns=no -children=4 +children=2 +tcp_children=2 user="@l_rusr@" group="@l_rgrp@" -fifo="@l_prefix@/var/opensips/opensips.fifo" -workdir="@l_prefix@/var/opensips" +wdir="@l_prefix@/var/opensips" # network configuration -alias="sip.example.com" -listen="127.0.0.1" -port=5060 +listen=udp:voip.realhost.tld:5060 +#listen = tls:voip.realhost.tld:5061 + +# network aliases +alias=voip.firsthost.tld:5060 +#alias=voip.firsthost.tld:5061 +alias=voip.secondhost.tld:5060 +#alias=voip.secondhost.tld:5061 + +# enable TLS +#https://confluence.terena.org/display/IPTelCB/3.5.2.+TLS+for+OpenSER+(UA-Proxy) +#http://www.opensips.org/html/docs/tutorials/tls-1.4.x.html +# +#Run 'openserctl tls rootCA' to create @l_prefix@/etc/openser/tls/rootCA/cacert.pem. +#Run 'openserctl tls userCERT' to create user-calist.pem, user-cert.pem, user-cert_req.pem, and user-privkey.pem in @l_prefix@/etc/openser/tls/user/. +#Copy @l_prefix@/etc/openser/tls/rootCA/cacert.pem to the client host. +#On Windows XP client hosts, run 'certmrg.msc' to import the certificate into the root certificate store. +# +#disable_tls = 0 +#tls_method = TLSv1 +#tls_verify_server = 1 +#tls_verify_client = 1 +#tls_require_client_certificate = 1 +#tls_ciphers_list = "HIGH:MEDIUM:!ADH" # openssl ciphers -v HIGH:MEDIUM +#tls_certificate = "@l_prefix@/etc/opensips/tls/user/user-cert.pem" +#tls_private_key = "@l_prefix@/etc/opensips/tls/user/user-privkey.pem" +#tls_ca_list = "@l_prefix@/etc/opensips/tls/user/user-calist.pem" + # -# EXTENSION MODULE LOADING +# Extension Module Loading +# http://www.opensips.org/index.php?n=Resources.DocsModules # +# set module path +mpath="@l_prefix@/lib/opensips/modules/" -#loadmodule "@l_prefix@/lib/opensips/modules/dbtext.so" +loadmodule "sl.so" # Stateless replier +loadmodule "tm.so" # Transaction stateful +loadmodule "signaling.so" # Signaling wrapper of sl/tm +loadmodule "rr.so" # Record Route and Route +loadmodule "maxfwd.so" # Maximum Forward processor +loadmodule "db_text.so" # Text backend for database API +loadmodule "usrloc.so" # User location implementation +loadmodule "registrar.so" # SIP Registrar implementation +loadmodule "uri.so" # Generic URI operation +loadmodule "auth.so" # Authentication Interface +loadmodule "textops.so" # Text based manipulations +loadmodule "acc.so" # Accounting +loadmodule "auth_db.so" # Database backend authentication +loadmodule "mi_fifo.so" # FIFO support for Management Interface +#loadmodule "flatstore.so" # Fast writing only text database +#loadmodule "alias_db.so" # Database aliases +#loadmodule "domain.so" # Multidomain support +#loadmodule "nathelper.so" # NAT traversal helper +#loadmodule "enum.so" # ENUM lookup -loadmodule "@l_prefix@/lib/opensips/modules/sl.so" -loadmodule "@l_prefix@/lib/opensips/modules/tm.so" -loadmodule "@l_prefix@/lib/opensips/modules/rr.so" -loadmodule "@l_prefix@/lib/opensips/modules/maxfwd.so" -loadmodule "@l_prefix@/lib/opensips/modules/usrloc.so" -loadmodule "@l_prefix@/lib/opensips/modules/registrar.so" -loadmodule "@l_prefix@/lib/opensips/modules/textops.so" - -#loadmodule "@l_prefix@/lib/opensips/modules/auth.so" -#loadmodule "@l_prefix@/lib/opensips/modules/auth_db.so" - -#loadmodule "@l_prefix@/lib/opensips/modules/nathelper.so" # -# EXTENSION MODULE CONFIGURATION +# Extension Module Configuration # +# ----- dbtext params ----- +modparam("db_text", "db_mode", 0) # caching for persistence -# module rr: -modparam("rr", "enable_full_lr", 1) +# ----- multimodule params ----- +modparam("usrloc|uri|auth_db", "db_url", "text://@l_prefix@/var/opensips/db") -# module usrloc: -modparam("usrloc", "db_mode", 0) -#modparam("usrloc", "db_mode", 2) -#modparam("usrloc|auth_db", "db_url", "dbtext://@l_prefix@/var/opensips/db") +# ----- rr params ----- +modparam("rr", "append_fromtag", 1) # important when using detect_direction -# module auth: -#modparam("auth_db", "calculate_ha1", 1) -#modparam("auth_db", "password_column", "password") -#modparam("auth_db", "user_column", "username") -#modparam("auth_db", "domain_column", "domain") +# ----- usrloc params ----- +/* see 'multimodule params' as well */ +modparam("usrloc", "db_mode", 2) # Write back database persistence scheme -# module nathelper: -#modparam("registrar", "nat_flag", 6) -#modparam("nathelper", "natping_interval", 30) -#modparam("nathelper", "ping_nated_only", 1) -#modparam("nathelper", "rtpproxy_sock", "unix:@l_prefix@/var/opensips/opensips_rtpproxy.sock") -#modparam("nathelper", "rtpproxy_disable", 0) -#modparam("nathelper", "rtpproxy_disable_tout", 20) -#modparam("nathelper", "sipping_from", "sip:pinger@sip.example.com") +# ----- registrar params ----- +modparam("registrar", "max_contacts", 10) # contacts per AOR allowed + +# ----- acc params ----- +/* see 'multimodule params' as well */ +modparam("acc", "db_url", "dbtext://@l_prefix@/var/opensips/db") +#modparam("acc", "db_url", "flatstore:@l_prefix@/var/opensips/acc") +modparam("acc", "early_media", 1) +modparam("acc", "report_cancels", 1) +modparam("acc", "detect_direction", 1) +modparam("acc", "log_level", 2) +modparam("acc", "log_flag", 1) +modparam("acc", "log_missed_flag", 2) +modparam("acc", "db_flag", 1) +modparam("acc", "db_missed_flag", 2) +modparam("acc", "failed_transaction_flag", 4) + +# ----- mi_fifo params ----- +modparam("mi_fifo", "fifo_name", "@l_prefix@/var/opensips/opensips.fifo") +modparam("mi_fifo", "reply_dir", "@l_prefix@/var/opensips/tmp/") + # -# MAIN ROUTING LOGIC +# Main Request Routing Logic # +route { + # message diagnostics + #log(3, "new branch at $ru\n"); + xlog("L_INFO", "$rm: Orig - $ou\n"); + xlog("L_INFO", "$rm: Req - $ru\n"); + xlog("L_INFO", "$rm: To - $tu\n"); + xlog("L_INFO", "$rm: Dest - $du\n"); + xlog("L_INFO", "$rm: From - $fu\n"); -route{ - # initial sanity checks -- messages with - # max_forwards==0, or excessively long requests - if (!mf_process_maxfwd_header("10")) { - sl_send_reply("483", "Too Many Hops"); + # sanity checks + if (!mf_process_maxfwd_header("10")) { # avoid loops in forward logic + sl_send_reply("483","Too Many Hops"); exit; - }; - if (msg:len >= max_len) { - sl_send_reply("513", "Message too big"); + } + if (msg:len > max_len) { # repel DoS attacks + sl_send_reply("513", "Message Too Large"); exit; }; - #if (method == "INVITE" && uri != myself) { - # sl_send_reply("403", "No relaying"); - # exit; - #}; + # sequential request within a dialog should + # take the path determined by record routing + if (has_totag()) { + if (loose_route()) { + if (is_method("BYE")) { + setflag(1); # do accouting... + setflag(4); # ...even if the transaction fails + } + # mark routing logic in request + append_hf("P-hint: rr-enforced\r\n"); + route(1); + } else { + sl_send_reply("404", "Not Found"); + } + exit; + } - # NAT: special handling for NAT'ed clients; first, NAT test is - # executed: it looks for via!=received and RFC1918 addresses in - # Contact (may fail if line-folding is used); also, the received - # test should, if completed, should check all vias for presence of - # received. - #if (nat_uac_test("3")) { - # # allow RR-ed requests, as these may indicate that NAT-enabled - # # aproxy takes care of it; unless it is REGISTER - # if (method == "REGISTER" || ! search("^Record-Route:")) { - # log("LOG: Someone trying to register from private IP, rewriting\n"); - # fix_nated_contact(); # rewrite contact with source IP of signalling - # if (method == "INVITE") { - # fix_nated_sdp("1"); # add direction=active to SDP - # }; - # force_rport(); # add rport parameter to topmost Via - # setflag(6); # mark as NAT'ed - # }; - #}; + # + # initial requests + # + if (is_method("CANCEL")) { # CANCEL processing + if (t_check_trans()) + t_relay(); + exit; + } - # we record-route all messages -- to make sure that - # subsequent messages will go through our proxy; that's - # particularly good if upstream and downstream entities - # use different transport protocol - if (method != "REGISTER") { + t_check_trans(); + + # authenticate if from local subscriber (uncomment to enable auth) + #if (!is_method("REGISTER") && from_uri == myself) { + # if (!proxy_authorize("", "subscriber")) { + # proxy_challenge("", "0"); + # exit; + # } + # if (!check_from()) { + # sl_send_reply("403","Forbidden"); + # exit; + # } + # + # consume_credentials(); + # # caller authenticated + #} + + # record route all messages to ensure that subsequent messages + # will go through our proxy, particularly good if upstream + # and downstream entities use different transport protocol + if (!is_method("REGISTER|MESSAGE")) { record_route(); - }; + } - # subsequent messages withing a dialog should take the - # path determined by record-routing - if (loose_route()) { - # mark routing logic in request - append_hf("P-hint: rr-enforced\r\n"); + # account only INVITEs + if (is_method("INVITE")) { + setflag(1); + } + + if (!uri == myself) { + /* replace with following line if multidomain support is used */ + #if (!is_uri_host_local()) { + append_hf("P-hint: outbound\r\n"); + # if you have some interdomain connections via TLS + #if ($rd == "tls_domain1.net") { + # t_relay("tls:domain1.net"); + # exit; + #} else if ($rd == "tls_domain2.net") { + # t_relay("tls:domain2.net"); + # exit; + #} route(1); - }; + } - if (uri != myself) { - # mark routing logic in request - append_hf("P-hint: outbound\r\n"); - route(1); - }; + # + # requests for my domain + # + if (is_method("PUBLISH")) { + sl_send_reply("503", "Service Unavailable"); + exit; + } - # if the request is for other domain use USRLOC - # (in case, it does not work, use the following command - # with proper names and addresses in it) - if (uri == myself) { - if (method == "REGISTER") { - # uncomment this if you want to use digest authentication - #if (!www_authorize("sip.example.com", "subscriber")) { - # www_challenge("sip.example.com", "0"); - # exit; - #}; - save("location"); + if (is_method("REGISTER")) { + # authenticate the REGISTER requests (uncomment to enable auth) + #if (!www_authorize("", "subscriber")) { + # www_challenge("", "0"); + # exit; + #} + # + #if (!check_to()) { + # sl_send_reply("403","Forbidden"); + # exit; + #} + + if (!save("location")) + sl_reply_error(); + + exit; + } + + if ($rU == NULL) { + # request with no Username in RURI + sl_send_reply("484","Address Incomplete"); + exit; + } + + lookup("location"); + switch ($retcode) { + case 1: + append_hf("P-hint: usrloc applied\r\n"); + break; + case -1: + t_newtran(); + t_reply("404", "Not Found"); exit; - }; + case -2: + sl_send_reply("405", "Method Not Allowed"); + exit; + case -3: + t_newtran(); + t_reply("500", "Server Internal Error"); + exit; + } - lookup("aliases"); - if (uri != myself) { - append_hf("P-hint: outbound alias\r\n"); - route(1); - }; - - # native SIP destinations are handled using our USRLOC DB - if (!lookup("location")) { - sl_send_reply("404", "Not Found"); - exit; - }; - append_hf("P-hint: usrloc applied\r\n"); - }; - - route(1); + setflag(2); # when routing via usrloc then + route(1); # log the missed calls as well } + +# +# Secondary Request Routing Logic +# route[1] { - # disable RFC1918 peers - if (uri =~ "[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && !search("^Route:")) { - sl_send_reply("479", "We don't forward to RFC 1918 IPv4 addresses"); - exit; - }; - - # NAT: if client or server know to be behind a NAT, enable relay - #if (isflagset(6)) { - # force_rtp_proxy(); - #}; - - # NAT: processing of replies; apply to all transactions - #t_on_reply("1"); - - # send it out now; use stateful forwarding as it works reliably even for UDP2TCP - if (!t_relay()) { + # for INVITEs enable some additional helper routes + if (is_method("INVITE")) { + t_on_branch("1"); + t_on_reply("1"); + t_on_failure("1"); + } + + # send with stateful forwarding which works reliably even for UDP2TCP + if (!t_relay()) sl_reply_error(); - }; + + exit; # safeguard } -#onreply_route[1] { - # NAT: is it a NAT'ed transaction ? - # otherwise, is it a transaction behind a NAT and we did not - # know at time of request processing ? (RFC1918 contacts) - #if (isflagset(6) && status =~ "(183)|2[0-9][0-9]") { - # fix_nated_contact(); - # force_rtp_proxy(); - #} else if (nat_uac_test("1")) { - # fix_nated_contact(); - #}; -#} +# +# Branch Request Routing Logic +# +branch_route[1] { + xlog("L_INFO", "new branch at $ru\n"); +} + + +# +# Reply Request Routing Logic +# +onreply_route[1] { + xlog("L_INFO", "incoming reply at $ru\n"); +# if ($ua =~ fritz.box) +# xlog("L_ERR", "$rm: The Fritzbox replied!\n"); +# if ($ua =~ fritz.box && has_body("application/sdp")) +# search_append_body("a=sendrecv.*", "\na=ptime:30"); +} + + +# +# Failure Request Routing Logic +# +failure_route[1] { + xlog("L_INFO", "failed route at $ru\n"); + if (t_was_cancelled()) + exit; + + # uncomment the following lines to block + # client redirect based on 3xx replies + #if (t_check_status("3[0-9][0-9]")) { + #t_reply("404","Not Found"); + # exit; + #} + + # uncomment the following lines to redirect + # failed calls to a different new destination + #if (t_check_status("486|408")) { + # sethostport("192.168.2.100:5060"); + # append_branch(); + # # do not set the missed call flag again + # t_relay(); + #} +} + + +# +# Local Request Routing Logic +# +local_route { + if (is_method("INVITE") && $ru=~"@foreign.tld") { + append_hf("P-hint: foreign request\r\n"); + exit; + } + if (is_method("BYE")) + xlog("L_INFO", "internally generated BYE\n"); +} + + +# +# Error Request Routing Logic +# +error_route { + xlog("L_ERR", "error route class=$(err.class) level=$(err.level) info=$(err.info) rcode=$(err.rcode) rreason=$(err.rreason)\n"); + xlog("L_ERR", "error from [$si:$sp]\n"); + xlog("L_ERR", "++++\n$mb\n++++\n"); + sl_send_reply("$err.rcode", "$err.rreason"); + exit; +} + diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch --- a/opensips/opensips.patch Wed Sep 21 14:02:13 2011 +0200 +++ b/opensips/opensips.patch Wed Sep 21 14:04:16 2011 +0200 @@ -1,29 +1,96 @@ +Index: main.c +diff -Nau main.c.orig main.c +--- main.c.orig 2009-12-10 14:11:03.590141302 +0100 ++++ main.c 2009-12-10 14:11:07.246237908 +0100 +@@ -1038,6 +1038,10 @@ + ret=-1; + my_argc=argc; my_argv=argv; + ++ /* if (!log_stderr), that's not usable yet! '/ ++ /* ...so unconditionally log to syslog for now */ ++ openlog(argv[0], LOG_PID|LOG_CONS, log_facility); ++ + /*init pkg mallocs (before parsing cfg or cmd line !)*/ + if (init_pkg_mallocs()==-1) + goto error00; +@@ -1370,6 +1374,11 @@ + + /* init_daemon? */ + if (!dont_fork){ ++ /* shortly after main() we called openlog(3) to log */ ++ /* the initialization, but since daemonize() has its */ ++ /* own syslog(3) handling, we need to close the log first */ ++ closelog(); /* close the initialization logging logic */ ++ + if ( daemonize((log_name==0)?argv[0]:log_name, &own_pgid) <0 ) + goto error; + } Index: Makefile.defs ---- Makefile.defs.orig 2009-03-23 19:32:01 +0100 -+++ Makefile.defs 2009-03-24 19:10:36 +0100 -@@ -1161,6 +1161,8 @@ +diff -Nau Makefile.defs.orig Makefile.defs +--- Makefile.defs.orig 2007-12-13 14:39:06.000000000 +0100 ++++ Makefile.defs 2008-01-14 16:48:02.811615000 +0100 +@@ -220,7 +220,7 @@ + else + doc-dir = doc/$(MAIN_NAME)/ + man-dir = man/ +- data-dir = $(MAIN_NAME)/ ++ data-dir = share/$(MAIN_NAME)/ + LOCALBASE ?= $(SYSBASE)/local + endif + endif +@@ -1432,6 +1432,10 @@ + LIBS+= -lsctp + endif - endif #mode=release - ++#conditionally add libfsl +LDFLAGS += -L$(prefix)/lib +LIBS += -lfsl ++ + ifneq ($(found_lock_method), yes) + $(warning No locking method found so far, trying SYS V sems) + DEFS+= -DUSE_SYSV_SEM # try sys v sems +Index: scripts/opensipsctl.8 +diff -Nau scripts/opensipsctl.8.orig scripts/opensipsctl.8 +--- scripts/opensipsctl.8.orig 2009-03-25 00:22:16.771365571 +0100 ++++ scripts/opensipsctl.8 2009-03-25 00:22:34.295365555 +0100 +@@ -20,8 +20,6 @@ - #*FLAGS used for compiling the modules - ifeq ($(CC_NAME), gcc) -@@ -1397,8 +1399,8 @@ + .SH FILES + .PD 0 +-.I /etc/opensips/.opensipsctlrc +-.br + .I /usr/local/etc/opensips/.opensipsctlrc + .br + .I ~/.opensipsctlrc +Index: scripts/osipsconsole +diff -Nau scripts/osipsconsole.orig scripts/osipsconsole +--- scripts/osipsconsole.orig 2009-12-08 03:31:32.633224883 +0100 ++++ scripts/osipsconsole 2009-12-08 03:31:51.119960848 +0100 +@@ -30,7 +30,6 @@ + use Term::ReadLine; + use DBI; + use POSIX; +-use Frontier::RPC2; + use IO::Socket; + use Socket; + #use Net::IP; +@@ -378,6 +377,12 @@ + } + } - #add libssl if needed - ifneq ($(TLS),) --DEFS+= -I$(LOCALBASE)/ssl/include -I$(LOCALBASE)/include -I$(SYSBASE)/include/openssl --LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto -+DEFS+= -I$(prefix)/include -+LIBS+= -L$(prefix)/lib -lssl -lcrypto - endif - - #add libsctp if needed ++ if ( $MD5 eq "" ) { ++ if ( $arr[0] =~ /^\s*MD5/ ) { ++ $MD5 = $arr[1]; ++ } ++ } ++ + if ( $AWK eq "" ) { + if ( $arr[0] =~ /^\s*AWK/ ) { + $AWK = $arr[1]; Index: modules/permissions/parse_config.c ---- modules/permissions/parse_config.c.orig 2009-03-23 19:31:32 +0100 -+++ modules/permissions/parse_config.c 2009-03-24 19:10:36 +0100 +diff -Nau modules/permissions/parse_config.c.orig modules/permissions/parse_config.c +--- modules/permissions/parse_config.c.orig 2008-08-03 15:54:01 +0200 ++++ modules/permissions/parse_config.c 2008-08-09 11:58:55 +0200 @@ -114,8 +114,11 @@ except = strstr(str, " EXCEPT "); if (except) { @@ -48,18 +115,82 @@ *e_exceptions = NULL; } -Index: rtpproxy-1.2.1/main.c ---- rtpproxy-1.2.1/main.c.orig 2009-03-24 05:46:13 +0100 -+++ rtpproxy-1.2.1/main.c 2009-03-24 19:10:36 +0100 -@@ -88,7 +88,11 @@ - bindhost = NULL; - - if ((n = resolve(ia, pf, bindhost, servname, AI_PASSIVE)) != 0) -+#if defined(__sun__) -+ errx(1, "setbindhost"); -+#else - errx(1, "setbindhost: %s", gai_strerror(n)); -+#endif +Index: modules/nathelper/nathelper.c +diff -Nau modules/nathelper/nathelper.c.orig modules/nathelper/nathelper.c +--- modules/nathelper/nathelper.c.orig 2010-12-20 14:33:50.000000000 +0100 ++++ modules/nathelper/nathelper.c 2011-01-26 17:48:40.685941382 +0100 +@@ -288,6 +288,9 @@ + return 0; } - static void ++/* MSvB macros */ ++#define OPENSIPS_NOOP ((void)0) ++ + + + +@@ -805,6 +808,7 @@ + #define FIX_MEDIP 0x02 + #define ADD_ANORTPPROXY 0x04 + #define FIX_ORGIP 0x08 ++#define FIX_RTCPIP 0x10 + + #define ADIRECTION "a=direction:active" + #define ADIRECTION_LEN (sizeof(ADIRECTION) - 1) +@@ -821,7 +825,9 @@ + { + char *buf; + int offset; ++ int binlump; + struct lump* anchor; ++ struct lump* templump; + str omip, nip, oip; + + /* check that updating mediaip is really necessary */ +@@ -852,7 +858,19 @@ + memcpy(buf, CRLF, CRLF_LEN); + memcpy(buf + CRLF_LEN, omip.s, omip.len); + memcpy(buf + CRLF_LEN + omip.len, oldip->s, oldip->len); +- if (insert_new_lump_after(anchor, buf, ++ ++ /* if the oldmediaip string is already */ ++ /* in the body then don't add it again */ ++ binlump = 0; ++ for (templump = msg->body_lumps; templump; templump = templump->next) ++ if (templump->op == LUMP_ADD && strstr(templump->u.value, buf)) ++ binlump = 1; ++ for (templump = msg->add_rm; templump; templump = templump->next) ++ if (templump->op == LUMP_ADD && strstr(templump->u.value, buf)) ++ binlump = 1; ++ if (strstr(body->s, buf) || binlump) ++ pkg_free(buf); ++ else if (insert_new_lump_after(anchor, buf, + omip.len + oldip->len + CRLF_LEN, 0) == NULL) { + LM_ERR("insert_new_lump_after failed\n"); + pkg_free(buf); +@@ -1038,6 +1056,12 @@ + p= p->next; + } + ++ if (level & FIX_RTCPIP) { ++ /* Iterate all a=rtcp: and replace ips in them. */ ++ if (replace_sdp_ip(msg, &body, "a=rtcp:", str2?&ip:0)==-1) ++ return -1; ++ } ++ + return 1; + } + +Index: parser/sdp/sdp_helpr_funcs.c +diff -Nau parser/sdp/sdp_helpr_funcs.c.orig parser/sdp/sdp_helpr_funcs.c +--- parser/sdp/sdp_helpr_funcs.c.orig 2010-12-08 15:14:06.000000000 +0100 ++++ parser/sdp/sdp_helpr_funcs.c 2011-01-27 00:39:50.128212053 +0100 +@@ -392,7 +392,7 @@ + + cp1 = NULL; + for (cp = body->s; (len = body->s + body->len - cp) > 0;) { +- cp1 = (char*)ser_memmem(cp, line, len, 2); ++ cp1 = (char*)ser_memmem(cp, line, len, strlen(line)); + if (cp1 == NULL || cp1[-1] == '\n' || cp1[-1] == '\r') + break; + cp = cp1 + 2; diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.dict --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.dict Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,20 @@ +Index: etc/dictionary.opensips +diff -Nau etc/dictionary.opensips.orig etc/dictionary.opensips +--- etc/dictionary.opensips.orig 2011-01-15 08:08:46.712651102 +0100 ++++ etc/dictionary.opensips 2011-01-15 08:07:55.702748921 +0100 +@@ -14,6 +14,7 @@ + + + #### Attributes ### ++ATTRIBUTE Sip-Method 101 integer + ATTRIBUTE Sip-Uri-User 208 string # Proprietary, auth_radius + ATTRIBUTE Sip-Group 211 string # Proprietary, group_radius + ATTRIBUTE Sip-Rpid 213 string # Proprietary, auth_radius +@@ -23,6 +24,7 @@ + + ### Service-Type Values ### + VALUE Service-Type Group-Check 12 # Proprietary, group_radius ++VALUE Service-Type Sip-Session 15 + VALUE Service-Type SIP-Caller-AVPs 30 # Proprietary, avp_radius + VALUE Service-Type SIP-Callee-AVPs 31 # Proprietary, avp_radius + diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.lcr --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.lcr Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,384 @@ +Index: modules/lcr/lcr_mod.c +diff -Nau modules/lcr/lcr_mod.c.orig modules/lcr/lcr_mod.c +--- modules/lcr/lcr_mod.c.orig 2009-03-09 14:42:46.000000000 +0100 ++++ modules/lcr/lcr_mod.c 2009-03-24 22:50:37.363366116 +0100 +@@ -114,9 +114,18 @@ + + #define PRIORITY_COL "priority" + ++#define USER_COL "usid" ++ ++#define REALM_COL "realm" ++ ++#define PASSWD_COL "passwd" ++ + #define MAX_NO_OF_GWS 32 + #define MAX_NO_OF_LCRS 256 + #define MAX_PREFIX_LEN 256 ++#define MAX_USER_LEN 64 ++#define MAX_REALM_LEN 64 ++#define MAX_PASSWD_LEN 64 + #define MAX_TAG_LEN 16 + #define MAX_FROM_URI_LEN 256 + +@@ -141,6 +150,12 @@ + char tag[MAX_TAG_LEN + 1]; + unsigned short tag_len; + unsigned int flags; ++ char user[MAX_USER_LEN]; ++ unsigned short user_len; ++ char realm[MAX_REALM_LEN]; ++ unsigned short realm_len; ++ char passwd[MAX_PASSWD_LEN]; ++ unsigned short passwd_len; + }; + + struct lcr_info { +@@ -196,6 +211,9 @@ + static str prefix_col = str_init(PREFIX_COL); + static str from_uri_col = str_init(FROM_URI_COL); + static str priority_col = str_init(PRIORITY_COL); ++static str user_col = str_init(USER_COL); ++static str realm_col = str_init(REALM_COL); ++static str passwd_col = str_init(PASSWD_COL); + + /* timer */ + int fr_inv_timer = DEF_FR_INV_TIMER; +@@ -208,6 +226,9 @@ + static char *contact_avp_param = NULL; + static char *rpid_avp_param = NULL; + static char *flags_avp_param = NULL; ++static char *user_avp_param = NULL; ++static char *realm_avp_param = NULL; ++static char *passwd_avp_param = NULL; + + /* prefix mode */ + int prefix_mode_param = DEF_PREFIX_MODE; +@@ -239,6 +260,12 @@ + static int_str rpid_avp; + static int flags_avp_type; + static int_str flags_avp; ++static int user_avp_type; ++static int_str user_avp; ++static int realm_avp_type; ++static int_str realm_avp; ++static int passwd_avp_type; ++static int_str passwd_avp; + + struct gw_info **gws; /* Pointer to current gw table pointer */ + struct gw_info *gws_1; /* Pointer to gw table 1 */ +@@ -327,6 +354,12 @@ + {"fr_inv_timer", INT_PARAM, &fr_inv_timer }, + {"fr_inv_timer_next", INT_PARAM, &fr_inv_timer_next }, + {"prefix_mode", INT_PARAM, &prefix_mode_param }, ++ {"user_column", STR_PARAM, &user_col.s }, ++ {"realm_column", STR_PARAM, &realm_col.s }, ++ {"passwd_column", STR_PARAM, &passwd_col.s }, ++ {"auth_username_avp", STR_PARAM, &user_avp_param }, ++ {"auth_realm_avp", STR_PARAM, &realm_avp_param }, ++ {"auth_password_avp", STR_PARAM, &passwd_avp_param }, + {0, 0, 0} + }; + +@@ -438,6 +471,9 @@ + prefix_col.len = strlen(prefix_col.s); + from_uri_col.len = strlen(from_uri_col.s); + priority_col.len = strlen(priority_col.s); ++ user_col.len = strlen(user_col.s); ++ realm_col.len = strlen(realm_col.s); ++ passwd_col.len = strlen(passwd_col.s); + + /* Bind database */ + if (lcr_db_bind(&db_url)) { +@@ -563,6 +599,60 @@ + return -1; + } + ++ if (user_avp_param && *user_avp_param) { ++ s.s = user_avp_param; s.len = strlen(s.s); ++ if (pv_parse_spec(&s, &avp_spec)==0 ++ || avp_spec.type!=PVT_AVP) { ++ LM_ERR("Malformed or non AVP definition <%s>\n", user_avp_param); ++ return -1; ++ } ++ ++ if(pv_get_avp_name(0, &(avp_spec.pvp), &user_avp, &avp_flags)!=0) { ++ LM_ERR("Invalid AVP definition <%s>\n", user_avp_param); ++ return -1; ++ } ++ user_avp_type = avp_flags; ++ } else { ++ LM_ERR("AVP user_avp has not been defined\n"); ++ return -1; ++ } ++ ++ if (realm_avp_param && *realm_avp_param) { ++ s.s = realm_avp_param; s.len = strlen(s.s); ++ if (pv_parse_spec(&s, &avp_spec)==0 ++ || avp_spec.type!=PVT_AVP) { ++ LM_ERR("Malformed or non AVP definition <%s>\n", realm_avp_param); ++ return -1; ++ } ++ ++ if(pv_get_avp_name(0, &(avp_spec.pvp), &realm_avp, &avp_flags)!=0) { ++ LM_ERR("Invalid AVP definition <%s>\n", realm_avp_param); ++ return -1; ++ } ++ realm_avp_type = avp_flags; ++ } else { ++ LM_ERR("AVP realm_avp has not been defined\n"); ++ return -1; ++ } ++ ++ if (passwd_avp_param && *passwd_avp_param) { ++ s.s = passwd_avp_param; s.len = strlen(s.s); ++ if (pv_parse_spec(&s, &avp_spec)==0 ++ || avp_spec.type!=PVT_AVP) { ++ LM_ERR("Malformed or non AVP definition <%s>\n", passwd_avp_param); ++ return -1; ++ } ++ ++ if(pv_get_avp_name(0, &(avp_spec.pvp), &passwd_avp, &avp_flags)!=0) { ++ LM_ERR("Invalid AVP definition <%s>\n", passwd_avp_param); ++ return -1; ++ } ++ passwd_avp_type = avp_flags; ++ } else { ++ LM_ERR("AVP passwd_avp has not been defined\n"); ++ return -1; ++ } ++ + /* Check table version */ + db_con_t* dbh; + if (lcr_dbf.init==0){ +@@ -801,16 +891,17 @@ + int reload_gws(void) + { + unsigned int i, port, strip, tag_len, prefix_len, from_uri_len, +- grp_id, priority; ++ user_len, realm_len, passwd_len, grp_id, priority; + struct in_addr ip_addr; + unsigned int flags; + uri_type scheme; + uri_transport transport; + db_con_t* dbh; + char *tag, *prefix, *from_uri; ++ char *user, *realm, *passwd; + db_res_t* res = NULL; + db_row_t* row; +- db_key_t gw_cols[8]; ++ db_key_t gw_cols[11]; + db_key_t lcr_cols[4]; + + gw_cols[0] = &ip_addr_col; +@@ -823,6 +914,9 @@ + in the two tables? (ge vw lcr) */ + gw_cols[6] = &grp_id_col; + gw_cols[7] = &flags_col; ++ gw_cols[8] = &user_col; ++ gw_cols[9] = &realm_col; ++ gw_cols[10] = &passwd_col; + + lcr_cols[0] = &prefix_col; + lcr_cols[1] = &from_uri_col; +@@ -846,7 +940,7 @@ + return -1; + } + +- if (lcr_dbf.query(dbh, NULL, 0, NULL, gw_cols, 0, 8, 0, &res) < 0) { ++ if (lcr_dbf.query(dbh, NULL, 0, NULL, gw_cols, 0, 11, 0, &res) < 0) { + LM_ERR("Failed to query gw data\n"); + lcr_dbf.close(dbh); + return -1; +@@ -938,6 +1032,45 @@ + lcr_dbf.close(dbh); + return -1; + } ++ if (VAL_NULL(ROW_VALUES(row) + 8) == 1) { ++ user_len = 0; ++ user = (char *)0; ++ } else { ++ user = (char *)VAL_STRING(ROW_VALUES(row) + 8); ++ user_len = strlen(user); ++ if (user_len > MAX_USER_LEN) { ++ LM_ERR("Too long gw user <%u>\n", user_len); ++ lcr_dbf.free_result(dbh, res); ++ lcr_dbf.close(dbh); ++ return -1; ++ } ++ } ++ if (VAL_NULL(ROW_VALUES(row) + 9) == 1) { ++ realm_len = 0; ++ realm = (char *)0; ++ } else { ++ realm = (char *)VAL_STRING(ROW_VALUES(row) + 9); ++ realm_len = strlen(realm); ++ if (realm_len > MAX_REALM_LEN) { ++ LM_ERR("Too long gw realm <%u>\n", realm_len); ++ lcr_dbf.free_result(dbh, res); ++ lcr_dbf.close(dbh); ++ return -1; ++ } ++ } ++ if (VAL_NULL(ROW_VALUES(row) + 10) == 1) { ++ passwd_len = 0; ++ passwd = (char *)0; ++ } else { ++ passwd = (char *)VAL_STRING(ROW_VALUES(row) + 10); ++ passwd_len = strlen(passwd); ++ if (passwd_len > MAX_PASSWD_LEN) { ++ LM_ERR("Too long gw passwd <%u>\n", passwd_len); ++ lcr_dbf.free_result(dbh, res); ++ lcr_dbf.close(dbh); ++ return -1; ++ } ++ } + if (*gws == gws_1) { + gws_2[i].ip_addr = (unsigned int)ip_addr.s_addr; + gws_2[i].port = port; +@@ -949,6 +1082,15 @@ + gws_2[i].tag_len = tag_len; + if (tag_len) + memcpy(&(gws_2[i].tag[0]), tag, tag_len); ++ gws_2[i].user_len = user_len; ++ if (user_len) ++ memcpy(&(gws_2[i].user[0]), user, user_len); ++ gws_2[i].realm_len = realm_len; ++ if (realm_len) ++ memcpy(&(gws_2[i].realm[0]), realm, realm_len); ++ gws_2[i].passwd_len = passwd_len; ++ if (passwd_len) ++ memcpy(&(gws_2[i].passwd[0]), passwd, passwd_len); + } else { + gws_1[i].ip_addr = (unsigned int)ip_addr.s_addr; + gws_1[i].port = port; +@@ -960,6 +1102,15 @@ + gws_1[i].tag_len = tag_len; + if (tag_len) + memcpy(&(gws_1[i].tag[0]), tag, tag_len); ++ gws_1[i].user_len = user_len; ++ if (user_len) ++ memcpy(&(gws_1[i].user[0]), user, user_len); ++ gws_1[i].realm_len = realm_len; ++ if (realm_len) ++ memcpy(&(gws_1[i].realm[0]), realm, realm_len); ++ gws_1[i].passwd_len = passwd_len; ++ if (passwd_len) ++ memcpy(&(gws_1[i].passwd[0]), passwd, passwd_len); + } + } + +@@ -1141,6 +1292,21 @@ + attr = add_mi_attr(node, MI_DUP_VALUE, "FLAGS", 5, p, len); + if(attr == NULL) + return -1; ++ ++ attr = add_mi_attr(node, MI_DUP_VALUE, "USER", 6, ++ (*gws)[i].user, (*gws)[i].user_len ); ++ if(attr == NULL) ++ return -1; ++ ++ attr = add_mi_attr(node, MI_DUP_VALUE, "REALM", 6, ++ (*gws)[i].realm, (*gws)[i].realm_len ); ++ if(attr == NULL) ++ return -1; ++ ++ attr = add_mi_attr(node, MI_DUP_VALUE, "PASSWD", 6, ++ (*gws)[i].passwd, (*gws)[i].passwd_len ); ++ if(attr == NULL) ++ return -1; + } + + for (i = 0; i < MAX_NO_OF_LCRS; i++) { +@@ -1184,6 +1350,9 @@ + char ruri[MAX_URI_SIZE]; + unsigned int i, j, k, index, addr, port, strip, gw_index, + duplicated_gw, flags, have_rpid_avp; ++ char *user; ++ char *realm; ++ char *passwd; + uri_type scheme; + uri_transport transport; + struct ip_addr address; +@@ -1407,6 +1576,9 @@ + transport = (*gws)[index].transport; + flags = (*gws)[index].flags; + strip = (*gws)[index].strip; ++ user = (*gws)[index].user; ++ realm = (*gws)[index].realm; ++ passwd = (*gws)[index].passwd; + if (strip > ruri_user.len) { + LM_ERR("Strip count of gw is too large <%u>\n", strip); + goto skip; +@@ -1476,6 +1648,25 @@ + val.s = value; + add_avp(gw_uri_avp_type|AVP_VAL_STR, gw_uri_avp, val); + LM_DBG("Added gw_uri_avp <%.*s>\n", value.len, value.s); ++ ++ value.s = user; ++ value.len = strlen(value.s); ++ val.s = value; ++ add_avp(user_avp_type|AVP_VAL_STR, user_avp, val); ++ LM_DBG("Added user_avp <%.*s>\n", value.len, value.s); ++ ++ value.s = realm; ++ value.len = strlen(value.s); ++ val.s = value; ++ add_avp(realm_avp_type|AVP_VAL_STR, realm_avp, val); ++ LM_DBG("Added realm_avp <%.*s>\n", value.len, value.s); ++ ++ value.s = passwd; ++ value.len = strlen(value.s); ++ val.s = value; ++ add_avp(passwd_avp_type|AVP_VAL_STR, passwd_avp, val); ++ LM_DBG("Added passwd_avp <%.*s>\n", value.len, value.s); ++ + skip: + continue; + } +@@ -1558,7 +1749,8 @@ + static int next_gw(struct sip_msg* _m, char* _s1, char* _s2) + { + int_str gw_uri_val, ruri_user_val, val; +- struct usr_avp *gu_avp, *ru_avp; ++ int_str user_val, realm_val, passwd_val; ++ struct usr_avp *gu_avp, *ru_avp, *usr_avp, *rlm_avp, *pwd_avp; + int rval; + str new_ruri; + char *at, *at_char, *strip_char, *endptr; +@@ -1575,6 +1767,35 @@ + gw_uri_val.s.len = gw_uri_val.s.len - (at - gw_uri_val.s.s); + gw_uri_val.s.s = at; + ++ /* Save gateway AVPs for use in script */ ++ usr_avp = search_first_avp(user_avp_type, user_avp, &user_val, 0); ++ rlm_avp = search_first_avp(realm_avp_type, realm_avp, &realm_val, 0); ++ pwd_avp = search_first_avp(passwd_avp_type, passwd_avp, &passwd_val, 0); ++ if (!usr_avp) { ++ LM_DBG("User AVP no set\n"); ++ return -1; ++ } ++ else { ++ add_avp(user_avp_type|AVP_VAL_STR, user_avp, user_val); ++ LM_DBG("Added user_avp <%.*s>\n", user_val.s.len, user_val.s.s); ++ } ++ if (!rlm_avp) { ++ LM_DBG("Realm AVP no set\n"); ++ return -1; ++ } ++ else { ++ add_avp(realm_avp_type|AVP_VAL_STR, realm_avp, realm_val); ++ LM_DBG("Added realm_avp <%.*s>\n", realm_val.s.len, realm_val.s.s); ++ } ++ if (!pwd_avp) { ++ LM_DBG("Passwd AVP no set\n"); ++ return -1; ++ } ++ else { ++ add_avp(passwd_avp_type|AVP_VAL_STR, passwd_avp, passwd_val); ++ LM_DBG("Added passwd_avp <%.*s>\n", passwd_val.s.len, passwd_val.s.s); ++ } ++ + /* Create new Request-URI taking URI user from ruri_user AVP + and other parts of from gateway URI AVP. */ + ru_avp = search_first_avp(ruri_user_avp_type, ruri_user_avp, diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.reg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.reg Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,85 @@ +Index: modules/registrar/save.c +diff -Nau modules/registrar/save.c.orig modules/registrar/save.c +--- modules/registrar/save.c.orig 2008-08-03 15:53:57.000000000 +0200 ++++ modules/registrar/save.c 2009-03-24 21:44:46.182865192 +0100 +@@ -76,7 +76,7 @@ + struct save_ctx { + unsigned int flags; + str aor; +- unsigned int max_contacts; ++ int max_contacts; + }; + + +@@ -388,7 +388,7 @@ + if (e == 0) + continue; + +- if (_sctx->max_contacts && (num >= _sctx->max_contacts)) { ++ if (_sctx->max_contacts && (num >= abs(_sctx->max_contacts))) { + if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { + /* we are overflowing the number of maximum contacts, + so remove the first (oldest) one to prevent this */ +@@ -494,6 +494,7 @@ + contact_t* _c, struct save_ctx *_sctx) + { + ucontact_info_t *ci; ++ ucontact_t *ucon = 0; + ucontact_t* c; + int e; + unsigned int cflags; +@@ -554,7 +555,7 @@ + continue; + + /* we need to add a new contact -> too many ?? */ +- if (_sctx->max_contacts && num>=_sctx->max_contacts) { ++ if (_sctx->max_contacts && num>=abs(_sctx->max_contacts)) { + if (_sctx->flags®_SAVE_FORCE_REG_FLAG) { + /* we are overflowing the number of maximum contacts, + so remove the first (oldest) one to prevent this */ +@@ -581,6 +582,23 @@ + goto error; + } + ++ /* remove matching contacts or matching Call-ID headers before */ ++ /* inserting a new one if indicated by a negative max_contacts */ ++ if (_sctx->max_contacts < 0) { ++ for (ucon = _r->contacts; ucon; ucon = ucon->next) { ++ if (((ci->callid->len == ucon->callid.len) && \ ++ !memcmp(ci->callid->s, ucon->callid.s, ci->callid->len)) \ ++ || \ ++ ((_c->uri.len==ucon->c.len) && \ ++ !memcmp(_c->uri.s, ucon->c.s, _c->len))) { ++ if (ul.delete_ucontact(_r, ucon) < 0) { ++ rerrno = R_UL_DEL_C; ++ LM_ERR("failed to delete contact\n"); ++ goto error; ++ } ++ } ++ } ++ } + if (ul.insert_ucontact( _r, &_c->uri, ci, &c) < 0) { + rerrno = R_UL_INS_C; + LM_ERR("failed to insert contact\n"); +Index: modules/registrar/sip_msg.c +diff -Nau modules/registrar/sip_msg.c.orig modules/registrar/sip_msg.c +--- modules/registrar/sip_msg.c.orig 2008-08-03 15:53:57.000000000 +0200 ++++ modules/registrar/sip_msg.c 2009-03-24 21:44:46.182865192 +0100 +@@ -137,7 +137,7 @@ + /* Message without contacts is OK */ + if (_m->contact == 0) return 0; + +- if (((contact_body_t*)_m->contact->parsed)->star == 1) { ++ if (((contact_body_t*)_m->contact->parsed)->star == -1) { + /* The first Contact HF is star */ + /* Expires must be zero */ + if (get_expires_hf(_m) > 0) { +@@ -167,7 +167,7 @@ + p = _m->contact->next; + while(p) { + if (p->type == HDR_CONTACT_T) { +- if (((contact_body_t*)p->parsed)->star == 1) { ++ if (((contact_body_t*)p->parsed)->star == -1) { + rerrno = R_STAR_CONT; + return 1; + } diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.rtpproxy --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.rtpproxy Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,57 @@ +Index: main.c +diff -Nau main.c.orig main.c +--- main.c.orig 2008-06-17 05:19:48 +0200 ++++ main.c 2008-08-09 11:58:55 +0200 +@@ -86,7 +86,11 @@ + bindhost = NULL; + + if ((n = resolve(ia, pf, bindhost, servname, AI_PASSIVE)) != 0) ++#if defined(__sun__) ++ errx(1, "setbindhost"); ++#else + errx(1, "setbindhost: %s", gai_strerror(n)); ++#endif + } + + static void +Index: rtpp_command.c +diff -Nau rtpp_command.c.orig rtpp_command.c +--- rtpp_command.c.orig 2009-03-25 02:53:17.397562078 +0100 ++++ rtpp_command.c 2009-03-25 02:52:59.126654989 +0100 +@@ -72,6 +72,36 @@ + static void handle_query(struct cfg *, int, struct sockaddr_storage *, + socklen_t, char *, struct rtpp_session *, int); + ++#if defined(__sun__) ++static char ++*strsep(char **stringp, const char *delim) ++{ ++ char *s; ++ const char *spanp; ++ int c, sc; ++ char *tok; ++ ++ if ((s = *stringp) == NULL) ++ return NULL; ++ for (tok = s;;) { ++ c = *s++; ++ spanp = delim; ++ do { ++ if ((sc = *spanp++) == c) { ++ if (c == 0) ++ s = NULL; ++ else ++ s[-1] = 0; ++ *stringp = s; ++ return tok; ++ } ++ } while (sc != 0); ++ } ++ /* NOTREACHED */ ++ return NULL; ++} ++ ++#endif + static int + create_twinlistener(struct cfg *cf, struct sockaddr *ia, int port, int *fds) + { diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.save --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.save Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,42 @@ +Index: modules/registrar/save.c +diff -Nau modules/registrar/save.c.orig modules/registrar/save.c +--- modules/registrar/save.c.orig 2008-03-07 14:12:56.307895000 +0100 ++++ modules/registrar/save.c 2008-03-08 00:03:02.436987000 +0100 +@@ -51,6 +51,7 @@ + #include "../../ut.h" + #include "../../qvalue.h" + #include "../../dset.h" ++#include "../../msg_translator.h" + #ifdef USE_TCP + #include "../../tcp_server.h" + #endif +@@ -687,9 +688,28 @@ + contact_t* c; + int st; + str aor; ++ unsigned int new_len = 0; ++ struct sip_msg* sip_manip = 0; + + rerrno = R_FINE; + ++ /* make a cheap shallow copy of the incoming message */ ++ sip_manip = (void*)pkg_malloc(sizeof(struct sip_msg)); ++ if (sip_manip==0) { ++ LM_ERR("no more pkg memory\n"); ++ goto error; ++ } ++ memcpy(sip_manip,_m,sizeof(struct sip_msg)); ++ ++ /* incorporate changes made to the routing script so far, */ ++ /* this mean that the so called 'lumps' will be processed */ ++ sip_manip->buf = build_res_buf_from_sip_res(_m, &new_len); ++ sip_manip->len = new_len; ++ ++ /* from here on, use the new refreshed message data as */ ++ /* specifically manipulated according to the user's wish */ ++ _m = sip_manip; /* only safe when passing by value */ ++ + if (parse_message(_m) < 0) { + goto error; + } +Don't forget to free(3) the pkg_alloc(3) memory!!! diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.patch.uac --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensips.patch.uac Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,195 @@ +Index: modules/uac/auth.c +diff -Nau modules/uac/auth.c.orig modules/uac/auth.c +--- modules/uac/auth.c.orig 2008-08-03 15:53:40.000000000 +0200 ++++ modules/uac/auth.c 2009-03-24 21:48:53.478867420 +0100 +@@ -143,14 +143,172 @@ + HASHHEX response; + str *new_hdr; + ++ /* pretransact */ ++ int nret = 0; ++ pv_value_t pv_val; ++ str *newuri = 0; ++ struct uac_credential *tst = 0; ++ struct hdr_field *tmp_hdr = 0; ++ struct hdr_field *del_hdr = 0; ++ ++ ++ /* Goes something like this... */ ++ /* HA1 = echo -n 'username:realm:password' | md5sum */ ++ /* echo -n 'itsme:mydom.com:stupidpass' | md5sum */ ++ /* HA2 = echo -n 'message:uri' | md5sum */ ++ /* echo -n 'INVITE:sip:danc@ing.fool.es' | md5sum */ ++ /* Response = echo -n 'HA1:nonce:HA2' | md5sum */ + /* get transaction */ + t = uac_tmb.t_gett(); +- if (t==T_UNDEFINED || t==T_NULL_CELL) +- { +- LM_CRIT("no current transaction found\n"); +- goto error; +- } ++ if (t==T_UNDEFINED || t==T_NULL_CELL) { ++ /* begin without any transaction */ ++ /* set relevant structure variables */ ++ crd = 0; ++ crd = pkg_malloc(sizeof(struct uac_credential)); ++ if (!crd) { ++ LM_ERR("no more pkg memory\n"); ++ goto error; ++ } ++ ++ /* set the realm from existing UAC message */ ++ tmp_hdr = msg->proxy_auth; ++ del_hdr = 0; ++ while (tmp_hdr) { ++ crd->realm.s = strchr(strstr(tmp_hdr->body.s, "realm="), '"') + 1; ++ crd->realm.len = strchr(crd->realm.s, '"') - crd->realm.s; ++ if(pv_get_spec_value(msg, &auth_realm_spec, &pv_val)==0 \ ++ && pv_val.rs.len>0) /* ensure realm is the desired one */ ++ if (strncmp(crd->realm.s, pv_val.rs.s, crd->realm.len)==0) ++ del_hdr = tmp_hdr; ++ tmp_hdr = tmp_hdr->sibling; ++ } ++ if (del_hdr) ++ crd->realm = pv_val.rs; /* success */ ++ else ++ nret++; /* failure */ ++ ++ /* set username from new AVP proxy values */ ++ if(pv_get_spec_value(msg, &auth_username_spec, &pv_val)!=0 \ ++ || pv_val.flags&PV_VAL_NULL || pv_val.rs.len<=0) ++ nret++; /* signal failure with nonzero value */ ++ else ++ crd->user = pv_val.rs; ++ ++ /* set password from new AVP proxy values */ ++ if(pv_get_spec_value(msg, &auth_password_spec, &pv_val)!=0 \ ++ || pv_val.flags&PV_VAL_NULL || pv_val.rs.len<=0) ++ nret++; /* signal failure with nonzero value */ ++ else ++ crd->passwd = pv_val.rs; ++ ++ if (nret) { /* if not found, look into predefined credentials */ ++ tst = uac_auth_api._lookup_realm(&crd->realm); ++ ++ if (tst==0) { /* found? */ ++ LM_DBG("no credential for realm \"%.*s\"\n", \ ++ crd->realm.len, crd->realm.s); ++ pkg_free(crd); ++ goto error; ++ } ++ ++ crd = tst; /* use predefined credentials */ ++ /* set the realm from existing UAC message */ ++ tmp_hdr = msg->proxy_auth; ++ del_hdr = 0; ++ while (tmp_hdr) { ++ if(pv_get_spec_value(msg, &auth_realm_spec, &pv_val)==0 \ ++ && pv_val.rs.len>0) /* ensure realm is the desired one */ ++ if (strncmp(crd->realm.s, pv_val.rs.s, crd->realm.len)==0) ++ del_hdr = tmp_hdr; ++ tmp_hdr = tmp_hdr->sibling; ++ } ++ if (del_hdr == 0) { /* proxy-auth header matching realm not found */ ++ LM_DBG("no credential for realm \"%.*s\"\n", \ ++ crd->realm.len, crd->realm.s); ++ pkg_free(crd); ++ goto error; ++ } ++ } ++ ++ /* set the uri from existing UAC message */ ++ newuri = pkg_malloc(sizeof(str)); ++ if (!newuri) { ++ LM_ERR("no more pkg memory\n"); ++ goto error; ++ } ++ newuri->s = pkg_malloc(msg->new_uri.len); ++ if (!newuri->s) { ++ LM_ERR("no more pkg memory\n"); ++ pkg_free(newuri); ++ goto error; ++ } ++ newuri->len = msg->new_uri.len; ++ strncpy(newuri->s, msg->new_uri.s, msg->new_uri.len); ++ if (!newuri->s) { ++ LM_DBG("failed to retrieve URI from UAC message\n"); ++ pkg_free(newuri->s); ++ pkg_free(newuri); ++ goto error; ++ } ++ ++ /* set the nonce from existing UAC message */ ++ tmp_hdr = msg->proxy_auth; ++ auth->nonce.len = 0; ++ auth->nonce.s = 0; ++ while (tmp_hdr) { ++ if(pv_get_spec_value(msg, &auth_realm_spec, &pv_val)==0 \ ++ && pv_val.rs.len>0) /* ensure realm is the desired one */ ++ if (strncmp(crd->realm.s, pv_val.rs.s, crd->realm.len)==0) { ++ auth->nonce.s = strchr(strstr(tmp_hdr->body.s, "nonce="), '"') + 1; ++ auth->nonce.len = strchr(auth->nonce.s, '"') - auth->nonce.s; ++ } ++ tmp_hdr = tmp_hdr->sibling; ++ } ++ if (auth->nonce.s == 0) { ++ LM_DBG("failed to retrieve nonce from UAC message\n"); ++ pkg_free(crd); ++ goto error; ++ } ++ ++ /* do authentication */ ++ uac_auth_api._do_uac_auth(msg, newuri, crd, auth, &auth_nc_cnonce, response); ++ if (response==0) { ++ LM_ERR("failed to calculate challenge response\n"); ++ pkg_free(crd); ++ goto error; ++ } ++ ++ /* build the authorization header */ ++ new_hdr = uac_auth_api._build_authorization_hdr(407, newuri, crd, auth, &auth_nc_cnonce, response); ++ if (new_hdr==0) { ++ LM_ERR("failed to build authorization hdr\n"); ++ pkg_free(crd); ++ goto error; ++ } ++ ++ /* remove the old proxy-auth header and relink message index */ ++ /* before updating the authorization credentials of the message */ ++ if (del_hdr) { /* updated a record and must remove the old one */ ++ if (del_lump(msg, del_hdr->name.s - msg->buf, del_hdr->len, 0)==0) { ++ LM_ERR("can't remove credentials\n"); ++ pkg_free(crd); ++ goto error; ++ } ++ } ++ ++ /* so far, so good -> add the header and set the proper RURI */ ++ if (apply_urihdr_changes(msg, newuri, new_hdr)<0) ++ { ++ LM_ERR("failed to apply changes\n"); ++ pkg_free(crd); ++ goto error; ++ } ++ ++ pkg_free(crd); /* finished calculating new response string, success */ ++ return 0; ++ } /* if (t==T_UNDEFINED || t==T_NULL_CELL) */ + ++ /* begin with transaction reply */ + /* get the selected branch */ + branch = uac_tmb.t_get_picked(); + if (branch<0) { +Index: modules/uac/uac.c +diff -Nau modules/uac/uac.c.orig modules/uac/uac.c +--- modules/uac/uac.c.orig 2008-08-03 15:53:40.000000000 +0200 ++++ modules/uac/uac.c 2009-03-24 21:49:48.922890737 +0100 +@@ -117,7 +117,7 @@ + REQUEST_ROUTE|BRANCH_ROUTE|FAILURE_ROUTE }, + {"uac_auth", (cmd_function)w_uac_auth, 0, + 0, 0, +- FAILURE_ROUTE }, ++ REQUEST_ROUTE|FAILURE_ROUTE }, + {0,0,0,0,0,0} + }; + diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensips.spec --- a/opensips/opensips.spec Wed Sep 21 14:02:13 2011 +0200 +++ b/opensips/opensips.spec Wed Sep 21 14:04:16 2011 +0200 @@ -1,6 +1,6 @@ ## ## opensips.spec -- OpenPKG RPM Package Specification -## Copyright (c) 2000-2010 OpenPKG Foundation e.V. +## 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 @@ -22,40 +22,62 @@ ## # package options -%define V_opensips 1.6.4 %define V_rtpproxy 1.2.1 # package information Name: opensips -Summary: Open SIP Server +Summary: Open SIP Router URL: http://www.opensips.org/ -Vendor: FhG FOKUS et al. +Vendor: Voice System SRL Packager: OpenPKG Foundation e.V. Distribution: OpenPKG Community Class: PLUS Group: VoIP License: GPL -Version: %{V_opensips} -Release: 20101221 +Version: 1.7.0 +Release: 20110912 # package options -%option with_fsl yes -%option with_ssl no +%option with_cons yes +%option with_fsl yes +%option with_ssl yes +%option with_sctp no +%option with_json no +%option with_croute no +%option with_ldap no +%option with_memcached no +%option with_radius no +%option with_snmp no +%option with_bdb no +%option with_mysql no +%option with_osp no +%option with_pgsql no +%option with_odbc no +%option with_geoip no +%option with_dbgmem no # list of sources -Source0: http://www.opensips.org/pub/opensips/%{version}/src/opensips-%{V_opensips}-tls_src.tar.gz -Source1: http://b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz +Source0: http://www.opensips.org/pub/opensips/%{version}/src/opensips-%{version}_src.tar.gz +Source1: http://www.b2bua.org/chrome/site/rtpproxy-%{V_rtpproxy}.tar.gz Source2: rc.opensips Source3: fsl.opensips Source4: opensips.cfg -Source5: opensips.schema-dbtext.txt Patch0: opensips.patch +Patch1: opensips.patch.dict +Patch2: opensips.patch.uac +Patch3: opensips.patch.reg +Patch4: opensips.patch.rtpproxy # build information -BuildPreReq: OpenPKG, openpkg >= 20100101, make, gcc, flex, bison, sed -PreReq: OpenPKG, openpkg >= 20100101 -BuildPreReq: pcre -PreReq: pcre +Prefix: %{l_prefix} +BuildRoot: %{l_buildroot} +BuildPreReq: OpenPKG, openpkg >= 20060823, make, gcc, flex, bison, sed +PreReq: OpenPKG, openpkg >= 20060823, bash +BuildPreReq: libxml, expat, curl, pkgconfig +PreReq: libxml, expat, curl +%if "%{with_cons}" == "yes" +PreReq: perl-dbi, perl-term +%endif %if "%{with_fsl}" == "yes" BuildPreReq: fsl PreReq: fsl @@ -64,22 +86,91 @@ BuildPreReq: openssl PreReq: openssl %endif +%if "%{with_croute}" == "yes" +BuildPreReq: confuse +PreReq: confuse +%endif +%if "%{with_json}" == "yes" +BuildPreReq: json +PreReq: json +%endif +%if "%{with_ldap}" == "yes" +BuildPreReq: openldap +PreReq: openldap +%endif +%if "%{with_memcached}" == "yes" +BuildPreReq: memcached +PreReq: memcached +%endif +%if "%{with_osp}" == "yes" +BuildPreReq: osptoolkit +PreReq: osptoolkit +%endif +%if "%{with_radius}" == "yes" +BuildPreReq: radiusclient +PreReq: radiusclient +%endif +%if "%{with_snmp}" == "yes" +BuildPreReq: snmp +PreReq: snmp +%endif +%if "%{with_bdb}" == "yes" +BuildPreReq: db +PreReq: db +%endif +%if "%{with_mysql}" == "yes" +BuildPreReq: mysql +PreReq: mysql +%endif +%if "%{with_pgsql}" == "yes" +BuildPreReq: postgresql +PreReq: postgresql +%endif +%if "%{with_odbc}" == "yes" +BuildPreReq: unixodbc +PreReq: unixodbc +%endif +%if "%{with_geoip}" == "yes" +BuildPreReq: geoip +PreReq: geoip +%endif +AutoReq: no +AutoReqProv: no %description OpenSIPS is (beside Kamailio) a successor to OpenSER, which in - turn was spawned from FhG FOKUS' SIP Express Router (SER). It + turn was spawned from FhG FOKUS's SIP Express Router (SER). It provides SIP (RFC3621) registrar, proxy and routing functionality. - A C shell like scripting language provides full control over the - server's behaviour. It's modular architecture allows only required - functionality to be loaded. + A C shell like scripting language provides for control over the + server's behaviour. It's modular architecture allows for fine + grained loading of required functionality. + + The third party Sippy RTPproxy from http://www.rtpproxy.org/ + is included to make communication between SIP user agents + behind NATs (Network Address Translators) possible. + + OpenSIPS can be used as a: OpenSIPS fits in scenarios: + + Registrar server SIP trunking + Router, proxy SIP load balancing + Redirect server SIP front end termination + Presence agent Residential providers + Back to back user agent white label solutions + Instant messaging server Enterprise services + SIP to SMS gateway LCR for multi gateways + SIP to XMPP gateway + Load balancer or dispatcher + Front end for asterisk + NAT traversal unit + Application server %track prog opensips = { - version = %{V_opensips} + version = %{version} url = http://www.opensips.org/pub/opensips/ regex = (\d+\.\d+\.\d+)/ url = http://www.opensips.org/pub/opensips/__NEWVER__/src/ - regex = opensips-(__VER__)-tls_src\.tar\.gz + regex = opensips-(__VER__)_src\.tar\.gz } prog opensips:rtpproxy = { version = %{V_rtpproxy} @@ -91,11 +182,267 @@ %setup -q -n opensips-%{version}-tls %setup -q -n opensips-%{version}-tls -T -D -a 1 %patch -p0 + %patch -p0 -P 1 + %patch -p0 -P 2 + %patch -p0 -P 3 + ( cd rtpproxy-%{V_rtpproxy} + %patch -p0 -P 4 + ) || exit $? + %{l_shtool} subst \ + -e 's;^#! */bin/sh;#! %{l_prefix}/bin/bash;' \ + scripts/opensipsctl + %{l_shtool} subst \ + -e 's;^#! */bin/bash;#! %{l_prefix}/bin/bash;' \ + modules/seas/doc/xml2sgml.sh \ + scripts/opensipsdbctl \ + test/* + %{l_shtool} subst \ +%if "%{with_dbgmem}" == "yes" + -e 's;\(-DF_MALLOC\);#\1;' \ + -e 's;#\(-DDBG_QM_MALLOC\);\1;' \ +%endif + -e 's;\(#define PKG_MEM_POOL_SIZE\) \(1024\*1024\);\1 8*\2;' \ + Makefile.defs \ + config.h + %{l_shtool} subst \ +%if "%{with_fsl}" == "yes" + -e 's;@fslldflags@;-L$(prefix)/lib;g' \ + -e 's;@fsllibs@;-lfsl;g' \ +%else + -e 's;@fslldflags@;;g' \ + -e 's;@fsllibs@;;g' \ +%endif + -e 's;^\(DEFS+= -I\)\$(LOCALBASE).*;\1$(prefix)/include;' \ + -e 's;^\(DEFS+= -L\)\$(LOCALBASE).*;\1$(prefix)/lib -lssl -lcrypto;' \ + -e 's;^SVNVERSION *=.*;;g' \ + -e 's;^DBHTML2TXT *=.*;;g' \ + -e 's;^DBXML2PDF *=.*;;g' \ + -e 's;lib64;lib;' \ + Makefile.defs + %{l_shtool} subst \ + -e 's;\(radiusclient\)-ng;\1;g' \ + modules/aaa_radius/aaa_radius.c \ + modules/aaa_radius/rad.c \ + Makefile.defs + %{l_shtool} subst \ + -e 's;\(\$(data-dir)\)/\(dbtext\)/opensips;\1/\2;g' \ + -e 's;\(\$(data-dir)\)/\(db_berkeley\)/opensips;\1/\2;g' \ + -e 's;\(/usr/local/etc/opensips\);\1/*;g' \ + -e 's;\(s#/usr/local/sbin\)#;\1/*#;g' \ + -e 's;\(s#/usr/share/doc/$(NAME)/#$(doc-target)\)#;\1/#;g' \ + -e 's;\(\$(MAKE).*\) \(install_module_custom\);\1 makefile_defs=0 \2;' \ + Makefile + %{l_shtool} subst \ + -e 's;^\(LIBS=\).*;\1-L`%{l_prefix}/bin/pkg-config --libs db`;' \ + utils/db_berkeley/Makefile + %{l_shtool} subst \ + -e 's;/usr/share/doc/opensips/AUTHORS;%{l_prefix}/share/opensips/doc/AUTHORS;' \ + scripts/opensipsctl.8 + %{l_shtool} subst \ + -e 's;\(ETCDIR=".*\)/"$;\1";' \ + -e 's;\(ETCDIR="\)/usr/local/\(etc/opensips"\);\1%{l_prefix}/\2;' \ + -e 's;\. /etc/opensips/opensipsctlrc;true;' \ + -e 's;\. ~/.opensipsctlrc;true;' \ + -e 's;/usr/local\(/lib/opensips/opensipsctl\);%{l_prefix}\1;' \ + -e 's;/usr/local/\(etc/opensips/opensipsctlrc\);%{l_prefix}/\1;' \ + -e 's;PATH=\$PATH:/usr/local/sbin;PATH=%{l_prefix}/sbin:$PATH;' \ + scripts/opensipsdbctl \ + scripts/opensipsctl + %{l_shtool} subst \ + -e 's;\(DB_PATH="\)[^"][^"]*;\1%{l_prefix}/var/opensips/db;' \ + scripts/osipsconsolerc \ + scripts/opensipsctlrc + %{l_shtool} subst \ + -e 's;=/var/run/\(opensips.pid\);=%{l_prefix}/var/opensips/\1;g' \ + -e 's;/var/run/\(opensips.pid\);%{l_prefix}/var/opensips/\1;g' \ + -e 's;\(my \$fifo_reply_path\) = "/tmp/";\1 = "%{l_prefix}/var/opensips/";' \ + -e 's;\(my \$HISTORY_FILE\) = "/tmp/osipsconsole_history";\1 = "%{l_prefix}/var/opensips/osipsconsole_history";' \ + scripts/opensipsctl \ + scripts/opensipsctlrc \ + scripts/osipsconsole \ + scripts/osipsconsolerc + %{l_shtool} subst \ + -e 's;/usr/local;;g' \ + -e 's;\(/etc/opensips/\)\.\(opensipsctlrc\);%{l_prefix}\1\2;g' \ + scripts/opensipsctl.8 + %{l_shtool} subst \ + -e 's;/var/run/\(opensips.pid\);%{l_prefix}/var/opensips/\1;' \ + scripts/opensipsctl.base + %{l_shtool} subst \ + -e 's;\(path=\)\$CHROOT_DIR/tmp/\(\$name\);\1${OSER_FIRET}/\2;g' \ + scripts/opensipsctl.fifo + %{l_shtool} subst \ + -e 's;/usr/local/share/opensips/dbtext/opensips;%{l_prefix}/var/opensips/db;' \ + scripts/opensipsctl.dbtext + %{l_shtool} subst \ + -e 's;\(DB_PATH="\)[^"][^"]*;%{l_prefix}/var/opensips/db_berkeley;' \ + scripts/opensipsctl.db_berkeley + %{l_shtool} subst \ + -e 's;PATH=\$PATH:/usr/local/sbin;PATH=%{l_prefix}/sbin:$PATH;' \ + scripts/opensipsctl \ + scripts/opensipsdbctl.base + %{l_shtool} subst \ + -e 's;/usr/local/etc/opensips/dbtext;%{l_prefix}/var/opensips/db;' \ + -e 's;\(\$DATA_DIR/dbtext\)/opensips;\1;g' \ + scripts/opensipsdbctl.dbtext + %{l_shtool} subst \ + -e 's;\(DATA_DIR="\)[^"][^"]*;\1%{l_prefix}/share/opensips;' \ + scripts/opensipsdbctl.dbtext \ + scripts/opensipsdbctl.oracle + %{l_shtool} subst \ + -e 's;/usr/local/etc/opensips/db_berkeley;%{l_prefix}/var/opensips/db_berkeley;' \ + -e 's;/usr/local/BerkeleyDB.[^/][^/]*/bin;%{l_prefix}/bin;' \ + scripts/opensipsdbctl.db_berkeley + %{l_shtool} subst \ + -e 's;/usr/local/\(share/opensips\);%{l_prefix}/\1;' \ + scripts/opensipsdbctl.db_berkeley \ + scripts/opensipsdbctl.mysql \ + scripts/opensipsdbctl.pgsql + %{l_shtool} subst \ + -e 's;\(script_flags(int\));\1,null);' \ + scripts/dbtext/opensips/dialog + %{l_shtool} subst \ + -e 's;body(string);body(blob);' \ + -e 's;sender(string);sender(string,null);' \ + scripts/dbtext/opensips/presentity + %{l_shtool} subst \ + -e 's;\(expires(int\));\1,null);' \ + -e 's;\(desired_expires(int\));\1,null);' \ + -e 's;\(contact(string\));\1,null);' \ + -e 's;\(remote_contact(string\));\1,null);' \ + -e 's;\(version(int\));\1,null);' \ + -e 's;\(extra_headers(string\));\1,null);' \ + scripts/dbtext/opensips/pua + %{l_shtool} subst \ + -e 's;\(reason(string\));\1,null);' \ + scripts/dbtext/opensips/active_watchers \ + scripts/dbtext/opensips/rls_watchers + %{l_shtool} subst \ + -e 's;#! */usr/bin/python;#! %{l_prefix}/bin/python;' \ + scripts/dbtextdb/*.py + %{l_shtool} subst \ + -e 's;#! */usr/bin/perl;#! %{l_prefix}/bin/perl;' \ + -e 's;^\(my \$PATH_BIN =\) "./";\1 "%{l_prefix}/bin/";' \ + -e 's;^\(my \$PATH_CTLRC =\) "./scripts/";\1 "%{l_prefix}/etc/opensips/";' \ + -e 's;^\(my \$PATH_ETC =\) "/usr/local/etc";\1 "%{l_prefix}/etc";' \ + -e 's;^\(my \$PATH_LIBS =\) "/usr/local/lib";\1 "%{l_prefix}/lib";' \ + -e 's;^\(my \$PATH_SHARE =\) "/usr/local/share";\1 "%{l_prefix}/share";' \ + -e 's;^\(my $path = \)"/tmp/";\1"%{l_prefix}/var/opensips/";' \ + scripts/osipsconsole + %{l_shtool} subst \ + -e 's;if ( -x "/usr/bin/";if ( -x "%{l_prefix}/bin";' \ + -e 's;if \[ -x "/usr/bin/\$1" \];if [ -x "%{l_prefix}/bin/$1" ];' \ + -e 's;\$TOOLPATH = "/usr/bin/";$TOOLPATH = "%{l_prefix}/bin/";' \ + -e 's;TOOLPATH="/usr/bin/\$1";TOOLPATH="%{l_prefix}/bin/$1";' \ + -e 's;if ( -x "/bin/";if ( -x "/usr/bin/";' \ + -e 's;if \[ -x "/bin/\$1" \];if [ -x "/usr/bin/$1" ];' \ + -e 's;\$TOOLPATH = "/bin/";$TOOLPATH = "/usr/bin/";' \ + -e 's;TOOLPATH="/bin/\$1";TOOLPATH="/usr/bin/$1";' \ + -e 's;if ( -x "/usr/local/bin/\$1";if ( -x "/bin/$1";' \ + -e 's;if \[ -x "/usr/local/bin/\$1" \];if [ -x "/bin/$1" ];' \ + -e 's;\$TOOLPATH = "/usr/local/bin/;$TOOLPATH = "/bin/;' \ + -e 's;TOOLPATH="/usr/local/bin/\$1";TOOLPATH="/bin/$1";' \ + scripts/osipsconsole \ + scripts/opensipsctl.base + %{l_shtool} subst \ + -e 's;^\(DEFS+=\).*\\$;\1 \\;' \ + -e "s;\-I[^ \t][^ \t]*;`%{l_prefix}/bin/pkg-config --cflags-only-I libcurl libxml-2.0`;g" \ + -e "s;^\(LIBS=\).*;\1`%{l_prefix}/bin/pkg-config --libs libcurl libxml-2.0`;" \ + modules/xcap_client/Makefile + %{l_shtool} subst \ + -e 's;^\(DEFS+=\).*\\$;\1 \\;' \ + -e "s;\-I[^ \t][^ \t]*;`%{l_prefix}/bin/pkg-config --cflags-only-I libxml-2.0`;g" \ + -e "s;^\(LIBS=\).*;\1`%{l_prefix}/bin/pkg-config --libs libxml-2.0`;" \ + modules/cpl-c/Makefile \ + modules/presence/Makefile \ + modules/presence_dialoginfo/Makefile \ + modules/presence_xml/Makefile \ + modules/pua/Makefile \ + modules/pua_bla/Makefile \ + modules/pua_dialoginfo/Makefile \ + modules/pua_mi/Makefile \ + modules/pua_usrloc/Makefile \ + modules/pua_xmpp/Makefile \ + modules/b2b_logic/Makefile \ + modules/rls/Makefile + %{l_shtool} subst \ + -e 's;^\(DEFS+=\).*;\1`%{l_prefix}/bin/pkg-config --cflags-only-I libconfuse`;' \ + -e 's;^\(LIBS=\).*;\1`%{l_prefix}/bin/pkg-config --libs libconfuse`;' \ + modules/carrierroute/Makefile + %{l_shtool} subst \ + -e 's;\(LIBS = .*-L\$(shell pg_config --libdir) -lpq\);\1 $(shell pg_config --libs);' \ + modules/db_postgres/Makefile + %{l_shtool} subst \ + -e 's;-I\$(LOCALBASE)/BerkeleyDB[0-9\.\-]*/include[\t ]*;;' \ + -e 's;-L\$(LOCALBASE)/BerkeleyDB[0-9\.\-]*/lib[\t ]*;;' \ + modules/db_berkeley/Makefile \ + utils/db_berkeley/Makefile + %{l_shtool} subst \ + -e 's;\(\$(cfg-prefix)\)\$(shell net-snmp-config --prefix);\1;' \ + modules/snmpstats/Makefile + %{l_shtool} subst \ + -e 's;LM_WARN(\(\"uac does not spread across\);LM_NOTICE(\1;' \ + modules/tm/uac.c + %{l_shtool} subst \ + -e 's;\(#define MAX_SSL_RETRIES\) 32;\1 1024;' \ + tls/tls_server.c + %{l_shtool} subst \ + -e 's;^\(default_bits[ \t]*=[ \t]*\)2048;\14096;' \ + etc/tls/ca.conf + %{l_shtool} subst \ + -e '1,2d' \ + etc/tls/README + %{l_shtool} subst \ + -e 's;\(radiusclient\)-ng;\1;g' \ + -e 's;/usr/local\(/etc/radiusclient/radiusclient.conf\);%{l_prefix}\1;' \ + radius.h %build + # select modules + modslist='b2b_entities b2b_logic cpl-c db_http dialplan identity jabber perl perlvdb presence presence_dialoginfo presence_mwi presence_xml pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp regex rls tlsops xcap_client xmpp' +%if "%{with_croute}" == "yes" + modslist="$modslist carrierroute" +%endif +%if "%{with_json}" == "yes" + modslist="$modslist json" +%endif +%if "%{with_ldap}" == "yes" + modslist="$modslist h350 ldap" +%endif +%if "%{with_memcached}" == "yes" + modslist="$modslist memcached" +%endif +%if "%{with_osp}" == "yes" + modslist="$modslist osp" +%endif +%if "%{with_radius}" == "yes" + modslist="$modslist aaa_radius auth_aaa group uri" +%endif +%if "%{with_snmp}" == "yes" + modslist="$modslist snmpstats" +%endif +%if "%{with_bdb}" == "yes" + modslist="$modslist db_berkeley" +%endif +%if "%{with_mysql}" == "yes" + modslist="$modslist db_mysql" +%endif +%if "%{with_pgsql}" == "yes" + modslist="$modslist db_postgres" +%endif +%if "%{with_odbc}" == "yes" + modslist="$modslist db_unixodbc" +%endif +%if "%{with_geoip}" == "yes" + modslist="$modslist mmgeoip" +%endif + # build dependencies %{l_make} %{l_mflags} \ - CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ + CC="%{l_cc}" \ +%if "%{with_sctp}" == "yes" + SCTP=1 \ +%endif %if "%{with_ssl}" == "yes" TLS=1 \ %endif @@ -103,22 +450,43 @@ dep >/dev/null 2>&1 || true # build program - %{l_make} %{l_mflags} \ - CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ -%if "%{with_ssl}" == "yes" - TLS=1 \ + %{l_make} %{l_mflags -O} \ + CC="%{l_cc}" \ +%if "%{with_sctp}" == "yes" + SCTP=1 \ %endif - prefix=%{l_prefix} - - # build modules - %{l_make} %{l_mflags} \ - CC="%{l_cc} %{l_cflags} %{l_cppflags}" \ %if "%{with_ssl}" == "yes" TLS=1 \ %endif prefix=%{l_prefix} \ - modules \ - skip_modules="mysql jabber" + opensips + + # build utilities + %{l_make} %{l_mflags -O} \ + CC="%{l_cc}" \ +%if "%{with_sctp}" == "yes" + SCTP=1 \ +%endif +%if "%{with_ssl}" == "yes" + TLS=1 \ +%endif + prefix=%{l_prefix} \ + modules="$modslist" \ + utils + + # build modules + %{l_make} %{l_mflags -O} \ + CC="%{l_cc}" \ +%if "%{with_sctp}" == "yes" + SCTP=1 \ +%endif +%if "%{with_ssl}" == "yes" + TLS=1 \ +%endif + include_modules="$modslist" \ + skip_modules="" \ + prefix=%{l_prefix} \ + modules # build rtpproxy extension ( cd rtpproxy-%{V_rtpproxy} @@ -128,62 +496,96 @@ case "%{l_platform -t}" in *-sunos* ) LIBS="$LIBS -lsocket -lnsl -lrt" ;; esac + export GREP="grep" ./configure - %{l_make} %{l_mflags} + %{l_make} %{l_mflags -O} ) || exit $? %install + rm -rf $RPM_BUILD_ROOT - # install program + # select modules + modslist='b2b_entities b2b_logic cpl-c db_http identity jabber perl perlvdb presence presence_dialoginfo presence_mwi presence_xml pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp regex rls tlsops xcap_client xmpp' +%if "%{with_croute}" == "yes" + modslist="$modslist carrierroute" +%endif +%if "%{with_json}" == "yes" + modslist="$modslist json" +%endif +%if "%{with_ldap}" == "yes" + modslist="$modslist h350 ldap" +%endif +%if "%{with_memcached}" == "yes" + modslist="$modslist memcached" +%endif +%if "%{with_osp}" == "yes" + modslist="$modslist osp" +%endif +%if "%{with_radius}" == "yes" + modslist="$modslist aaa_radius auth_aaa group uri" +%endif +%if "%{with_snmp}" == "yes" + modslist="$modslist snmpstats" +%endif +%if "%{with_bdb}" == "yes" + modslist="$modslist db_berkeley" +%endif +%if "%{with_mysql}" == "yes" + modslist="$modslist db_mysql" +%endif +%if "%{with_pgsql}" == "yes" + modslist="$modslist db_postgres" +%endif +%if "%{with_odbc}" == "yes" + modslist="$modslist db_unixodbc" +%endif +%if "%{with_geoip}" == "yes" + modslist="$modslist mmgeoip" +%endif + + # install program, utils, and modules %{l_make} %{l_mflags} \ INSTALL="%{l_shtool} install%{l_nil} -c" \ basedir=$RPM_BUILD_ROOT \ prefix=%{l_prefix} \ - cfg-prefix=$RPM_BUILD_ROOT \ - cfg-target=%{l_prefix}/etc/opensips/ \ - doc-dir=share/opensips/doc/ \ - man-dir=man/ \ + doc-dir=share/opensips/doc \ + man-dir=man \ + data-dir=share/opensips \ + include_modules="$modslist" \ + skip_modules="" \ install - # install modules - %{l_make} %{l_mflags} \ - INSTALL="%{l_shtool} install%{l_nil} -c" \ - basedir=$RPM_BUILD_ROOT \ - prefix=%{l_prefix} \ - cfg-prefix=$RPM_BUILD_ROOT \ - cfg-target=%{l_prefix}/etc/opensips/ \ - doc-dir=share/opensips/doc/ \ - man-dir=man/ \ - install-modules \ - skip_modules="mysql jabber" - - # install rtpproxy extension + # install rtpproxy software %{l_shtool} install -c -s -m 755 \ - rtpproxy-%{V_rtpproxy}/rtpproxy $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_rtpproxy + rtpproxy-%{V_rtpproxy}/rtpproxy \ + $RPM_BUILD_ROOT%{l_prefix}/sbin/rtpproxy # strip down installation strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* >/dev/null 2>&1 || true - rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/opensips_mysql.sh - # post-adjust installation - %{l_shtool} subst \ - -e 's;/etc/opensips/opensipsctlrc;%{l_prefix}/etc/opensips/opensipsctlrc;g' \ - $RPM_BUILD_ROOT%{l_prefix}/sbin/opensipsctl - %{l_shtool} mkdir -f -p -m 755 \ - $RPM_BUILD_ROOT%{l_prefix}/etc/opensips - %{l_shtool} install -c -m 644 \ - -e 's;^# \(PID_FILE\)=.*;\1=%{l_prefix}/var/opensips/opensips.pid;' \ - -e 's;^# \(OSIPS_FIFO\)=.*;\1=%{l_prefix}/var/opensips/opensips.fifo;' \ - scripts/opensipsctlrc \ - $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/opensipsctlrc + # create installation hierarchy + %{l_shtool} mkdir -f -p -m 700 \ + $RPM_BUILD_ROOT%{l_prefix}/var/opensips/acc \ + $RPM_BUILD_ROOT%{l_prefix}/var/opensips/tmp # install default configuration %{l_shtool} mkdir -f -p -m 755 \ $RPM_BUILD_ROOT%{l_prefix}/etc/opensips - %{l_shtool} install -c -m 755 %{l_value -s -a} \ + %{l_shtool} install -c -m 644 %{l_value -s -a} \ %{SOURCE opensips.cfg} \ + %{SOURCE opensipsctlrc} \ + %{SOURCE osipsconsolerc} \ $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/ + # conditionally install osipsconsole resources +%if "%{with_cons}" == "yes" + %{l_shtool} install -c -m 644 %{l_value -s -a} \ + %{SOURCE osipsconsolerc} \ + $RPM_BUILD_ROOT%{l_prefix}/etc/opensips/ +%else + rm $RPM_BUILD_ROOT%{l_prefix}/sbin/osipsconsole +%endif + # install OSSP fsl configuration %{l_shtool} mkdir -f -p -m 755 \ $RPM_BUILD_ROOT%{l_prefix}/etc/fsl @@ -191,23 +593,17 @@ %{SOURCE fsl.opensips} \ $RPM_BUILD_ROOT%{l_prefix}/etc/fsl/ - # install run-command script + # install runcommand script %{l_shtool} mkdir -f -p -m 755 \ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d %{l_shtool} install -c -m 755 %{l_value -s -a} \ %{SOURCE rc.opensips} \ $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/ - # create database directory and install database schema definitions - %{l_shtool} mkdir -f -p -m 755 \ - $RPM_BUILD_ROOT%{l_prefix}/var/opensips - %{l_shtool} install -c -m 644 \ - %{SOURCE opensips.schema-dbtext.txt} \ - $RPM_BUILD_ROOT%{l_prefix}/share/opensips/ - # determine installation files %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \ %{l_files_std} \ + '%not %dir %{l_prefix}/etc/fsl' \ '%config %{l_prefix}/etc/fsl/*' \ '%config %{l_prefix}/etc/opensips/*' \ '%doc %{l_prefix}/share/opensips/doc/*' \ @@ -216,20 +612,17 @@ %files -f files %clean + rm -rf $RPM_BUILD_ROOT %post - # on install, setup database + # on install, setup database (osipsconsole db create /pfx/var/opensips/db) if [ ! -d $RPM_INSTALL_PREFIX/var/opensips/db ]; then - mkdir $RPM_INSTALL_PREFIX/var/opensips/db - chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db - chmod 755 $RPM_INSTALL_PREFIX/var/opensips/db - schema="$RPM_INSTALL_PREFIX/share/opensips/opensips.schema-dbtext.txt" - for table in `sed -e '/^#.*/d' -e '/^$/d' -e 's;\([^:]*\):.*;\1;' <$schema | sort -u`; do - grep "^${table}:" $schema | sed -e "s;^${table}: *;;" \ - >$RPM_INSTALL_PREFIX/var/opensips/db/$table - done - chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true - chmod 644 $RPM_INSTALL_PREFIX/var/opensips/db/* 2>/dev/null || true + %{l_shtool} mkdir -f -p -m 700 -o %{l_rusr} -g %{l_rgrp} \ + $RPM_INSTALL_PREFIX/var/opensips/db + rm -f $RPM_INSTALL_PREFIX/share/opensips/dbtext/*.orig + %{l_shtool} install -c -m 600 -o %{l_rusr} -g %{l_rgrp} \ + $RPM_INSTALL_PREFIX/share/opensips/dbtext/* \ + $RPM_INSTALL_PREFIX/var/opensips/db/ fi # after upgrade, restart service diff -r 8f552d1cd671 -r 67e813202d53 opensips/opensipsctlrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/opensipsctlrc Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,134 @@ +## +## opensipsctlrc -- OpenSIPS control tools configuration +## + +## your SIP domain +SIP_DOMAIN=name.host.tld + +## chrooted directory +# $CHROOT_DIR="/path/to/chrooted/directory" + +## Database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT; +## by default none is loaded. Use opensipsdbctl to setup a database. +DBENGINE=DBTEXT + +## database host +# DBHOST=localhost + +## database name (for ORACLE this is TNS name) +# DBNAME=opensips + +# database path used by dbtext or db_berkeley +DB_PATH=@l_prefix@/var/opensips/db + +## database read/write user +# DBRWUSER=@l_rusr@ + +## password for database read/write user +# DBRWPW=rente_word_pass_rw + +## database read only user +# DBROUSER=@l_rusr@ + +## password for database read only user +# DBROPW=rentero_word_pass + +## database super user (for ORACLE this is 'scheme-creator' user) +# DBROOTUSER=@l_susr@ + +# user name column +# USERCOL="username" + + +# SQL definitions +# If you change this definitions here, then you must change them +# in db/schema/entities.xml too. +# + +# FOREVER="2020-05-28 21:32:15" +# DEFAULT_ALIASES_EXPIRES=$FOREVER +# DEFAULT_Q="1.0" +# DEFAULT_CALLID="Default-Call-ID" +# DEFAULT_CSEQ="13" +# DEFAULT_LOCATION_EXPIRES=$FOREVER + + +# Program to calculate a message-digest fingerprint +# MD5="md5sum" + +# awk tool +# AWK="awk" + +# grep tool +# GREP="grep" + +# sed tool +# SED="sed" + + +# Describe what additional tables to install. Valid values for the variables +# below are yes/no/ask. With ask (default) it will interactively ask the user +# for an answer, while yes/no allow for automated, unassisted installs. +# + +# If to install tables for the modules in the EXTRA_MODULES variable. +# INSTALL_EXTRA_TABLES=ask + +# If to install presence related tables. +# INSTALL_PRESENCE_TABLES=ask + +# Define what module tables should be installed. +# If you use the postgres database and want to change the installed tables, +# then you must also adjust the STANDARD_TABLES or EXTRA_TABLES variable +# accordingly in the opensipsdbctl.base script. + +# opensips standard modules +# STANDARD_MODULES="standard acc lcr domain group permissions registrar usrloc +# msilo alias_db uri_db speeddial avpops auth_db pdt dialog +# dispatcher dialplan drouting nathelper load_balancer" + +# opensips extra modules +# EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute userblacklist" + + +## type of aliases used: DB - database aliases; UL - usrloc aliases +## - default: none +# ALIASES_TYPE="DB" + +## control engine: FIFO or UNIXSOCK +## - default FIFO +CTLENGINE=FIFO + +## path to FIFO file +OSIPS_FIFO=@l_prefix@/var/opensips/opensips.fifo + +## path to server inbound FIFO directory +OSER_FIRET=@l_prefix@/var/opensips + +## MI_CONNECTOR control engine: FIFO, UNIXSOCK, UDP, XMLRPC +# MI_CONNECTOR=FIFO:@l_prefix@/var/opensips/opensips.fifo +# MI_CONNECTOR=UNIXSOCK:/tmp/opensips.sock +# MI_CONNECTOR=UDP:192.168.2.133:8000 +# MI_CONNECTOR=XMLRPC:192.168.2.133:8000 + +## check ACL names; default on (1); off (0) +# VERIFY_ACL=1 + +## ACL names - if VERIFY_ACL is set, only the ACL names from below list +## are accepted +# ACL_GROUPS="local ld int voicemail free-pstn" + +## verbose - debug purposes - default '0' +# VERBOSE=1 + +## do (1) or don't (0) store plaintext passwords +## in the subscriber table - default '1' +STORE_PLAINTEXT_PW=0 + +## OPENSIPS START Options +## PID file path - default is: /var/run/opensips.pid +PID_FILE=@l_prefix@/var/opensips/opensips.pid + +## Extra start options - default is: not set +# example: start opensips with 64MB share memory: STARTOPTIONS="-m 64" +# STARTOPTIONS= diff -r 8f552d1cd671 -r 67e813202d53 opensips/osipsconsolerc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/opensips/osipsconsolerc Wed Sep 21 14:04:16 2011 +0200 @@ -0,0 +1,98 @@ +## +## osipsconsolerc -- OpenSIPS management configuration +## + +## your SIP domain +SIP_DOMAIN=name.host.tld + +## Database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, or DBTEXT; +## by default none is loaded. Use opensipsdbctl to setup a database. +DBENGINE=DBTEXT + +## database host +# DBHOST=localhost + +## database port for PostgreSQL +# DBPORT=5433 + +## database name (for ORACLE this is TNS name) +# DBNAME=opensips + +## database path used by dbtext or db_berkeley +DB_PATH=@l_prefix@/var/opensips/db + +## database read/write user +# DBRWUSER=@l_rusr@ + +## password for database read/write user +# DBRWPW=rente_word_pass_rw + +## database read only user +# DBROUSER=@l_rusr@ + +## password for database read only user +# DBROPW=rentero_word_pass + +## database super user (for ORACLE this is 'scheme-creator' user) +# DBROOTUSER=@l_susr@ + +# Program to calculate a message-digest fingerprint +# MD5="md5sum" + +# awk tool +# AWK="awk" + +# grep tool +# GREP="egrep" + +# sed tool +# SED="sed" + + +# Describe what additional tables to install. Valid values for the variables +# below are yes/no/ask. With ask (default) it will interactively ask the user +# for an answer, while yes/no allow for automated, unassisted installs. +# + +# Define what module tables should be installed. +# If you use the postgres database and want to change the installed tables, +# then you must also adjust the STANDARD_TABLES or EXTRA_TABLES variable +# accordingly in the opensipsdbctl.base script. + +# opensips standard modules +# STANDARD_MODULES="standard acc lcr domain group permissions registrar +# usrloc msilo alias_db uri_db speeddial avpops auth_db +# pdt dialog dispatcher dialplan drouting nathelper +# load_balancer" + +# opensips extra modules +# EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute userblacklist" + + +## type of aliases used: DB - database aliases; UL - usrloc aliases +## - default: none +# ALIASES_TYPE="DB" + +## MI_CONNECTOR control engine: FIFO, UNIXSOCK, UDP, XMLRPC +# MI_CONNECTOR=FIFO:@l_prefix@/var/opensips/opensips.fifo +# MI_CONNECTOR=UNIXSOCK:/tmp/opensips.sock +# MI_CONNECTOR=UDP:192.168.2.133:8000 +# MI_CONNECTOR=XMLRPC:192.168.2.133:8000 + +## check ACL names; default on (1); off (0) +# VERIFY_ACL=1 + +## ACL names - if VERIFY_ACL is set, only ACL names from list are accepted +# ACL_GROUPS="local ld int voicemail free-pstn" + +## do (1) or don't (0) store plaintext passwords +## in the subscriber table - default '1' +STORE_PLAINTEXT_PW=0 + +## OPENSIPS START Options +## PID file path - default is: /var/run/opensips.pid +PID_FILE=@l_prefix@/var/opensips/opensips.pid + +## Extra start options - default is: not set +# example: start opensips with 64MB share memory: STARTOPTIONS="-m 64" +# STARTOPTIONS= diff -r 8f552d1cd671 -r 67e813202d53 opensips/rc.opensips --- a/opensips/rc.opensips Wed Sep 21 14:02:13 2011 +0200 +++ b/opensips/rc.opensips Wed Sep 21 14:04:16 2011 +0200 @@ -5,8 +5,8 @@ %config opensips_enable="$openpkg_rc_def" - opensips_flags="" opensips_rtpproxy="yes" + opensips_rtpproxy_addr="127.0.0.1:12345" opensips_log_prolog="true" opensips_log_epilog="true" opensips_log_numfiles="10" @@ -18,7 +18,9 @@ opensips_pidfile="@l_prefix@/var/opensips/opensips.pid" opensips_rtpproxy_pidfile="@l_prefix@/var/opensips/opensips_rtpproxy.pid" opensips_rtpproxy_socket="@l_prefix@/var/opensips/opensips_rtpproxy.sock" - opensips_rtpproxy_listen=`grep '^listen=' $opensips_cfgfile | sed -e 's/^listen="\(.*\)".*/\1/'` + opensips_signal () { + [ -f $opensips_pidfile ] && kill -$1 `cat $opensips_pidfile` + } opensips_rtpproxy_signal () { [ -f $opensips_rtpproxy_pidfile ] && kill -$1 `cat $opensips_rtpproxy_pidfile` } @@ -29,7 +31,7 @@ if @l_prefix@/sbin/opensips -c >/dev/null 2>&1; then opensips_usable="yes" fi - if @l_prefix@/sbin/opensipsctl ps >/dev/null 2>&1; then + if rcService opensips enable yes && opensips_signal 0; then opensips_active="yes" fi echo "opensips_enable=\"$opensips_enable\"" @@ -40,20 +42,20 @@ rcService opensips enable yes || exit 0 rcService opensips active yes && exit 0 if rcVarIsYes opensips_rtpproxy; then - cmd="@l_prefix@/sbin/opensips_rtpproxy" \ - cmd="$cmd -l $opensips_rtpproxy_listen" + cmd="@l_prefix@/sbin/rtpproxy" \ + cmd="$cmd -u @l_rusr@" + cmd="$cmd -l $opensips_rtpproxy_addr" cmd="$cmd -s unix:$opensips_rtpproxy_socket" cmd="$cmd -p $opensips_rtpproxy_pidfile" su @l_rusr@ -c "$cmd" fi - @l_prefix@/sbin/opensips \ - -P $opensips_pidfile \ - ${opensips_flags} + @l_prefix@/sbin/opensipsctl start %stop -u @l_susr@ rcService opensips enable yes || exit 0 rcService opensips active no && exit 0 @l_prefix@/sbin/opensipsctl stop + rm -f $opensips_pidfile 2>/dev/null || true if rcVarIsYes opensips_rtpproxy; then opensips_rtpproxy_signal TERM fi