________________________________

From: asterisk-users-boun...@lists.digium.com
[mailto:asterisk-users-boun...@lists.digium.com] On Behalf Of Matthew
Jordan
Sent: Friday, October 17, 2014 10:46 AM
To: Asterisk Users Mailing List - Non-Commercial Discussion
Subject: Re: [asterisk-users] AMI and CDR(answer)

 

 

 

On Thu, Oct 16, 2014 at 4:12 PM, Murthy Gandikota <mgandik...@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

 

 

I agree with a caveat. As I mentioned before, strftime can be used
instead of CDR(answer) for the answer time. It will be like any other
user defined variable.

-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
New to Asterisk? Join us for a live introductory webinar every Thurs:
               http://www.asterisk.org/hello

asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to