diff options
Diffstat (limited to 'channels')
-rw-r--r-- | channels/chan_dahdi.c | 32 | ||||
-rw-r--r-- | channels/chan_iax2.c | 61 | ||||
-rw-r--r-- | channels/chan_sip.c | 35 | ||||
-rw-r--r-- | channels/chan_skinny.c | 30 |
4 files changed, 48 insertions, 110 deletions
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c index bb6bd2d42..10b6295cd 100644 --- a/channels/chan_dahdi.c +++ b/channels/chan_dahdi.c @@ -16068,7 +16068,7 @@ static int action_dahdishowchannels(struct mansession *s, const struct message * struct dahdi_pvt *tmp = NULL; const char *id = astman_get_header(m, "ActionID"); const char *dahdichannel = astman_get_header(m, "DAHDIChannel"); - char idText[256] = ""; + char idText[256]; int channels = 0; int dahdichanquery; @@ -16077,9 +16077,12 @@ static int action_dahdishowchannels(struct mansession *s, const struct message * dahdichanquery = -1; } - astman_send_ack(s, m, "DAHDI channel status will follow"); - if (!ast_strlen_zero(id)) + idText[0] = '\0'; + if (!ast_strlen_zero(id)) { snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id); + } + + astman_send_listack(s, m, "DAHDI channel status will follow", "start"); ast_mutex_lock(&iflock); @@ -16142,13 +16145,9 @@ static int action_dahdishowchannels(struct mansession *s, const struct message * ast_mutex_unlock(&iflock); - astman_append(s, - "Event: DAHDIShowChannelsComplete\r\n" - "%s" - "Items: %d\r\n" - "\r\n", - idText, - channels); + astman_send_list_complete_start(s, m, "DAHDIShowChannelsComplete", channels); + astman_append(s, "Items: %d\r\n", channels); + astman_send_list_complete_end(s); return 0; } @@ -16177,7 +16176,7 @@ static int action_prishowspans(struct mansession *s, const struct message *m) action_id[0] = '\0'; } - astman_send_ack(s, m, "Span status will follow"); + astman_send_listack(s, m, "Span status will follow", "start"); count = 0; for (idx = 0; idx < ARRAY_LEN(pris); ++idx) { @@ -16194,14 +16193,9 @@ static int action_prishowspans(struct mansession *s, const struct message *m) } } - astman_append(s, - "Event: %sComplete\r\n" - "Items: %d\r\n" - "%s" - "\r\n", - show_cmd, - count, - action_id); + astman_send_list_complete_start(s, m, "PRIShowSpansComplete", count); + astman_append(s, "Items: %d\r\n", count); + astman_send_list_complete_end(s); return 0; } #endif /* defined(HAVE_PRI) */ diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index c01bf5c7a..bb65df460 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -6872,31 +6872,23 @@ static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers } if (s) { - if (cont->peerlist) { /* IAXpeerlist */ - astman_append(s, "Event: PeerEntry\r\n%s" "Channeltype: IAX\r\n", cont->idtext); - if (!ast_strlen_zero(peer->username)) { - astman_append(s, "ObjectName: %s\r\n" "ObjectUsername: %s\r\n", peer->name, peer->username); - } else { - astman_append(s, "ObjectName: %s\r\n", name); } - } else { /* IAXpeers */ - astman_append(s, "Event: PeerEntry\r\n%s" "Channeltype: IAX2\r\n" @@ -6904,28 +6896,21 @@ static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers cont->idtext, name); } - astman_append(s, "ChanObjectType: peer\r\n" "IPaddress: %s\r\n", tmp_host); - if (cont->peerlist) { /* IAXpeerlist */ - astman_append(s, "Mask: %s\r\n" "Port: %s\r\n", tmp_mask, tmp_port); - } else { /* IAXpeers */ - astman_append(s, "IPport: %s\r\n", tmp_port); - } - astman_append(s, "Dynamic: %s\r\n" "Trunk: %s\r\n" @@ -6935,19 +6920,13 @@ static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers ast_test_flag64(peer, IAX_TRUNK) ? "yes" : "no", peer->encmethods ? ast_str_buffer(encmethods) : "no", status); - if (cont->peerlist) { /* IAXpeerlist */ - astman_append(s, "\r\n"); - } else { /* IAXpeers */ - astman_append(s, "Description: %s\r\n\r\n", peer->description); - } - } else { ast_cli(fd, PEERS_FORMAT, name, @@ -6962,7 +6941,6 @@ static void _iax2_show_peers_one(int fd, struct mansession *s, struct show_peers } cont->total_peers++; - } static int __iax2_show_peers(int fd, int *total, struct mansession *s, const int argc, const char * const argv[]) @@ -7275,16 +7253,14 @@ static int manager_iax2_show_peers(struct mansession *s, const struct message *m snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id); astman_send_listack(s, m, "Peer status list will follow", "start"); - /* List the peers in separate manager events */ + + /* List the peers in separate manager events */ __iax2_show_peers(-1, &total, s, 3, a); - /* Send final confirmation */ - astman_append(s, - "Event: PeerlistComplete\r\n" - "EventList: Complete\r\n" - "ListItems: %d\r\n" - "%s" - "\r\n", total, idtext); - return 0; + + /* Send final confirmation */ + astman_send_list_complete_start(s, m, "PeerlistComplete", total); + astman_send_list_complete_end(s); + return 0; } /*! \brief callback to display iax peers in manager format */ @@ -7312,25 +7288,16 @@ static int manager_iax2_show_peer_list(struct mansession *s, const struct messag snprintf(cont.idtext, sizeof(cont.idtext), "ActionID: %s\r\n", id); } - astman_append(s, - "Response: Success\r\n" - "%sMessage: IAX Peer status list will follow\r\n\r\n", - cont.idtext); - + astman_send_listack(s, m, "IAX Peer status list will follow", "start"); i = ao2_iterator_init(peers, 0); for (; (peer = ao2_iterator_next(&i)); peer_unref(peer)) { - _iax2_show_peers_one(-1, s, &cont, peer); - } ao2_iterator_destroy(&i); - astman_append(s, - "Event: PeerlistComplete\r\n" - "%sListItems: %d\r\n\r\n", - cont.idtext, - cont.total_peers); + astman_send_list_complete_start(s, m, "PeerlistComplete", cont.total_peers); + astman_send_list_complete_end(s); return RESULT_SUCCESS; } @@ -7435,12 +7402,8 @@ static int manager_iax2_show_registry(struct mansession *s, const struct message } AST_LIST_UNLOCK(®istrations); - astman_append(s, - "Event: RegistrationsComplete\r\n" - "EventList: Complete\r\n" - "ListItems: %d\r\n" - "%s" - "\r\n", total, idtext); + astman_send_list_complete_start(s, m, "RegistrationsComplete", total); + astman_send_list_complete_end(s); return 0; } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index af115d40f..61b0a62b5 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -19248,12 +19248,8 @@ static int manager_show_registry(struct mansession *s, const struct message *m) } ao2_iterator_destroy(&iter); - astman_append(s, - "Event: RegistrationsComplete\r\n" - "EventList: Complete\r\n" - "ListItems: %d\r\n" - "%s" - "\r\n", total, idtext); + astman_send_list_complete_start(s, m, "RegistrationsComplete", total); + astman_send_list_complete_end(s); return 0; } @@ -19271,15 +19267,13 @@ static int manager_sip_show_peers(struct mansession *s, const struct message *m) snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id); astman_send_listack(s, m, "Peer status list will follow", "start"); + /* List the peers in separate manager events */ _sip_show_peers(-1, &total, s, m, 3, a); + /* Send final confirmation */ - astman_append(s, - "Event: PeerlistComplete\r\n" - "EventList: Complete\r\n" - "ListItems: %d\r\n" - "%s" - "\r\n", total, idtext); + astman_send_list_complete_start(s, m, "PeerlistComplete", total); + astman_send_list_complete_end(s); return 0; } @@ -20042,9 +20036,11 @@ static int manager_sip_peer_status(struct mansession *s, const struct message *m { const char *id = astman_get_header(m,"ActionID"); const char *peer_name = astman_get_header(m,"Peer"); - char idText[256] = ""; + char idText[256]; struct sip_peer *peer = NULL; + int num_peers = 0; + idText[0] = '\0'; if (!ast_strlen_zero(id)) { snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id); } @@ -20062,15 +20058,17 @@ static int manager_sip_peer_status(struct mansession *s, const struct message *m } } - astman_send_ack(s, m, "Peer status will follow"); + astman_send_listack(s, m, "Peer status will follow", "start"); if (!peer) { struct ao2_iterator i = ao2_iterator_init(peers, 0); + while ((peer = ao2_t_iterator_next(&i, "iterate thru peers table for SIPpeerstatus"))) { ao2_lock(peer); send_manager_peer_status(s, peer, idText); ao2_unlock(peer); sip_unref_peer(peer, "unref peer for SIPpeerstatus"); + ++num_peers; } ao2_iterator_destroy(&i); } else { @@ -20078,14 +20076,11 @@ static int manager_sip_peer_status(struct mansession *s, const struct message *m send_manager_peer_status(s, peer, idText); ao2_unlock(peer); sip_unref_peer(peer, "unref peer for SIPpeerstatus"); + ++num_peers; } - - astman_append(s, - "Event: SIPpeerstatusComplete\r\n" - "%s" - "\r\n", - idText); + astman_send_list_complete_start(s, m, "SIPpeerstatusComplete", num_peers); + astman_send_list_complete_end(s); return 0; } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index 9269fbf6e..6b16d6bef 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -4135,24 +4135,17 @@ static char *_skinny_show_devices(int fd, int *total, struct mansession *s, cons /* Inspired from chan_sip */ static int manager_skinny_show_devices(struct mansession *s, const struct message *m) { - const char *id = astman_get_header(m, "ActionID"); const char *a[] = {"skinny", "show", "devices"}; - char idtext[256] = ""; int total = 0; - if (!ast_strlen_zero(id)) - snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id); - astman_send_listack(s, m, "Device status list will follow", "start"); + /* List the devices in separate manager events */ _skinny_show_devices(-1, &total, s, m, 3, a); + /* Send final confirmation */ - astman_append(s, - "Event: DevicelistComplete\r\n" - "EventList: Complete\r\n" - "ListItems: %d\r\n" - "%s" - "\r\n", total, idtext); + astman_send_list_complete_start(s, m, "DevicelistComplete", total); + astman_send_list_complete_end(s); return 0; } @@ -4384,24 +4377,17 @@ static char *_skinny_show_lines(int fd, int *total, struct mansession *s, const /* Inspired from chan_sip */ static int manager_skinny_show_lines(struct mansession *s, const struct message *m) { - const char *id = astman_get_header(m, "ActionID"); const char *a[] = {"skinny", "show", "lines"}; - char idtext[256] = ""; int total = 0; - if (!ast_strlen_zero(id)) - snprintf(idtext, sizeof(idtext), "ActionID: %s\r\n", id); - astman_send_listack(s, m, "Line status list will follow", "start"); + /* List the lines in separate manager events */ _skinny_show_lines(-1, &total, s, m, 3, a); + /* Send final confirmation */ - astman_append(s, - "Event: LinelistComplete\r\n" - "EventList: Complete\r\n" - "ListItems: %d\r\n" - "%s" - "\r\n", total, idtext); + astman_send_list_complete_start(s, m, "LinelistComplete", total); + astman_send_list_complete_end(s); return 0; } |