-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update openSIPS IMS configuration files
Co-authored-by: Razvan Crainea <[email protected]>
- Loading branch information
1 parent
2dc170e
commit f12631b
Showing
3 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,9 @@ mpath="/usr/lib/x86_64-linux-gnu/opensips/modules" | |
|
||
####### Modules Section ######## | ||
|
||
#### MYSQL module | ||
loadmodule "db_mysql.so" | ||
|
||
#### SIGNALING module | ||
loadmodule "signaling.so" | ||
|
||
|
@@ -135,6 +138,18 @@ modparam("rtpengine", "rtpengine_sock", "udp:RTPENGINE_IP:2223") | |
loadmodule "event_route.so" | ||
loadmodule "json.so" | ||
|
||
#### PRESENCE modules | ||
loadmodule "presence.so" | ||
loadmodule "presence_reginfo.so" | ||
loadmodule "pua.so" | ||
modparam("pua|presence","db_url", "mysql://opensips_pcscf:heslo@MYSQL_IP/opensips_pcscf") | ||
|
||
loadmodule "pua_reginfo.so" | ||
|
||
modparam("pua_reginfo", "ul_domain", "location") | ||
modparam("pua_reginfo", "ul_identities_key", "identities") | ||
modparam("pua_reginfo", "default_domain", "IMS_DOMAIN") | ||
modparam("pua_reginfo", "server_address", "sip:[email protected]_DOMAIN") | ||
|
||
|
||
####### Routing Logic ######## | ||
|
@@ -180,6 +195,11 @@ route{ | |
t_on_reply("rtpengine_answer"); | ||
} | ||
|
||
if (is_method("SUBSCRIBE|NOTIFY") && is_myself($rd)) { | ||
route(handle_presence); | ||
exit; | ||
} | ||
|
||
# route it out to whatever destination was set by loose_route() | ||
# in $du (destination URI). | ||
route(relay); | ||
|
@@ -208,6 +228,10 @@ route{ | |
t_on_reply("register_reply"); | ||
route(relay); | ||
exit; | ||
} else if (is_method("SUBSCRIBE|PUBLISH")) { | ||
xlog("L_INFO", "[$ci] Received $rm for $tu - handling\n"); | ||
route(handle_presence); | ||
exit; | ||
} else if (is_method("INVITE")) { | ||
if (loose_route()) { | ||
xlog("L_INFO", "[$ci] Received INVITE for $tu - relaying to S-CSCF ($ru/$du)\n"); | ||
|
@@ -275,6 +299,9 @@ onreply_route[register_reply] { | |
} else if ($T_reply_code == 200) { | ||
if (!save("location", "no-reply, path-off")) | ||
xlog("L_ERR", "[$ci] could not save\n"); | ||
else | ||
ul_add_key("location", "$tU@$td", "identities", "$hdr(P-Associated-URI)"); | ||
reginfo_update("$tU@$td"); | ||
} | ||
|
||
} | ||
|
@@ -436,3 +463,20 @@ event_route[E_DM_REQUEST] { | |
|
||
} | ||
} | ||
|
||
route[handle_presence] { | ||
if (!t_newtran()){ | ||
sl_reply_error(); | ||
exit; | ||
} | ||
if ($hdr(Event) != "reg") { | ||
xlog("L_ERR", "[$ci] Unhandled event $hdr(Event)\n"); | ||
send_reply(489, "Bad Event"); | ||
exit; | ||
} | ||
|
||
if (is_method("PUBLISH")) | ||
handle_publish(); | ||
if (is_method("SUBSCRIBE")) | ||
handle_subscribe(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ log_level=3 | |
xlog_level=3 | ||
log_stderror=yes | ||
log_stdout=yes | ||
xlog_buf_size=16384 | ||
log_facility=LOG_LOCAL0 | ||
|
||
udp_workers=4 | ||
|
@@ -126,6 +127,12 @@ modparam("dialplan","db_url", "mysql://opensips_scscf:heslo@MYSQL_IP/opensips_sc | |
#### auth module | ||
loadmodule "auth.so" | ||
|
||
#### JSON module | ||
loadmodule "json.so" | ||
|
||
#### XML module | ||
loadmodule "xml.so" | ||
|
||
|
||
|
||
####### Routing Logic ######## | ||
|
@@ -223,9 +230,8 @@ route{ | |
$rU = $(rU{s.select,0,;}); | ||
} | ||
if (!dp_translate(1, $rU, $var(dialplan))) { | ||
xlog("L_ERR", "[$ci] dial $rU not in dialplan\n"); | ||
t_reply(404, "Unknown user"); | ||
exit; | ||
$var(dialplan) = "USER"; | ||
xlog("L_DBG", "[$ci] unknown dialplan - considering $var(dialplan)\n"); | ||
} | ||
xlog("L_INFO", "[$ci] Dial $rU is a $var(dialplan) dialplan\n"); | ||
switch ($var(dialplan)) { | ||
|
@@ -273,7 +279,21 @@ route[aka_resume_sar] { | |
xlog("[$ci] SAA rc: $var(rc), SAA AVPs: $var(rpl_avps)\n"); | ||
$avp(attr) = $ct.fields(params); | ||
append_to_reply("Service-Route: <sip:[email protected]_DOMAIN:6060;lr>\r\n"); | ||
append_to_reply("P-Associated-URI: <$fu>\r\n"); | ||
$json(rpl_avps) := $var(rpl_avps); | ||
for ($var(item) in $(json(rpl_avps)[*])) { | ||
$json(item) := $var(item); | ||
for ($var(key) in $(json(item.keys)[*])) { | ||
if ($var(key) == "Cx-User-Data") { | ||
$xml(data) := $json(item/$var(key)); | ||
$xml(profile) := $xml(data/IMSSubscription/ServiceProfile); | ||
$var(idx) = 0; | ||
while ($xml(profile/ServiceProfile/PublicIdentity[$var(idx)]) != NULL) { | ||
append_to_reply("P-Associated-URI: <$xml(profile/ServiceProfile/PublicIdentity[$var(idx)]/Identity.val)>\r\n"); | ||
$var(idx) = $var(idx) + 1; | ||
} | ||
} | ||
} | ||
} | ||
if (!save("location", "path-lazy")) { | ||
t_reply(503, "Internal Error"); | ||
exit; | ||
|