Module: kamailio
Branch: master
Commit: 64ae9ed7212c1db352ab583b8d319358da23775f
URL:
https://github.com/kamailio/kamailio/commit/64ae9ed7212c1db352ab583b8d31935…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-06-10T14:05:41+02:00
siputils: removed duplicated function for e164 check
---
Modified: src/modules/siputils/checks.c
Modified: src/modules/siputils/checks.h
Modified: src/modules/siputils/rpid.c
Modified: src/modules/siputils/siputils.c
---
Diff:
https://github.com/kamailio/kamailio/commit/64ae9ed7212c1db352ab583b8d31935…
Patch:
https://github.com/kamailio/kamailio/commit/64ae9ed7212c1db352ab583b8d31935…
---
diff --git a/src/modules/siputils/checks.c b/src/modules/siputils/checks.c
index 3e01eb97829..792cfca94aa 100644
--- a/src/modules/siputils/checks.c
+++ b/src/modules/siputils/checks.c
@@ -656,7 +656,7 @@ int tel2sip(struct sip_msg* _msg, char* _uri, char* _hostpart, char*
_res)
/*
* Check if parameter is an e164 number.
*/
-static inline int e164_check(str* _user)
+int siputils_e164_check(str* _user)
{
int i;
char c;
@@ -675,7 +675,7 @@ static inline int e164_check(str* _user)
/*
* Check if user part of URI in pseudo variable is an e164 number
*/
-int is_e164(struct sip_msg* _m, char* _sp, char* _s2)
+int w_is_e164(struct sip_msg* _m, char* _sp, char* _s2)
{
pv_spec_t *sp;
pv_value_t pv_val;
@@ -688,7 +688,7 @@ int is_e164(struct sip_msg* _m, char* _sp, char* _s2)
LM_DBG("missing argument\n");
return -1;
}
- return e164_check(&(pv_val.rs));
+ return siputils_e164_check(&(pv_val.rs));
} else {
LM_ERR("pseudo variable value is not string\n");
return -1;
@@ -743,7 +743,7 @@ int is_uri_user_e164(str *uri)
if (chr == NULL) return -1;
user.len = chr - user.s;
- return e164_check(&user);
+ return siputils_e164_check(&user);
}
/*
diff --git a/src/modules/siputils/checks.h b/src/modules/siputils/checks.h
index 2a05bdd53d8..164f086f26e 100644
--- a/src/modules/siputils/checks.h
+++ b/src/modules/siputils/checks.h
@@ -89,7 +89,9 @@ int is_uri_user_e164(str *uri);
/*
* Check if pseudo variable argument value is an e164 number
*/
-int is_e164(struct sip_msg* _m, char* _sp, char* _s2);
+int w_is_e164(struct sip_msg* _m, char* _sp, char* _s2);
+
+int siputils_e164_check(str* _user);
/*
* Set userpart of URI
diff --git a/src/modules/siputils/rpid.c b/src/modules/siputils/rpid.c
index 617f3d4220a..c725116034c 100644
--- a/src/modules/siputils/rpid.c
+++ b/src/modules/siputils/rpid.c
@@ -37,6 +37,7 @@
#include "../../core/parser/parser_f.h"
#include "../../core/ut.h"
#include "../../core/pvar.h"
+#include "checks.h"
#include "rpid.h"
@@ -95,29 +96,6 @@ void get_rpid_avp( int_str *rpid_avp_p, int *rpid_avp_type_p )
}
-/*!
- * \brief Check if user is a E164 number
- * \param _user user
- * \note Copy of is_e164 from enum module
- * \return 1 if its a E164 number, -1 if not
- */
-static inline int is_e164(str* _user)
-{
- int i;
- char c;
-
- if ((_user->len > 2) && (_user->len < 17) &&
((_user->s)[0] == '+')) {
- for (i = 1; i < _user->len; i++) {
- c = (_user->s)[i];
- if ((c < '0') || (c > '9')) return -1;
- }
- return 1;
- } else {
- return -1;
- }
-}
-
-
/*!
* \brief Append RPID helper function
* \param _m SIP message
@@ -325,7 +303,7 @@ int is_rpid_user_e164(struct sip_msg* _m, char* _s1, char* _s2)
goto err;
}
- return is_e164(&uri.user);
+ return siputils_e164_check(&uri.user);
err:
return -1;
diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c
index 704f3e9a299..2e7ddeb7c08 100644
--- a/src/modules/siputils/siputils.c
+++ b/src/modules/siputils/siputils.c
@@ -141,7 +141,7 @@ static cmd_export_t cmds[]={
REQUEST_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE|ONREPLY_ROUTE},
{"is_uri", (cmd_function)is_uri, 1, fixup_spve_null,
fixup_free_spve_null, ANY_ROUTE},
- {"is_e164", (cmd_function)is_e164, 1, fixup_pvar_null,
+ {"is_e164", (cmd_function)w_is_e164, 1, fixup_pvar_null,
fixup_free_pvar_null, REQUEST_ROUTE|FAILURE_ROUTE|LOCAL_ROUTE},
{"is_uri_user_e164", (cmd_function)w_is_uri_user_e164, 1, fixup_pvar_null,
fixup_free_pvar_null, ANY_ROUTE},