Add "registered" option to iax2 show peers
authorMark Spencer <markster@digium.com>
Wed, 16 Jul 2003 18:45:12 +0000 (18:45 +0000)
committerMark Spencer <markster@digium.com>
Wed, 16 Jul 2003 18:45:12 +0000 (18:45 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1195 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_iax2.c

index 8e9f021..3c0f3e6 100755 (executable)
@@ -2320,13 +2320,22 @@ static int iax2_show_peers(int fd, int argc, char *argv[])
 #define FORMAT "%-15.15s  %-15.15s %s  %-15.15s  %-5d%s  %-10s\n"
        struct iax2_peer *peer;
        char name[256] = "";
-       if (argc != 3)
+       int registeredonly=0;
+       if ((argc != 3) && (argc != 4))
                return RESULT_SHOWUSAGE;
+       if ((argc == 4)) {
+               if (!strcasecmp(argv[3], "registered")) {
+                       registeredonly = 1;
+               } else
+                       return RESULT_SHOWUSAGE;
+       }
        ast_pthread_mutex_lock(&peerl.lock);
        ast_cli(fd, FORMAT2, "Name/Username", "Host", "   ", "Mask", "Port", "Status");
        for (peer = peerl.peers;peer;peer = peer->next) {
                char nm[20];
                char status[20];
+               if (registeredonly && !peer->addr.sin_addr.s_addr)
+                       continue;
                if (strlen(peer->username))
                        snprintf(name, sizeof(name), "%s/%s", peer->name, peer->username);
                else