[asterisk-users] AMI and CDR(answer)

Matthew Jordan mjordan at digium.com
Fri Oct 17 12:45:54 CDT 2014


On Thu, Oct 16, 2014 at 4:12 PM, Murthy Gandikota <mgandikota at nts.net>
wrote:

>        in cdr.c
>
> void ast_cdr_reset(struct ast_cdr *cdr, struct ast_flags *_flags)
>
> {
>
>         struct ast_cdr *duplicate;
>
>         struct ast_flags flags = { 0 };
>
>
>
>         if (_flags)
>
>                 ast_copy_flags(&flags, _flags, AST_FLAGS_ALL);
>
>
>
>         for ( ; cdr ; cdr = cdr->next) {
>
>                 /* Detach if post is requested */
>
>                 if (ast_test_flag(&flags, AST_CDR_FLAG_LOCKED) ||
> !ast_test_flag(cdr, AST_CDR_FLAG_LOCKED)) {
>
>                         if (ast_test_flag(&flags, AST_CDR_FLAG_POSTED)) {
>
>                                 ast_cdr_end(cdr);
>
>                                 if ((duplicate =
> ast_cdr_dup_unique_swap(cdr))) {
>
>                                         ast_cdr_detach(duplicate);
>
>                                 }
>
>                                 ast_set_flag(cdr, AST_CDR_FLAG_POSTED);
>
>                         }
>
>
>
>                         /* enable CDR only */
>
>                         if (ast_test_flag(&flags,
> AST_CDR_FLAG_POST_ENABLE)) {
>
>                                 ast_clear_flag(cdr,
> AST_CDR_FLAG_POST_DISABLED);
>
>                                 continue;
>
>                         }
>
>
>
>                         /* clear variables */
>
>                         if (!ast_test_flag(&flags,
> AST_CDR_FLAG_KEEP_VARS)) {
>
>                                 ast_cdr_free_vars(cdr, 0);
>
>                         }
>
>
>
>                         /* Reset to initial state */
>
>                         ast_clear_flag(cdr, AST_FLAGS_ALL);
>
>                         memset(&cdr->start, 0, sizeof(cdr->start));
>
>                         memset(&cdr->end, 0, sizeof(cdr->end));
>
>                         memset(&cdr->answer, 0, sizeof(cdr->answer));
>
>                         cdr->billsec = 0;
>
>                         cdr->duration = 0;
>
>                         ast_cdr_start(cdr);
>
>                         cdr->disposition = AST_CDR_NOANSWER;
>
>                 }
>
>         }
>
> }
>
> If this line:
>
> memset(&cdr->answer, 0, sizeof(cdr->answer));
>
>
>
> is commented away, should work.
>
>
>
>
>

I don't think you need to change the Asterisk source for this (particularly
since it is supposed to be wiping the answer time there).

If you want to keep the original answer time, use a custom field in your
CDR, and set it prior to resetting:

exten => Set(CDR(orig_answer)=${CDR(answer)})
exten => ResetCDR(v)

Note the usage of 'v' to keep the custom variable that you just set.

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20141017/6adc68e6/attachment.html>


More information about the asterisk-users mailing list