Merge deployment using openSIP IMS onto master branch
Co-authored-by: Razvan Crainea <razvan@opensips.org>
This commit is contained in:
13
opensips_ims_icscf/freeDiameter.conf
Normal file
13
opensips_ims_icscf/freeDiameter.conf
Normal file
@@ -0,0 +1,13 @@
|
||||
Identity = "icscf.IMS_DOMAIN";
|
||||
Realm = "IMS_DOMAIN";
|
||||
Port = ICSCF_BIND_PORT;
|
||||
ListenOn = "ICSCF_IP";
|
||||
SecPort = 0;
|
||||
No_SCTP;
|
||||
NoRelay;
|
||||
|
||||
ConnectPeer = "hss.IMS_DOMAIN" {
|
||||
No_TLS;
|
||||
ConnectTo = "PYHSS_IP";
|
||||
port = PYHSS_BIND_PORT;
|
||||
};
|
32
opensips_ims_icscf/icscf.dictionary
Normal file
32
opensips_ims_icscf/icscf.dictionary
Normal file
@@ -0,0 +1,32 @@
|
||||
VENDOR 10415 TGPP
|
||||
|
||||
ATTRIBUTE Visited-Network-Identifier 600 string 10415
|
||||
ATTRIBUTE Public-Identity 601 string 10415
|
||||
ATTRIBUTE Server-Name 602 string 10415
|
||||
|
||||
APPLICATION-AUTH 16777216/10415 3GPP Cx
|
||||
|
||||
REQUEST 300 User-Authorization Request
|
||||
{
|
||||
Session-Id | REQUIRED | 1
|
||||
Origin-Host | REQUIRED | 1
|
||||
Origin-Realm | REQUIRED | 1
|
||||
Destination-Realm | REQUIRED | 1
|
||||
Vendor-Specific-Application-Id | REQUIRED | 1
|
||||
Auth-Session-State | REQUIRED | 1
|
||||
User-Name | REQUIRED | 1
|
||||
Public-Identity | REQUIRED | 1
|
||||
Visited-Network-Identifier | REQUIRED | 1
|
||||
}
|
||||
|
||||
ANSWER 300 User-Authorization Answer
|
||||
{
|
||||
Session-Id | REQUIRED | 1
|
||||
Origin-Host | REQUIRED | 1
|
||||
Origin-Realm | REQUIRED | 1
|
||||
Destination-Host | OPTIONAL | 1
|
||||
Destination-Realm | OPTIONAL | 1
|
||||
Vendor-Specific-Application-Id | REQUIRED | 1
|
||||
Auth-Session-State | REQUIRED | 1
|
||||
Experimental-Result | REQUIRED | 1
|
||||
}
|
48
opensips_ims_icscf/icscf_init.sh
Executable file
48
opensips_ims_icscf/icscf_init.sh
Executable file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
# BSD 2-Clause License
|
||||
|
||||
# Copyright (c) 2020, Supreeth Herle
|
||||
# All rights reserved.
|
||||
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
|
||||
# 1. Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
|
||||
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
[ ${#MNC} == 3 ] && IMS_DOMAIN="ims.mnc${MNC}.mcc${MCC}.3gppnetwork.org" || IMS_DOMAIN="ims.mnc0${MNC}.mcc${MCC}.3gppnetwork.org"
|
||||
|
||||
mkdir -p /etc/opensips
|
||||
cp /mnt/icscf/freeDiameter.conf /etc/opensips
|
||||
cp /mnt/icscf/icscf.dictionary /etc/opensips
|
||||
cp /mnt/icscf/opensips.cfg /etc/opensips
|
||||
|
||||
sed -i 's|ICSCF_IP|'$ICSCF_IP'|g' /etc/opensips/freeDiameter.conf
|
||||
sed -i 's|PYHSS_IP|'$PYHSS_IP'|g' /etc/opensips/freeDiameter.conf
|
||||
sed -i 's|IMS_DOMAIN|'$IMS_DOMAIN'|g' /etc/opensips/freeDiameter.conf
|
||||
sed -i 's|PYHSS_BIND_PORT|'$PYHSS_BIND_PORT'|g' /etc/opensips/freeDiameter.conf
|
||||
sed -i 's|ICSCF_BIND_PORT|'$ICSCF_BIND_PORT'|g' /etc/opensips/freeDiameter.conf
|
||||
|
||||
sed -i 's|ICSCF_IP|'$ICSCF_IP'|g' /etc/opensips/opensips.cfg
|
||||
sed -i 's|IMS_DOMAIN|'$IMS_DOMAIN'|g' /etc/opensips/opensips.cfg
|
||||
|
||||
# Sync docker time
|
||||
#ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
|
||||
exec /usr/sbin/opensips -F $@
|
227
opensips_ims_icscf/opensips.cfg
Normal file
227
opensips_ims_icscf/opensips.cfg
Normal file
@@ -0,0 +1,227 @@
|
||||
#
|
||||
# OpenSIPS residential configuration script
|
||||
# by OpenSIPS Solutions <team@opensips-solutions.com>
|
||||
#
|
||||
# This script was generated via "make menuconfig", from
|
||||
# the "Residential" scenario.
|
||||
# You can enable / disable more features / functionalities by
|
||||
# re-generating the scenario with different options.#
|
||||
#
|
||||
# Please refer to the Core CookBook at:
|
||||
# https://opensips.org/Resources/DocsCookbooks
|
||||
# for a explanation of possible statements, functions and parameters.
|
||||
#
|
||||
|
||||
|
||||
####### Global Parameters #########
|
||||
|
||||
/* uncomment the following lines to enable debugging */
|
||||
#debug_mode=yes
|
||||
|
||||
log_level=3
|
||||
xlog_level=3
|
||||
log_stderror=yes
|
||||
log_stdout=yes
|
||||
log_facility=LOG_LOCAL0
|
||||
|
||||
udp_workers=4
|
||||
|
||||
/* uncomment the next line to enable the auto temporary blacklisting of
|
||||
not available destinations (default disabled) */
|
||||
#disable_dns_blacklist=no
|
||||
|
||||
/* uncomment the next line to enable IPv6 lookup after IPv4 dns
|
||||
lookup failures (default disabled) */
|
||||
#dns_try_ipv6=yes
|
||||
|
||||
|
||||
socket=udp:ICSCF_IP:4060
|
||||
socket=tcp:ICSCF_IP:4060
|
||||
|
||||
alias="icscf.IMS_DOMAIN"
|
||||
|
||||
#set module path
|
||||
mpath="/usr/lib/x86_64-linux-gnu/opensips/modules"
|
||||
|
||||
####### Modules Section ########
|
||||
####### http module ######
|
||||
loadmodule "httpd.so"
|
||||
|
||||
modparam("httpd", "ip", "ICSCF_IP")
|
||||
modparam("httpd", "port", 8080)
|
||||
|
||||
|
||||
#### SIGNALING module
|
||||
loadmodule "signaling.so"
|
||||
|
||||
#### StateLess module
|
||||
loadmodule "sl.so"
|
||||
|
||||
#### Transaction Module
|
||||
loadmodule "tm.so"
|
||||
modparam("tm", "fr_timeout", 5)
|
||||
modparam("tm", "fr_inv_timeout", 30)
|
||||
modparam("tm", "restart_fr_on_each_reply", 0)
|
||||
modparam("tm", "onreply_avp_mode", 1)
|
||||
|
||||
#### Record Route Module
|
||||
loadmodule "rr.so"
|
||||
/* do not append from tag to the RR (no need for this script) */
|
||||
modparam("rr", "append_fromtag", 0)
|
||||
|
||||
#### MAX ForWarD module
|
||||
loadmodule "maxfwd.so"
|
||||
|
||||
#### SIP MSG OPerationS module
|
||||
loadmodule "sipmsgops.so"
|
||||
|
||||
#### FIFO Management Interface
|
||||
loadmodule "mi_fifo.so"
|
||||
modparam("mi_fifo", "fifo_name", "/run/opensips/opensips_fifo")
|
||||
modparam("mi_fifo", "fifo_mode", 0666)
|
||||
|
||||
#### USeR LOCation module
|
||||
loadmodule "usrloc.so"
|
||||
modparam("usrloc", "nat_bflag", "NAT")
|
||||
modparam("usrloc", "working_mode_preset", "single-instance-no-db")
|
||||
|
||||
#### REGISTRAR module
|
||||
loadmodule "registrar.so"
|
||||
modparam("registrar", "tcp_persistent_flag", "TCP_PERSISTENT")
|
||||
/* uncomment the next line not to allow more than 10 contacts per AOR */
|
||||
#modparam("registrar", "max_contacts", 10)
|
||||
|
||||
#### ACCounting module
|
||||
loadmodule "acc.so"
|
||||
/* what special events should be accounted ? */
|
||||
modparam("acc", "early_media", 0)
|
||||
modparam("acc", "report_cancels", 0)
|
||||
/* by default we do not adjust the direct of the sequential requests.
|
||||
if you enable this parameter, be sure to enable "append_fromtag"
|
||||
in "rr" module */
|
||||
modparam("acc", "detect_direction", 0)
|
||||
|
||||
loadmodule "proto_udp.so"
|
||||
loadmodule "proto_tcp.so"
|
||||
|
||||
#### aaa_diameter module
|
||||
loadmodule "aaa_diameter.so"
|
||||
modparam("aaa_diameter", "fd_log_level", 1) # max amount of logging, quite annoying
|
||||
modparam("aaa_diameter", "realm", "IMS_DOMAIN")
|
||||
modparam("aaa_diameter", "peer_identity", "hss")
|
||||
modparam("aaa_diameter", "aaa_url",
|
||||
"diameter:/etc/opensips/freeDiameter.conf;extra-avps-file:/etc/opensips/icscf.dictionary")
|
||||
|
||||
#### JSON module
|
||||
loadmodule "json.so"
|
||||
|
||||
|
||||
|
||||
####### Routing Logic ########
|
||||
|
||||
# main request routing logic
|
||||
|
||||
route{
|
||||
xlog("L_INFO", "[$ci] Start route time [$Tf] method ($rm) r-uri ($ru) \n");
|
||||
|
||||
if (!mf_process_maxfwd_header(10)) {
|
||||
send_reply(483,"Too Many Hops");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (has_totag()) {
|
||||
|
||||
# handle hop-by-hop ACK (no routing required)
|
||||
if ( is_method("ACK") && t_check_trans() ) {
|
||||
t_relay();
|
||||
exit;
|
||||
}
|
||||
|
||||
# sequential request within a dialog should
|
||||
# take the path determined by record-routing
|
||||
if ( !loose_route() ) {
|
||||
# we do record-routing for all our traffic, so we should not
|
||||
# receive any sequential requests without Route hdr.
|
||||
send_reply(404,"Not here");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (is_method("BYE")) {
|
||||
# do accounting even if the transaction fails
|
||||
do_accounting("log","failed");
|
||||
}
|
||||
|
||||
# route it out to whatever destination was set by loose_route()
|
||||
# in $du (destination URI).
|
||||
route(relay);
|
||||
exit;
|
||||
}
|
||||
|
||||
# CANCEL processing
|
||||
if (is_method("CANCEL")) {
|
||||
if (t_check_trans())
|
||||
t_relay();
|
||||
exit;
|
||||
}
|
||||
|
||||
# absorb retransmissions, but do not create transaction
|
||||
t_check_trans();
|
||||
|
||||
if (is_method("REGISTER")) {
|
||||
xlog("L_INFO", "[$ci] Received REGISTER for $tu - doing UAR\n");
|
||||
|
||||
$var(payload) = "[
|
||||
{ \"Session-Id\": \"icscf.IMS_DOMAIN;"+$Ts+"."+$Tsm+";"+$pp+"\" },
|
||||
{ \"Origin-Host\": \"icscf.IMS_DOMAIN\" },
|
||||
{ \"Origin-Realm\": \"IMS_DOMAIN\" },
|
||||
{ \"Destination-Realm\": \"IMS_DOMAIN\" },
|
||||
{ \"Vendor-Specific-Application-Id\": [{\"Vendor-Id\": 10415},
|
||||
{\"Auth-Application-Id\": 16777216}]},
|
||||
{ \"Auth-Session-State\": 1 },
|
||||
{ \"User-Name\": \""+$fU+"@"+$fd+"\" },
|
||||
{ \"Public-Identity\": \""+$fu+"\" },
|
||||
{ \"Visited-Network-Identifier\": \"IMS_DOMAIN\" }
|
||||
]";
|
||||
|
||||
$var(rc) = dm_send_request(16777216, 300, $var(payload), $var(rpl_avps));
|
||||
xlog("[$ci] UAA rc: $var(rc), UAA AVPs: $var(rpl_avps)\n");
|
||||
|
||||
$var(server_name) = NULL;
|
||||
$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) == "Server-Name") {
|
||||
$var(server_name) = $json(item/$var(key));
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($var(server_name) != NULL)
|
||||
break;
|
||||
}
|
||||
|
||||
if ($var(server_name) == NULL) {
|
||||
xlog("L_ERR", "[$ci] No server available!\n");
|
||||
send_reply(503,"Not available");
|
||||
exit;
|
||||
}
|
||||
|
||||
# relay to S-CSCF
|
||||
xlog("L_INFO", "[$ci] using S-CSCF $var(server_name)\n");
|
||||
$ru = $var(server_name);
|
||||
|
||||
route(relay);
|
||||
exit;
|
||||
}
|
||||
|
||||
send_reply(503,"Not Implemented");
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
route[relay] {
|
||||
if (!t_relay()) {
|
||||
send_reply(500,"Internal Error");
|
||||
}
|
||||
exit;
|
||||
}
|
Reference in New Issue
Block a user