Add NRF-NFM subscription for PCF registration notification
This commit is contained in:
@@ -1007,19 +1007,29 @@ route[preload_pcscf] {
|
||||
|
||||
#!ifdef WITH_N5
|
||||
event_route[nghttp2:request] {
|
||||
nghttp2_reply("404", "<html><body>Not Found</body></html>");
|
||||
xinfo("request: $nghttp2(method) - url: $nghttp2(path) - data: [$nghttp2(data)]\n");
|
||||
|
||||
// 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:", "PCSCF");
|
||||
nghttp2_reply("200", "<html><body>PCF registered at PCSCF</body></html>");
|
||||
} else {
|
||||
// Optionally handle other URLs or do nothing
|
||||
nghttp2_reply("404", "<html><body>Not Found</body></html>");
|
||||
}
|
||||
}
|
||||
|
||||
route[NRF_NFM] {
|
||||
if ($shv(n5_hb_fail_count) > 5) {
|
||||
if ($var(n5_hb_fail_count) > 5) {
|
||||
xlog("L_ERR", "PCSCF NF no longer registered at SCP. Re-attempting registration!!\n");
|
||||
$shv(n5_initalized) = 0;
|
||||
$var(n5_initalized) = 0;
|
||||
}
|
||||
|
||||
$var(time_now) = $_s($timef(%a, %d %b %Y %H:%M:%S %Z));
|
||||
|
||||
# TODO: Send at heartbeat intervals received in reponse to NF registration
|
||||
if ($shv(n5_initalized) == 1) {
|
||||
if ($var(n5_initalized) == 1) {
|
||||
# Send Heartbeat
|
||||
$var(nf_hb_headers) = "content-type: application/json-patch+json\r\n";
|
||||
$var(nf_hb_headers) = $var(nf_hb_headers) + "accept: application/json,application/problem+json\r\n";
|
||||
@@ -1042,20 +1052,20 @@ route[NRF_NFM] {
|
||||
}';
|
||||
jansson_append("obj", "", $var(nf_hb_body), "$var(nf_hb_json_body)");
|
||||
|
||||
http_client_request_v2pk("PATCH", "http://SCP_BIND_IP:SCP_BIND_PORT/nnrf-nfm/v1/nf-instances/$shv(pcscf_uuid)", "$var(nf_hb_json_body)", "$var(nf_hb_headers)", "$var(nf_hb_result)");
|
||||
http_client_request_v2pk("PATCH", "http://SCP_BIND_IP:SCP_BIND_PORT/nnrf-nfm/v1/nf-instances/$var(pcscf_uuid)", "$var(nf_hb_json_body)", "$var(nf_hb_headers)", "$var(nf_hb_result)");
|
||||
switch ($rc) {
|
||||
case 204:
|
||||
$shv(n5_hb_fail_count) = 0;
|
||||
$var(n5_hb_fail_count) = 0;
|
||||
break;
|
||||
default:
|
||||
$shv(n5_hb_fail_count) = $shv(n5_hb_fail_count) + 1;
|
||||
$var(n5_hb_fail_count) = $var(n5_hb_fail_count) + 1;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
# Generate UUID for PCSCF
|
||||
$shv(pcscf_uuid) = $uuid(g);
|
||||
$var(pcscf_uuid) = $uuid(g);
|
||||
|
||||
# Register NF
|
||||
$var(nf_reg_headers) = "content-type: application/json\r\n";
|
||||
@@ -1066,7 +1076,7 @@ route[NRF_NFM] {
|
||||
$var(nf_reg_headers) = $var(nf_reg_headers) + "3gpp-sbi-sender-timestamp: " + $var(time_now);
|
||||
|
||||
$var(nf_reg_body) = '{
|
||||
"nfInstanceId": "$shv(pcscf_uuid)",
|
||||
"nfInstanceId": "PCSCF_UUID",
|
||||
"nfType": "PCSCF",
|
||||
"nfStatus": "REGISTERED",
|
||||
"ipv4Addresses": ["N5_BIND_IP"],
|
||||
@@ -1075,8 +1085,8 @@ route[NRF_NFM] {
|
||||
"capacity": 100,
|
||||
"load": 0,
|
||||
"nfServiceList": {
|
||||
"$shv(pcscf_uuid)": {
|
||||
"serviceInstanceId": "$shv(pcscf_uuid)",
|
||||
"PCSCF_UUID": {
|
||||
"serviceInstanceId": "PCSCF_UUID",
|
||||
"serviceName": "npcf-policyauthorization",
|
||||
"versions": [
|
||||
{
|
||||
@@ -1102,20 +1112,56 @@ route[NRF_NFM] {
|
||||
},
|
||||
"nfProfileChangesSupportInd": true
|
||||
}';
|
||||
$var(nf_reg_body) = $(var(nf_reg_body){re.subst,/PCSCF_UUID/$var(pcscf_uuid)/g});
|
||||
jansson_append("obj", "", "$var(nf_reg_body)", "$var(nf_reg_json_body)");
|
||||
|
||||
http_client_request_v2pk("PUT", "http://SCP_BIND_IP:SCP_BIND_PORT/nnrf-nfm/v1/nf-instances/$shv(pcscf_uuid)", "$var(nf_reg_json_body)", "$var(nf_reg_headers)", "$var(nf_reg_result)");
|
||||
http_client_request_v2pk("PUT", "http://SCP_BIND_IP:SCP_BIND_PORT/nnrf-nfm/v1/nf-instances/$var(pcscf_uuid)", "$var(nf_reg_json_body)", "$var(nf_reg_headers)", "$var(nf_reg_result)");
|
||||
switch ($rc) {
|
||||
case 201:
|
||||
xlog("L_INFO", "P-CSCF NF registered successfully at SCP\n");
|
||||
$shv(n5_initalized) = 1;
|
||||
$shv(n5_hb_fail_count) = 0;
|
||||
$var(n5_initalized) = 1;
|
||||
$var(n5_hb_fail_count) = 0;
|
||||
route(NRF_NFM_SUBSCRIBE_PCF);
|
||||
break;
|
||||
default:
|
||||
xlog("L_ERR", "P-CSCF NF failed to register at SCP with code=$rc\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
route[NRF_NFM_SUBSCRIBE_PCF] {
|
||||
# Subscribe to PCF NF registration notification
|
||||
$var(time_now) = $_s($timef(%a, %d %b %Y %H:%M:%S %Z));
|
||||
$var(pcf_subc_headers) = "content-type: application/json\r\n";
|
||||
$var(pcf_subc_headers) = $var(pcf_subc_headers) + "accept: application/json,application/problem+json\r\n";
|
||||
$var(pcf_subc_headers) = $var(pcf_subc_headers) + "3gpp-sbi-discovery-target-nf-type: NRF\r\n";
|
||||
$var(pcf_subc_headers) = $var(pcf_subc_headers) + "3gpp-sbi-callback: Nnrf_NFManagement_NFStatusNotify\r\n";
|
||||
$var(pcf_subc_headers) = $var(pcf_subc_headers) + "3gpp-sbi-max-rsp-time: 10000\r\n";
|
||||
$var(pcf_subc_headers) = $var(pcf_subc_headers) + "3gpp-sbi-discovery-service-names: nnrf-nfm\r\n";
|
||||
$var(pcf_subc_headers) = $var(pcf_subc_headers) + "3gpp-sbi-sender-timestamp: " + $var(time_now);
|
||||
|
||||
$var(pcf_subc_body) = '{
|
||||
"nfStatusNotificationUri": "http://N5_BIND_IP:N5_BIND_PORT/nnrf-nfm/v1/nf-status-notify",
|
||||
"reqNfInstanceId": "PCSCF_UUID",
|
||||
"subscrCond": {
|
||||
"nfType": "PCF"
|
||||
},
|
||||
"reqNfType": "PCSCF",
|
||||
"requesterFeatures": "1"
|
||||
}';
|
||||
$var(pcf_subc_body) = $(var(pcf_subc_body){re.subst,/PCSCF_UUID/$var(pcscf_uuid)/g});
|
||||
jansson_append("obj", "", "$var(pcf_subc_body)", "$var(pcf_subc_json_body)");
|
||||
|
||||
http_client_request_v2pk("POST", "http://SCP_BIND_IP:SCP_BIND_PORT/nnrf-nfm/v1/subscriptions", "$var(pcf_subc_json_body)", "$var(pcf_subc_headers)", "$var(pcf_subc_result)");
|
||||
switch ($rc) {
|
||||
case 201:
|
||||
xlog("L_INFO", "P-CSCF NF subscribed for PCF NF registration notification\n");
|
||||
break;
|
||||
default:
|
||||
xlog("L_ERR", "P-CSCF NF failed to subscribe for PCF NF registration notification\n");
|
||||
return;
|
||||
}
|
||||
}
|
||||
#!endif
|
||||
|
||||
#!ifdef WITH_XMLRPC
|
||||
|
Reference in New Issue
Block a user