]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix CDR for supervised transfer in chan_zap and chan_sip (bug #1595)
authorRussell Bryant <russell@russellbryant.com>
Sun, 3 Oct 2004 20:22:41 +0000 (20:22 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sun, 3 Oct 2004 20:22:41 +0000 (20:22 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/v1-0@3903 65c4cc65-6c06-0410-ace0-fbb531ad65f3

cdr.c
channels/chan_sip.c
channels/chan_zap.c
include/asterisk/cdr.h

diff --git a/cdr.c b/cdr.c
index f4e97efcec337e8ec0554535e886371f1fd4500c..5a8102f300896649e5c7011259c41aa5f29f8846 100755 (executable)
--- a/cdr.c
+++ b/cdr.c
@@ -524,11 +524,16 @@ void ast_cdr_reset(struct ast_cdr *cdr, int flags)
        
 }
 
-void ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr) {
+struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr) 
+{
+       struct ast_cdr *ret;
        if (cdr) {
+               ret = cdr;
                while(cdr->next)
                        cdr = cdr->next;
                cdr->next = newcdr;
-       } else
-               ast_log(LOG_ERROR, "Can't append a CDR to NULL!\n");
+       } else {
+               ret = newcdr;
+       }
+       return ret;
 }
index 3d929c3e8f7c2929411393d3c9379187e1fb8c48..4bca746552d3d9794dcdbc9767e82f16a1c3ac61 100755 (executable)
@@ -7001,6 +7001,14 @@ static int attempt_transfer(struct sip_pvt *p1, struct sip_pvt *p2)
                ast_moh_stop(p1->owner->bridge);
                ast_moh_stop(p1->owner);
                ast_moh_stop(p2->owner);
+               if (p1->owner->cdr) {
+                       p2->owner->cdr = ast_cdr_append(p2->owner->cdr, p1->owner->cdr);
+                       p1->owner->cdr = NULL;
+               }
+               if (p1->owner->bridge->cdr) {
+                       p2->owner->cdr = ast_cdr_append(p2->owner->cdr, p1->owner->bridge->cdr);
+                       p1->owner->bridge->cdr = NULL;
+               }
                if (ast_channel_masquerade(p2->owner, p1->owner->bridge)) {
                        ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", p2->owner->name, p1->owner->bridge->name);
                        return -1;
@@ -7009,6 +7017,14 @@ static int attempt_transfer(struct sip_pvt *p1, struct sip_pvt *p2)
                ast_moh_stop(p2->owner->bridge);
                ast_moh_stop(p2->owner);
                ast_moh_stop(p1->owner);
+               if (p2->owner->cdr) {
+                       p1->owner->cdr = ast_cdr_append(p1->owner->cdr, p2->owner->cdr);
+                       p2->owner->cdr = NULL;
+               }
+               if (p2->owner->bridge->cdr) {
+                       p1->owner->cdr = ast_cdr_append(p1->owner->cdr, p2->owner->bridge->cdr);
+                       p2->owner->bridge->cdr = NULL;
+               }
                if (ast_channel_masquerade(p1->owner, p2->owner->bridge)) {
                        ast_log(LOG_WARNING, "Failed to masquerade %s into %s\n", p1->owner->name, p2->owner->bridge->name);
                        return -1;
index 925b62f44f9ab345cbf62574b63adbd4cc32fac7..cbb93f1d66a61d1043457215a03d5f3fe118af1a 100755 (executable)
@@ -2886,6 +2886,18 @@ static int attempt_transfer(struct zt_pvt *p)
                if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RINGING) {
                        ast_indicate(p->subs[SUB_REAL].owner->bridge, AST_CONTROL_RINGING);
                }
+               if (p->subs[SUB_REAL].owner->cdr) {
+                       /* Move CDR from second channel to current one */
+                       p->subs[SUB_THREEWAY].owner->cdr =
+                               ast_cdr_append(p->subs[SUB_THREEWAY].owner->cdr, p->subs[SUB_REAL].owner->cdr);
+                       p->subs[SUB_REAL].owner->cdr = NULL;
+               }
+               if (p->subs[SUB_REAL].owner->bridge->cdr) {
+                       /* Move CDR from second channel's bridge to current one */
+                       p->subs[SUB_THREEWAY].owner->cdr =
+                               ast_cdr_append(p->subs[SUB_THREEWAY].owner->cdr, p->subs[SUB_REAL].owner->bridge->cdr);
+                       p->subs[SUB_REAL].owner->bridge->cdr = NULL;
+               }
                if (ast_channel_masquerade(p->subs[SUB_THREEWAY].owner, p->subs[SUB_REAL].owner->bridge)) {
                        ast_log(LOG_WARNING, "Unable to masquerade %s as %s\n",
                                        p->subs[SUB_REAL].owner->bridge->name, p->subs[SUB_THREEWAY].owner->name);
@@ -2899,6 +2911,18 @@ static int attempt_transfer(struct zt_pvt *p)
                        ast_indicate(p->subs[SUB_THREEWAY].owner->bridge, AST_CONTROL_RINGING);
                }
                ast_moh_stop(p->subs[SUB_THREEWAY].owner->bridge);
+               if (p->subs[SUB_THREEWAY].owner->cdr) {
+                       /* Move CDR from second channel to current one */
+                       p->subs[SUB_REAL].owner->cdr = 
+                               ast_cdr_append(p->subs[SUB_REAL].owner->cdr, p->subs[SUB_THREEWAY].owner->cdr);
+                       p->subs[SUB_THREEWAY].owner->cdr = NULL;
+               }
+               if (p->subs[SUB_THREEWAY].owner->bridge->cdr) {
+                       /* Move CDR from second channel's bridge to current one */
+                       p->subs[SUB_REAL].owner->cdr = 
+                               ast_cdr_append(p->subs[SUB_REAL].owner->cdr, p->subs[SUB_THREEWAY].owner->bridge->cdr);
+                       p->subs[SUB_THREEWAY].owner->bridge->cdr = NULL;
+               }
                if (ast_channel_masquerade(p->subs[SUB_REAL].owner, p->subs[SUB_THREEWAY].owner->bridge)) {
                        ast_log(LOG_WARNING, "Unable to masquerade %s as %s\n",
                                        p->subs[SUB_THREEWAY].owner->bridge->name, p->subs[SUB_REAL].owner->name);
index 90d9433e3e213474d7855146499a9fd7ee3211e7..c274d8a815260bfc5311139e5e2d33eb2599efe7 100755 (executable)
@@ -254,6 +254,6 @@ extern char ast_default_accountcode[20];
 #define ast_cdr_add_flag(cdr, flag) ((cdr)->flags |= (flag))
 #define ast_cdr_del_flag(cdr, flag) ((cdr)->flags &= ~(flag))
 
-extern void ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
+extern struct ast_cdr *ast_cdr_append(struct ast_cdr *cdr, struct ast_cdr *newcdr);
 
 #endif /* _CDR_H */