--- chan_iax2.c 2006-10-29 21:29:46.000000000 -0600 +++ chan_iax2.c.patch 2006-10-29 21:42:39.000000000 -0600 @@ -34,7 +34,7 @@ #include "asterisk.h" -ASTERISK_FILE_VERSION(__FILE__, "$Revision: 46475 $") +ASTERISK_FILE_VERSION(__FILE__, "$Revision: 46202 $") #include #include @@ -4052,9 +4052,10 @@ struct iax2_peer *peer = NULL; char name[256]; + char *id; int registeredonly=0; char *term = manager ? "\r\n" : "\n"; - + char idtext[256] = ""; switch (argc) { case 6: if (!strcasecmp(argv[3], "registered")) @@ -4089,11 +4090,9 @@ } - if (s) - astman_append(s, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", term); - else + if (!s) { ast_cli(fd, FORMAT2, "Name/Username", "Host", " ", "Mask", "Port", " ", "Status", term); - + } AST_LIST_LOCK(&peers); AST_LIST_TRAVERSE(&peers, peer, entry) { char nm[20]; @@ -4129,12 +4128,16 @@ peer->encmethods ? "(E)" : " ", status, term); if (s) - astman_append(s, FORMAT, name, - peer->addr.sin_addr.s_addr ? ast_inet_ntoa( peer->addr.sin_addr) : "(Unspecified)", - ast_test_flag(peer, IAX_DYNAMIC) ? "(D)" : "(S)", - nm, - ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_TRUNK) ? "(T)" : " ", - peer->encmethods ? "(E)" : " ", status, term); + astman_append(s, + "Event: PeerEntry\r\n%s" + "Channeltype: IAX2\r\n" + "ObjectName: %s\r\n" + "IPaddress: %s\r\n" + "IPport: %d\r\n" + "Dynamic: %s\r\n" + "Status: %s\r\n\r\n", + idtext, name, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "-none-", ntohs(peer->addr.sin_port), ast_test_flag(peer, IAX_DYNAMIC) ? "yes" : "no", status); + else ast_cli(fd, FORMAT, name, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(peer->addr.sin_addr) : "(Unspecified)", @@ -4146,9 +4149,7 @@ } AST_LIST_UNLOCK(&peers); - if (s) - astman_append(s,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term); - else + if (!s) ast_cli(fd,"%d iax2 peers [%d online, %d offline, %d unmonitored]%s", total_peers, online_peers, offline_peers, unmonitored_peers, term); if (havepattern) @@ -4262,13 +4263,16 @@ { char *a[] = { "iax2", "show", "users" }; int ret; - char *id; - id = astman_get_header(m,"ActionID"); + char *id = astman_get_header(m,"ActionID"); + char idtext[256] = ""; + int total=0; + if (!ast_strlen_zero(id)) - astman_append(s, "ActionID: %s\r\n",id); + sprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id); + + astman_send_ack(s,m, "Peer status list will follow"); ret = __iax2_show_peers(1, -1, s, 3, a ); - astman_append(s, "\r\n\r\n" ); - return ret; + return 0; } /* /JDG */ static char *regstate2str(int regstate) @@ -8084,12 +8088,11 @@ continue; f->sentyet++; - ast_mutex_lock(&iaxsl[f->callno]); + /* Send a copy immediately -- errors here are ok, so don't bother locking */ if (iaxs[f->callno]) { send_packet(f); count++; } - ast_mutex_unlock(&iaxsl[f->callno]); if (f->retries < 0) { /* This is not supposed to be retransmitted */ AST_LIST_REMOVE(&iaxq.queue, f, list);