debug=3 # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=no # (cmd line: -E)
log_facility=LOG_LOCAL0
#/* Uncomment these lines to enter debugging mode
#fork=no
#log_stderror=yes
#*/
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
children=4
#change
listen=udp:10.0.0.10:5060
listen=udp:10.0.0.10:5061
listen=udp:10.0.0.10:5062
alias=msg1.domain.me
sip_warning=yes
# ------------------ module loading ----------------------------------
mpath="/usr/lib64/opensips/modules/"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "dialog.so"
loadmodule "uac_auth.so"
loadmodule "uac.so"
loadmodule "db_mysql.so"
loadmodule "acc.so"
loadmodule "exec.so"
loadmodule "xmpp.so"
# RR
modparam("rr", "append_fromtag", 1)
# UAC
modparam("uac", "restore_mode", "none")
# ----------------- setting module-specific parameters ---------------
#change
modparam("xmpp", "sip_domain", "msg1.domain.me")
modparam("xmpp", "xmpp_domain", "msg1.domain.me")
modparam("xmpp", "xmpp_host", "msg1.domain.me")
modparam("xmpp", "xmpp_port", 5275)
modparam("xmpp", "xmpp_password", "password")
modparam("xmpp", "backend", "component")
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")
modparam("acc", "early_media", 1)
modparam("acc", "report_cancels", 1)
modparam("acc", "db_flag", 2)
#change
modparam("acc", "db_url", "mysql://root:password@localhost/asterisk")
modparam("acc", "db_table_acc",'ast_cdr')
modparam("acc", "db_extra", "src=$avp(src); dst=$avp(dst); channel=$avp(channel); dstchannel=$avp(dstchannel); accountcode=$avp(accountcode); userfield=$avp(userfield);clid=$avp(callid)")
modparam("acc", "acc_time_column", "calldate")
modparam("acc", "acc_sip_code_column", "lastapp")
modparam("acc", "acc_callid_column", "lastdata")
modparam("acc", "acc_method_column", "dcontext")
modparam("acc", "acc_sip_reason_column", "disposition")
modparam("acc", "log_extra", "src=$avp(src); dst=$avp(dst); channel=$avp(channel); dstchannel=$avp(dstchannel); accountcode=$avp(accountcode); userfield=$avp(userfield);content=$avp(content);callid=$avp(callid)")
modparam("acc", "log_flag", 2)
modparam("acc", "log_level", 2)
modparam("acc", "log_facility", "LOG_LOCAL0")
# ------------------------- request routing logic -------------------
route {
record_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");
exit;
};
if (!is_method("MESSAGE")) {
exit;
}
if (msg:len >= 2048) {
sl_send_reply("513", "Message too big");
exit;
};
### absorb retransmissions ###
if (!t_newtran()) {
sl_reply_error();
return;
} else {
xlog("[CORE] [$rm] Created new transaction [$si:$sp]\n");
}
setflag(2);
switch($rp) {
case 5060:
xlog("######################################");
xlog(" FROM EXTERNAL SENDING TO ILC- $si - $rp");
xlog(" [PEER] [$rm] External destination detected, rewriting ruri [$ru/$ci]\n");
xlog("######################################");
## Rewrite the request uri and the to domain
## If the request-uri (user portion length is 11) then strip the first digit off
## 1-555-555-1234 -> 555-555-1234 (without the dashses for readability)
if ($(fU{s.len}) == 11) {
uac_replace_from("sip:$(fU{s.substr,1,0})@$fd");
}
if ($(rU{s.len}) == 11) {
strip(1);
}
#change
$ru = "sip:" + $rU + "@10.0.0.10:5062";
$avp(src) = $(fU{s.substr,1,0});
$avp(dst) = $(tU{s.substr,1,0});
$avp(channel) = $fu;
$avp(dstchannel) = $tu;
$avp(accountcode) = $rU;
$avp(userfield) = "EVT00023";
$avp(content) = $rb;
$avp(callid) = $(ci{s.select,0,@});
if (exec_msg("/etc/opensips/ilc.php --rU=\"$rU\" --rd=\"$rd\" --td=\"$td\" --rb=\"$rb\" --fu=\"$fu\" --fU=\"$fU\" --fd=\"$fd\"")) {
t_reply("200", "Accepted");
} else {
t_reply("404", "Not found");
}
t_relay();
break;
case 5061:
xlog("######################################");
xlog(" TO OPENFIRE - 5061");
xlog(" [$rm] Processing request from [$si] r-uri [$ru]\n");
xlog("######################################");
#change
$ru = "sip:" + $rU + "@domain.me";
if (xmpp_send_message()) {
t_reply("200", "Accepted");
} else {
t_reply("404", "Not found");
}
break;
case 5062:
xlog("######################################");
xlog(" TO OUTSIDE- $rp");
xlog(" [PEER] [$rm] Processing and relaying message from [CORE] to [PEER] [$si:$sp]\n");
xlog("######################################");
$avp(from) = "sip:1" + $fU + "@10.0.0.10";
$avp(to) = "sip:1" + $tU + "@outside.domain.com";
uac_replace_from("", "$avp(from)");
uac_replace_to("", "$avp(to)");
## If the To: user (user porition is 10) the prefix a 1 to the beginning
## 555-555-1234 -> 1-555-555-1234 (without the dashses for readability)
if ($(fU{s.len}) == 10) {
prefix("1");
}
#change - uncomment and delete
$ru = "sip:" + $tU + "@domain.me:5063";
$avp(src) = $fU;
$avp(dst) = $tU;
$avp(channel) = $fu;
$avp(dstchannel) = $tu;
$avp(accountcode) = $fU;
$avp(userfield) = "EVT00024";
$avp(content) = $rb;
$avp(callid) = $(ci{s.select,0,@});
t_relay();
break;
}
return;
}