浏览代码

crupto: replace local fixup functions with core helpers

Daniel-Constantin Mierla 1 年之前
父节点
当前提交
baa1775565
共有 1 个文件被更改,包括 2 次插入49 次删除
  1. 2 49
      src/modules/crypto/crypto_mod.c

+ 2 - 49
src/modules/crypto/crypto_mod.c

@@ -58,10 +58,8 @@ static void mod_destroy(void);
 
 static int w_crypto_aes_encrypt(
 		sip_msg_t *msg, char *inb, char *keyb, char *outb);
-static int fixup_crypto_aes_encrypt(void **param, int param_no);
 static int w_crypto_aes_decrypt(
 		sip_msg_t *msg, char *inb, char *keyb, char *outb);
-static int fixup_crypto_aes_decrypt(void **param, int param_no);
 
 static int w_crypto_nio_in(sip_msg_t *msg, char *p1, char *p2);
 static int w_crypto_nio_out(sip_msg_t *msg, char *p1, char *p2);
@@ -86,9 +84,9 @@ str _crypto_netio_key = STR_NULL;
 
 static cmd_export_t cmds[] = {
 		{"crypto_aes_encrypt", (cmd_function)w_crypto_aes_encrypt, 3,
-				fixup_crypto_aes_encrypt, 0, ANY_ROUTE},
+				fixup_spve2_pvar, fixup_free_spve2_pvar, ANY_ROUTE},
 		{"crypto_aes_decrypt", (cmd_function)w_crypto_aes_decrypt, 3,
-				fixup_crypto_aes_decrypt, 0, ANY_ROUTE},
+				fixup_spve2_pvar, fixup_free_spve2_pvar, ANY_ROUTE},
 		{"crypto_netio_in", (cmd_function)w_crypto_nio_in, 0, 0, 0, ANY_ROUTE},
 		{"crypto_netio_out", (cmd_function)w_crypto_nio_out, 0, 0, 0,
 				ANY_ROUTE},
@@ -345,28 +343,6 @@ static int w_crypto_aes_encrypt(
 	return ki_crypto_aes_encrypt_helper(msg, &ins, &keys, dst);
 }
 
-/**
- *
- */
-static int fixup_crypto_aes_encrypt(void **param, int param_no)
-{
-	if(param_no == 1 || param_no == 2) {
-		if(fixup_spve_null(param, 1) < 0)
-			return -1;
-		return 0;
-	} else if(param_no == 3) {
-		if(fixup_pvar_null(param, 1) != 0) {
-			LM_ERR("failed to fixup result pvar\n");
-			return -1;
-		}
-		if(((pv_spec_t *)(*param))->setf == NULL) {
-			LM_ERR("result pvar is not writeble\n");
-			return -1;
-		}
-	}
-	return 0;
-}
-
 /**
  *
  */
@@ -590,29 +566,6 @@ static int w_crypto_aes_decrypt(
 	return ki_crypto_aes_decrypt_helper(msg, &ins, &keys, dst);
 }
 
-/**
- *
- */
-static int fixup_crypto_aes_decrypt(void **param, int param_no)
-{
-	if(param_no == 1 || param_no == 2) {
-		if(fixup_spve_null(param, 1) < 0)
-			return -1;
-		return 0;
-	} else if(param_no == 3) {
-		if(fixup_pvar_null(param, 1) != 0) {
-			LM_ERR("failed to fixup result pvar\n");
-			return -1;
-		}
-		if(((pv_spec_t *)(*param))->setf == NULL) {
-			LM_ERR("result pvar is not writeble\n");
-			return -1;
-		}
-	}
-	return 0;
-}
-
-
 /**
  * testing function
  */