Minor refactor and cosmetic changes in PCSCF cfg files

This commit is contained in:
herlesupreeth
2024-12-31 13:53:16 +01:00
parent e73e1c32af
commit d779b57644
4 changed files with 1003 additions and 1182 deletions

View File

@@ -461,7 +461,7 @@ modparam("http_client", "response_headers", 1)
modparam("http_client", "query_result", 1)
modparam("nghttp2", "listen_addr", "N5_BIND_IP")
modparam("nghttp2", "listen_port", "N5_BIND_PORT")
# Replace the following with your own Key and Cert, you can use HAProxy to terminate TLS towards Clients (Open5gs)
# Replace the following with your own Key and Cert, you can use HAProxy to terminate TLS towards Clients e.g. Open5gs PCF
# modparam("nghttp2", "tls_private_key", "/mnt/pcscf/http2_key.pem")
# modparam("nghttp2", "tls_public_key", "/mnt/pcscf/http2_tr.pem")
@@ -1022,7 +1022,7 @@ route[preload_pcscf] {
event_route[nghttp2:request] {
xinfo("request: $nghttp2(method) - url: $nghttp2(path) - data: [$nghttp2(data)]\n");
// Check if the requested URL is /nf-status-notify
# Check if the requested URL is /nf-status-notify
if ($nghttp2(path) == "/nf-status-notify") {
nghttp2_reply_header("Content-Type", "text/html");
nghttp2_reply_header("Server:", "AF");
@@ -1034,7 +1034,7 @@ event_route[nghttp2:request] {
nghttp2_reply_header("Server", "AF");
nghttp2_reply("204", "No Content");
} else {
// Optionally handle other URLs or do nothing
# Optionally handle other URLs or do nothing
nghttp2_reply_header("accept", "application/json");
nghttp2_reply_header("accept", "application/problem+json");
nghttp2_reply_header("Content-Type", "application/json");

View File

@@ -75,13 +75,11 @@ route[MO]
}
remove_hf("Security-Verify");
#
#Route N5 Request
#
#!ifdef WITH_N5
if(is_method("INVITE")) {
route(N5_INIT_REQ);
}
#!endif
#!ifdef TRF_FUNCTION
$var(trf) = TRF_FUNCTION;
@@ -105,121 +103,99 @@ route[MO]
t_on_reply("MO_reply");
}
#!ifdef WITH_N5
#################################
## Route Logic for N5 Requests ##
#################################
# 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:
# Storing IDs and IPs of UE into variables to use them later in the N5 Request
$var(orig_ue_ip) = $si;
$var(orig_ue_port) = $sp;
$var(pcscf_ip) = $Ri;
$var(pcscf_port) = $Rp;
# now checking it on console if I got what I wanted :
xlog("L_INFO", "connection Info for UE $var(orig_ue_ip) $var(orig_ue_port)\n");
xlog("L_INFO", "connection Info for P-CSCF is: $var(pcscf_ip) $var(pcscf_port)\n");
# now trying some way to store IP of Orig UE
$var(user_id_req_ip) = $fU; # should get the user part of the Orig UE from request
xlog("L_INFO", "Connection Info for UE $var(orig_ue_ip) $var(orig_ue_port)\n");
xlog("L_INFO", "Connection Info for P-CSCF is: $var(pcscf_ip) $var(pcscf_port)\n");
$var(user_id_req_ip) = $fU;
# Store the IP in the hash table associated with the UE
$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");
# 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;
# Store the Port in the hash table associated with the UE
$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");
## now saving SDP Info from UE to variables to use them later in the N5 Flow Fdecs :
# Storing SDP Info of UE to variables to use them later in the N5 Flow Fdecs
$var(sdp_src_ip) = $sdp(c:ip);
$var(sdp_src_port) = $sdp(m0:rtp:port);
$var(sdp_src_rtcp_port) = $sdp(m0:rtcp:port);
$var(sdp_mline_raw) = $sdp(m0:raw);
$var(sdp_src_ip) = $sdp(c:ip);
$var(sdp_src_port) = $sdp(m0:rtp:port);
$var(sdp_src_rtcp_port) = $sdp(m0:rtcp:port);
$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
$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
$var(user_id_sdp_ip) = $fU;
# Store the SDP source IP in the hash table associated with the UE
$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 source 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
$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
$var(user_id_sdp_port) = $fU;
# Store the SDP Media_Port in the hash table associated with the UE
$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
$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
$var(user_id_sdp_rtcp_port) = $fU;
# 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);
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");
#### 5G VoNR N5 NPCF Authorization reuqest
if(is_method("INVITE")){
# 5G VoNR N5 NPCF Authorization request
xlog("L_DBG", "IMS: INVITE ORIG TO $tU\n");
### Getting the IP/Port of UE
$var(orig_ue_ip) = $fU; # User Part of the from Header to get the USER
# Retrieve the IP/Port of UE
$var(orig_ue_ip) = $fU;
$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");
$var(orig_ue_port) = $fU; # User Part of the from Header to get the USER
$var(orig_ue_port) = $fU;
$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 SDP Connection Info and Media Port for UE
$var(sdp_id_ue) = $fU; # User Part of the from Header to get the USER
# Retrieving SDP Connection Info and Media Port for UE
$var(sdp_id_ue) = $fU;
$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(sdp_id_ue_port) = $fU;
$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(sdp_id_ue_rtcp_port) = $fU;
$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");
#### now start to build the N5 Request
# Build the N5 Request
xlog("L_INFO","Preparing QoS N5 Message to PCF for the INVITE\n");
xlog("L_INFO","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
# Set afAppId and dnn in 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
# 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
# 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", "$var(medSubComp1)");
@@ -228,7 +204,7 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
jansson_set("string", "flowUsage", "NO_INFO", "$var(medSubComp1)");
### RTCP
# 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", "$var(medSubComp2)");
@@ -246,7 +222,7 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
xlog("L_INFO","Set evSubsc\n");
### Set evSubsc
# Set evSubsc
jansson_set("string", "event", "QOS_NOTIF", "$var(event1)");
jansson_set("string", "notifMethod", "PERIODIC", "$var(event1)");
jansson_append("obj", "", "$var(event1)", "$var(events)");
@@ -257,18 +233,18 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
jansson_set("obj", "evSubsc", "$var(evSubsc)", "$var(payload)");
### Set other parameters in payload
# Set other parameters in payload
jansson_set("string", "notifUri", "http://172.22.0.21:7777", "$var(payload)");
jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$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)");
### Assemble the final JSON request
# Assemble the final JSON request
jansson_set("obj", "ascReqData", "$var(payload)", "$var(json_request)");
xlog("L_INFO", "Set headers for the HTTP2 Request\n");
### Set headers
# Set headers
$var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
xlog("L_INFO", "Today is $var(time_now)\n");
@@ -280,28 +256,25 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
$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_INFO","Sending the request to PCF\n");
### Send the request to PCF
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions", "$var(json_request)", "$var(headers)", "$var(result)" );
# Send the request to PCF
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions", "$var(json_request)", "$var(headers)", "$var(result)");
### here we want to kill the dialog in case QoS faild or continue if QoS success.
switch ($rc) {
# Success case
case 201:
xlog("L_INFO", "N5 QoS Session successfully Created $rc\n");
xlog("L_INFO", "HTTP results: $var(result)\n");
xlog("L_INFO", "HTTP response: $rc\n");
xlog("L_INFO", "Location Header: $httprhdr(location)\n");
# Now I will retrieve the AppSessionID out of the location Header it should be always at the end
# Example URL: "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/(someSessionID)"
# Retrieve the AppSession Id out of the location header in response
# Example URL: "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/(someSessionID)"
# Firt store the url of the lcoation Header in var
# Store the url of the lcoation Header in var
$var(url) = $httprhdr(location);
# Get the length of the URL
$var(len) = $(var(url){s.len});
# Initialize the position variable to the length of the URL
$var(pos) = $var(len);
@@ -309,45 +282,34 @@ xlog("L_INFO", "SDP Info : Connection IP is $var(sdp_src_ip) Port is $var(sdp_sr
while ($var(pos) > 0) {
$var(pos) = $var(pos) - 1;
if ($(var(url){s.substr,$var(pos),1}) == "/") {
# We've found the last slash
break;
}
}
# Extract the substring after the last slash
# now doing some magic
# Set the starting position after the last slash
# Extract the substring after the last slash
# Set the starting position after the last slash
$var(start_pos) = $var(pos) + 1;
# Calculate the length of the substring after the last slash
$var(substring_length) = $var(len) - $var(start_pos);
# Extract the substring after the last slash
$var(app_session) = $(var(url){s.substr,$var(start_pos),$var(substring_length)});
xlog("L_INFO", "AppSession Id for user $fU is: $var(app_session)\n");
# now checking it on console if I got what I wanted :
xlog("L_INFO", "AppSession for user $fU is: $var(app_session)\n");
# now trying some way to store AppSession with 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
$var(user_id) = $fU;
# Store the AppSession Id in the hash table associated with the UE
$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 Id for user $var(user_id): $var(app_session)\n");
break;
# Failure case
default:
xlog("L_ERR", "N5 QoS Session faild - Reason code: $rc\n");
send_reply("412", "MOC N5 QoS Session Creation faild");
xlog("L_ERR", "N5 QoS authorization failed - Reason code: $rc\n");
send_reply("412", "Register N5 QoS authorization failed");
exit;
} # switch ends here
}
}
}
#####################################
##### END OF N5 VoNR Request logic ##
#####################################
#!endif
######################################################################
# Replies to Originating Initial Requests
@@ -364,11 +326,10 @@ onreply_route[MO_reply] {
append_hf("Contact: $ct;$hdr(C-Params)\r\n");
}
## N5 PATCH Request
if (t_check_status("180|183|200") && has_body("application/sdp")){
xlog("L_INFO", "received early answer in 18x, Patching N5 session in PCF...\n");
xlog("L_INFO", "N5 PATCH: About to test if this is a retransmitted reply which is still currently suspended\n");
#!ifdef WITH_N5
# N5 PATCH Request for updating AppSession context
if (t_check_status("180|183|200") && has_body("application/sdp")) {
xlog("L_INFO", "Received early answer in 18x. Patching N5 session in PCF\n");
if (t_is_retr_async_reply()) {
xlog("L_INFO", "Dropping retransmitted reply which is still currently suspended\n");
drop();
@@ -377,15 +338,13 @@ onreply_route[MO_reply] {
}
## Terminating N5 AppSession after BYE##
if(is_method("BYE|CANCEL") || status=~"[45][0-9][0-9]"){
xlog("L_ALERT", "Terminating AppSession For Call fom User $fU due to call END or Call Faild\n");
# Retrieveing
$var(user_id_midcall_rel) = $fU; # User Part of the from Header to get the USER
# Terminating N5 AppSession after BYE
if (is_method("BYE|CANCEL") || status=~"[45][0-9][0-9]") {
xlog("L_ALERT", "Terminating AppSession for Call fom User $fU due to call END or Call Failed\n");
# Retrieve the AppSession Id from the hash table
$var(user_id_midcall_rel) = $fU;
$var(user_appsess_midcall_rel) = $sht(user_data=>$var(user_id_midcall_rel));
xlog("L_INFO", "Terminating Stored AppSession for user $var(user_id_midcall_rel): $var(user_appsess_midcall_rel)\n");
xlog("L_INFO", "Terminating stored AppSession for user $var(user_id_midcall_rel): $var(user_appsess_midcall_rel)\n");
$var(headers) = "X-SIP-Status: De-Registration\r\n";
$var(headers) = $var(headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n";
@@ -401,11 +360,8 @@ onreply_route[MO_reply] {
xlog("L_INFO", "response header: $var(response_code)\n");
xlog("L_INFO", "response header: $httprhdr(location)\n");
xlog("L_INFO", "response header: $rc\n");
}
#!endif
#!ifdef WITH_IPSEC
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
@@ -415,7 +371,7 @@ onreply_route[MO_reply] {
route(NATMANAGE);
#!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");
if (t_is_retr_async_reply()) {
@@ -432,14 +388,11 @@ onreply_route[MO_reply] {
exit;
}
}
##
}
route[MO_aar_reply]
{
#this is async so to know status we have to check the reply avp
# Check reply AVP since the operation is async
switch ($avp(s:aar_return_code)) {
case 1:
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
@@ -449,7 +402,7 @@ route[MO_aar_reply]
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
# 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;
@@ -463,22 +416,20 @@ route[MO_aar_reply]
######################################################################
route[MO_indialog] {
## N5 PATCH Request
if(is_method("INVITE")){
#!ifdef WITH_N5
# N5 PATCH Request for updating AppSession context
if (is_method("INVITE")) {
xlog("L_INFO"," InDialog SDP Answer N5 Request for reINVITE\n");
route(N5_PATCH_REQ);
}
## Terminating N5 AppSession after BYE##
if(is_method("BYE|CANCEL"))
{
xlog("L_ALERT","Terminating AppSession For Call for User $fU due to call END or Call Faild\n");
# Retrieveing
$var(user_id_call_rel) = $fU; # User Part of the from Header to get the USER
# Terminating N5 AppSession after BYE
if (is_method("BYE|CANCEL")) {
xlog("L_ALERT","Terminating AppSession for Call from User $fU due to call END or Call Failed\n");
# Retrieve the AppSession Id from the hash table
$var(user_id_call_rel) = $fU;
$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");
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";
@@ -494,9 +445,8 @@ route[MO_indialog] {
xlog("L_INFO", "response header: $var(response_code)\n");
xlog("L_INFO", "response header: $httprhdr(location)\n");
xlog("L_INFO", "response header: $rc\n");
}
#!endif
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");
@@ -525,20 +475,17 @@ onreply_route[MO_indialog_reply] {
xnotice("Received IP and Port: ($Ri:$Rp)\n");
xnotice("Contact header: $ct\n");
##
## N5 PATCH Request
if (t_check_status("180|183|200") && has_body("application/sdp")){
xlog("L_DBG", "received early answer in 18x, Patching N5 session in PCF...\n");
xlog("L_DBG", "N5 PATCH: About to test if this is a retransmitted reply which is still currently suspended\n");
#!ifdef WITH_N5
# N5 PATCH Request for updating AppSession context
if (t_check_status("180|183|200") && has_body("application/sdp")) {
xlog("L_DBG", "Received early answer in 18x. Patching N5 session in PCF\n");
if (t_is_retr_async_reply()) {
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
drop();
}
route(N5_PATCH_REQ);
}
#!endif
# In case of 1xx and 2xx do NAT
if(status=~"[12][0-9][0-9]")
@@ -565,7 +512,7 @@ onreply_route[MO_indialog_reply] {
route[MO_indialog_aar_reply]
{
#this is async so to know status we have to check the reply avp
# Check reply AVP since the operation is async
switch ($avp(s:aar_return_code)) {
case 1:
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
@@ -575,7 +522,7 @@ route[MO_indialog_aar_reply]
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
# 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;
@@ -583,88 +530,80 @@ route[MO_indialog_aar_reply]
}
#!endif
}
###################################################
#### 5G VoNR N5 NPCF Authorization PATCH reuqest ##
###################################################
#!ifdef WITH_N5
# 5G VoNR N5 Policy Authorization PATCH request
route[N5_PATCH_REQ] {
xlog("L_INFO", "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
# Retrieve the IP/Port of UE
$var(orig_id_ue_ip) = $fU;
$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(orig_ue_port) = $fU;
$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 SDP Connection Info and Media Port for UE
$var(sdp_id_ue) = $fU; # User Part of the from Header to get the USER
# Retrieve SDP Connection Info and Media Port for UE
$var(sdp_id_ue) = $fU;
$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(sdp_id_ue_port) = $fU;
$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(sdp_id_ue_rtcp_port) = $fU;
$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
# Retrieve 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
# Retrieve AppSession Id
$var(user_id_inv_rep) = $fU;
$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_INFO", "Stored AppSession Id for user $var(user_id_inv_rep): $var(user_appsess_inv_rep)\n");
xlog("L_INFO","Preparing PATCH N5 Message for SDP Answer\n");
xlog("L_INFO","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
# 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", "dnn", "ims", "$var(payload)");
### Set medComponents
# Set media components
jansson_set("integer", "medCompN", 1, "$var(medComp)");
jansson_set("string", "qosReference", "qosVoNR", "$var(medComp)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
jansson_set("string", "qosReference", "qosVoNR", "$var(medComp)");
jansson_set("string", "medType", "AUDIO", "$var(medComp)");
jansson_set("array", "codecs", "[\"downlink\\n$var(sdp_answ_codec)\\n\", \"uplink\\n$var(sdp_answ_codec)\\n\"]", "$var(medComp)");
### RTP
# 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)"); # 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", "marBwDl", "5000 Kbps", "$var(medSubComp1)");
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)");
jansson_set("string", "flowUsage", "NO_INFO", "$var(medSubComp1)");
### RTCP
# 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)"); # 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", "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
@@ -677,7 +616,7 @@ route[N5_PATCH_REQ] {
xlog("L_INFO","DEBUG: Set evSubsc\n");
### Set evSubsc
# Set evSubsc
jansson_set("string", "event", "QOS_NOTIF", "$var(event1)");
jansson_set("string", "notifMethod", "PERIODIC", "$var(event1)");
jansson_append("obj", "", "$var(event1)", "$var(events)");
@@ -688,22 +627,23 @@ route[N5_PATCH_REQ] {
jansson_set("obj", "evSubsc", "$var(evSubsc)", "$var(payload)");
### Set other parameters in payload
# Set other parameters in payload
jansson_set("string", "notifUri", "http://172.22.0.21:7777", "$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", "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
jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$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
# Assemble the final JSON request
jansson_set("obj", "ascReqData", "$var(payload)", "$var(json_request)");
xlog("L_INFO","Set headers for the HTTP2 Request\n");
### Set headers
# Set headers
$var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
xlog("L_INFO", "Today is $var(time_now)\n");
$var(headers) = "Content-Type: application/merge-patch+json\r\n"; # added content-type an set it to "application/merge-patch+json" fo compatibility with RFC7386 for JSON PATCH/Merge
# Set Content-type to application/merge-patch+json for compatibility with RFC7386 for JSON PATCH/Merge
$var(headers) = "Content-Type: application/merge-patch+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";
@@ -711,11 +651,9 @@ route[N5_PATCH_REQ] {
$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_INFO","Sending the request to PCF\n");
### Send the request to PCF
# 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)" );
#### here we want to kill the dialog in case QoS faild or contiue if QoS success, who knows ;( but this will help where we could have instability on RAN causing mutiple dead contacts with only one working causing INVITE Forks to dead contacts leading to 404 from PCF
switch ($rc) {
case 200:
xlog("L_INFO", "N5 QoS Session modification success - reason code: $rc\n");
@@ -728,10 +666,6 @@ route[N5_PATCH_REQ] {
xlog("L_ERR", "N5 QoS Session modification faild - reason code: $rc\n");
send_reply("412", "MOC N5 QoS Session modify faild");
exit;
} # switch ends here
}
}
########################################
######### END of 5G VoNR N5 Request ####
########################################
#!endif

View File

@@ -10,11 +10,11 @@ route[MT] {
xnotice("Term P-CSCF connection information : IP is $RAi and Port is $RAp \n");
set_dlg_profile("term");
#Route N5 Request
#
#!ifdef WITH_N5
if(is_method("INVITE")) {
route(N5_INIT_MT_REQ);
}
#!endif
#!ifdef WITH_IPSEC
ipsec_forward("location", IPSEC_FORWARD_FLAGS);
@@ -38,11 +38,10 @@ onreply_route[MT_reply] {
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
### N5 PATCH Request
if (t_check_status("180|183|200") && has_body("application/sdp")){
xlog("L_INFO", "received early answer in 18x, Patching N5 session in PCF...\n");
xlog("L_INFO", "N5 PATCH: About to test if this is a retransmitted reply which is still currently suspended\n");
#!ifdef WITH_N5
# N5 PATCH Request for updating AppSession context
if (t_check_status("180|183|200") && has_body("application/sdp")) {
xlog("L_INFO", "Received early answer in 18x. Patching N5 session in PCF\n");
if (t_is_retr_async_reply()) {
xlog("L_INFO", "Dropping retransmitted reply which is still currently suspended\n");
drop();
@@ -50,14 +49,12 @@ onreply_route[MT_reply] {
route(N5_PATCH_MT_REQ);
}
## terminate QoS Session after Error response
if(status=~"[45][0-9][0-9]")
{
xnotice("Received Error response ON the Call, going to terminate N5 Session\n");
# Terminating N5 AppSession after error response
if (status=~"[45][0-9][0-9]") {
xnotice("Received Error response for the Call. Going to terminate N5 Session\n");
route(N5_MTC_TERM);
}
#!endif
#!ifdef WITH_RX
if (t_check_status("183|200") && has_body("application/sdp")){
@@ -67,7 +64,6 @@ onreply_route[MT_reply] {
xnotice("Contact header: $ct\n");
xlog("L_DBG", "IMS: Received 183 inside term_initial_reply\n");
xlog("L_DBG", "About to test if this is a retransmitted reply which is still currently suspended\n");
if (t_is_retr_async_reply()) {
xlog("L_DBG", "Dropping retransmitted reply which is still currently suspended\n");
drop();
@@ -88,7 +84,7 @@ route[MT_aar_reply]
{
xlog("L_DBG", "IMS: TERM_SESSION_AAR_REPLY\n");
#this is async so to know status we have to check the reply avp
# Check reply AVP since the operation is async
switch ($avp(s:aar_return_code)) {
case 1:
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
@@ -98,7 +94,7 @@ route[MT_aar_reply]
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
# 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;
@@ -113,23 +109,19 @@ route[MT_aar_reply]
######################################################################
route[MT_indialog] {
## N5 PATCH Request
if(is_method("INVITE")){
xlog("L_INFO"," InDialog SDP Change, sending N5 Request for it\n");
#!ifdef WITH_N5
# N5 PATCH Request for updating AppSession context
if (is_method("INVITE")) {
xlog("L_INFO"," InDialog SDP Change. Sending N5 Request to update appSession context\n");
route(N5_PATCH_REQ);
}
## Terminating N5 AppSession after BYE##
if(is_method("BYE|CANCEL"))
{
xlog("L_INFO"," InDialog Call End/Cancel/Error, terminating N5 QoS Session ...\n");
# Terminating N5 AppSession after BYE
if (is_method("BYE|CANCEL")) {
xlog("L_INFO"," InDialog Call End/Cancel/Error. Terminating N5 QoS Session\n");
route(N5_MTC_TERM);
}
#### END of N5 Request
#!endif
xnotice("PCSCF MT_indialog: \n Destination URI: $du\n Request URI: $ru\n");
xnotice("Source IP and Port: ($si:$sp)\n Route-URI: $route_uri\n");
@@ -158,17 +150,17 @@ onreply_route[MT_indialog_reply] {
xnotice("Received IP and Port: ($Ri:$Rp)\n");
xnotice("Contact header: $ct\n");
### N5 PATCH Request for Indialog reply
#!ifdef WITH_N5
# N5 PATCH Request for updating AppSession context for Indialog reply
if (t_check_status("180|183|200") && has_body("application/sdp")){
xlog("L_INFO", "received MT_indialog_reply, Patching N5 session in PCF...\n");
xlog("L_INFO", "N5 PATCH: About to test if this is a retransmitted reply which is still currently suspended\n");
xlog("L_INFO", "Received MT_indialog_reply. Patching N5 session in PCF\n");
if (t_is_retr_async_reply()) {
xlog("L_INFO", "Dropping retransmitted reply which is still currently suspended\n");
drop();
}
route(N5_PATCH_MT_REQ);
}
#!endif
# In case of 1xx and 2xx do NAT
if(status=~"[12][0-9][0-9]")
@@ -195,7 +187,7 @@ onreply_route[MT_indialog_reply] {
route[MT_indialog_aar_reply]
{
#this is async so to know status we have to check the reply avp
# Check reply AVP since the operation is async
switch ($avp(s:aar_return_code)) {
case 1:
xlog("L_DBG", "Diameter: Orig AAR success on media authorization\n");
@@ -205,7 +197,7 @@ route[MT_indialog_aar_reply]
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
# 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;
@@ -214,116 +206,80 @@ route[MT_indialog_aar_reply]
#!endif
}
#################################
## Route Logic for N5 Requests ##
#################################
#!ifdef WITH_N5
# Route Logic for N5 Requests
route[N5_INIT_MT_REQ] {
## 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
$var(term_ue_ip) = $dd;
$var(term_sip_ue_port) = $rp;
$var(pcscf_sip_ip) = $Ri;
$var(pcscf_sip_port) = $Rp;
# now checking it on console if I got what I wanted :
xlog("L_INFO", "SIP connection Info for Term UE $var(term_ue_ip) $var(term_sip_ue_port)\n");
xlog("L_INFO", "SIP connection Info for P-CSCF is: $var(pcscf_sip_ip) $var(pcscf_sip_port)\n");
# now trying some way to store IP of Term UE
$var(term_user_id_req_ip) = $tU; # should get the user part of the Orig UE from request
xlog("L_INFO", "SIP Connection Info for Term UE $var(term_ue_ip) $var(term_sip_ue_port)\n");
xlog("L_INFO", "SIP Connection Info for P-CSCF is: $var(pcscf_sip_ip) $var(pcscf_sip_port)\n");
$var(term_user_id_req_ip) = $tU;
# Store the IP in the hash table associated with the UE
$sht(user_sip_ips=>$var(term_user_id_req_ip)) = $var(term_ue_ip);
xlog("L_INFO", "SIP/SDP IP Info for Term UE MSISDN $var(term_user_id_req_ip): $var(term_ue_ip)\n");
# now trying some way to store Port of Term UE
$var(term_user_id_req_port) = $tU; # should get the user part of the Orig UE from request
$var(term_user_id_req_port) = $tU;
# Store the Port in the hash table associated with the UE
$sht(user_sip_ports=>$var(term_user_id_req_port)) = $var(term_sip_ue_port);
xlog("L_INFO", "SIP Port Info for UE MSISDN $var(term_user_id_req_port): $var(term_sip_ue_port)\n");
#### 5G VoNR N5 NPCF Authorization reuqest
if(is_method("INVITE")){
xlog("L_INFO", "IMS: MTC INVITE TO $tU\n");
## retrieving SDP Connection Info and Media Port for Orig UE ( in case we will start with INVITE):
$var(sdp_src_ip) = $sdp(c:ip);
$var(sdp_src_port) = $sdp(m0:rtp:port);
$var(orig_ue_sdp_rtcp_port) = $sdp(m0:rtcp:port);
$var(sdp_mline_raw) = $sdp(m0:raw);
# Retrieving SDP Connection Info and Media Port for UE
$var(sdp_src_ip) = $sdp(c:ip);
$var(sdp_src_port) = $sdp(m0:rtp:port);
$var(orig_ue_sdp_rtcp_port) = $sdp(m0:rtcp:port);
$var(sdp_mline_raw) = $sdp(m0:raw);
xlog("L_INFO", "SDP Info From INVITE: $sdp(c:ip) -- $sdp(m0:rtp:port) -- $sdp(m0:rtcp:port)\n");
# SDP IP Orig Party
# now trying some way to store SDP SRC_IP of Orig Party
$var(call_id_sdp_ip) = $ci; # call-ID
# Store the SDP IP in the hash table associated with the Call-ID
$var(call_id_sdp_ip) = $ci;
# Store the SDP IP in the hash table associated with the Call-Id
$sht(user_sdps_ip=>$var(call_id_sdp_ip)) = $var(sdp_src_ip);
#Testing retrival
$var(ret_call_id_sdp_ip) = $ci; # User Port of the from Header to get the USER
$var(ret_call_id_sdp_ip) = $ci;
$var(sdp_src_ip) = $sht(user_sdps_ip=>$var(ret_call_id_sdp_ip));
xlog("L_INFO", "SDP IP of orig UE $fU Call-ID $var(call_id_sdp_ip): $var(sdp_src_ip)\n");
# SDP RTP Port Orig Party
$var(sdp_call_id_port) = $ci; # call-ID
# store SDP Media_Port in the hash table associated with the Call-ID
$var(sdp_call_id_port) = $ci;
# Store SDP Media Port in the hash table associated with the Call-Id
$sht(user_sdps_port=>$var(sdp_call_id_port)) = $var(sdp_src_port);
xlog("L_INFO", "SDP Port for MTC Call-ID $var(sdp_call_id_port) is: $var(sdp_src_port)\n");
# SDP RTCP Port Orig Party
$var(sdp_call_id_rtcp_port) = $ci; # User Port of the from Header to get the USER
#Store SDP RTCP Port in the hash table associated with the Call-ID
$var(sdp_call_id_rtcp_port) = $ci;
#Store SDP RTCP Port in the hash table associated with the Call-Id
$sht(user_sdps_rtcp_port=>$var(sdp_call_id_rtcp_port)) = $var(orig_ue_sdp_rtcp_port);
#Testing retrival
$var(sdp_call_id_rtcp_port) = $ci;
$var(orig_ue_sdp_rtcp_port) = $sht(user_sdps_rtcp_port=>$var(sdp_call_id_rtcp_port));
xlog("L_INFO", "SDP RTCP Port for UE with MSISDN $fU is: $var(orig_ue_sdp_rtcp_port)\n");
xlog("L_INFO", "Preparing QoS N5 Message to PCF for INVITE To term UE\n");
#### now start to build the N5 Request
xlog("L_INFO", "Preparing QoS N5 Message to PCF for INVITE TO term UE\n");
xlog("L_INFO", "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", "+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
# Set afAppId and dnn in payload
# TODO: Get the value from SIP Header
jansson_set("string", "afAppId", "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"", "$var(payload)");
jansson_set("string", "dnn", "ims", "$var(payload)");
### Set medComponents
# 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
# RTP
jansson_set("integer", "fNum", 1, "$var(medSubComp1)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(sdp_src_ip) $var(sdp_src_port) to $dd 49000-51000\", \"permit in 17 from $dd 49000-51000 to $var(sdp_src_ip) $var(sdp_src_port)\"]", "$var(medSubComp1)");
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp1)");
@@ -331,8 +287,7 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)");
jansson_set("string", "flowUsage", "NO_INFO", "$var(medSubComp1)");
### RTCP
# RTCP
jansson_set("integer", "fNum", 2, "$var(medSubComp2)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(sdp_src_ip) $var(orig_ue_sdp_rtcp_port) to $dd 49000-51000\", \"permit in 17 from $dd 49000-51000 to $var(sdp_src_ip) $var(orig_ue_sdp_rtcp_port)\"]", "$var(medSubComp2)");
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp2)");
@@ -350,7 +305,7 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
xlog("L_INFO","DEBUG: Set evSubsc\n");
### Set evSubsc
# Set evSubsc
jansson_set("string", "event", "QOS_NOTIF", "$var(event1)");
jansson_set("string", "notifMethod", "PERIODIC", "$var(event1)");
jansson_append("obj", "", "$var(event1)", "$var(events)");
@@ -361,18 +316,18 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
jansson_set("obj", "evSubsc", "$var(evSubsc)", "$var(payload)");
### Set other parameters in payload
# Set other parameters in payload
jansson_set("string", "notifUri", "http://172.22.0.21:7777", "$var(payload)");
jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$var(payload)");
jansson_set("string", "gpsi", "msisdn-$tU", "$var(payload)");
jansson_set("string", "suppFeat", "2", "$var(payload)");
jansson_set("string", "ueIpv4", "$dd", "$var(payload)");
### Assemble the final JSON request
# Assemble the final JSON request
jansson_set("obj", "ascReqData", "$var(payload)", "$var(json_request)");
xlog("L_INFO","DEBUG: Set headers for the HTTP2 Request\n");
### Set headers
# Set headers
$var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
xlog("L_INFO", "Today is $var(time_now)\n");
@@ -384,28 +339,25 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
$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_INFO","Sending the request to PCF\n");
### Send the request to PCF
# Send the request to PCF
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions", "$var(json_request)", "$var(headers)", "$var(result)" );
### here we want to kill the dialog in case QoS faild or continue if QoS success.
switch ($rc) {
# Success case
case 201:
xlog("L_INFO", "N5 QoS Session successfully Created $rc\n");
xlog("L_INFO", "HTTP results: $var(result)\n");
xlog("L_INFO", "HTTP response: $rc\n");
xlog("L_INFO", "Location Header: $httprhdr(location)\n");
# Now I will retrieve the AppSessionID out of the location Header it should be always at the end
# Example URL: "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/(someSessionID)"
# Retrieve the AppSession Id out of the location header in response
# Example URL: "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/(someSessionID)"
# Firt store the url of the lcoation Header in var
# Store the url of the lcoation Header in var
$var(url) = $httprhdr(location);
# Get the length of the URL
$var(len) = $(var(url){s.len});
# Initialize the position variable to the length of the URL
$var(pos) = $var(len);
@@ -418,24 +370,19 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
}
}
# Extract the substring after the last slash
# now doing some magic
# Set the starting position after the last slash
# Extract the substring after the last slash
# Set the starting position after the last slash
$var(start_pos) = $var(pos) + 1;
# Calculate the length of the substring after the last slash
$var(substring_length) = $var(len) - $var(start_pos);
# Extract the substring after the last slash
$var(mtc_app_session) = $(var(url){s.substr,$var(start_pos),$var(substring_length)});
# now checking it on console if I got what I wanted :
xlog("L_INFO", "AppSession for user $tU is: $var(mtc_app_session)\n");
xlog("L_INFO", "AppSession Id for user $tU is: $var(mtc_app_session)\n");
# now trying some way to store AppSession with the registred UE
$var(term_user_id) = $tU; # should get the user part of the Orig UE
$var(term_user_id) = $tU;
# Store the AppSession in the hash table associated with the UE
# Store the AppSession Id in the hash table associated with the UE
$sht(user_data=>$var(term_user_id)) = $var(mtc_app_session);
xlog("L_INFO", "Stored AppSession for user $var(term_user_id): $var(mtc_app_session)\n");
break;
@@ -443,70 +390,57 @@ $var(sdp_mline_raw) = $sdp(m0:raw);
xlog("L_ERR", "N5 QoS Session faild - Reason code: $rc\n");
send_reply("412", "MTC N5 QoS Session Creation faild");
exit;
} # switch ends here
# } # else for AppSession not null ends here
} # If Methode INVITE ends here
}
}
############
#############
#############
# 5G VoNR N5 Policy Authorization PATCH request
route[N5_PATCH_MT_REQ] {
xlog("L_INFO", "N5_PATCH_MT_REQ, building N5 PATCH Request\n");
## retrieving SDP Connection Info and Media Port for UE
$var(sdp_call_id) = $ci; # Call-ID for INVITE
# Retrieve SDP Connection Info and Media Port for UE
$var(sdp_call_id) = $ci;
$var(orig_ue_sdp_ip) = $sht(user_sdps_ip=>$var(sdp_call_id));
xlog("L_INFO", "SDP IP for UE with MSISDN $fU Call-ID $var(sdp_call_id) is: $var(orig_ue_sdp_ip)\n");
$var(sdp_call_id_port) = $ci; # User Port of the from Header to get the USER
$var(sdp_call_id_port) = $ci;
$var(orig_ue_sdp_port) = $sht(user_sdps_port=>$var(sdp_call_id_port));
xlog("L_INFO", "SDP RTP Port for UE with MSISDN $fU Call-ID $var(sdp_call_id_port) is: $var(orig_ue_sdp_port)\n");
$var(sdp_call_id_rtcp_port) = $ci; # Call ID for INVITE
$var(sdp_call_id_rtcp_port) = $ci;
$var(orig_ue_sdp_rtcp_port) = $sht(user_sdps_rtcp_port=>$var(sdp_call_id_rtcp_port));
xlog("L_INFO", "SDP RTCP Port for UE with MSISDN $fU Call-ID $var(sdp_call_id_rtcp_port) is: $var(orig_ue_sdp_rtcp_port)\n");
## retrieving SDP Connection Info from SDP Answer
# Retrieve 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(mtc_resp_app_id) = $tU; # User Part of the from Header to get the USER
# Retrieve AppSession
$var(mtc_resp_app_id) = $tU;
$var(user_appsess_mtc_rep) = $sht(user_data=>$var(mtc_resp_app_id));
xlog("L_INFO", "Stored MTC AppSession for user $var(mtc_resp_app_id): $var(user_appsess_mtc_rep)\n");
#### now start to build the N5 Request
xlog("L_INFO","Preparing PATCH N5 Message for SDP Answer\n");
xlog("L_INFO","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
# 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", "dnn", "ims", "$var(payload)");
### Set medComponents
# Set medComponents
jansson_set("integer", "medCompN", 1, "$var(medComp)");
jansson_set("string", "qosReference", "qosVoNR", "$var(medComp)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
jansson_set("string", "qosReference", "qosVoNR", "$var(medComp)");
jansson_set("string", "medType", "AUDIO", "$var(medComp)");
jansson_set("array", "codecs", "[\"downlink\\n$var(sdp_answ_codec)\\n\", \"uplink\\n$var(sdp_answ_codec)\\n\"]", "$var(medComp)");
### RTP
# RTP
jansson_set("integer", "fNum", 1, "$var(medSubComp1)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(orig_ue_sdp_ip) $var(orig_ue_sdp_port) to $var(sdp_answ_ip) $var(sdp_answ_port)\", \"permit in 17 from $var(sdp_answ_ip) $var(sdp_answ_port) to $var(orig_ue_sdp_ip) $var(orig_ue_sdp_port)\"]", "$var(medSubComp1)");
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp1)");
@@ -514,8 +448,7 @@ route[N5_PATCH_MT_REQ] {
jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp1)");
jansson_set("string", "flowUsage", "NO_INFO", "$var(medSubComp1)");
### RTCP
# RTCP
jansson_set("integer", "fNum", 2, "$var(medSubComp2)");
jansson_set("array", "fDescs", "[\"permit out 17 from $var(orig_ue_sdp_ip) $var(orig_ue_sdp_rtcp_port) to $var(sdp_answ_ip) $var(sdp_answ_rtcp_port)\", \"permit in 17 from $var(sdp_answ_ip) $var(sdp_answ_rtcp_port) to $var(orig_ue_sdp_ip) $var(orig_ue_sdp_rtcp_port)\"]", "$var(medSubComp2)");
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp2)");
@@ -533,7 +466,7 @@ route[N5_PATCH_MT_REQ] {
xlog("L_INFO","DEBUG: Set evSubsc\n");
### Set evSubsc
# Set evSubsc
jansson_set("string", "event", "QOS_NOTIF", "$var(event1)");
jansson_set("string", "notifMethod", "PERIODIC", "$var(event1)");
jansson_append("obj", "", "$var(event1)", "$var(events)");
@@ -544,22 +477,23 @@ route[N5_PATCH_MT_REQ] {
jansson_set("obj", "evSubsc", "$var(evSubsc)", "$var(payload)");
### Set other parameters in payload
# Set other parameters in payload
jansson_set("string", "notifUri", "http://172.22.0.21:7777", "$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", "gpsi", "msisdn-$tU", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
jansson_set("string", "suppFeat", "2", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
jansson_set("string", "ueIpv4", "$si", "$var(payload)"); # not all element in PATCH/Merge request are needed only the chanegd one, could be reenabled if needed
jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$var(payload)");
jansson_set("string", "gpsi", "msisdn-$tU", "$var(payload)");
jansson_set("string", "suppFeat", "2", "$var(payload)");
jansson_set("string", "ueIpv4", "$si", "$var(payload)");
### Assemble the final JSON request
# Assemble the final JSON request
jansson_set("obj", "ascReqData", "$var(payload)", "$var(json_request)");
xlog("L_INFO","DEBUG: Set headers for the HTTP2 Request\n");
### Set headers
# Set headers
$var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
xlog("L_INFO", "Today is $var(time_now)\n");
$var(headers) = "Content-Type: application/merge-patch+json\r\n"; # added content-type an set it to "application/merge-patch+json" fo compatibility with RFC7386 for JSON PATCH/Merge
# Set Content-type to application/merge-patch+json for compatibility with RFC7386 for JSON PATCH/Merge
$var(headers) = "Content-Type: application/merge-patch+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";
@@ -567,11 +501,9 @@ route[N5_PATCH_MT_REQ] {
$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_INFO","Sending the request to PCF\n");
### Send the request to PCF
# Send the request to PCF
http_client_request_v2pk("PATCH", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/$var(user_appsess_mtc_rep)", "$var(json_request)", "$var(headers)", "$var(result)" );
#### here we want to kill the dialog in case QoS faild or continue if QoS success.
switch ($rc) {
case 200:
xlog("L_INFO", "N5 QoS Session modification success - reason code: $rc\n");
@@ -584,34 +516,25 @@ route[N5_PATCH_MT_REQ] {
xlog("L_ERR", "N5 QoS Session modification faild - reason code: $rc\n");
send_reply("412", "MTC N5 QoS Session modify faild");
exit;
} # switch ends here
}
}
########################################
######### END of 5G VoNR N5 Request ####
########################################
route[N5_MTC_TERM] {
## something need to be clear here about BYE ;( To/From Headers!!!
xlog("L_ALERT","Terminating AppSession For Call for User $tU due to call END\n");
# Retrieveing and paying attention to whom ended teh call
$var(mtc_resp_app_id) = $tU; # User Part of the from Header to get the USER
# Retrieve appSession based on To URI
$var(mtc_resp_app_id) = $tU;
$var(user_appsess_mtc_rep) = $sht(user_data=>$var(mtc_resp_app_id));
if $var(user_appsess_mtc_rep) == 0 {
xlog("L_INFO", "we dont have AppSessionID to terminate, doing alternative Method\n");
xlog("L_INFO", "No AppSession Id found to terminate. Trying using From URI\n");
# Retrieveing and paying attention to whom ended teh call
$var(mtc_resp_app_id) = $fU; # User Part of the from Header to get the USER
# Retrieve appSession based on From URI
$var(mtc_resp_app_id) = $fU;
$var(user_appsess_mtc_rep) = $sht(user_data=>$var(mtc_resp_app_id));
xlog("L_INFO", "Alt-Method : Terminating Stored AppSession for user $var(mtc_resp_app_id): $var(user_appsess_mtc_rep)\n");
} else {
xlog("L_INFO", "We have AppSessionID, doing normal Method\n");
xlog("L_INFO", "Normal Method : Stored MTC AppSession for user $var(mtc_resp_app_id): $var(user_appsess_mtc_rep)\n");
xlog("L_INFO", "Normal Method : MTC AppSession for user $var(mtc_resp_app_id): $var(user_appsess_mtc_rep)\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";
@@ -623,5 +546,5 @@ route[N5_MTC_TERM] {
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/$var(user_appsess_mtc_rep)/delete", "$var(json_request)", "$var(headers)", "$var(result)" );
xlog("L_INFO", "cURL header: $curlerror(error)\n");
xlog("L_INFO", "HTTP response: $rc\n");
}
#!endif

View File

@@ -21,20 +21,20 @@ route[REGISTER] {
exit;
}
### N5 Request create and terminate
xlog("L_INFO","Checking if its a Registration and not a De-Reg for $fu\n");
#!ifdef WITH_N5
$var(reg_exp) = $expires(min);
xlog("L_INFO","Checking Expire $fu and it is : $var(reg_exp)\n");
xlog("L_INFO","Expire for $fu is :$var(reg_exp)\n");
# tying a dirty workaround to make it only excute after IPSec tunnel to prevent double excution
# Trying a dirty workaround to make it only excute after IPSec tunnel to prevent double excution
if ($expires(min) != 0 && is_present_hf("Security-Verify")) {
route(REGISTER_N5_Req);
route(REGISTER_N5_REQ);
}
if ($expires(min) == 0 ) {
xlog("L_ALERT","delete N5 Session for $fu due to de-register\n");
if ($expires(min) == 0) {
xlog("L_ALERT","Delete N5 Session for $fu due to de-register\n");
route(REG_N5_TERMINATE);
}
#!endif
#!ifdef WITH_IPSEC
$sht(ipsec_clients=>$(ct{nameaddr.uri})) = $null;
@@ -310,11 +310,12 @@ onreply_route[REGISTER_reply]
failure_route[REGISTER_failure]
{
# Terminate N5 Session on Reg Failure
#!ifdef WITH_N5
# Terminate N5 Session on Reg Failure
if (t_check_status("403|408|[5-6][0-9][0-9]")) {
route(REG_N5_TERMINATE);
}
#!endif
#!ifdef WITH_IPBLOCK
if (t_check_status("403|[5-6][0-9][0-9]")) {
@@ -338,33 +339,24 @@ failure_route[REGISTER_failure]
}
#!ifdef WITH_N5
#############################################
##### 5G Experemntal PCF N5 Interface Reg ##
#############################################
route[REGISTER_N5_Req]
# N5 Policy Authorization - Create Application session context for SIP Registration
route[REGISTER_N5_REQ]
{
xlog("L_INFO","SIP Registration - Starting N5 QoS Auth for $fu\n");
xlog("L_INFO","its a Registration, starting N5 QoS Auth for $fu\n");
xlog("L_INFO","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
# Set afAppId and dnn in 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
# Set media components in payload
jansson_set("integer", "medCompN", 0, "$var(medComp)");
jansson_set("string", "qosReference", "qosVoNR", "$var(medComp)");
jansson_set("string", "medType", "CONTROL", "$var(medComp)");
@@ -373,17 +365,15 @@ route[REGISTER_N5_Req]
jansson_set("array", "fDescs", "[\"permit out ip from $RAi $RAp to $si $sp\", \"permit in ip from $si $sp to $RAi $RAp\"]", "$var(medSubComp)");
jansson_set("string", "fStatus", "ENABLED", "$var(medSubComp)");
jansson_set("string", "flowUsage", "AF_SIGNALLING", "$var(medSubComp)");
# jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp)");
# jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp)");
# jansson_set("string", "marBwDl", "5000 Kbps", "$var(medSubComp)");
# jansson_set("string", "marBwUl", "3000 Kbps", "$var(medSubComp)");
jansson_set("obj", "0", "$var(medSubComp)", "$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_INFO","Set evSubsc\n");
### Set evSubsc
# Set evSubsc
jansson_set("string", "event", "QOS_NOTIF", "$var(event1)");
jansson_set("string", "notifMethod", "PERIODIC", "$var(event1)");
jansson_append("obj", "", "$var(event1)", "$var(events)");
@@ -394,21 +384,18 @@ xlog("L_INFO","Set evSubsc\n");
jansson_set("obj", "evSubsc", "$var(evSubsc)", "$var(payload)");
### Set other parameters in payload
# Set other parameters in payload
jansson_set("string", "notifUri", "http://172.22.0.21:7777", "$var(payload)");
jansson_set("string", "sponStatus", "SPONSOR_DISABLED", "$var(payload)");
jansson_set("string", "supi", "imsi-$au", "$var(payload)");
jansson_set("string", "suppFeat", "2", "$var(payload)");
jansson_set("string", "ueIpv4", "$si", "$var(payload)");
### Assemble the final JSON request
# Assemble the final JSON request
jansson_set("obj", "ascReqData", "$var(payload)", "$var(json_request)");
xlog("L_INFO","Set headers for the HTTP2 Request\n");
### Set headers
# Set HTTP2 request headers
$var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
xlog("L_INFO", "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";
@@ -417,29 +404,25 @@ xlog("L_INFO","Set evSubsc\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_INFO","DEBUG: Sending the request to PCF\n");
### Send the request to PCF
xlog("L_INFO","SIP Registration. Sending N5 QoS Auth for $fu to PCF\n");
# Send the request to PCF
http_client_request_v2pk("POST", "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions", "$var(json_request)", "$var(headers)", "$var(result)" );
### here we want to kill the dialog in case QoS faild or continue if QoS success.
switch ($rc) {
# Success case
case 201:
xlog("L_INFO", "N5 QoS Session successfully Created $rc\n");
xlog("L_INFO", "HTTP results: $var(result)\n");
xlog("L_INFO", "HTTP response: $rc\n");
xlog("L_INFO", "Location Header: $httprhdr(location)\n");
# Retrieve the AppSession Id out of the location Header if the resopnse is 201.
# Example URL: "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/(someSessionID)"
xlog("L_ALERT","Saving AppSessionID to HTABLE\n");
# Now I will retrieve the AppSessionID out of the location Header it should be always at the end
# Example URL: "http://172.22.0.27:7777/npcf-policyauthorization/v1/app-sessions/(someSessionID)"
# Firt store the url of the lcoation Header in var
# Store the url of the location header
$var(url) = $httprhdr(location);
# Get the length of the URL
$var(len) = $(var(url){s.len});
# Initialize the position variable to the length of the URL
$var(pos) = $var(len);
@@ -447,64 +430,44 @@ xlog("L_INFO","Set evSubsc\n");
while ($var(pos) > 0) {
$var(pos) = $var(pos) - 1;
if ($(var(url){s.substr,$var(pos),1}) == "/") {
# We've found the last slash
break;
}
}
# Extract the substring after the last slash
# now doing some magic
# Extract the substring after the last slash
$var(start_pos) = $var(pos) + 1;
$var(end_pos) = $var(len) - $var(start_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 :
xlog("L_INFO", "AppSession for user $au is: $var(app_session)\n");
xlog("L_INFO", "AppSession Id for user $au is: $var(app_session)\n");
# now trying some way to store AppSession with the registred UE
$var(user_id) = $au; # should get the user part of the registred UE
# Store the AppSession in the hash table associated with the UE
$var(user_id) = $au;
# Store the AppSession Id in the hash table associated with the UE
$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 Id for user $var(user_id): $var(app_session)\n");
#######
## Storing IMSI for later use :
######
xlog("L_ALERT","Storing User IMSI to HTABLE for later use\n");
$var(ue_imsi) = $au;
# now checking it on console if I got what I wanted :
xlog("L_INFO", "IP for UE is: $var(ue_imsi)\n");
# now trying some way to store AppSession with the registred UE
$var(ue_imsi_reg_ip) = $si; # should get the user part of the registred UE
$var(ue_imsi_reg_ip) = $si;
# Store the AppSession in the hash table associated with the UE
$sht(user_ids=>$var(ue_imsi_reg_ip)) = $var(ue_imsi);
xlog("L_INFO", "Stored IMSI for IP $var(ue_imsi_reg_ip) is: $var(ue_imsi)\n");
break;
# now contiue with Reg Proccess, Or:
# Failure case
default:
xlog("L_ERR", "N5 QoS Session faild - Reason code: $rc\n");
send_reply("412", "Register N5 QoS Session Creation faild");
xlog("L_ERR", "N5 QoS Session authorization failed - Reason code: $rc\n");
send_reply("412", "Register N5 QoS authorization failed");
exit;
} # switch ends here
### N5 REQ Route END
}
}
###########################
## Terminating AppSession #
###########################
# N5 Policy Authorization - Application session termination for SIP De-registration
route[REG_N5_TERMINATE]
{
xlog("L_ALERT","its a De-Registration for $fu, terminating N5 AppSession\n");
# Retrieveing
$var(user_id_dereg) = $fU; # User Part of the from Header to get the USER
xlog("L_ALERT","SIP De-Registration for $fu - Terminating N5 AppSession\n");
# Retrieve the AppSession Id from the hash table
$var(user_id_dereg) = $fU;
$var(user_appsess_dereg) = $sht(user_data=>$var(user_id_dereg));
xlog("L_INFO", "Terminating Stored AppSession for user $var(user_id_dereg): $var(user_appsess_dereg)\n");
xlog("L_INFO", "Terminating stored AppSession for user $var(user_id_dereg): $var(user_appsess_dereg)\n");
$var(headers) = "X-SIP-Status: De-Registration\r\n";
$var(headers) = $var(headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n";
@@ -520,5 +483,6 @@ route[REG_N5_TERMINATE]
xlog("L_INFO", "HTTP results: $var(result)\n");
xlog("L_INFO", "HTTP response: $rc\n");
xlog("L_INFO", "Location Header: $httprhdr(location)\n");
}
#!endif