Module: kamailio
Branch: master
Commit: 675f2d6eef14bc77e82fc9677208a7f507236f33
URL:
https://github.com/kamailio/kamailio/commit/675f2d6eef14bc77e82fc9677208a7f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-07-02T21:51:26+02:00
phonenum: added ccname attribute
- get code for country name
- GH #1576
---
Modified: src/modules/phonenum/cphonenumber.cpp
Modified: src/modules/phonenum/cphonenumber.h
Modified: src/modules/phonenum/phonenum_pv.c
---
Diff:
https://github.com/kamailio/kamailio/commit/675f2d6eef14bc77e82fc9677208a7f…
Patch:
https://github.com/kamailio/kamailio/commit/675f2d6eef14bc77e82fc9677208a7f…
---
diff --git a/src/modules/phonenum/cphonenumber.cpp
b/src/modules/phonenum/cphonenumber.cpp
index b723543f55..60f5039c88 100644
--- a/src/modules/phonenum/cphonenumber.cpp
+++ b/src/modules/phonenum/cphonenumber.cpp
@@ -138,6 +138,7 @@ telnum_t* telnum_parse(char* number, char* region)
string regionCode;
_phoneUtil.GetRegionCodeForNumber(parsedNumber, ®ionCode);
res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
+ res->ccname = strdup(regionCode.c_str());
return res;
}
@@ -154,6 +155,7 @@ telnum_t* telnum_new(char* number)
tn->normalized = NULL;
tn->ltype = NULL;
tn->ndesc = NULL;
+ tn->ccname = NULL;
tn->error = NULL;
return tn;
}
@@ -178,5 +180,8 @@ void telnum_free(telnum_t* tn)
if (tn->ndesc) {
free(tn->ndesc);
}
+ if (tn->ccname) {
+ free(tn->ccname);
+ }
free(tn);
}
diff --git a/src/modules/phonenum/cphonenumber.h b/src/modules/phonenum/cphonenumber.h
index 7ac06ab1da..ab73b938fd 100644
--- a/src/modules/phonenum/cphonenumber.h
+++ b/src/modules/phonenum/cphonenumber.h
@@ -34,6 +34,7 @@ typedef struct telnum {
char* normalized;
char* ltype;
char* ndesc;
+ char* ccname;
char* error;
int cctel;
int valid;
diff --git a/src/modules/phonenum/phonenum_pv.c b/src/modules/phonenum/phonenum_pv.c
index 31f60a6428..a34382239a 100644
--- a/src/modules/phonenum/phonenum_pv.c
+++ b/src/modules/phonenum/phonenum_pv.c
@@ -181,6 +181,8 @@ int pv_parse_phonenum_name(pv_spec_p sp, str *in)
case 6:
if(strncmp(pvs.s, "number", 6) == 0)
gpv->type = 0;
+ else if(strncmp(pvs.s, "ccname", 6) == 0)
+ gpv->type = 7;
else
goto error;
break;
@@ -255,6 +257,10 @@ int pv_get_phonenum(struct sip_msg *msg, pv_param_t *param,
pv_value_t *res)
return pv_get_sintval(msg, param, res, gpv->item->r.record->cctel);
case 6: /* valid */
return pv_get_sintval(msg, param, res, gpv->item->r.record->valid);
+ case 7: /* ccname */
+ if(gpv->item->r.record->ccname==NULL)
+ return pv_get_null(msg, param, res);
+ return pv_get_strzval(msg, param, res, gpv->item->r.record->ccname);
default: /* number */
if(gpv->item->r.record->number==NULL)
return pv_get_null(msg, param, res);