Browse Source

ims_charging: Add option to get and use P-Access-Network-Info for terminating scenario (#3726)

Add option to configure node functionality for Ro requests
Morten Tryfoss 1 year ago
parent
commit
76cd7979aa

+ 1 - 1
src/modules/ims_charging/Ro_data.c

@@ -88,7 +88,7 @@ ims_information_t *new_ims_information(event_type_t *event_type,
 	mem_new(x->role_of_node, sizeof(int32_t), pkg);
 	*(x->role_of_node) = node_role;
 
-	//x->node_functionality = cfg.node_func;
+	x->node_functionality = cfg.node_func;
 
 	if(outgoing_session_id && outgoing_session_id->s)
 		str_dup_ptr(x->outgoing_session_id, *outgoing_session_id, pkg);

+ 2 - 0
src/modules/ims_charging/config.h

@@ -9,6 +9,8 @@ typedef struct
 	str destination_realm;
 	str *service_context_id;
 	int strip_plus_from_e164;
+	int use_pani_from_term_invite;
+	int node_func;
 } client_ro_cfg;
 
 #endif

+ 41 - 0
src/modules/ims_charging/doc/ims_charging_admin.xml

@@ -854,6 +854,47 @@ modparam("ims_charging", "vendor_specific_id", 10)
         <programlisting format="linespecific">
 ...
 modparam("ims_charging", "strip_plus_from_e164", 1)
+...
+        </programlisting>
+      </example>
+    </section>
+
+    <section>
+      <title><varname>use_pani_from_term_invite</varname> (int)</title>
+
+      <para>P-Access-Network-Info is normally relevant for the "orig" scenario where it's extracted from INVITE. This setting instruct Kamailio
+        to include it in "term" scenario too, where it might have been added to the INVITE based on info from a REGISTER. 
+        Normally used to start a charging session when the user is roaming.</para>
+
+      <para><emphasis>Default value is 0.</emphasis></para>
+
+      <example>
+        <title><varname>use_pani_from_term_invite</varname>parameter
+        usage</title>
+
+        <programlisting format="linespecific">
+...
+modparam("ims_charging", "use_pani_from_term_invite", 1)
+...
+        </programlisting>
+      </example>
+    </section>
+
+    <section>
+      <title><varname>node_func</varname> (int)</title>
+
+      <para>Defines what should be sent as Node-Functionality (862) in the Diameter Ro request.
+        Possible values are: 0 (S-CSCF), 1 (P-CSCF), 2 (I-CSCF), 3 (MRFC), 4 (MGCF), 5 (BFCF) or 6 (AS)</para>
+
+      <para><emphasis>Default value is 0 (S-CSCF).</emphasis></para>
+
+      <example>
+        <title><varname>node_func</varname>parameter
+        usage</title>
+
+        <programlisting format="linespecific">
+...
+modparam("ims_charging", "node_func", 1)
 ...
         </programlisting>
       </example>

+ 10 - 0
src/modules/ims_charging/ims_charging_mod.c

@@ -171,6 +171,9 @@ static param_export_t params[] = {
 		{"app_provided_party_avp", PARAM_STR, &app_provided_party_spec},
 		{"strip_plus_from_e164", INT_PARAM,
 				&cfg.strip_plus_from_e164}, /*wheter to strip or keep + sign from E164 numbers (tel: uris), according to diameter spec*/
+		{"use_pani_from_term_invite", INT_PARAM,
+				&cfg.use_pani_from_term_invite}, /*wheter to read and use P-Access-Network-Info header from INVITE on term scenario*/
+		{"node_func", INT_PARAM, &cfg.node_func}, /* node functionality */
 		{0, 0, 0}};
 
 /** module exports */
@@ -231,6 +234,10 @@ int fix_parameters()
 			return -1;
 		}
 	}
+	if(cfg.node_func < 0 || cfg.node_func > 6) {
+		LM_ERR("node_func: invalid value - must be between 0 and 6\n");
+		return 0;
+	}
 
 	init_custom_user(custom_user_spec.s ? &custom_user_avp : 0);
 	init_app_provided_party(
@@ -647,6 +654,9 @@ static int ki_ro_ccr(sip_msg_t *msg, str *s_route_name, str *s_direction,
 
 		pani = cscf_get_access_network_info(msg, &h);
 	} else if(dir == RO_TERM_DIRECTION) {
+		if(cfg.use_pani_from_term_invite) {
+			pani = cscf_get_access_network_info(msg, &h);
+		}
 		//get callee IMPU from called part id - if not present then skip this
 		if((identity = cscf_get_public_identity_from_called_party_id(msg, &h))
 						.len