Răsfoiți Sursa

ims_ipsec_pcscf: use core fixup helper functions

- remove unused parameter for w_destroy_by_contact()
Daniel-Constantin Mierla 1 an în urmă
părinte
comite
0a6e742e7d
1 a modificat fișierele cu 14 adăugiri și 36 ștergeri
  1. 14 36
      src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c

+ 14 - 36
src/modules/ims_ipsec_pcscf/ims_ipsec_pcscf_mod.c

@@ -59,7 +59,7 @@ static int w_create(struct sip_msg *_m, char *_d, char *_cflags);
 static int w_forward(struct sip_msg *_m, char *_d, char *_cflags);
 static int w_forward(struct sip_msg *_m, char *_d, char *_cflags);
 static int w_destroy(struct sip_msg *_m, char *_d, char *_aor);
 static int w_destroy(struct sip_msg *_m, char *_d, char *_aor);
 static int w_destroy_by_contact(struct sip_msg *_m, char *_d, char *_aor,
 static int w_destroy_by_contact(struct sip_msg *_m, char *_d, char *_aor,
-		char *_received_host, char *_received_port, char *_cflags);
+		char *_received_host, char *_received_port);
 
 
 /*! \brief Fixup functions */
 /*! \brief Fixup functions */
 static int domain_fixup(void **param, int param_no);
 static int domain_fixup(void **param, int param_no);
@@ -90,7 +90,8 @@ static cmd_export_t cmds[] = {
 		0, REQUEST_ROUTE | ONREPLY_ROUTE },
 		0, REQUEST_ROUTE | ONREPLY_ROUTE },
 	{"ipsec_destroy", (cmd_function)w_destroy, 2, unregister_fixup,
 	{"ipsec_destroy", (cmd_function)w_destroy, 2, unregister_fixup,
 		0, ANY_ROUTE },
 		0, ANY_ROUTE },
-	{"ipsec_destroy_by_contact", (cmd_function)w_destroy_by_contact, 4, unregister2_fixup, 0, ANY_ROUTE},
+	{"ipsec_destroy_by_contact", (cmd_function)w_destroy_by_contact, 4,
+		unregister2_fixup, 0, ANY_ROUTE},
 	{"bind_ims_ipsec_pcscf", (cmd_function)bind_ipsec_pcscf, 1, 0,
 	{"bind_ims_ipsec_pcscf", (cmd_function)bind_ipsec_pcscf, 1, 0,
 		0, 0},
 		0, 0},
 	{0, 0, 0, 0, 0, 0}
 	{0, 0, 0, 0, 0, 0}
@@ -474,26 +475,8 @@ static int unregister2_fixup(void **param, int param_no)
 	if(param_no == 1) {
 	if(param_no == 1) {
 		return domain_fixup(param, param_no);
 		return domain_fixup(param, param_no);
 	} else {
 	} else {
-		pv_elem_t *model = NULL;
-		str s;
-
-		/* convert to str */
-		s.s = (char *)*param;
-		s.len = strlen(s.s);
-
-		model = NULL;
-		if(s.len == 0) {
-			LM_ERR("no param!\n");
-			return E_CFG;
-		}
-		if(pv_parse_format(&s, &model) < 0 || model == NULL) {
-			LM_ERR("wrong format [%s]!\n", s.s);
-			return E_CFG;
-		}
-		*param = (void *)model;
-		return 0;
+		return fixup_spve_all(param, param_no);
 	}
 	}
-	return E_CFG;
 }
 }
 
 
 /*! \brief
 /*! \brief
@@ -532,9 +515,8 @@ static int w_destroy(struct sip_msg *_m, char *_d, char *_aor)
 }
 }
 
 
 static int w_destroy_by_contact(struct sip_msg *_m, char *_d, char *_aor,
 static int w_destroy_by_contact(struct sip_msg *_m, char *_d, char *_aor,
-		char *_received_host, char *_received_port, char *_cflags)
+		char *_received_host, char *_received_port)
 {
 {
-	pv_elem_t *model;
 	str aor;
 	str aor;
 	str received_host;
 	str received_host;
 	str received_port;
 	str received_port;
@@ -545,25 +527,21 @@ static int w_destroy_by_contact(struct sip_msg *_m, char *_d, char *_aor,
 		return -1;
 		return -1;
 	}
 	}
 
 
-	model = (pv_elem_t *)_aor;
-	if(pv_printf_s(_m, model, &aor) < 0) {
-		LM_ERR("error - cannot print the format\n");
+	if(fixup_get_svalue(_m, (gparam_t *)_aor, &aor) < 0) {
+		LM_ERR("failed to get aor parameter\n");
 		return -1;
 		return -1;
 	}
 	}
-	LM_DBG("URI: %.*s\n", aor.len, aor.s);
-
-	model = (pv_elem_t *)_received_host;
-	if(pv_printf_s(_m, model, &received_host) < 0) {
-		LM_ERR("error - cannot print the format\n");
+	if(fixup_get_svalue(_m, (gparam_t *)_received_host, &received_host) < 0) {
+		LM_ERR("failed to get received host parameter\n");
 		return -1;
 		return -1;
 	}
 	}
-	LM_DBG("Received-Host: %.*s\n", received_host.len, received_host.s);
-
-	model = (pv_elem_t *)_received_port;
-	if(pv_printf_s(_m, model, &received_port) < 0) {
-		LM_ERR("error - cannot print the format\n");
+	if(fixup_get_svalue(_m, (gparam_t *)_received_port, &received_port) < 0) {
+		LM_ERR("failed to get received host parameter\n");
 		return -1;
 		return -1;
 	}
 	}
+
+	LM_DBG("URI: %.*s\n", aor.len, aor.s);
+	LM_DBG("Received-Host: %.*s\n", received_host.len, received_host.s);
 	LM_DBG("Received-Port: %.*s\n", received_port.len, received_port.s);
 	LM_DBG("Received-Port: %.*s\n", received_port.len, received_port.s);
 	if(str2sint(&received_port, &port) != 0) {
 	if(str2sint(&received_port, &port) != 0) {
 		LM_ERR("error - cannot convert %.*s to an int!\n", received_port.len,
 		LM_ERR("error - cannot convert %.*s to an int!\n", received_port.len,