added the N5 to the initial INVITE

added the N5 to the initial INVITE and then update the session with HTTP PATCH after receiving 180/183/200/ with SDP.
This commit is contained in:
NUCLEAR-WAR
2024-08-09 10:34:57 +02:00
committed by Supreeth Herle
parent e29d02828d
commit ac0252d636

View File

@@ -21,11 +21,11 @@ route[MO]
remove_hf("P-Asserted-Identity"); remove_hf("P-Asserted-Identity");
remove_hf("P-Preferred-Identity"); remove_hf("P-Preferred-Identity");
####################################################################################################################### #################
## now lets try a N5 PolicyAuthorizationrequest to user Session in the PCF ### NOTE: THIS IS EXREAMLLY EXPEREMENTAL!!## ## now lets try a N5 PolicyAuthorizationrequest to user Session in the PCF ### NOTE: THIS IS EXREAMLLY EXPEREMENTAL!!
####################################################################################################################### ###############
############## Route added by Abdul karim Barbour ##################################################################### ##############
####################################################################################################################### ##############
## Storing IDs and IPs from UE into variables to use them later in the N5 Request: ## Storing IDs and IPs from UE into variables to use them later in the N5 Request:
@@ -43,14 +43,14 @@ route[MO]
$var(user_id_req_ip) = $fU; # should get the user part of the Orig UE from request $var(user_id_req_ip) = $fU; # should get the user part of the Orig UE from request
# Store the IP in the hash table associated with the UE # Store the IP in the hash table associated with the UE
$sht(user_data=>$var(user_id_req_ip)) = $var(orig_ue_ip); $sht(user_sip_ips=>$var(user_id_req_ip)) = $var(orig_ue_ip);
xlog("L_INFO", "IP Info for UE MSISDN $var(user_id_req_ip): $var(orig_ue_ip)\n"); xlog("L_INFO", "IP Info for UE MSISDN $var(user_id_req_ip): $var(orig_ue_ip)\n");
# nnow trying some way to store Port of Orig UE # now trying some way to store Port of Orig UE
$var(user_id_req_port) = $fU; # should get the user part of the Orig UE from request $var(user_id_req_port) = $fU; # should get the user part of the Orig UE from request
# Store the Port in the hash table associated with the UE # Store the Port in the hash table associated with the UE
$sht(user_ids=>$var(user_id_req_port)) = $var(orig_ue_port); $sht(user_sip_ports=>$var(user_id_req_port)) = $var(orig_ue_port);
xlog("L_INFO", "Port Info for UE MSISDN $var(user_id_req_port): $var(orig_ue_port)\n"); xlog("L_INFO", "Port Info for UE MSISDN $var(user_id_req_port): $var(orig_ue_port)\n");
## now saving SDP Info from UE to variables to use them later in the N5 Flow Fdecs : ## now saving SDP Info from UE to variables to use them later in the N5 Flow Fdecs :
@@ -62,155 +62,39 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_src_port) Mline dump $var(sdp_mline_raw) \n"); xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_src_port) Mline dump $var(sdp_mline_raw) \n");
# now trying some way to store SDP SRC_IP of Orig UE # now trying some way to store SDP SRC_IP of Orig UE
$var(user_id_sdp_ip) = $fU; # should get the user part of the Orig UE from request $var(user_id_sdp_ip) = $fU; # should get the user part of the Orig UE from request
# Store the AppSession in the hash table associated with the UE # Store the AppSession in the hash table associated with the UE
$sht(user_sdps_ip=>$var(user_id_sdp_ip)) = $var(sdp_src_ip); $sht(user_sdps_ip=>$var(user_id_sdp_ip)) = $var(sdp_src_ip);
xlog("L_INFO", "SDP SRC_IP of Orig UE $var(user_id_sdp_ip): $var(sdp_src_ip)\n"); xlog("L_INFO", "SDP SRC_IP of Orig UE $var(user_id_sdp_ip): $var(sdp_src_ip)\n");
# now trying some way to store SDP Media_Port of Orig UE # now trying some way to store SDP Media_Port of Orig UE
$var(user_id_sdp_port) = $fU; # should get the user part of the Orig UE from request $var(user_id_sdp_port) = $fU; # should get the user part of the Orig UE from request
# store SDP Media_Port in the hash table associated with the UE # store SDP Media_Port in the hash table associated with the UE
$sht(user_sdps_port=>$var(user_id_sdp_port)) = $var(sdp_src_port); $sht(user_sdps_port=>$var(user_id_sdp_port)) = $var(sdp_src_port);
xlog("L_INFO", "SDP Media_Port of Orig UE $var(user_id_sdp_port): $var(sdp_src_port)\n"); xlog("L_INFO", "SDP Media_Port of Orig UE $var(user_id_sdp_port): $var(sdp_src_port)\n");
# now trying some way to store SDP RTCP_Media_Port of Orig UE # now trying some way to store SDP RTCP_Media_Port of Orig UE
$var(user_id_sdp_rtcp_port) = $fU; # should get the user part of the Orig UE from request $var(user_id_sdp_rtcp_port) = $fU; # should get the user part of the Orig UE from request
# Store the RTCP_Media_Port in the hash table associated with the UE # Store the RTCP_Media_Port in the hash table associated with the UE
$sht(user_sdps_rtcp_port=>$var(user_id_sdp_rtcp_port)) = $var(sdp_src_rtcp_port); $sht(user_sdps_rtcp_port=>$var(user_id_sdp_rtcp_port)) = $var(sdp_src_rtcp_port);
xlog("L_INFO", "SDP RTCP_Media_Port of Orig UE $var(user_id_sdp_rtcp_port): $var(sdp_src_rtcp_port)\n"); xlog("L_INFO", "SDP RTCP_Media_Port of Orig UE $var(user_id_sdp_rtcp_port): $var(sdp_src_rtcp_port)\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");
}
######################################################################
# Replies to Originating Initial Requests
######################################################################
onreply_route[MO_reply] {
xnotice("PCSCF MO_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 (is_present_hf("C-Params")) {
remove_hf("Contact");
remove_hf("C-Params");
append_hf("Contact: $ct;$hdr(C-Params)\r\n");
}
#!ifdef WITH_IPSEC
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
#!endif
# In case of 1xx and 2xx do NAT
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
####################################################
## N5 PolicyAuthorizationrequest QoS ###############
####################################################
## Route added by Abdul karim Barbour ##############
####################################################
#### 5G VoNR N5 NPCF Authorization reuqest #### 5G VoNR N5 NPCF Authorization reuqest
if (t_check_status("183|200|180") && has_body("application/sdp")){ if(is_method("INVITE")){
xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n"); xlog("L_DBG", "IMS: INVITE ORIG TO $tU\n");
if (t_is_retr_async_reply()) {
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
drop();
}
### Getting the IP/Port of UE ### Getting the IP/Port of UE
$var(orig_ue_ip) = $fU; # User Part of the from Header to get the USER $var(orig_ue_ip) = $fU; # User Part of the from Header to get the USER
$var(ue_ip_addr) = $sht(user_data=>$var(orig_ue_ip)); $var(ue_ip_addr) = $sht(user_sip_ips=>$var(orig_ue_ip));
xlog("L_INFO", "IP for UE $var(orig_ue_ip) is: $var(ue_ip_addr)\n"); xlog("L_INFO", "IP for UE $var(orig_ue_ip) is: $var(ue_ip_addr)\n");
$var(orig_ue_port) = $fU; # User Part of the from Header to get the USER $var(orig_ue_port) = $fU; # User Part of the from Header to get the USER
$var(ue_port_sip) = $sht(user_ids=>$var(orig_ue_port)); $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"); xlog("L_INFO", "IP for UE $var(orig_ue_port) is: $var(ue_port_sip)\n");
## retrieving IMSI from Registration ## retrieving IMSI from Registration
@@ -231,14 +115,7 @@ route(NATMANAGE);
$var(sdp_id_ue_rtcp_port) = $fU; # User Port of the from Header to get the USER $var(sdp_id_ue_rtcp_port) = $fU; # User Port of the from Header to get the USER
$var(ue_sdp_rtcp_port) = $sht(user_sdps_rtcp_port=>$var(sdp_id_ue_rtcp_port)); $var(ue_sdp_rtcp_port) = $sht(user_sdps_rtcp_port=>$var(sdp_id_ue_rtcp_port));
xlog("L_INFO", "SDP Port for UE with MSISDN $var(sdp_id_ue_rtcp_port) is: $var(ue_sdp_rtcp_port)\n"); xlog("L_INFO", "SDP Port for UE with MSISDN $var(sdp_id_ue_rtcp_port) is: $var(ue_sdp_rtcp_port)\n");
## retrieving SDP Connection Info from SDP Answer
$var(sdp_answ_ip) = $sdp(c:ip);
$var(sdp_answ_port) = $sdp(m0:rtp:port);
$var(sdp_answ_rtcp_port) = $sdp(m0:rtcp:port);
$var(sdp_answ_codec) = $(rb{line.sw,a=rtpmap}{s.select,1, });
xlog("L_INFO", "SDP Answer connection Info is: $var(sdp_answ_ip), RTP port $var(sdp_answ_port), RTCP Port $var(sdp_answ_rtcp_port) and codec is $var(sdp_answ_codec)\n");
#### now start to build the N5 Request #### now start to build the N5 Request
@@ -263,9 +140,9 @@ route(NATMANAGE);
jansson_set("string", "medType", "AUDIO", "$var(medComp)"); jansson_set("string", "medType", "AUDIO", "$var(medComp)");
jansson_set("array", "codecs", "[\"downlink\\noffer\\n\", \"uplink\\nanswer\\n\"]", "$var(medComp)"); jansson_set("array", "codecs", "[\"downlink\\noffer\\n\", \"uplink\\nanswer\\n\"]", "$var(medComp)");
### RTP ### RTP
jansson_set("integer", "fNum", 1, "$var(medSubComp1)"); jansson_set("integer", "fNum", 1, "$var(medSubComp1)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(sdp_answ_ip) $var(sdp_answ_port) to $var(ue_sdp_ip) $var(ue_sdp_port)\", \"permit in 17 from $var(ue_sdp_ip) $var(ue_sdp_port) to $var(sdp_answ_ip) $var(sdp_answ_port)\"]", "$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", "$var(medSubComp1)"); jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp1)");
jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp1)"); jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp1)");
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)"); jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)");
@@ -274,7 +151,7 @@ route(NATMANAGE);
### RTCP ### RTCP
jansson_set("integer", "fNum", 2, "$var(medSubComp2)"); jansson_set("integer", "fNum", 2, "$var(medSubComp2)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(sdp_answ_ip) $var(sdp_answ_rtcp_port) to $var(ue_sdp_ip) $var(ue_sdp_rtcp_port)\", \"permit in 17 from $var(ue_sdp_ip) $var(ue_sdp_rtcp_port) to $var(sdp_answ_ip) $var(sdp_answ_rtcp_port)\"]", "$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", "$var(medSubComp2)"); jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp2)");
jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp2)"); jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp2)");
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp2)"); jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp2)");
@@ -362,21 +239,274 @@ route(NATMANAGE);
$var(app_session) = $(var(url){s.substr,$var(start_pos),$var(end_pos)}); $var(app_session) = $(var(url){s.substr,$var(start_pos),$var(end_pos)});
# now checking it on console if I got what I wanted : # now checking it on console if I got what I wanted :
xlog("L_INFO", "AppSession for user $au is: $var(app_session)\n"); xlog("L_INFO", "AppSession for user $fU is: $var(app_session)\n");
# now trying some way to store AppSession with the registred UE # now trying some way to store AppSession with the registred UE
$var(user_id) = $fU; # should get the user part of the registred UE $var(user_id) = $fU; # should get the user part of the Orig UE
# Store the AppSession in the hash table associated with the UE # Store the AppSession in the hash table associated with the UE
$sht(user_data=>$var(user_id)) = $var(app_session); $sht(user_data=>$var(user_id)) = $var(app_session);
xlog("L_INFO", "Stored AppSession for user $var(user_id): $var(app_session)\n"); xlog("L_INFO", "Stored AppSession for user $var(user_id): $var(app_session)\n");
} }
##################################################
######### END of 5G VoNR N5 Request have Fun! ####
##################################################
#####################################################################
##### 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");
}
######################################################################
# Replies to Originating Initial Requests
######################################################################
onreply_route[MO_reply] {
xnotice("PCSCF MO_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 (is_present_hf("C-Params")) {
remove_hf("Contact");
remove_hf("C-Params");
append_hf("Contact: $ct;$hdr(C-Params)\r\n");
}
#!ifdef WITH_IPSEC
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
#!endif
# In case of 1xx and 2xx do NAT
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
#############################################
#### 5G VoNR N5 NPCF Authorization reuqest ##
#############################################
if (t_check_status("183|200|180") && 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();
}
### 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));
xlog("L_INFO", "IP for UE $var(orig_id_ue_ip) is: $var(ue_sip_ip_addr)\n");
$var(orig_ue_port) = $fU; # User Part of the from Header to get the USER
$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));
xlog("L_INFO", "SDP IP for UE with MSISDN $var(sdp_id_ue) is: $var(ue_sdp_ip)\n");
$var(sdp_id_ue_port) = $fU; # User Port of the from Header to get the USER
$var(ue_sdp_port) = $sht(user_sdps_port=>$var(sdp_id_ue_port));
xlog("L_INFO", "SDP Port for UE with MSISDN $var(sdp_id_ue_port) is: $var(ue_sdp_port)\n");
$var(sdp_id_ue_rtcp_port) = $fU; # User Port of the from Header to get the USER
$var(ue_sdp_rtcp_port) = $sht(user_sdps_rtcp_port=>$var(sdp_id_ue_rtcp_port));
xlog("L_INFO", "SDP Port for UE with MSISDN $var(sdp_id_ue_rtcp_port) is: $var(ue_sdp_rtcp_port)\n");
## retrieving SDP Connection Info from SDP Answer
$var(sdp_answ_ip) = $sdp(c:ip);
$var(sdp_answ_port) = $sdp(m0:rtp:port);
$var(sdp_answ_rtcp_port) = $sdp(m0:rtcp:port);
$var(sdp_answ_codec) = $(rb{line.sw,a=rtpmap}{s.select,1, });
xlog("L_INFO", "SDP Answer connection Info is: $var(sdp_answ_ip), RTP port $var(sdp_answ_port), RTCP Port $var(sdp_answ_rtcp_port) and codec is $var(sdp_answ_codec)\n");
## Retrieveing AppSession from initial INVITE N5 Request
$var(user_id_inv_rep) = $fU; # User Part of the from Header to get the USER
$var(user_appsess_inv_rep) = $sht(user_data=>$var(user_id_inv_rep));
xlog("L_INFO", "Terminating Stored AppSession for user $var(user_id_inv_rep): $var(user_appsess_inv_rep)\n");
#### now start to build the N5 Request
xlog("L_ALERT","DEBUG: Preparing N5 Message to PCF for $fu\n");
xlog("L_ALERT","DEBUG: Initialize empty arrays and objects\n");
### Initialize empty arrays and objects
$var(events) = '[]';
$var(medComponents) = '{}';
$var(medSubComps) = '{}';
$var(evSubsc) = '{}';
$var(payload) = '{}';
### Set afAppId and dnn in payload
jansson_set("string", "afAppId", "urn:urn-7:3gpp-service.ims.icsi.mmtel", "$var(payload)");
jansson_set("string", "dnn", "ims", "$var(payload)");
### Set medComponents
jansson_set("integer", "medCompN", 1, "$var(medComp)");
jansson_set("string", "qosReference", "qosVoNR", "$var(medComp)");
jansson_set("string", "medType", "AUDIO", "$var(medComp)");
jansson_set("array", "codecs", "[\"downlink\\noffer\\n\", \"uplink\\nanswer\\n\"]", "$var(medComp)");
### RTP
jansson_set("integer", "fNum", 1, "$var(medSubComp1)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(sdp_answ_ip) $var(sdp_answ_port) to $var(ue_sdp_ip) $var(ue_sdp_port)\", \"permit in 17 from $var(ue_sdp_ip) $var(ue_sdp_port) to $var(sdp_answ_ip) $var(sdp_answ_port)\"]", "$var(medSubComp1)");
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 $var(sdp_answ_ip) $var(sdp_answ_rtcp_port) to $var(ue_sdp_ip) $var(ue_sdp_rtcp_port)\", \"permit in 17 from $var(ue_sdp_ip) $var(ue_sdp_rtcp_port) to $var(sdp_answ_ip) $var(sdp_answ_rtcp_port)\"]", "$var(medSubComp2)");
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
jansson_set("obj", "0", "$var(medSubComp1)", "$var(medSubComps)");
jansson_set("obj", "1", "$var(medSubComp2)", "$var(medSubComps)");
jansson_set("obj", "medSubComps", "$var(medSubComps)", "$var(medComp)");
jansson_set("obj", "0", "$var(medComp)", "$var(medComponents)");
jansson_set("obj", "medComponents", "$var(medComponents)", "$var(payload)");
xlog("L_ALERT","DEBUG: Set evSubsc\n");
### Set evSubsc
jansson_set("string", "event", "QOS_NOTIF", "$var(event1)");
jansson_set("string", "notifMethod", "PERIODIC", "$var(event1)");
jansson_append("obj", "", "$var(event1)", "$var(events)");
jansson_set("string", "event", "ANI_REPORT", "$var(event2)");
jansson_set("string", "notifMethod", "ONE_TIME", "$var(event2)");
jansson_append("obj", "", "$var(event2)", "$var(events)");
jansson_set("array", "events", "$var(events)", "$var(evSubsc)");
jansson_set("obj", "evSubsc", "$var(evSubsc)", "$var(payload)");
### 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_sip_ip_addr)", "$var(payload)");
### Assemble the final JSON request
jansson_set("obj", "ascReqData", "$var(payload)", "$var(json_request)");
xlog("L_ALERT","DEBUG: Set headers for the HTTP2 Request\n");
### Set headers
$var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
xlog("Today is $var(time_now)\n");
$var(headers) = "Content-Type: application/json\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);
xlog("L_ALERT","DEBUG: Sending the request to PCF\n");
### Send the request to PCF
http_client_request_v2pk("PATCH", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/$var(user_appsess_inv_rep)", "$var(json_request)", "$var(headers)", "$var(result)" );
xlog("HTTP response: $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");
}
########################################
######### END of 5G VoNR N5 Request ####
########################################
#!ifdef WITH_RX #!ifdef WITH_RX
if (t_check_status("183|200") && has_body("application/sdp")){ if (t_check_status("183|200") && has_body("application/sdp")){
xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n"); xlog("L_DBG", "IMS: Received 183/200 inside orig_initial_reply\n");
@@ -419,14 +549,16 @@ route[MO_aar_reply]
} }
###################################################################### ######################################################################
# In-Dialog-Mo-Requests # In-Dialog-Mo-Requests
###################################################################### ######################################################################
route[MO_indialog] { route[MO_indialog] {
################################### ###############################
## Terminating N5 QoS AppSession ## ## Terminating N5 AppSession ##
################################### ###############################
if(is_method("BYE")) if(is_method("BYE"))
{ {
@@ -434,7 +566,7 @@ route[MO_indialog] {
# Retrieveing # Retrieveing
$var(user_id_call_rel) = $fU; # User Part of the from Header to get the USER $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)); $var(user_appsess_call_rel) = $sht(user_data=>$var(user_id_call_rel));
xlog("L_INFO", "Terminating Stored AppSession for user $var(user_id_dereg): $var(user_id_call_rel)\n"); 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) = "X-SIP-Status: De-Registration\r\n";
$var(headers) = $var(headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n"; $var(headers) = $var(headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n";
@@ -452,10 +584,6 @@ route[MO_indialog] {
} }
##########################################
## End of Terminating N5 QoS AppSession ##
##########################################
xnotice("PCSCF MO_indialog: \n Destination URI: $du\n Request URI: $ru\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("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n");