moving the N5 Route logic to its own Route and improve it
move the INIT Req to its own route move the modify req into its own logic adding calls to the suitable logic ( INIT Req, ReqReply, Indialog req) in the suitable routeing block
This commit is contained in:
committed by
Supreeth Herle
parent
3915449019
commit
36b0191cbe
@@ -21,11 +21,97 @@ route[MO]
|
||||
remove_hf("P-Asserted-Identity");
|
||||
remove_hf("P-Preferred-Identity");
|
||||
|
||||
#################
|
||||
## now lets try a N5 PolicyAuthorizationrequest to user Session in the PCF ### NOTE: THIS IS EXREAMLLY EXPEREMENTAL!!
|
||||
###############
|
||||
##############
|
||||
##############
|
||||
# Add P-Charging-Vector
|
||||
sip_p_charging_vector("g");
|
||||
|
||||
if (is_present_hf("P-Preferred-Identity") && pcscf_assert_identity("location", "$hdr(P-Preferred-Identity)") && $hdr(P-Preferred-Identity) =~ "sip:.*") {
|
||||
append_hf("P-Asserted-Identity: $hdr(P-Preferred-Identity)\r\n");
|
||||
} else if (is_present_hf("P-Asserted-Identity") && pcscf_assert_identity("location", "$hdr(P-Asserted-Identity)") && $hdr(P-Asserted-Identity) =~ "sip:.*") {
|
||||
append_hf("P-Asserted-Identity: $hdr(P-Asserted-Identity)\r\n");
|
||||
} else if (pcscf_assert_identity("location", "$(fu{tobody.uri})")) {
|
||||
# For broken SIP implementation in Samsung devices
|
||||
if ($fu =~ "tel:.*") {
|
||||
$var(new_hdr) = $(fu{tobody.uri}) + "@NETWORKNAME";
|
||||
$var(new_hdr) = $(var(new_hdr){re.subst,/tel:/sip:/g});
|
||||
append_hf("P-Asserted-Identity: <$var(new_hdr)>\r\n");
|
||||
$fu = $var(new_hdr);
|
||||
} else {
|
||||
append_hf("P-Asserted-Identity: <$(fu{tobody.uri})>\r\n");
|
||||
}
|
||||
} else {
|
||||
append_hf("P-Asserted-Identity: <$pcscf_asserted_identity>\r\n");
|
||||
}
|
||||
|
||||
if (!pcscf_follows_service_routes("location")){
|
||||
#Variant 1 - deny access to the network
|
||||
#send_reply("400","Bad Request - Not following indicated service routes");
|
||||
#break;
|
||||
|
||||
#Variant 2 - enforce routes and let the dialog continue
|
||||
pcscf_force_service_routes("location");
|
||||
}
|
||||
|
||||
# add IBCF/THIG route here if required
|
||||
# Check for "sec-agree" in the Require header:
|
||||
if (is_present_hf("Require") && $hdr(Require) =~ ".*sec-agree.*") {
|
||||
# Remove the old Require-Header:
|
||||
remove_hf("Require");
|
||||
# Replace ", sec-agree" with ""
|
||||
$var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
|
||||
if ($(var(new_hdr){s.len}) > 0) {
|
||||
append_hf("Require: $var(new_hdr)\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
# Check for "sec-agree" in the Proxy-Require header:
|
||||
if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~ ".*sec-agree.*") {
|
||||
# Remove the old Proxy-Require-Header:
|
||||
remove_hf("Proxy-Require");
|
||||
# Replace ", sec-agree" with ""
|
||||
$var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
|
||||
if ($(var(new_hdr){s.len}) > 0) {
|
||||
append_hf("Proxy-Require: $var(new_hdr)\r\n");
|
||||
}
|
||||
}
|
||||
remove_hf("Security-Verify");
|
||||
|
||||
|
||||
#
|
||||
#Route N5 Request
|
||||
#
|
||||
if(is_method("INVITE")) {
|
||||
route(N5_INIT_REQ);
|
||||
}
|
||||
xlog("L_ALERT", "Route N5 logic is finished now continue with the normal route\n");
|
||||
|
||||
|
||||
#!ifdef TRF_FUNCTION
|
||||
$var(trf) = TRF_FUNCTION;
|
||||
# Check for "sec-agree" in the Proxy-Require header:
|
||||
if (is_present_hf("Feature-Caps")) {
|
||||
# Remove the old Proxy-Require-Header:
|
||||
remove_hf("Feature-Caps");
|
||||
append_hf("Feature-Caps: $hdr(Feature-Caps);+g.3gpp.trf=\"<sip:$var(trf);lr>\"\r\n");
|
||||
} else {
|
||||
append_hf("Feature-Caps: *;+g.3gpp.trf=\"<sip:$var(trf);lr>\"\r\n");
|
||||
}
|
||||
#!endif
|
||||
# Add a visited Network-ID-Header:
|
||||
if (is_present_hf("P-Visited-Network-ID")) {
|
||||
$var(new_hdr) = "NETWORKNAME, "+$hdr(P-Visited-Network-ID);
|
||||
append_hf("P-Visited-Network-ID: $var(new_hdr)\r\n");
|
||||
} else {
|
||||
append_hf("P-Visited-Network-ID: NETWORKNAME\r\n");
|
||||
}
|
||||
set_dlg_profile("orig");
|
||||
t_on_reply("MO_reply");
|
||||
}
|
||||
|
||||
|
||||
#################################
|
||||
## Route Logic for N5 Requests ##
|
||||
#################################
|
||||
route[N5_INIT_REQ] {
|
||||
|
||||
## Storing IDs and IPs from UE into variables to use them later in the N5 Request:
|
||||
|
||||
@@ -97,11 +183,6 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
|
||||
$var(ue_port_sip) = $sht(user_sip_ports=>$var(orig_ue_port));
|
||||
xlog("L_INFO", "IP for UE $var(orig_ue_port) is: $var(ue_port_sip)\n");
|
||||
|
||||
## retrieving IMSI from Registration
|
||||
$var(imsi_reg) = $var(ue_ip_addr); # User Part of the from Header to get the USER
|
||||
$var(ue_imsi_inv) = $sht(user_ids=>$var(imsi_reg));
|
||||
xlog("L_INFO", "IMSI for UE with IP $var(ue_ip_addr) is: $var(ue_imsi_inv)\n");
|
||||
|
||||
## retrieving SDP Connection Info and Media Port for UE
|
||||
$var(sdp_id_ue) = $fU; # User Part of the from Header to get the USER
|
||||
$var(ue_sdp_ip) = $sht(user_sdps_ip=>$var(sdp_id_ue));
|
||||
@@ -119,7 +200,7 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
|
||||
|
||||
#### now start to build the N5 Request
|
||||
|
||||
xlog("L_ALERT","DEBUG: Preparing N5 Message to PCF for $fu\n");
|
||||
xlog("L_ALERT","DEBUG: Preparing QoS N5 Message to PCF for the INVITE\n");
|
||||
|
||||
xlog("L_ALERT","DEBUG: Initialize empty arrays and objects\n");
|
||||
|
||||
@@ -131,7 +212,7 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
|
||||
$var(payload) = '{}';
|
||||
|
||||
### Set afAppId and dnn in payload
|
||||
jansson_set("string", "afAppId", "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"", "$var(payload)");
|
||||
jansson_set("string", "afAppId", "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"", "$var(payload)"); # adding a note that this could be improved in future to get the value SIP Header
|
||||
jansson_set("string", "dnn", "ims", "$var(payload)");
|
||||
|
||||
### Set medComponents
|
||||
@@ -143,18 +224,18 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
|
||||
### RTP
|
||||
jansson_set("integer", "fNum", 1, "$var(medSubComp1)");
|
||||
jansson_set("array", "fDescs", "[\"permit out 17 from any to $var(ue_sdp_ip) $var(ue_sdp_port)\", \"permit in 17 from $var(ue_sdp_ip) $var(ue_sdp_port) to any\"]", "$var(medSubComp1)");
|
||||
jansson_set("string", "fStatus", "ENABLED-UPLINK", "$var(medSubComp1)");
|
||||
# jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp1)"); # commented out BW accourding to Open5GC code if they are not there they will be taken from WEBGUI, could be reenabled if needed
|
||||
# jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)"); # commented out BW accourding to Open5GC code if they are not there they will be taken from WEBGUI, could be reenabled if needed
|
||||
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp1)");
|
||||
jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp1)");
|
||||
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)");
|
||||
jansson_set("string", "flowUsage", "NO_INFO", "$var(medSubComp1)");
|
||||
|
||||
|
||||
### RTCP
|
||||
jansson_set("integer", "fNum", 2, "$var(medSubComp2)");
|
||||
jansson_set("array", "fDescs", "[\"permit out 17 from any to $var(ue_sdp_ip) $var(ue_sdp_rtcp_port)\", \"permit in 17 from $var(ue_sdp_ip) $var(ue_sdp_rtcp_port) to any\"]", "$var(medSubComp2)");
|
||||
jansson_set("string", "fStatus", "ENABLED-UPLINK", "$var(medSubComp2)");
|
||||
# jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp2)"); # commented out BW accourding to Open5GC code if they are not there they will be taken from WEBGUI, could be reenabled if needed
|
||||
# jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp2)"); # commented out BW accourding to Open5GC code if they are not there they will be taken from WEBGUI, could be reenabled if needed
|
||||
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp2)");
|
||||
jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp2)");
|
||||
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp2)");
|
||||
jansson_set("string", "flowUsage", "RTCP", "$var(medSubComp2)");
|
||||
|
||||
# Merging the flows under MediaSubComponent
|
||||
@@ -181,7 +262,6 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
|
||||
### Set other parameters in payload
|
||||
jansson_set("string", "notifUri", "http://172.22.0.21:8284", "$var(payload)");
|
||||
jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$var(payload)");
|
||||
jansson_set("string", "supi", "imsi-$var(ue_imsi_inv)", "$var(payload)");
|
||||
jansson_set("string", "gpsi", "msisdn-$fU", "$var(payload)");
|
||||
jansson_set("string", "suppFeat", "4", "$var(payload)");
|
||||
jansson_set("string", "ueIpv4", "$var(ue_ip_addr)", "$var(payload)");
|
||||
@@ -249,92 +329,11 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
|
||||
xlog("L_INFO", "Stored AppSession for user $var(user_id): $var(app_session)\n");
|
||||
}
|
||||
|
||||
|
||||
|
||||
#####################################################################
|
||||
##### END OF N5 VoNR Experement !!!! the variables should be saved ##
|
||||
#####################################################################
|
||||
#####################################################################
|
||||
#####################################################################
|
||||
|
||||
|
||||
|
||||
|
||||
# Add P-Charging-Vector
|
||||
sip_p_charging_vector("g");
|
||||
|
||||
if (is_present_hf("P-Preferred-Identity") && pcscf_assert_identity("location", "$hdr(P-Preferred-Identity)") && $hdr(P-Preferred-Identity) =~ "sip:.*") {
|
||||
append_hf("P-Asserted-Identity: $hdr(P-Preferred-Identity)\r\n");
|
||||
} else if (is_present_hf("P-Asserted-Identity") && pcscf_assert_identity("location", "$hdr(P-Asserted-Identity)") && $hdr(P-Asserted-Identity) =~ "sip:.*") {
|
||||
append_hf("P-Asserted-Identity: $hdr(P-Asserted-Identity)\r\n");
|
||||
} else if (pcscf_assert_identity("location", "$(fu{tobody.uri})")) {
|
||||
# For broken SIP implementation in Samsung devices
|
||||
if ($fu =~ "tel:.*") {
|
||||
$var(new_hdr) = $(fu{tobody.uri}) + "@NETWORKNAME";
|
||||
$var(new_hdr) = $(var(new_hdr){re.subst,/tel:/sip:/g});
|
||||
append_hf("P-Asserted-Identity: <$var(new_hdr)>\r\n");
|
||||
$fu = $var(new_hdr);
|
||||
} else {
|
||||
append_hf("P-Asserted-Identity: <$(fu{tobody.uri})>\r\n");
|
||||
}
|
||||
} else {
|
||||
append_hf("P-Asserted-Identity: <$pcscf_asserted_identity>\r\n");
|
||||
}
|
||||
|
||||
if (!pcscf_follows_service_routes("location")){
|
||||
#Variant 1 - deny access to the network
|
||||
#send_reply("400","Bad Request - Not following indicated service routes");
|
||||
#break;
|
||||
|
||||
#Variant 2 - enforce routes and let the dialog continue
|
||||
pcscf_force_service_routes("location");
|
||||
}
|
||||
|
||||
# add IBCF/THIG route here if required
|
||||
# Check for "sec-agree" in the Require header:
|
||||
if (is_present_hf("Require") && $hdr(Require) =~ ".*sec-agree.*") {
|
||||
# Remove the old Require-Header:
|
||||
remove_hf("Require");
|
||||
# Replace ", sec-agree" with ""
|
||||
$var(new_hdr) = $(hdr(Require){re.subst,/[, ]*sec-agree//gi});
|
||||
if ($(var(new_hdr){s.len}) > 0) {
|
||||
append_hf("Require: $var(new_hdr)\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
# Check for "sec-agree" in the Proxy-Require header:
|
||||
if (is_present_hf("Proxy-Require") && $hdr(Proxy-Require) =~ ".*sec-agree.*") {
|
||||
# Remove the old Proxy-Require-Header:
|
||||
remove_hf("Proxy-Require");
|
||||
# Replace ", sec-agree" with ""
|
||||
$var(new_hdr) = $(hdr(Proxy-Require){re.subst,/[, ]*sec-agree//gi});
|
||||
if ($(var(new_hdr){s.len}) > 0) {
|
||||
append_hf("Proxy-Require: $var(new_hdr)\r\n");
|
||||
}
|
||||
}
|
||||
remove_hf("Security-Verify");
|
||||
|
||||
#!ifdef TRF_FUNCTION
|
||||
$var(trf) = TRF_FUNCTION;
|
||||
# Check for "sec-agree" in the Proxy-Require header:
|
||||
if (is_present_hf("Feature-Caps")) {
|
||||
# Remove the old Proxy-Require-Header:
|
||||
remove_hf("Feature-Caps");
|
||||
append_hf("Feature-Caps: $hdr(Feature-Caps);+g.3gpp.trf=\"<sip:$var(trf);lr>\"\r\n");
|
||||
} else {
|
||||
append_hf("Feature-Caps: *;+g.3gpp.trf=\"<sip:$var(trf);lr>\"\r\n");
|
||||
}
|
||||
#!endif
|
||||
# Add a visited Network-ID-Header:
|
||||
if (is_present_hf("P-Visited-Network-ID")) {
|
||||
$var(new_hdr) = "NETWORKNAME, "+$hdr(P-Visited-Network-ID);
|
||||
append_hf("P-Visited-Network-ID: $var(new_hdr)\r\n");
|
||||
} else {
|
||||
append_hf("P-Visited-Network-ID: NETWORKNAME\r\n");
|
||||
}
|
||||
set_dlg_profile("orig");
|
||||
t_on_reply("MO_reply");
|
||||
}
|
||||
#####################################
|
||||
##### END OF N5 VoNR Request logic ##
|
||||
#####################################
|
||||
|
||||
######################################################################
|
||||
# Replies to Originating Initial Requests
|
||||
@@ -350,6 +349,14 @@ onreply_route[MO_reply] {
|
||||
remove_hf("C-Params");
|
||||
append_hf("Contact: $ct;$hdr(C-Params)\r\n");
|
||||
}
|
||||
|
||||
## N5 PATCH Request
|
||||
if (t_check_status("183|200|180") && has_body("application/sdp")){
|
||||
xlog("L_ALERT","Proccessing QoS N5 Request for SDP Answer on INVITE\n");
|
||||
route(N5_PATCH_REQ);
|
||||
}
|
||||
xlog("L_ALERT"," finnished N5 PATCH Request now continue Orig_Reply logic\n");
|
||||
|
||||
#!ifdef WITH_IPSEC
|
||||
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
|
||||
#!endif
|
||||
@@ -357,17 +364,182 @@ onreply_route[MO_reply] {
|
||||
if(status=~"[12][0-9][0-9]")
|
||||
route(NATMANAGE);
|
||||
|
||||
###################################################
|
||||
#### 5G VoNR N5 NPCF Authorization PATCH reuqest ##
|
||||
###################################################
|
||||
|
||||
if (t_check_status("183|200|180") && has_body("application/sdp")){
|
||||
#!ifdef WITH_RX
|
||||
if (t_check_status("183|200") && has_body("application/sdp")){
|
||||
xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n");
|
||||
|
||||
if (t_is_retr_async_reply()) {
|
||||
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
|
||||
drop();
|
||||
}
|
||||
|
||||
xlog("L_DBG","Diameter: Orig authorizing media via Rx\n");
|
||||
$avp(FTAG_CUSTOM_AVP)=$ft;
|
||||
$avp(TTAG_CUSTOM_AVP)=$tt;
|
||||
$avp(CALLID_CUSTOM_AVP)=$ci;
|
||||
|
||||
if (Rx_AAR("MO_aar_reply","orig","",-1) == 0) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
|
||||
}
|
||||
|
||||
route[MO_aar_reply]
|
||||
{
|
||||
#this is async so to know status we have to check the reply avp
|
||||
switch ($avp(s:aar_return_code)) {
|
||||
case 1:
|
||||
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
|
||||
break;
|
||||
default:
|
||||
xlog("L_ERR", "IMS: AAR failed Orig\n");
|
||||
xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)");
|
||||
#comment this if you want to allow even if Rx fails
|
||||
if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){
|
||||
dlg_terminate("all", "Sorry no QoS available");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
}
|
||||
|
||||
######################################################################
|
||||
# In-Dialog-Mo-Requests
|
||||
######################################################################
|
||||
route[MO_indialog] {
|
||||
|
||||
## N5 PATCH Request
|
||||
|
||||
if(is_method("INVITE")){
|
||||
xlog("L_ALERT"," InDialog SDP Answer N5 Request for reINVITE\n");
|
||||
route(N5_PATCH_REQ);
|
||||
}
|
||||
|
||||
## Terminating N5 AppSession after BYE##
|
||||
|
||||
if(is_method("BYE"))
|
||||
{
|
||||
xlog("L_ALERT","Terminating AppSession For Call fom User $fu due to call END\n");
|
||||
# Retrieveing
|
||||
$var(user_id_call_rel) = $fU; # User Part of the from Header to get the USER
|
||||
$var(user_appsess_call_rel) = $sht(user_data=>$var(user_id_call_rel));
|
||||
xlog("L_INFO", "Terminating Stored AppSession for user $var(user_id_call_rel): $var(user_id_call_rel)\n");
|
||||
|
||||
$var(headers) = "X-SIP-Status: De-Registration\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n";
|
||||
$var(headers) = $var(headers) + "accept: application/json\r\n";
|
||||
$var(headers) = $var(headers) + "accept: application/problem+json\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-max-rsp-time: 10000\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-discovery-service-names: npcf-policyauthorization\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-sender-timestamp: " + $var(time_now);
|
||||
|
||||
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/$var(user_appsess_call_rel)/delete", "$var(json_request)", "$var(headers)", "$var(result)" );
|
||||
xlog("Termination resuls: $var(result)\n");
|
||||
xlog("L_ALERT", "response header: $curlerror(error)\n");
|
||||
xlog("L_ALERT", "response header: $var(response_code)\n");
|
||||
xlog("L_ALERT", "response header: $httprhdr(location)\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
xnotice("PCSCF MO_indialog: \n Destination URI: $du\n Request URI: $ru\n");
|
||||
xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n");
|
||||
xnotice("Received IP and Port: ($Ri:$Rp)\n");
|
||||
xnotice("Contact header: $ct\n");
|
||||
setflag(FLT_MOBILE_ORIG);
|
||||
t_on_reply("MO_indialog_reply");
|
||||
|
||||
# Append rport only if its a request coming from UE
|
||||
if (is_request() && ($hdrc(Via) == 1)) {
|
||||
force_rport();
|
||||
}
|
||||
|
||||
#!ifdef WITH_IPSEC
|
||||
if ($dd != "" && $rd != "" && $fs != "") {
|
||||
if ($rd =~ ".*" + $dd + ".*") {
|
||||
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
}
|
||||
|
||||
onreply_route[MO_indialog_reply] {
|
||||
xnotice("PCSCF MO_indialog_reply: \n Destination URI: $du\n Request URI: $ru\n");
|
||||
xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n");
|
||||
xnotice("Received IP and Port: ($Ri:$Rp)\n");
|
||||
xnotice("Contact header: $ct\n");
|
||||
|
||||
##
|
||||
|
||||
if (t_check_status("200") && has_body("application/sdp")){
|
||||
|
||||
if (t_is_retr_async_reply()) {
|
||||
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
|
||||
drop();
|
||||
}
|
||||
|
||||
xlog("L_ALERT"," InDialog SDP Answer N5 Request for 200OK reINVITE\n");
|
||||
route(N5_PATCH_REQ);
|
||||
}
|
||||
xlog("L_ALERT"," back to Orig_Reply logic\n");
|
||||
|
||||
# In case of 1xx and 2xx do NAT
|
||||
if(status=~"[12][0-9][0-9]")
|
||||
route(NATMANAGE);
|
||||
|
||||
#!ifdef WITH_RX
|
||||
if (t_check_status("183|200") && has_body("application/sdp") && !is_method("PRACK")) {
|
||||
if (t_is_retr_async_reply()) {
|
||||
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
|
||||
drop();
|
||||
}
|
||||
|
||||
xlog("L_DBG", "IMS: ORIG_SUBSEQUENT reply. This is a 200 OK to a re-INVITE\n");
|
||||
xlog("L_DBG","Diameter: Orig authorizing media via Rx\n");
|
||||
$avp(FTAG_CUSTOM_AVP)=$ft;
|
||||
$avp(TTAG_CUSTOM_AVP)=$tt;
|
||||
$avp(CALLID_CUSTOM_AVP)=$ci;
|
||||
|
||||
if (Rx_AAR("MO_indialog_aar_reply","orig","",-1) == 0) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
route[MO_indialog_aar_reply]
|
||||
{
|
||||
#this is async so to know status we have to check the reply avp
|
||||
switch ($avp(s:aar_return_code)) {
|
||||
case 1:
|
||||
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
|
||||
break;
|
||||
default:
|
||||
xlog("L_ERR", "IMS: AAR failed Orig\n");
|
||||
xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)");
|
||||
#comment this if you want to allow even if Rx fails
|
||||
if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){
|
||||
dlg_terminate("all", "Sorry no QoS available");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
}
|
||||
###################################################
|
||||
#### 5G VoNR N5 NPCF Authorization PATCH reuqest ##
|
||||
###################################################
|
||||
route[N5_PATCH_REQ] {
|
||||
|
||||
|
||||
xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n");
|
||||
|
||||
|
||||
### Getting the IP/Port of UE
|
||||
$var(orig_id_ue_ip) = $fU; # User Part of the from Header to get the USER
|
||||
$var(ue_sip_ip_addr) = $sht(user_sip_ips=>$var(orig_id_ue_ip));
|
||||
@@ -377,11 +549,6 @@ onreply_route[MO_reply] {
|
||||
$var(ue_port_sip) = $sht(user_sip_ports=>$var(orig_ue_port));
|
||||
xlog("L_INFO", "IP for UE $var(orig_ue_port) is: $var(ue_port_sip)\n");
|
||||
|
||||
## retrieving IMSI from Registration
|
||||
$var(imsi_inv_rep) = $var(ue_sip_ip_addr); # User Part of the from Header to get the USER
|
||||
$var(ue_imsi_inv) = $sht(user_ids=>$var(imsi_inv_rep));
|
||||
xlog("L_INFO", "IMSI for UE with IP $var(ue_ip_addr) is: $var(ue_imsi_inv)\n");
|
||||
|
||||
## retrieving SDP Connection Info and Media Port for UE
|
||||
$var(sdp_id_ue) = $fU; # User Part of the from Header to get the USER
|
||||
$var(ue_sdp_ip) = $sht(user_sdps_ip=>$var(sdp_id_ue));
|
||||
@@ -410,7 +577,7 @@ onreply_route[MO_reply] {
|
||||
|
||||
#### now start to build the N5 Request
|
||||
|
||||
xlog("L_ALERT","DEBUG: Preparing N5 Message to PCF for $fu\n");
|
||||
xlog("L_ALERT","DEBUG: Preparing PATCH N5 Message for SDP Answer\n");
|
||||
|
||||
xlog("L_ALERT","DEBUG: Initialize empty arrays and objects\n");
|
||||
|
||||
@@ -472,7 +639,6 @@ onreply_route[MO_reply] {
|
||||
### Set other parameters in payload
|
||||
jansson_set("string", "notifUri", "http://172.22.0.21:8284", "$var(payload)");
|
||||
# jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
|
||||
# jansson_set("string", "supi", "imsi-$var(ue_imsi_inv)", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
|
||||
# jansson_set("string", "gpsi", "msisdn-$fU", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
|
||||
# jansson_set("string", "suppFeat", "4", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
|
||||
# jansson_set("string", "ueIpv4", "$var(ue_sip_ip_addr)", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
|
||||
@@ -501,157 +667,9 @@ onreply_route[MO_reply] {
|
||||
xlog("L_ALERT", "response header: $curlerror(error)\n");
|
||||
xlog("L_ALERT", "response header: $var(response_code)\n");
|
||||
xlog("L_ALERT", "response header: $httprhdr(location)\n");
|
||||
|
||||
}
|
||||
|
||||
########################################
|
||||
######### END of 5G VoNR N5 Request ####
|
||||
########################################
|
||||
|
||||
#!ifdef WITH_RX
|
||||
if (t_check_status("183|200") && has_body("application/sdp")){
|
||||
xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n");
|
||||
|
||||
if (t_is_retr_async_reply()) {
|
||||
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
|
||||
drop();
|
||||
}
|
||||
|
||||
xlog("L_DBG","Diameter: Orig authorizing media via Rx\n");
|
||||
$avp(FTAG_CUSTOM_AVP)=$ft;
|
||||
$avp(TTAG_CUSTOM_AVP)=$tt;
|
||||
$avp(CALLID_CUSTOM_AVP)=$ci;
|
||||
|
||||
if (Rx_AAR("MO_aar_reply","orig","",-1) == 0) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
route[MO_aar_reply]
|
||||
{
|
||||
#this is async so to know status we have to check the reply avp
|
||||
switch ($avp(s:aar_return_code)) {
|
||||
case 1:
|
||||
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
|
||||
break;
|
||||
default:
|
||||
xlog("L_ERR", "IMS: AAR failed Orig\n");
|
||||
xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)");
|
||||
#comment this if you want to allow even if Rx fails
|
||||
if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){
|
||||
dlg_terminate("all", "Sorry no QoS available");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
######################################################################
|
||||
# In-Dialog-Mo-Requests
|
||||
######################################################################
|
||||
route[MO_indialog] {
|
||||
|
||||
###############################
|
||||
## Terminating N5 AppSession ##
|
||||
###############################
|
||||
|
||||
if(is_method("BYE"))
|
||||
{
|
||||
xlog("L_ALERT","Terminating AppSession For Call fom User $fu\n");
|
||||
# Retrieveing
|
||||
$var(user_id_call_rel) = $fU; # User Part of the from Header to get the USER
|
||||
$var(user_appsess_call_rel) = $sht(user_data=>$var(user_id_call_rel));
|
||||
xlog("L_INFO", "Terminating Stored AppSession for user $var(user_id_call_rel): $var(user_id_call_rel)\n");
|
||||
|
||||
$var(headers) = "X-SIP-Status: De-Registration\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n";
|
||||
$var(headers) = $var(headers) + "accept: application/json\r\n";
|
||||
$var(headers) = $var(headers) + "accept: application/problem+json\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-max-rsp-time: 10000\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-discovery-service-names: npcf-policyauthorization\r\n";
|
||||
$var(headers) = $var(headers) + "3gpp-sbi-sender-timestamp: " + $var(time_now);
|
||||
|
||||
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/$var(user_appsess_call_rel)/delete", "$var(json_request)", "$var(headers)", "$var(result)" );
|
||||
xlog("Termination resuls: $var(result)\n");
|
||||
xlog("L_ALERT", "response header: $curlerror(error)\n");
|
||||
xlog("L_ALERT", "response header: $var(response_code)\n");
|
||||
xlog("L_ALERT", "response header: $httprhdr(location)\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
xnotice("PCSCF MO_indialog: \n Destination URI: $du\n Request URI: $ru\n");
|
||||
xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n");
|
||||
xnotice("Received IP and Port: ($Ri:$Rp)\n");
|
||||
xnotice("Contact header: $ct\n");
|
||||
setflag(FLT_MOBILE_ORIG);
|
||||
t_on_reply("MO_indialog_reply");
|
||||
|
||||
# Append rport only if its a request coming from UE
|
||||
if (is_request() && ($hdrc(Via) == 1)) {
|
||||
force_rport();
|
||||
}
|
||||
|
||||
#!ifdef WITH_IPSEC
|
||||
if ($dd != "" && $rd != "" && $fs != "") {
|
||||
if ($rd =~ ".*" + $dd + ".*") {
|
||||
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
}
|
||||
|
||||
onreply_route[MO_indialog_reply] {
|
||||
xnotice("PCSCF MO_indialog_reply: \n Destination URI: $du\n Request URI: $ru\n");
|
||||
xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n");
|
||||
xnotice("Received IP and Port: ($Ri:$Rp)\n");
|
||||
xnotice("Contact header: $ct\n");
|
||||
|
||||
# In case of 1xx and 2xx do NAT
|
||||
if(status=~"[12][0-9][0-9]")
|
||||
route(NATMANAGE);
|
||||
|
||||
#!ifdef WITH_RX
|
||||
if (t_check_status("183|200") && has_body("application/sdp") && !is_method("PRACK")) {
|
||||
if (t_is_retr_async_reply()) {
|
||||
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
|
||||
drop();
|
||||
}
|
||||
|
||||
xlog("L_DBG", "IMS: ORIG_SUBSEQUENT reply. This is a 200 OK to a re-INVITE\n");
|
||||
xlog("L_DBG","Diameter: Orig authorizing media via Rx\n");
|
||||
$avp(FTAG_CUSTOM_AVP)=$ft;
|
||||
$avp(TTAG_CUSTOM_AVP)=$tt;
|
||||
$avp(CALLID_CUSTOM_AVP)=$ci;
|
||||
|
||||
if (Rx_AAR("MO_indialog_aar_reply","orig","",-1) == 0) {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
route[MO_indialog_aar_reply]
|
||||
{
|
||||
#this is async so to know status we have to check the reply avp
|
||||
switch ($avp(s:aar_return_code)) {
|
||||
case 1:
|
||||
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
|
||||
break;
|
||||
default:
|
||||
xlog("L_ERR", "IMS: AAR failed Orig\n");
|
||||
xlog("L_ERR", "IMS: ttag: "+ "$avp(TTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: ftag: "+ "$avp(FTAG_CUSTOM_AVP)");
|
||||
xlog("L_ERR", "IMS: callid: "+ "$avp(CALLID_CUSTOM_AVP)");
|
||||
#comment this if you want to allow even if Rx fails
|
||||
if(dlg_get("$avp(CALLID_CUSTOM_AVP)","$avp(FTAG_CUSTOM_AVP)","$avp(TTAG_CUSTOM_AVP)")){
|
||||
dlg_terminate("all", "Sorry no QoS available");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user