Make "dahdi show channels" show an outgoing called number.
authorRichard Mudgett <rmudgett@digium.com>
Fri, 23 Jul 2010 19:53:03 +0000 (19:53 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 23 Jul 2010 19:53:03 +0000 (19:53 +0000)
The "dahdi show channels" extension column previously only showed the
called number of an incoming call.  It now shows the called number for an
outgoing call as well.

(closes issue #17653)
Reported by: amazinzay
Patches:
      issue17653_trunk.txt uploaded by rmudgett (license 664)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@279156 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c

index 0e64fac..372af0f 100644 (file)
@@ -5099,11 +5099,41 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
 {
        struct dahdi_pvt *p = ast->tech_pvt;
        int x, res, mysig;
-       char dest[256]; /* must be same length as p->dialdest */
+       char *dest;
+       AST_DECLARE_APP_ARGS(args,
+               AST_APP_ARG(group);     /* channel/group token */
+               AST_APP_ARG(ext);       /* extension token */
+               //AST_APP_ARG(opts);    /* options token */
+               AST_APP_ARG(other);     /* Any remining unused arguments */
+       );
 
        ast_mutex_lock(&p->lock);
-       ast_copy_string(dest, rdest, sizeof(dest));
        ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
+
+       /* Split the dialstring */
+       dest = ast_strdupa(rdest);
+       AST_NONSTANDARD_APP_ARGS(args, dest, '/');
+       if (!args.ext) {
+               args.ext = "";
+       }
+
+#if defined(HAVE_PRI)
+       if (dahdi_sig_pri_lib_handles(p->sig)) {
+               char *subaddr;
+
+               sig_pri_extract_called_num_subaddr(p->sig_pvt, rdest, p->exten, sizeof(p->exten));
+
+               /* Remove any subaddress for uniformity with incoming calls. */
+               subaddr = strchr(p->exten, ':');
+               if (subaddr) {
+                       *subaddr = '\0';
+               }
+       } else
+#endif /* defined(HAVE_PRI) */
+       {
+               ast_copy_string(p->exten, args.ext, sizeof(p->exten));
+       }
+
        if ((ast->_state == AST_STATE_BUSY)) {
                p->subs[SUB_REAL].needbusy = 1;
                ast_mutex_unlock(&p->lock);
@@ -5183,12 +5213,7 @@ static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
                /* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
                p->dialdest[0] = '\0';
 
-               c = strchr(dest, '/');
-               if (c) {
-                       c++;
-               } else {
-                       c = "";
-               }
+               c = args.ext;
                if (!p->hidecallerid) {
                        l = ast->caller.id.number.valid ? ast->caller.id.number.str : NULL;
                } else {