Browse code

pv: config function to shift xavps to left with rotation

Daniel-Constantin Mierla authored on 10/05/2022 17:35:52
Showing 1 changed files
... ...
@@ -608,6 +608,8 @@ static int w_xavi_child_sets(sip_msg_t *msg, char *prname, char *pcname,
608 608
 static int w_xavi_rm(sip_msg_t *msg, char *prname, char *p2);
609 609
 static int w_xavi_child_rm(sip_msg_t *msg, char *prname, char *pcname);
610 610
 
611
+static int w_xavp_lshift(sip_msg_t *msg, char *pxname, char *pidx);
612
+
611 613
 int pv_xavp_copy_fixup(void** param, int param_no);
612 614
 int pv_evalx_fixup(void** param, int param_no);
613 615
 int w_pv_evalx(struct sip_msg *msg, char *dst, str *fmt);
... ...
@@ -684,6 +686,9 @@ static cmd_export_t cmds[]={
684 686
 	{"xavi_child_rm", (cmd_function)w_xavi_child_rm,
685 687
 		2, fixup_spve_spve, fixup_free_spve_spve,
686 688
 		ANY_ROUTE},
689
+	{"xavp_lshift", (cmd_function)w_xavp_lshift,
690
+		2, fixup_spve_igp, fixup_free_spve_igp,
691
+		ANY_ROUTE},
687 692
 	{"sbranch_set_ruri",  (cmd_function)w_sbranch_set_ruri,  0, 0, 0,
688 693
 		ANY_ROUTE },
689 694
 	{"sbranch_append",    (cmd_function)w_sbranch_append,    0, 0, 0,
... ...
@@ -904,6 +909,38 @@ static int ki_xavp_print(sip_msg_t* msg)
904 909
 	return 1;
905 910
 }
906 911
 
912
+/**
913
+ *
914
+ */
915
+static int ki_xavp_lshift(sip_msg_t *msg, str *xname, int idx)
916
+{
917
+	int ret;
918
+
919
+	ret = xavp_lshift(xname, NULL, idx);
920
+
921
+	return (ret==0)?1:ret;
922
+}
923
+
924
+/**
925
+ *
926
+ */
927
+static int w_xavp_lshift(sip_msg_t *msg, char *pxname, char *pidx)
928
+{
929
+	str xname = STR_NULL;
930
+	int idx = 0;
931
+
932
+	if(fixup_get_svalue(msg, (gparam_t*)pxname, &xname)<0) {
933
+		LM_ERR("failed to get the xavp name\n");
934
+		return -1;
935
+	}
936
+	if(fixup_get_svalue(msg, (gparam_t*)pidx, &idx)<0) {
937
+		LM_ERR("failed to get the xavp index\n");
938
+		return -1;
939
+	}
940
+
941
+	return ki_xavp_lshift(msg, &xname, idx);
942
+}
943
+
907 944
 static int ki_xavu_print(sip_msg_t* msg)
908 945
 {
909 946
 	xavu_print_list(NULL);
... ...
@@ -3173,6 +3210,11 @@ static sr_kemi_t sr_kemi_pvx_exports[] = {
3173 3210
 		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_STR,
3174 3211
 			SR_KEMIP_INT, SR_KEMIP_NONE, SR_KEMIP_NONE }
3175 3212
 	},
3213
+	{ str_init("pvx"), str_init("xavp_lshift"),
3214
+		SR_KEMIP_INT, ki_xavp_lshift,
3215
+		{ SR_KEMIP_STR, SR_KEMIP_INT, SR_KEMIP_NONE,
3216
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
3217
+	},
3176 3218
 
3177 3219
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
3178 3220
 };