Review Board 1.7.16


CDR: Add Calling and Called Subaddress fields to CDR record

Review Request #460 - Created Jan. 13, 2010 and submitted

Alec Davis
trunk
16600
Reviewers
asterisk-dev
rmudgett, tilghman
Asterisk
Trunk now supports ISDN subaddress, as disussed on asterisk-dev list - better to add fields than to try manipulating existing fields.

Only records the received string, not the 'User Specified flag' or the Odd/Even flag.

I used the following syntax to add additional mysql fields
  mysql> alter table cdr ADD (callingsubaddr varchar(80) not null);
  mysql> alter table cdr ADD (calledsubaddr varchar(80) not null);
I need to check whether 'not null' is required, as in many cases the caller wont have subaddress info.

cdr backend collector support:
yes (after user adds required 'callingsubaddr' and 'calledsubaddr' fields):
   cdr_adaptive_odbc, cdr_mysql, cdr_pgsql and cdr_tds will automatically fill in field if like name field exists in database. 
   cdr_custom requires user added field in cdr_custom.conf like ;Master.csv => "${CDR(clid)}",${CDR(callingsubaddr)}", etc

maybe (requires cdr collector supporting code):
   cdr_custom, requires optional user config flag and supporting code, IE. cdr_csv:logcallingsubaddr=yes etc.
      Has been suggested to ignore cdr_custom, as users interested in 'dnid' wouldn't seriously be using cdr_custom.
   cdr_radius, requires optional user config flag and supporting code.
      Tilghman considered cdr_radius 'adaptive support', but it has no real method for querying what was supported on the backend.
tested with trunk, with Jtec 5551234:1234 calling Asterisk 8699:8690.

dialplan code:
;Voicemail
exten => 8699,1,NoOp(NAME=${CALLERID(name)} NUM='${CALLERID(num)}' SUBADDR='${CALLERID(subaddr)}' DNID='${CALLERID(dnid)}' DNIDSUBADDR='${CALLERID(dnid-subaddr)}' RDNIS
='${CALLERID(rdnis)}')
exten => 8699,n,Answer()
exten => 8699,n,VoicemailMain

exten => h,1,Verbose(0,NAME=${CALLERID(name)} NUM='${CALLERID(num)}' SUBADDR='${CALLERID(subaddr)}' DNID='${CALLERID(dnid)}' DNIDSUBADDR='${CALLERID(dnid-subaddr)}' RDN
IS='${CALLERID(rdnis)}')

console output:
With additional debug lines in 'set_one_cid' it can be seen from the console output that callingsubaddr and calledsubaddr are set correctly.

'ast_cdr_init' is called when the channel and cdr are created, but channel variables 'callingsubaddr' and 'calledsubaddr' havn't yet been set.
'ast_cdr_update' is called early in __ast_pbx_run, where the channel variables as mentioned above have now been set, thus the cdr variables are now correctly created and visible during a call with 'core show channel DAHDI/xxxxx', and are recorded in the backend cdr database.

console output:
[Jan 20 21:34:44] WARNING[14394]: cdr.c:897 ast_cdr_init: ALEC
[Jan 20 21:34:44] WARNING[14394]: cdr.c:870 set_one_cid: callingsubaddr='<unknown>'
[Jan 20 21:34:44] WARNING[14394]: cdr.c:874 set_one_cid: calledsubaddr='<unknown>'
[Jan 20 21:34:44] WARNING[14398]: cdr.c:1087 ast_cdr_update: ALEC
[Jan 20 21:34:44] WARNING[14398]: cdr.c:870 set_one_cid: callingsubaddr='1234'
[Jan 20 21:34:44] WARNING[14398]: cdr.c:874 set_one_cid: calledsubaddr='8690'
    -- Executing [8699@incoming:1] NoOp("DAHDI/i1/45551234:1234-1", "NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''") in new stack
    -- Executing [8699@incoming:2] Answer("DAHDI/i1/45551234:1234-1", "") in new stack
    -- Accepting call from '45551234' to '8699' on channel 0/1, span 1
    -- Executing [8699@incoming:3] VoiceMailMain("DAHDI/i1/45551234:1234-1", "") in new stack
    -- <DAHDI/i1/45551234:1234-1> Playing 'vm-login.slin' (language 'en')
    -- Channel 0/1, span 1 got hangup request, cause 16
[Jan 20 21:34:55] WARNING[14398]: app_voicemail.c:9210 vm_authenticate: Couldn't read username
    -- Executing [h@incoming:1] Verbose("DAHDI/i1/45551234:1234-1", "0,NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''") in new stack
NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''
    -- Hungup 'DAHDI/i1/45551234:1234-1'


mysql table entry after above call:

mysql> select calldate,clid,src,callingsubaddr,dnid,calledsubaddr,dst,lastapp,duration from cdr where calldate > "2010-01-20" ;
+---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
| calldate            | clid     | src      | callingsubaddr | dnid | calledsubaddr | dst  | lastapp       | duration |
+---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
| 2010-01-20 21:34:44 | 45551234 | 45551234 | 1234           | 8699 | 8690          | 8699 | VoiceMailMain |       11 |
+---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
1 row in set (0.00 sec)
Review request changed
Updated (Jan. 19, 2010, 9:08 p.m.)
  • tested with trunk, with Jtec 5551234:1234 calling Asterisk 8699:8690.
    
    dialplan code:
    ;Voicemail
    exten => 8699,1,NoOp(NAME=${CALLERID(name)} NUM='${CALLERID(num)}' SUBADDR='${CALLERID(subaddr)}' DNID='${CALLERID(dnid)}' DNIDSUBADDR='${CALLERID(dnid-subaddr)}' RDNIS
    ='${CALLERID(rdnis)}')
    exten => 8699,n,Answer()
    exten => 8699,n,VoicemailMain
    
    exten => h,1,Verbose(0,NAME=${CALLERID(name)} NUM='${CALLERID(num)}' SUBADDR='${CALLERID(subaddr)}' DNID='${CALLERID(dnid)}' DNIDSUBADDR='${CALLERID(dnid-subaddr)}' RDN
    IS='${CALLERID(rdnis)}')
    
    console output:
    With debug lines in 'set_one_cid' it can be seen from the console output that callingsubaddr and calledsubaddr are now set correctly, this required the ast_cdr_update in sig_pri.c
    
    
    console output: after ast_cdr_update change in sig_pri, also forced update in dialplan removed.
    [Jan 19 00:50:08] WARNING[23332]: cdr.c:868 set_one_cid: dnid='<unknown>'
    [Jan 19 00:50:08] WARNING[23332]: cdr.c:871 set_one_cid: callingsubaddr='<unknown>'
    [Jan 19 00:50:08] WARNING[23332]: cdr.c:875 set_one_cid: calledsubaddr='<unknown>'
        -- Executing [8699@incoming:1] NoOp("DAHDI/i1/45551234:1234-3", "NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''") in new stack
        -- Executing [8699@incoming:2] Answer("DAHDI/i1/455551234:1234-3", "") in new stack
        -- Accepting call from '45551234' to '8699' on channel 0/8, span 1
    [Jan 19 00:50:08] WARNING[23332]: cdr.c:868 set_one_cid: dnid='8699'
    [Jan 19 00:50:08] WARNING[23332]: cdr.c:871 set_one_cid: callingsubaddr='1234'
    [Jan 19 00:50:08] WARNING[23332]: cdr.c:875 set_one_cid: calledsubaddr='8690'
        -- Executing [8699@incoming:3] VoiceMailMain("DAHDI/i1/45551234:1234-3", "") in new stack
        -- <DAHDI/i1/45551234:1234-3> Playing 'vm-login.slin' (language 'en')
        -- Channel 0/8, span 1 got hangup request, cause 16
    [Jan 19 00:50:11] WARNING[23349]: app_voicemail.c:9210 vm_authenticate: Couldn't read username
        -- Executing [h@incoming:1] Verbose("DAHDI/i1/45551234:1234-3", "0,NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''") in new stack
    NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''
        -- Hungup 'DAHDI/i1/45551234:1234-3'
    
    
    mysql table entry after above call:
    
    mysql> select calldate,clid,src,callingsubaddr,dnid,calledsubaddr,dst,lastapp,duration from cdr where calldate > "2010-01-19 00:57" ;
    +---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
    | calldate            | clid     | src      | callingsubaddr | dnid | calledsubaddr | dst  | lastapp       | duration |
    +---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
    | 2010-01-19 00:57:28 | 45551234 | 45551234 | 1234           | 8699 | 8690          | 8699 | VoiceMailMain |        3 |
    +---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
    1 row in set (0.01 sec)
    
    
    

    tested with trunk, with Jtec 5551234:1234 calling Asterisk 8699:8690.
    
    dialplan code:
    ;Voicemail
    exten => 8699,1,NoOp(NAME=${CALLERID(name)} NUM='${CALLERID(num)}' SUBADDR='${CALLERID(subaddr)}' DNID='${CALLERID(dnid)}' DNIDSUBADDR='${CALLERID(dnid-subaddr)}' RDNIS
    ='${CALLERID(rdnis)}')
    exten => 8699,n,Answer()
    exten => 8699,n,VoicemailMain
    
    exten => h,1,Verbose(0,NAME=${CALLERID(name)} NUM='${CALLERID(num)}' SUBADDR='${CALLERID(subaddr)}' DNID='${CALLERID(dnid)}' DNIDSUBADDR='${CALLERID(dnid-subaddr)}' RDN
    IS='${CALLERID(rdnis)}')
    
    console output:
    With additional debug lines in 'set_one_cid' it can be seen from the console output that callingsubaddr and calledsubaddr are set correctly.
    
    'ast_cdr_init' is called when the channel and cdr are created, but channel variables 'callingsubaddr' and 'calledsubaddr' havn't yet been set.
    'ast_cdr_update' is called early in __ast_pbx_run, where the channel variables as mentioned above have now been set, thus the cdr variables are now correctly created and visible during a call with 'core show channel DAHDI/xxxxx', and are recorded in the backend cdr database.
    
    console output:
    [Jan 20 21:34:44] WARNING[14394]: cdr.c:897 ast_cdr_init: ALEC
    [Jan 20 21:34:44] WARNING[14394]: cdr.c:870 set_one_cid: callingsubaddr='<unknown>'
    [Jan 20 21:34:44] WARNING[14394]: cdr.c:874 set_one_cid: calledsubaddr='<unknown>'
    [Jan 20 21:34:44] WARNING[14398]: cdr.c:1087 ast_cdr_update: ALEC
    [Jan 20 21:34:44] WARNING[14398]: cdr.c:870 set_one_cid: callingsubaddr='1234'
    [Jan 20 21:34:44] WARNING[14398]: cdr.c:874 set_one_cid: calledsubaddr='8690'
        -- Executing [8699@incoming:1] NoOp("DAHDI/i1/45551234:1234-1", "NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''") in new stack
        -- Executing [8699@incoming:2] Answer("DAHDI/i1/45551234:1234-1", "") in new stack
        -- Accepting call from '45551234' to '8699' on channel 0/1, span 1
        -- Executing [8699@incoming:3] VoiceMailMain("DAHDI/i1/45551234:1234-1", "") in new stack
        -- <DAHDI/i1/45551234:1234-1> Playing 'vm-login.slin' (language 'en')
        -- Channel 0/1, span 1 got hangup request, cause 16
    [Jan 20 21:34:55] WARNING[14398]: app_voicemail.c:9210 vm_authenticate: Couldn't read username
        -- Executing [h@incoming:1] Verbose("DAHDI/i1/45551234:1234-1", "0,NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''") in new stack
    NAME= NUM='45551234' SUBADDR='1234' DNID='8699' DNIDSUBADDR='8690' RDNIS=''
        -- Hungup 'DAHDI/i1/45551234:1234-1'
    
    
    mysql table entry after above call:
    
    mysql> select calldate,clid,src,callingsubaddr,dnid,calledsubaddr,dst,lastapp,duration from cdr where calldate > "2010-01-20" ;
    +---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
    | calldate            | clid     | src      | callingsubaddr | dnid | calledsubaddr | dst  | lastapp       | duration |
    +---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
    | 2010-01-20 21:34:44 | 45551234 | 45551234 | 1234           | 8699 | 8690          | 8699 | VoiceMailMain |       11 |
    +---------------------+----------+----------+----------------+------+---------------+------+---------------+----------+
    1 row in set (0.00 sec)
    
Updated to reflect changes due to commit 241416, which reverts ast_cdr_update additions in sig_pri.c, and addition of the early ast_cdr_update() in pbx.c:__ast_pbx_run

Ready to ship.
Ship it!
Posted (Jan. 20, 2010, 4:06 a.m.)
I don't have anything more to add to this.

https://reviewboard.asterisk.org/ runs on a server provided by Digium, Inc. and uses bandwidth donated to the open source Asterisk community by API Digital Communications in Huntsville, AL USA.
Please report problems with this site to asteriskteam@digium.com.