Browse code

Merge 956ba123133ff50bf34c8eb52fb82b799cabdb1f into 819ca1d7afe558d944fa88b2d453bf7ae7fcc819

Riccardo-78 authored on 11/01/2022 03:28:12 • GitHub committed on 11/01/2022 03:28:12
Showing 2 changed files
... ...
@@ -2932,6 +2932,8 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
2932 2932
 	str mop = {NULL, 0};
2933 2933
 	str mval = {NULL, 0};
2934 2934
 	str sval = {NULL, 0};
2935
+	unsigned int ival = 0;
2936
+	unsigned int mival = 0;
2935 2937
 	int n = 0;
2936 2938
 	int m = 0;
2937 2939
 	int vkey = 0;
... ...
@@ -2960,6 +2962,8 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
2960 2962
 		vkey = 2;
2961 2963
 	} else if(mkey.len==6 && strncmp(mkey.s, "callid", mkey.len)==0) {
2962 2964
 		vkey = 3;
2965
+	} else if(mkey.len==8 && strncmp(mkey.s, "start_ts", mkey.len)==0) {
2966
+		vkey = 4;
2963 2967
 	} else {
2964 2968
 		LM_ERR("invalid key %.*s\n", mkey.len, mkey.s);
2965 2969
 		rpc->fault(c, 500, "Invalid matching key parameter");
... ...
@@ -2983,6 +2987,10 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
2983 2987
 		}
2984 2988
 	} else if(strncmp(mop.s, "sw", 2)==0) {
2985 2989
 		vop = 2;
2990
+	} else if(strncmp(mop.s, "gt", 2)==0) {
2991
+		vop = 3;
2992
+	} else if(strncmp(mop.s, "lt", 2)==0) {
2993
+		vop = 4;
2986 2994
 	} else {
2987 2995
 		LM_ERR("invalid matching operator %.*s\n", mop.len, mop.s);
2988 2996
 		rpc->fault(c, 500, "Invalid matching operator parameter");
... ...
@@ -2992,6 +3000,18 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
2992 3000
 		n = 0;
2993 3001
 	}
2994 3002
 
3003
+	if (vkey == 4  && vop <= 2) {
3004
+		LM_ERR("Matching operator %.*s not supported with start_ts key\n", mop.len, mop.s);
3005
+		rpc->fault(c, 500, "Matching operator not supported with start_ts key");
3006
+		return;
3007
+	}
3008
+
3009
+	if (vkey != 4  && vop >= 3) {
3010
+		LM_ERR("Matching operator %.*s not supported with key %.*s\n", mop.len, mop.s, mkey.len, mkey.s);
3011
+		rpc->fault(c, 500, "Matching operator not supported");
3012
+		return;
3013
+	}
3014
+
2995 3015
 	for(i=0; i<d_table->size; i++) {
2996 3016
 		dlg_lock(d_table, &(d_table->entries[i]));
2997 3017
 		for(dlg=d_table->entries[i].first; dlg!=NULL; dlg=dlg->next) {
... ...
@@ -3009,6 +3029,9 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
3009 3029
 				case 3:
3010 3030
 					sval = dlg->callid;
3011 3031
 				break;
3032
+				case 4:
3033
+					ival = dlg->start_ts;
3034
+				break;
3012 3035
 			}
3013 3036
 			switch(vop) {
3014 3037
 				case 0:
... ...
@@ -3031,6 +3054,17 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
3031 3054
 						matched = 1;
3032 3055
 					}
3033 3056
 				break;
3057
+				case 3:		
3058
+					/* greater than */
3059
+					if (str2int(&mval, &mival) == 0 && ival > mival) {
3060
+						matched = 1;
3061
+					}
3062
+				break;
3063
+				case 4:
3064
+					if (str2int(&mval, &mival) == 0 && ival < mival) {
3065
+						matched = 1;
3066
+					}
3067
+				break;
3034 3068
 			}
3035 3069
 			if (matched==1) {
3036 3070
 				m++;
... ...
@@ -2500,12 +2500,16 @@ dlg_reset_property("timeout-noreset");
2500 2500
 				<emphasis>mkey</emphasis> - matching key. It can be: 'ruri' -
2501 2501
 				match against R-URI of the dialog; 'furi' - match against From
2502 2502
 				header URI of the dialog; 'turi' - match against the To header
2503
-				URI of the dialog; 'callid' - match against Call-Id value.
2503
+				URI of the dialog; 'callid' - match against Call-Id value;
2504
+				'start_ts' - match against start timestamp.
2504 2505
 			</para></listitem>
2505 2506
 			<listitem><para>
2506 2507
 				<emphasis>mop</emphasis> - matching operator. It can be: 'eq' -
2507 2508
 				match using string comparison; 're' - match using regular
2508
-				expression; 'sw' - match using starts-with (prefix) comparison.
2509
+				expression; 'sw' - match using starts-with (prefix) comparison;
2510
+				'gt' - match using integer greater comparison; 'lt' - match
2511
+				using integer lesser comparison. Integer comparison can be used
2512
+				only with 'start_ts' key.
2509 2513
 			</para></listitem>
2510 2514
 			<listitem><para>
2511 2515
 				<emphasis>mval</emphasis> - matching value.
... ...
@@ -2517,6 +2521,8 @@ dlg_reset_property("timeout-noreset");
2517 2521
 &kamcmd; dlg.list_match furi eq sip:alice@test.com 2
2518 2522
 ...
2519 2523
 &kamcmd; dlg.list_match furi sw sip:alice@
2524
+...
2525
+&kamcmd; dlg.list_match start_ts gt s:1641550904
2520 2526
 ...
2521 2527
 		</programlisting>
2522 2528
 		</section>