Przeglądaj źródła

sca: get cfg int parameter in wrapper functions

Daniel-Constantin Mierla 7 lat temu
rodzic
commit
3ecd1958a5

+ 39 - 11
src/modules/sca/sca.c

@@ -70,10 +70,10 @@ static int sca_mod_init(void);
 static int sca_child_init(int);
 static void sca_mod_destroy(void);
 static int sca_set_config(sca_mod *);
-static int sca_call_info_update_0_f(sip_msg_t* msg);
-static int sca_call_info_update_1_f(sip_msg_t* msg, char*);
-static int sca_call_info_update_2_f(sip_msg_t* msg, char* , char*);
-static int sca_call_info_update_3_f(sip_msg_t* msg, char* , char*, char *);
+static int sca_call_info_update_0_f(sip_msg_t* msg, char*, char*);
+static int sca_call_info_update_1_f(sip_msg_t* msg, char*, char*);
+static int sca_call_info_update_2_f(sip_msg_t* msg, char*, char*);
+static int sca_call_info_update_3_f(sip_msg_t* msg, char*, char*, char *);
 int fixup_ciu(void **, int);
 int fixup_free_ciu(void **param, int param_no);
 
@@ -418,26 +418,54 @@ void sca_mod_destroy(void)
 	sca_db_disconnect();
 }
 
-static int sca_call_info_update_0_f(sip_msg_t* msg) {
-	return sca_call_info_update(msg, NULL, NULL, NULL);
+static int sca_call_info_update_0_f(sip_msg_t* msg, char* p1, char* p2)
+{
+	return sca_call_info_update(msg, SCA_CALL_INFO_SHARED_BOTH, NULL, NULL);
 }
-static int sca_call_info_update_1_f(sip_msg_t* msg, char* p1) {
-	return sca_call_info_update(msg, p1, NULL, NULL);
+
+static int sca_call_info_update_1_f(sip_msg_t* msg, char* p1, char* p2)
+{
+	int update_mask = SCA_CALL_INFO_SHARED_BOTH;
+
+	if (get_int_fparam(&update_mask, msg, (fparam_t *) p1) < 0) {
+		LM_ERR("sca_call_info_update: argument 1: bad value "
+				"(integer expected)\n");
+		return (-1);
+	}
+
+	return sca_call_info_update(msg, update_mask, NULL, NULL);
 }
-static int sca_call_info_update_2_f(sip_msg_t* msg, char* p1, char* p2) {
+
+static int sca_call_info_update_2_f(sip_msg_t* msg, char* p1, char* p2)
+{
 	str uri_to = STR_NULL;
+	int update_mask = SCA_CALL_INFO_SHARED_BOTH;
+
+	if (get_int_fparam(&update_mask, msg, (fparam_t *) p1) < 0) {
+		LM_ERR("sca_call_info_update: argument 1: bad value "
+				"(integer expected)\n");
+		return (-1);
+	}
 	if(get_str_fparam(&uri_to, msg, (gparam_p)p2)!=0)
 	{
 		LM_ERR("unable to get value from param pvar_to\n");
 		return -1;
 	}
-	return sca_call_info_update(msg, p1, &uri_to, NULL);
+	return sca_call_info_update(msg, update_mask, &uri_to, NULL);
 }
+
 static int sca_call_info_update_3_f(sip_msg_t* msg,
 	char* p1, char* p2, char * p3)
 {
 	str uri_to = STR_NULL;
 	str uri_from = STR_NULL;
+	int update_mask = SCA_CALL_INFO_SHARED_BOTH;
+
+	if (get_int_fparam(&update_mask, msg, (fparam_t *) p1) < 0) {
+		LM_ERR("sca_call_info_update: argument 1: bad value "
+				"(integer expected)\n");
+		return (-1);
+	}
 	if(get_str_fparam(&uri_to, msg, (gparam_p)p2)!=0)
 	{
 		LM_ERR("unable to get value from param pvar_to\n");
@@ -448,7 +476,7 @@ static int sca_call_info_update_3_f(sip_msg_t* msg,
 		LM_ERR("unable to get value from param pvar_from\n");
 		return -1;
 	}
-	return sca_call_info_update(msg, p1, &uri_to, &uri_from);
+	return sca_call_info_update(msg, update_mask, &uri_to, &uri_from);
 }
 
 int fixup_ciu(void **param, int param_no)

+ 3 - 9
src/modules/sca/sca_call_info.c

@@ -1786,7 +1786,8 @@ struct sca_call_info_dispatch call_info_dispatch[] = {
 #define SCA_CALL_INFO_UPDATE_FLAG_FROM_ALLOC	(1 << 0)
 #define SCA_CALL_INFO_UPDATE_FLAG_TO_ALLOC	(1 << 1)
 
-int sca_call_info_update(sip_msg_t *msg, char *p1, str *uri_to, str *uri_from)
+int sca_call_info_update(sip_msg_t *msg, int update_mask, str *uri_to,
+		str *uri_from)
 {
 	sca_call_info call_info;
 	hdr_field_t *call_info_hdr;
@@ -1802,7 +1803,6 @@ int sca_call_info_update(sip_msg_t *msg, char *p1, str *uri_to, str *uri_from)
 	int i;
 	int method;
 	int rc = -1;
-	int update_mask = SCA_CALL_INFO_SHARED_BOTH;
 
 	method = sca_get_msg_method(msg);
 
@@ -1829,13 +1829,7 @@ int sca_call_info_update(sip_msg_t *msg, char *p1, str *uri_to, str *uri_from)
 		return (-1);
 	}
 
-	if (p1 != NULL) {
-		if (get_int_fparam(&update_mask, msg, (fparam_t *) p1) < 0) {
-			LM_ERR("sca_call_info_update: argument 1: bad value "
-					"(integer expected)\n");
-			return (-1);
-		}
-
+	if (update_mask != SCA_CALL_INFO_SHARED_BOTH) {
 		switch (update_mask) {
 		case SCA_CALL_INFO_SHARED_NONE:
 			update_mask = SCA_CALL_INFO_SHARED_BOTH;

+ 1 - 1
src/modules/sca/sca_call_info.h

@@ -59,7 +59,7 @@ typedef struct _sca_call_info sca_call_info;
 
 extern const str SCA_CALL_INFO_HEADER_STR;
 
-int sca_call_info_update(sip_msg_t *, char *, str*, str*);
+int sca_call_info_update(sip_msg_t *, int, str*, str*);
 void sca_call_info_sl_reply_cb(void *);
 void sca_call_info_ack_cb(struct cell *, int, struct tmcb_params *);