Browse code

ims_qos: Added new parameters for AAR,AVP517

- Added new parameters: af_signaling_ip6, component_media_type,
flow_protocol, omit_flow_ports, rs_default_bandwidth,
rr_default_bandwidth. Check doc for details.

Aleksandar Yosifov authored on 25/03/2022 15:18:10 • Daniel-Constantin Mierla committed on 01/04/2022 11:54:38
Showing 4 changed files
... ...
@@ -384,7 +384,139 @@ modparam("ims_qos", "include_rtcp_fd", 1)
384 384
         </programlisting>
385 385
       </example>
386 386
     </section>
387
-    
387
+
388
+    <section>
389
+      <title><varname>af_signaling_ip</varname> (String)</title>
390
+
391
+      <para>Set P-CSCF IPv4 address to generate the flows for the UE<->PCSCF signaling path. Used only for AAR register, Flow-Description AVP (507)</para>
392
+
393
+      <para><emphasis> Default value is 127.0.0.1</emphasis></para>
394
+
395
+      <example>
396
+        <title><varname>af_signaling_ip</varname> parameter
397
+        usage</title>
398
+
399
+        <programlisting format="linespecific">
400
+...
401
+modparam("ims_qos", "af_signaling_ip", "127.0.0.1")
402
+...
403
+        </programlisting>
404
+      </example>
405
+    </section>
406
+
407
+    <section>
408
+      <title><varname>af_signaling_ip6</varname> (String)</title>
409
+
410
+      <para>Set P-CSCF IPv6 address to generate the flows for the UE<->PCSCF signaling path. Used only for AAR register, Flow-Description AVP (507)</para>
411
+
412
+      <para><emphasis> Default value is ""</emphasis></para>
413
+
414
+      <example>
415
+        <title><varname>af_signaling_ip6</varname> parameter
416
+        usage</title>
417
+
418
+        <programlisting format="linespecific">
419
+...
420
+modparam("ims_qos", "af_signaling_ip6", "fd16::205:2dee:ce4a:ab22")
421
+...
422
+        </programlisting>
423
+      </example>
424
+    </section>
425
+
426
+    <section>
427
+      <title><varname>media_type</varname> (String)</title>
428
+
429
+      <para>Describe Media Type AVP(520) for AAR register</para>
430
+
431
+      <para><emphasis> Default value is 'control'</emphasis></para>
432
+
433
+      <example>
434
+        <title><varname>media_type</varname> parameter
435
+        usage</title>
436
+
437
+        <programlisting format="linespecific">
438
+...
439
+modparam("ims_qos", "media_type", "audio")
440
+...
441
+        </programlisting>
442
+      </example>
443
+    </section>
444
+
445
+    <section>
446
+      <title><varname>flow_protocol</varname> (String)</title>
447
+
448
+      <para>Describe Flow protocol for Flow-Description AVP (507). Used only for AAR register</para>
449
+
450
+      <para><emphasis> Default value is 'IP'</emphasis></para>
451
+
452
+      <example>
453
+        <title><varname>flow_protocol</varname> parameter
454
+        usage</title>
455
+
456
+        <programlisting format="linespecific">
457
+...
458
+modparam("ims_qos", "flow_protocol", "UDP")
459
+...
460
+        </programlisting>
461
+      </example>
462
+    </section>
463
+
464
+    <section>
465
+      <title><varname>omit_flow_ports</varname> integer</title>
466
+
467
+      <para>If set to 1 ommit ports for Flow-Description AVP (507). Used only for AAR register</para>
468
+
469
+      <para><emphasis> Default value is 0, Add ports to Flow-Description AVP (507)</emphasis></para>
470
+
471
+      <example>
472
+        <title><varname>omit_flow_ports</varname> parameter
473
+        usage</title>
474
+
475
+        <programlisting format="linespecific">
476
+...
477
+modparam("ims_qos", "omit_flow_ports", 1)
478
+...
479
+        </programlisting>
480
+      </example>
481
+    </section>
482
+
483
+    <section>
484
+      <title><varname>rs_default_bandwidth</varname> integer</title>
485
+
486
+      <para>Describe default RS-Bandwidth AVP(522) for AAR</para>
487
+
488
+      <para><emphasis> Default value is 0</emphasis></para>
489
+
490
+      <example>
491
+        <title><varname>rs_default_bandwidth</varname> parameter
492
+        usage</title>
493
+
494
+        <programlisting format="linespecific">
495
+...
496
+modparam("ims_qos", "rs_default_bandwidth", 600)
497
+...
498
+        </programlisting>
499
+      </example>
500
+    </section>
501
+
502
+    <section>
503
+      <title><varname>rr_default_bandwidth</varname> integer</title>
504
+
505
+      <para>Describe default RR-Bandwidth AVP(521) for AAR</para>
506
+
507
+      <para><emphasis> Default value is 0</emphasis></para>
508
+
509
+      <example>
510
+        <title><varname>rr_default_bandwidth</varname> parameter
511
+        usage</title>
512
+
513
+        <programlisting format="linespecific">
514
+...
515
+modparam("ims_qos", "rr_default_bandwidth", 2000)
516
+...
517
+        </programlisting>
518
+      </example>
519
+    </section>
388 520
   </section>
389 521
 
390 522
   <section>
... ...
@@ -147,7 +147,14 @@ str rx_forced_peer = str_init("");
147 147
 
148 148
 /* P-CSCF IP address to generate the flows for the UE<->PCSCF signaling path */
149 149
 str af_signaling_ip = str_init("127.0.0.1");
150
+/* P-CSCF IPv6 address to generate the flows for the UE<->PCSCF signaling path */
151
+str af_signaling_ip6 = str_init("");
150 152
 
153
+str component_media_type = str_init("control");
154
+str flow_protocol = str_init("IP");
155
+int omit_flow_ports = 0;
156
+int rs_default_bandwidth = 0;
157
+int rr_default_bandwidth = 0;
151 158
 
152 159
 /* commands wrappers and fixups */
153 160
 static int w_rx_aar(struct sip_msg *msg, char *route, char* dir, char *id, int id_type);
... ...
@@ -199,6 +206,12 @@ static param_export_t params[] = {
199 206
 		{ "rx_forced_peer", PARAM_STR, &rx_forced_peer},
200 207
 		{ "rx_auth_expiry", INT_PARAM, &rx_auth_expiry},
201 208
 		{ "af_signaling_ip", PARAM_STR, &af_signaling_ip}, /* IP of this P-CSCF, to be used in the flow for the AF-signaling */
209
+		{ "af_signaling_ip6", PARAM_STR, &af_signaling_ip6}, /* IPv6 of this P-CSCF, to be used in the flow for the AF-signaling */
210
+		{ "media_type", PARAM_STR, &component_media_type}, /*  */
211
+		{ "flow_protocol", PARAM_STR, &flow_protocol}, /*  */
212
+		{ "omit_flow_ports", INT_PARAM, &omit_flow_ports}, /*  */
213
+		{ "rs_default_bandwidth", INT_PARAM, &rs_default_bandwidth}, /*  */
214
+		{ "rr_default_bandwidth", INT_PARAM, &rr_default_bandwidth}, /*  */
202 215
 		{ "cdp_event_latency", INT_PARAM, &cdp_event_latency}, /*flag: report slow processing of CDP callback events or not */
203 216
 		{ "cdp_event_threshold", INT_PARAM, &cdp_event_threshold}, /*time in ms above which we should report slow processing of CDP callback event*/
204 217
 		{ "cdp_event_latency_log", INT_PARAM, &cdp_event_latency_loglevel}, /*log-level to use to report slow processing of CDP callback event*/
... ...
@@ -78,6 +78,9 @@ extern struct ims_qos_counters_h ims_qos_cnts_h;
78 78
 extern int authorize_video_flow;
79 79
 
80 80
 extern str af_signaling_ip;
81
+extern str af_signaling_ip6;
82
+extern str component_media_type;
83
+extern str flow_protocol;
81 84
 
82 85
 str IMS_Serv_AVP_val = {"IMS Services", 12};
83 86
 str IMS_Em_Serv_AVP_val = {"Emergency IMS Call", 18};
... ...
@@ -952,10 +955,10 @@ int rx_send_aar_register(struct sip_msg *msg, AAASession* auth, saved_transactio
952 955
     AAA_AVP* avp = 0;
953 956
     char x[4];
954 957
     str identifier;
955
-    str media;
956 958
 
957 959
     str ip;
958 960
     uint16_t ip_version;
961
+    str via_host;
959 962
 
960 963
     //we get ip and identifier for the auth session data
961 964
     rx_authsessiondata_t* p_session_data = 0;
... ...
@@ -998,8 +1001,6 @@ int rx_send_aar_register(struct sip_msg *msg, AAASession* auth, saved_transactio
998 1001
 
999 1002
     /* Create flow description for AF-Signaling */
1000 1003
     //add this to auth session data
1001
-    media.s = "control";
1002
-    media.len = strlen("control");
1003 1004
     str raw_stream;
1004 1005
     raw_stream.s = 0;
1005 1006
     raw_stream.len = 0;
... ...
@@ -1014,16 +1015,26 @@ int rx_send_aar_register(struct sip_msg *msg, AAASession* auth, saved_transactio
1014 1015
     port_to.len = snprintf(c_port_to, 10, "%u", saved_t_data->recv_port);
1015 1016
     port_to.s = c_port_to;
1016 1017
 
1017
-    str protocol;
1018
-    protocol.s = "IP";
1019
-    protocol.len = strlen("IP");
1018
+    via_host.len = saved_t_data->via_host.len;
1019
+    via_host.s = saved_t_data->via_host.s;
1020
+
1021
+    if (ip_version == AF_INET6 && via_host.len && via_host.s[0]=='[') {
1022
+        /* skip over [ ] */
1023
+        if (via_host.s[via_host.len - 1]!=']') {
1024
+            LM_ERR("Invalid IPv6 format %.*s\n", via_host.len, via_host.s);
1025
+                goto error;
1026
+        }
1027
+
1028
+        via_host.s++;
1029
+        via_host.len -= 2;
1030
+    }
1020 1031
 
1021 1032
     //rx_add_media_component_description_avp_register(aar);
1022 1033
     /* Add media component description avp for register*/
1023 1034
     rx_add_media_component_description_avp(aar, 1,
1024
-               &media, &saved_t_data->via_host,
1025
-               &port_from, &af_signaling_ip,
1026
-               &port_to, &protocol,
1035
+               &component_media_type, &via_host,
1036
+               &port_from, ip_version == AF_INET ? &af_signaling_ip : &af_signaling_ip6,
1037
+               &port_to, &flow_protocol,
1027 1038
                &raw_stream,
1028 1039
                &raw_stream, DLG_MOBILE_REGISTER, AVP_EPC_Flow_Usage_AF_Signaling);
1029 1040
 
... ...
@@ -68,6 +68,10 @@ extern str regex_sdp_ip_prefix_to_maintain_in_fd;
68 68
 
69 69
 extern int include_rtcp_fd;
70 70
 
71
+extern int omit_flow_ports;
72
+extern int rs_default_bandwidth;
73
+extern int rr_default_bandwidth;
74
+
71 75
 static const int prefix_length_ipv6 = 128;
72 76
 
73 77
 /**
... ...
@@ -426,7 +430,7 @@ inline int rx_add_media_component_description_avp(AAAMessage *msg, int number, s
426 430
 		}
427 431
 
428 432
 		/*media-sub-component*/
429
-		if (dlg_direction != DLG_MOBILE_ORIGINATING) {
433
+		if (dlg_direction != DLG_MOBILE_ORIGINATING && dlg_direction != DLG_MOBILE_REGISTER) {
430 434
 				media_sub_component[media_sub_component_number] = rx_create_media_subcomponent_avp(number, transport, ipA, portA, ipB, portB, flow_usage_type);
431 435
 				if (media_sub_component[media_sub_component_number])
432 436
 					cdpb.AAAAddAVPToList(&list, media_sub_component[media_sub_component_number]);
... ...
@@ -508,6 +512,11 @@ inline int rx_add_media_component_description_avp(AAAMessage *msg, int number, s
508 512
 
509 513
 				// Get A=RS-bandwidth from SDP-Reply:
510 514
 				bandwidth = sdp_b_value(rpl_raw_payload, "RS");
515
+
516
+				if (bandwidth == 0) {
517
+					bandwidth = rs_default_bandwidth;
518
+				}
519
+
511 520
 				LM_DBG("Answer: Got bandwidth %i from b=RS-Line\n", bandwidth);
512 521
 				if (bandwidth > 0) {
513 522
 						// Add AVP
... ...
@@ -520,6 +529,11 @@ inline int rx_add_media_component_description_avp(AAAMessage *msg, int number, s
520 529
 				}
521 530
 				// Get A=RS-bandwidth from SDP-Reply:
522 531
 				bandwidth = sdp_b_value(rpl_raw_payload, "RR");
532
+
533
+				if (bandwidth == 0) {
534
+					bandwidth = rr_default_bandwidth;
535
+				}
536
+
523 537
 				LM_DBG("Answer: Got bandwidth %i from b=RR-Line\n", bandwidth);
524 538
 				if (bandwidth > 0) {
525 539
 						// Add AVP
... ...
@@ -639,10 +653,12 @@ static str from_s = {" from ", 6};
639 653
 static str to_s = {" to ", 4};
640 654
 //removed final %s - this is options which Rx 29.214 says will not be used for flow-description AVP
641 655
 static char * permit_out_with_ports = "permit out %s from %.*s %u to %.*s %u";
656
+static char * permit_out_without_ports = "permit out %s from %.*s to %.*s";
642 657
 static char * permit_out_with_any_as_dst = "permit out %s from %.*s %u to any";
643 658
 //static char * permit_out_with_any_as_src = "permit out %s from any to %.*s %u";
644 659
 //static char * permit_out_with_ports = "permit out %s from %.*s %u to %.*s %u %s";
645 660
 static char * permit_in_with_ports = "permit in %s from %.*s %u to %.*s %u";
661
+static char * permit_in_without_ports = "permit in %s from %.*s to %.*s";
646 662
 static char * permit_in_with_any_as_src = "permit in %s from any to %.*s %u";
647 663
 //static char * permit_in_with_any_as_dst = "permit in %s from %.*s %u to any";
648 664
 //static char * permit_in_with_ports = "permit in %s from %.*s %u to %.*s %u %s";
... ...
@@ -692,7 +708,7 @@ AAA_AVP *rx_create_media_subcomponent_avp(int number, str* proto,
692 708
 		char *proto_nr = 0;
693 709
 		if (proto->len == 2 && strncasecmp(proto->s,"IP", proto->len) == 0) {
694 710
 			proto_nr = "ip";
695
-		} else if (proto->len == 2 && strncasecmp(proto->s,"UDP", proto->len) == 0) {
711
+		} else if (proto->len == 3 && strncasecmp(proto->s,"UDP", proto->len) == 0) {
696 712
 			proto_nr = "17";
697 713
 		} else if (proto->len == 3 && strncasecmp(proto->s,"TCP", proto->len) == 0) {
698 714
 			proto_nr = "6";
... ...
@@ -720,9 +736,14 @@ AAA_AVP *rx_create_media_subcomponent_avp(int number, str* proto,
720 736
 				
721 737
 		/*IMS Flow descriptions*/
722 738
 		/*first flow is the receive flow*/
723
-		
724
-		len = (permit_out.len + from_s.len + to_s.len + ipB->len + ipA->len + 4 +
739
+
740
+		if (omit_flow_ports) {
741
+			len = (permit_out.len + from_s.len + to_s.len + ipB->len + ipA->len + 4 +
742
+						proto_len + 1/*nul terminator*/) * sizeof(char);
743
+		}else{
744
+			len = (permit_out.len + from_s.len + to_s.len + ipB->len + ipA->len + 4 +
725 745
 						proto_len + portA->len + portB->len + 1/*nul terminator*/) * sizeof(char);
746
+		}
726 747
 		
727 748
 		if (!flowdata_buf.s || flowdata_buflen < len) {
728 749
 				if (flowdata_buf.s)
... ...
@@ -735,10 +756,16 @@ AAA_AVP *rx_create_media_subcomponent_avp(int number, str* proto,
735 756
 				}
736 757
 				flowdata_buflen = len;
737 758
 		}
738
-		
739
-		flowdata_buf.len = snprintf(flowdata_buf.s, len, permit_out_with_ports, proto_nr,
740
-						ipA->len, ipA->s, intportA,
741
-						ipB->len, ipB->s, intportB);
759
+
760
+		if (omit_flow_ports) {
761
+			flowdata_buf.len = snprintf(flowdata_buf.s, len, permit_out_without_ports, proto_nr,
762
+							ipA->len, ipA->s,
763
+							ipB->len, ipB->s);
764
+		}else{
765
+			flowdata_buf.len = snprintf(flowdata_buf.s, len, permit_out_with_ports, proto_nr,
766
+							ipA->len, ipA->s, intportA,
767
+							ipB->len, ipB->s, intportB);
768
+		}
742 769
 		
743 770
 		flowdata_buf.len = strlen(flowdata_buf.s);
744 771
 		flow_description1 = cdpb.AAACreateAVP(AVP_IMS_Flow_Description,
... ...
@@ -748,8 +775,14 @@ AAA_AVP *rx_create_media_subcomponent_avp(int number, str* proto,
748 775
 		cdpb.AAAAddAVPToList(&list, flow_description1);
749 776
 		
750 777
 		/*second flow*/
751
-		len2 = (permit_in.len + from_s.len + to_s.len + ipB->len + ipA->len + 4 +
752
-						proto_len + portA->len + portB->len + 1/*nul terminator*/) * sizeof(char);		
778
+		if (omit_flow_ports) {
779
+			len2 = (permit_in.len + from_s.len + to_s.len + ipB->len + ipA->len + 4 +
780
+						proto_len + 1/*nul terminator*/) * sizeof(char);
781
+		}else{
782
+			len2 = (permit_in.len + from_s.len + to_s.len + ipB->len + ipA->len + 4 +
783
+						proto_len + portA->len + portB->len + 1/*nul terminator*/) * sizeof(char);
784
+		}
785
+
753 786
 		if (!flowdata_buf.s || len < len2) {
754 787
 				len = len2;
755 788
 				if (flowdata_buf.s)
... ...
@@ -762,10 +795,16 @@ AAA_AVP *rx_create_media_subcomponent_avp(int number, str* proto,
762 795
 				}
763 796
 				flowdata_buflen = len;
764 797
 		}
765
-		
766
-		flowdata_buf.len = snprintf(flowdata_buf.s, len, permit_in_with_ports, proto_nr,
767
-						ipB->len, ipB->s, intportB,
768
-						ipA->len, ipA->s, intportA);
798
+
799
+		if (omit_flow_ports) {
800
+			flowdata_buf.len = snprintf(flowdata_buf.s, len, permit_in_without_ports, proto_nr,
801
+							ipB->len, ipB->s,
802
+							ipA->len, ipA->s);
803
+		}else{
804
+			flowdata_buf.len = snprintf(flowdata_buf.s, len, permit_in_with_ports, proto_nr,
805
+							ipB->len, ipB->s, intportB,
806
+							ipA->len, ipA->s, intportA);
807
+		}
769 808
 		
770 809
 		flowdata_buf.len = strlen(flowdata_buf.s);
771 810
 		flow_description2 = cdpb.AAACreateAVP(AVP_IMS_Flow_Description,