Currently you have the following information available when using `phonenum_match(num, pvc)` from the `phonenum` module:
* number - phone number that is matched
* valid - 1 if the matched number has a valid result; 0 otherwise
* normalized - normalized phone number
* cctel - country code for phone number
* ltype - local network type
* ndesc - phone number description
* error - error string if phone number matching fails.
It would be useful to have access also to the `cc` information.
Right now, `cctel` outputs the country code (digits) for the number.
Example:
+34123456789 --> cctel = 34
The enhancement would be to add the country code (string) for the number (maybe in the `cc` position?):
+34123456789 --> cc = ES
Having a look at the phonenum module code (`cphonenumber.cpp`), I understand (with my very little idea of C) that country code (string) information is in fact used to get the country code (digits). So I think it would be only a matter of returning one more key:value:
https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphon…
```
string regionCode;
_phoneUtil.GetRegionCodeForNumber(parsedNumber, ®ionCode);
res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
```
Something like (pseudocode, this obviously doesn't work but gives the idea):
```
string regionCode;
_phoneUtil.GetRegionCodeForNumber(parsedNumber, ®ionCode);
res->cctel = _phoneUtil.GetCountryCodeForRegion(regionCode);
res->cc = regionCode;
```
So then later in kamailio you can do for example:
```xlog("L_INFO", "Call from $phn(src=>cc) to $phn(dst=>cc)\n");```
I have also seen that a function to provide this info exists in the module level, but I haven't seen it used anywhere else but the declaration:
https://github.com/kamailio/kamailio/blob/master/src/modules/phonenum/cphon…
This feels like a really easy change and I tried to do it myself, but I didn't manage to get through the complete path from "getting the info" to "making it available in the pvc" so here I am asking for help.
Thanks!
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/1576
Module: kamailio
Branch: master
Commit: b87b65237401420328b2afccdec69f45f1ada826
URL: https://github.com/kamailio/kamailio/commit/b87b65237401420328b2afccdec69f4…
Author: Kamailio Dev <kamailio.dev(a)kamailio.org>
Committer: Kamailio Dev <kamailio.dev(a)kamailio.org>
Date: 2018-07-03T15:01:37+02:00
modules: readme files regenerated - benchmark ... [skip ci]
---
Modified: src/modules/benchmark/README
---
Diff: https://github.com/kamailio/kamailio/commit/b87b65237401420328b2afccdec69f4…
Patch: https://github.com/kamailio/kamailio/commit/b87b65237401420328b2afccdec69f4…
---
diff --git a/src/modules/benchmark/README b/src/modules/benchmark/README
index c69987a9af..425324d110 100644
--- a/src/modules/benchmark/README
+++ b/src/modules/benchmark/README
@@ -52,6 +52,8 @@ Bastian Friedrich
6.2. benchmark.enable_timer
6.3. benchmark.granularity
6.4. benchmark.loglevel
+ 6.5. benchmark.timer_list
+ 6.6. benchmark.timer_name_list
7. Example of usage
@@ -74,7 +76,9 @@ Bastian Friedrich
1.5. bm_start_timer usage
1.6. bm_log_timer usage
1.7. Enabling a timer
- 1.8. benchmark usage
+ 1.8. List all timers
+ 1.9. List one timer
+ 1.10. benchmark usage
2.1. Using the benchmark module's API from another module
Chapter 1. Admin Guide
@@ -109,6 +113,8 @@ Chapter 1. Admin Guide
6.2. benchmark.enable_timer
6.3. benchmark.granularity
6.4. benchmark.loglevel
+ 6.5. benchmark.timer_list
+ 6.6. benchmark.timer_name_list
7. Example of usage
@@ -276,6 +282,8 @@ bm_log_timer("test");
6.2. benchmark.enable_timer
6.3. benchmark.granularity
6.4. benchmark.loglevel
+ 6.5. benchmark.timer_list
+ 6.6. benchmark.timer_name_list
6.1. benchmark.enable_global
@@ -300,11 +308,80 @@ kamcmd benchmark.enable_timer test 1
Modifies the module log level. See "loglevel" variable.
+6.5. benchmark.timer_list
+
+ List data for all timers (Last complete period and global data)
+ Displays info close to the one output in the log by using a RPC
+ structure. period_sum, period_min and period_media show data for last
+ granularity period already completed.
+
+ Example 1.8. List all timers
+...
+kamcmd benchmark.timer_list
+{
+ name: test
+ state: enabled
+ id: 0
+ granularity: 2
+ period_sum: 69
+ period_min: 22
+ period_max: 47
+ period_media: 34.500000
+ calls: 4
+ sum: 217
+ global_min: 22
+ global_max: 88
+ global_media: 54.250000
+}
+{
+ name: test2
+ state: enabled
+ id: 1
+ granularity: 2
+ period_sum: 122
+ period_min: 25
+ period_max: 97
+ period_media: 61.000000
+ calls: 4
+ sum: 349
+ global_min: 25
+ global_max: 151
+ global_media: 87.250000
+}
+...
+
+6.6. benchmark.timer_name_list
+
+ List data for one timer based on its name (Last complete period and
+ global data) It displays info close to the one output in the log by
+ using a RPC structure. period_sum, period_min and period_media show
+ data for last granularity period already completed.
+
+ Example 1.9. List one timer
+...
+kamcmd benchmark.timer_name_list test
+{
+ name: test
+ state: enabled
+ id: 0
+ granularity: 2
+ period_sum: 69
+ period_min: 22
+ period_max: 47
+ period_media: 34.500000
+ calls: 4
+ sum: 217
+ global_min: 22
+ global_max: 88
+ global_media: 54.250000
+}
+...
+
7. Example of usage
Measure the duration of user location lookup.
- Example 1.8. benchmark usage
+ Example 1.10. benchmark usage
...
bm_start_timer("usrloc-lookup");
lookup("location");
Added an allocator function to allocate the hash in shared memory.
Added also locking stuff
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [X] Commit message has the format required by CONTRIBUTING guide
- [X] Commits are split per component (core, individual modules, libs, utils, ...)
- [X] Each component has a single commit (if not, squash them into one commit)
- [X] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [X] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [X] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
Added a new allocator function to str_hash.h. This new function allows to allocate the hash table in shared memory.
Changes to struct str_hash_table:
- Added a gen_lock_set_t (locks) to hold the lock set
- Added an int (locks_no) to hold the number of locks
- Added an indicator (memory) to know if the table was allocated in private memory (p) or shared memory(s)
Changes to struct str_hash_head:
- Added an int(lock_idx) that hold the index of the lock when the head is locked.
Changes to struct str_hash_entry:
- Added a pointer to the head the entry belongs to. This allows to unlock the head when needed.
Added functions to lock and unlock the head when needed.
Modified functions str_hash_add and str_hash_get to lock the head when needed
Added function str_hash_destroy to remove the hash table and all its contents from memory.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1535
-- Commit Summary --
* str_hash: Option to allocate hash in shm
-- File Changes --
M src/core/str_hash.h (100)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1535.patchhttps://github.com/kamailio/kamailio/pull/1535.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1535
<!-- Kamailio Pull Request Template -->
<!--
IMPORTANT:
- for detailed contributing guidelines, read:
https://github.com/kamailio/kamailio/blob/master/.github/CONTRIBUTING.md
- pull requests must be done to master branch, unless they are backports
of fixes from master branch to a stable branch
- backports to stable branches must be done with 'git cherry-pick -x ...'
- code is contributed under BSD for core and main components (tm, sl, auth, tls)
- code is contributed GPLv2 or a compatible license for the other components
- GPL code is contributed with OpenSSL licensing exception
-->
#### Pre-Submission Checklist
<!-- Go over all points below, and after creating the PR, tick all the checkboxes that apply -->
<!-- All points should be verified, otherwise, read the CONTRIBUTING guidelines from above-->
<!-- If you're unsure about any of these, don't hesitate to ask on sr-dev mailing list -->
- [x] Commit message has the format required by CONTRIBUTING guide
- [x] Commits are split per component (core, individual modules, libs, utils, ...)
- [x] Each component has a single commit (if not, squash them into one commit)
- [x] No commits to README files for modules (changes must be done to docbook files
in `doc/` subfolder, the README file is autogenerated)
#### Type Of Change
- [ ] Small bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)
#### Checklist:
<!-- Go over all points below, and after creating the PR, tick the checkboxes that apply -->
- [ ] PR should be backported to stable branches
- [x] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)
#### Description
<!-- Describe your changes in detail -->
Added two RPC functions to benchmark module:
timer_list and timer_name_list
timer_list shows info for every timer (last complete period and global data)
timer_name_list shows same info as timer_list but for a timer selected by its name.
You can view, comment on, or merge this pull request online at:
https://github.com/kamailio/kamailio/pull/1580
-- Commit Summary --
* benchmark: RPC commands timer_list and timer_name_list
* benchmark: documentation for RPC functions timer_list and timer_name_list
-- File Changes --
M src/modules/benchmark/benchmark.c (185)
M src/modules/benchmark/benchmark.h (3)
M src/modules/benchmark/doc/benchmark_admin.xml (80)
-- Patch Links --
https://github.com/kamailio/kamailio/pull/1580.patchhttps://github.com/kamailio/kamailio/pull/1580.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/1580