|
@@ -804,30 +804,24 @@ found:
|
|
* Check if the parameter is a valid telephone number
|
|
* Check if the parameter is a valid telephone number
|
|
* - optional leading + followed by digits only
|
|
* - optional leading + followed by digits only
|
|
*/
|
|
*/
|
|
-int is_tel_number(sip_msg_t *msg, char *_sp, char* _s2)
|
|
|
|
|
|
+int ki_is_tel_number(sip_msg_t *msg, str *tval)
|
|
{
|
|
{
|
|
- str tval = {0, 0};
|
|
|
|
int i;
|
|
int i;
|
|
|
|
|
|
- if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0)
|
|
|
|
- {
|
|
|
|
- LM_ERR("cannot get parameter value\n");
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- if(tval.len<1)
|
|
|
|
|
|
+ if(tval==NULL || tval->len<1)
|
|
return -2;
|
|
return -2;
|
|
|
|
|
|
i = 0;
|
|
i = 0;
|
|
- if(tval.s[0]=='+') {
|
|
|
|
- if(tval.len<2)
|
|
|
|
|
|
+ if(tval->s[0]=='+') {
|
|
|
|
+ if(tval->len<2)
|
|
return -2;
|
|
return -2;
|
|
- if(tval.s[1]<'1' || tval.s[1]>'9')
|
|
|
|
|
|
+ if(tval->s[1]<'1' || tval->s[1]>'9')
|
|
return -2;
|
|
return -2;
|
|
i = 2;
|
|
i = 2;
|
|
}
|
|
}
|
|
|
|
|
|
- for(; i<tval.len; i++) {
|
|
|
|
- if(tval.s[i]<'0' || tval.s[i]>'9')
|
|
|
|
|
|
+ for(; i<tval->len; i++) {
|
|
|
|
+ if(tval->s[i]<'0' || tval->s[i]>'9')
|
|
return -2;
|
|
return -2;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -836,24 +830,35 @@ int is_tel_number(sip_msg_t *msg, char *_sp, char* _s2)
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Check if the parameter contains decimal digits only
|
|
|
|
|
|
+ * Check if the parameter is a valid telephone number
|
|
|
|
+ * - optional leading + followed by digits only
|
|
*/
|
|
*/
|
|
-int is_numeric(sip_msg_t *msg, char *_sp, char* _s2)
|
|
|
|
|
|
+int is_tel_number(sip_msg_t *msg, char *_sp, char* _s2)
|
|
{
|
|
{
|
|
str tval = {0, 0};
|
|
str tval = {0, 0};
|
|
- int i;
|
|
|
|
|
|
|
|
- if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0)
|
|
|
|
- {
|
|
|
|
|
|
+ if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
|
|
LM_ERR("cannot get parameter value\n");
|
|
LM_ERR("cannot get parameter value\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- if(tval.len<=0)
|
|
|
|
|
|
+
|
|
|
|
+ return ki_is_tel_number(msg, &tval);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Check if the parameter contains decimal digits only
|
|
|
|
+ */
|
|
|
|
+int ki_is_numeric(sip_msg_t *msg, str *tval)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ if(tval==NULL || tval->len<=0)
|
|
return -2;
|
|
return -2;
|
|
|
|
|
|
i = 0;
|
|
i = 0;
|
|
- for(; i<tval.len; i++) {
|
|
|
|
- if(tval.s[i]<'0' || tval.s[i]>'9')
|
|
|
|
|
|
+ for(; i<tval->len; i++) {
|
|
|
|
+ if(tval->s[i]<'0' || tval->s[i]>'9')
|
|
return -2;
|
|
return -2;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -862,66 +867,81 @@ int is_numeric(sip_msg_t *msg, char *_sp, char* _s2)
|
|
|
|
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Check if the parameter contains alphanumeric characters
|
|
|
|
|
|
+ * Check if the parameter contains decimal digits only
|
|
*/
|
|
*/
|
|
-int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2)
|
|
|
|
|
|
+int is_numeric(sip_msg_t *msg, char *_sp, char* _s2)
|
|
{
|
|
{
|
|
str tval = {0, 0};
|
|
str tval = {0, 0};
|
|
- int i;
|
|
|
|
|
|
|
|
if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
|
|
if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
|
|
LM_ERR("cannot get parameter value\n");
|
|
LM_ERR("cannot get parameter value\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
- if(tval.len<=0)
|
|
|
|
|
|
+
|
|
|
|
+ return ki_is_numeric(msg, &tval);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Check if the parameter contains alphanumeric characters
|
|
|
|
+ */
|
|
|
|
+int ki_is_alphanum(sip_msg_t *msg, str *tval)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+
|
|
|
|
+ if(tval==NULL || tval->len<=0)
|
|
return -2;
|
|
return -2;
|
|
|
|
|
|
i = 0;
|
|
i = 0;
|
|
- for(; i<tval.len; i++) {
|
|
|
|
- if( !((tval.s[i]>='0' && tval.s[i]<='9')
|
|
|
|
- || (tval.s[i]>='A' && tval.s[i]<='Z')
|
|
|
|
- || (tval.s[i]>='z' && tval.s[i]<='z')) )
|
|
|
|
- return -3;
|
|
|
|
|
|
+ for(; i<tval->len; i++) {
|
|
|
|
+ if( !((tval->s[i]>='0' && tval->s[i]<='9')
|
|
|
|
+ || (tval->s[i]>='A' && tval->s[i]<='Z')
|
|
|
|
+ || (tval->s[i]>='z' && tval->s[i]<='z')) )
|
|
|
|
+ return -3;
|
|
}
|
|
}
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
- * Check if the parameter contains alphanumeric characters or are part of
|
|
|
|
- * the second parameter
|
|
|
|
|
|
+ * Check if the parameter contains alphanumeric characters
|
|
*/
|
|
*/
|
|
-int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
|
|
|
|
|
|
+int ksr_is_alphanum(sip_msg_t *msg, char *_sp, char* _s2)
|
|
{
|
|
{
|
|
str tval = {0, 0};
|
|
str tval = {0, 0};
|
|
- str eset = {0, 0};
|
|
|
|
- int i;
|
|
|
|
- int j;
|
|
|
|
- int found;
|
|
|
|
|
|
|
|
if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
|
|
if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
|
|
- LM_ERR("cannot get tval parameter value\n");
|
|
|
|
- return -1;
|
|
|
|
- }
|
|
|
|
- if(fixup_get_svalue(msg, (gparam_t*)_se, &eset)!=0) {
|
|
|
|
- LM_ERR("cannot get eset parameter value\n");
|
|
|
|
|
|
+ LM_ERR("cannot get parameter value\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
|
|
- if(tval.len<=0)
|
|
|
|
|
|
+ return ki_is_alphanum(msg, &tval);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Check if the parameter contains alphanumeric characters or are part of
|
|
|
|
+ * the second parameter
|
|
|
|
+ */
|
|
|
|
+int ki_is_alphanumex(sip_msg_t *msg, str *tval, str *eset)
|
|
|
|
+{
|
|
|
|
+ int i;
|
|
|
|
+ int j;
|
|
|
|
+ int found;
|
|
|
|
+
|
|
|
|
+ if(tval==NULL || tval->len<=0)
|
|
return -2;
|
|
return -2;
|
|
|
|
|
|
i = 0;
|
|
i = 0;
|
|
- for(; i<tval.len; i++) {
|
|
|
|
- if( !((tval.s[i]>='0' && tval.s[i]<='9')
|
|
|
|
- || (tval.s[i]>='A' && tval.s[i]<='Z')
|
|
|
|
- || (tval.s[i]>='z' && tval.s[i]<='z')) ) {
|
|
|
|
- if(eset.len<=0) {
|
|
|
|
|
|
+ for(; i<tval->len; i++) {
|
|
|
|
+ if( !((tval->s[i]>='0' && tval->s[i]<='9')
|
|
|
|
+ || (tval->s[i]>='A' && tval->s[i]<='Z')
|
|
|
|
+ || (tval->s[i]>='z' && tval->s[i]<='z')) ) {
|
|
|
|
+ if(eset==NULL || eset->len<=0) {
|
|
return -3;
|
|
return -3;
|
|
}
|
|
}
|
|
found = 0;
|
|
found = 0;
|
|
- for(j=0; j<eset.len; j++) {
|
|
|
|
- if(tval.s[i]==eset.s[j]) {
|
|
|
|
|
|
+ for(j=0; j<eset->len; j++) {
|
|
|
|
+ if(tval->s[i]==eset->s[j]) {
|
|
found = 1;
|
|
found = 1;
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -934,3 +954,24 @@ int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
|
|
|
|
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Check if the parameter contains alphanumeric characters or are part of
|
|
|
|
+ * the second parameter
|
|
|
|
+ */
|
|
|
|
+int ksr_is_alphanumex(sip_msg_t *msg, char *_sp, char* _se)
|
|
|
|
+{
|
|
|
|
+ str tval = {0, 0};
|
|
|
|
+ str eset = {0, 0};
|
|
|
|
+
|
|
|
|
+ if(fixup_get_svalue(msg, (gparam_t*)_sp, &tval)!=0) {
|
|
|
|
+ LM_ERR("cannot get tval parameter value\n");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+ if(fixup_get_svalue(msg, (gparam_t*)_se, &eset)!=0) {
|
|
|
|
+ LM_ERR("cannot get eset parameter value\n");
|
|
|
|
+ return -1;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return ki_is_alphanumex(msg, &tval, &eset);
|
|
|
|
+}
|