aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-03 00:51:57 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-03 00:51:57 +0000
commit48cae2ce726e032c1ebb1a1711cb812cc51ee2a3 (patch)
treebfc40c837271ee2d04cb23e1aa173b290a8eb5d0
parent7270663abbf68aeacd97ee28ff277d9fdc946fc9 (diff)
Merge OEJ's print groups feature (bug #3228, with changes)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4636 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_dumpchan.c62
-rwxr-xr-xchannels/chan_sip.c21
-rwxr-xr-xinclude/asterisk/utils.h3
-rwxr-xr-xutils.c26
4 files changed, 69 insertions, 43 deletions
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index fbeeeedf3..0ef92f6d8 100755
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -19,6 +19,7 @@
#include <asterisk/options.h>
#include <asterisk/utils.h>
#include <asterisk/lock.h>
+#include <asterisk/utils.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
@@ -29,9 +30,9 @@ static char *synopsis = "Dump Info About The Calling Channel";
static char *desc =
" DumpChan([<min_verbose_level>])\n"
"Displays information on channel and listing of all channel\n"
-"variables. If min_verbose_level is specified, output is only\n"
+"variables. If min_verbose_level is specified, output is only\n"
"displayed when the verbose level is currently set to that number\n"
-"or greater. Always returns 0.\n\n";
+"or greater. Always returns 0.\n\n";
STANDARD_LOCAL_USER;
@@ -42,6 +43,9 @@ static int ast_serialize_showchan(struct ast_channel *c, char *buf, size_t size)
struct timeval now;
long elapsed_seconds=0;
int hour=0, min=0, sec=0;
+ char cgrp[256];
+ char pgrp[256];
+
gettimeofday(&now, NULL);
memset(buf,0,size);
if (!c)
@@ -55,30 +59,30 @@ static int ast_serialize_showchan(struct ast_channel *c, char *buf, size_t size)
}
snprintf(buf,size,
- "Name=%s\n"
- "Type=%s\n"
- "UniqueID=%s\n"
- "CallerID=%s\n"
- "CallerIDName=%s\n"
- "DNIDDigits=%s\n"
- "State=%s(%d)\n"
- "Rings=%d\n"
- "NativeFormat=%d\n"
- "WriteFormat=%d\n"
- "ReadFormat=%d\n"
- "1stFileDescriptor=%d\n"
- "Framesin=%d%s\n"
- "Framesout=%d%s\n"
- "TimetoHangup=%ld\n"
- "ElapsedTime=%dh%dm%ds\n"
- "Context=%s\n"
- "Extension=%s\n"
- "Priority=%d\n"
- "CallGroup=%d\n"
- "PickupGroup=%d\n"
- "Application=%s\n"
- "Data=%s\n"
- "Blocking_in=%s\n",
+ "Name= %s\n"
+ "Type= %s\n"
+ "UniqueID= %s\n"
+ "CallerID= %s\n"
+ "CallerIDName= %s\n"
+ "DNIDDigits= %s\n"
+ "State= %s (%d)\n"
+ "Rings= %d\n"
+ "NativeFormat= %d\n"
+ "WriteFormat= %d\n"
+ "ReadFormat= %d\n"
+ "1stFileDescriptor= %d\n"
+ "Framesin= %d %s\n"
+ "Framesout= %d %s\n"
+ "TimetoHangup= %ld\n"
+ "ElapsedTime= %dh%dm%ds\n"
+ "Context= %s\n"
+ "Extension= %s\n"
+ "Priority= %d\n"
+ "CallGroup= %s\n"
+ "PickupGroup= %s\n"
+ "Application= %s\n"
+ "Data= %s\n"
+ "Blocking_in= %s\n",
c->name,
c->type,
c->uniqueid,
@@ -99,8 +103,8 @@ static int ast_serialize_showchan(struct ast_channel *c, char *buf, size_t size)
c->context,
c->exten,
c->priority,
- c->callgroup,
- c->pickupgroup,
+ ast_print_group(cgrp, sizeof(cgrp), c->callgroup),
+ ast_print_group(pgrp, sizeof(pgrp), c->pickupgroup),
( c->appl ? c->appl : "(N/A)" ),
( c-> data ? (!ast_strlen_zero(c->data) ? c->data : "(Empty)") : "(None)"),
(ast_test_flag(c, AST_FLAG_BLOCKING) ? c->blockproc : "(Not Blocking)"));
@@ -125,7 +129,7 @@ static int dumpchan_exec(struct ast_channel *chan, void *data)
pbx_builtin_serialize_variables(chan, vars, sizeof(vars));
ast_serialize_showchan(chan, info, sizeof(info));
if (option_verbose >= level)
- ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n",chan->name,line,info,vars,line);
+ ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n",chan->name, line, info, vars, line);
LOCAL_USER_REMOVE(u);
return res;
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 9b18e3508..2b36e1a7f 100755
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -5902,20 +5902,8 @@ static int sip_show_objects(int fd, int argc, char *argv[])
/*--- print_group: Print call group and pickup group ---*/
static void print_group(int fd, unsigned int group)
{
- unsigned int i;
- int first=1;
-
- for (i=0; i<=31; i++) { /* Max group is 31 */
- if (group & (1 << i)) {
- if (!first) {
- ast_cli(fd, ", ");
- } else {
- first=0;
- }
- ast_cli(fd, "%u", i);
- }
- }
- ast_cli(fd, " (%u)\n", group);
+ char buf[256];
+ ast_cli(fd, ast_print_group(buf, sizeof(buf), group) );
}
static const char *dtmfmode2str(int mode)
@@ -5928,6 +5916,7 @@ static const char *dtmfmode2str(int mode)
case SIP_DTMF_INBAND:
return "inband";
}
+ return "<error>";
}
static const char *insecure2str(int mode)
@@ -5940,6 +5929,7 @@ static const char *insecure2str(int mode)
case SIP_INSECURE_VERY:
return "very";
}
+ return "<error>";
}
/*--- sip_show_peer: Show one peer in detail ---*/
@@ -9065,6 +9055,7 @@ static int reload_config(void)
return 0;
}
+/*--- sip_get_rtp_peer: Returns null if we can't reinvite */
static struct ast_rtp *sip_get_rtp_peer(struct ast_channel *chan)
{
struct sip_pvt *p;
@@ -9287,12 +9278,14 @@ static int sip_getheader(struct ast_channel *chan, void *data)
return 0;
}
+/*--- sip_get_codec: Return peers codec ---*/
static int sip_get_codec(struct ast_channel *chan)
{
struct sip_pvt *p = chan->pvt->pvt;
return p->peercapability;
}
+/*--- sip_rtp: Interface structure with callbacks used to connect to rtp module --*/
static struct ast_rtp_protocol sip_rtp = {
get_rtp_info: sip_get_rtp_peer,
get_vrtp_info: sip_get_vrtp_peer,
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index afea97e83..9798543ba 100755
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -73,3 +73,6 @@ extern int ast_pthread_create(pthread_t *thread, pthread_attr_t *attr, void *(*s
extern char *ast_strcasestr(const char *, const char *);
#endif
+
+/* print call- and pickup groups into buffer */
+char *ast_print_group(char *buf, int buflen, unsigned int group);
diff --git a/utils.c b/utils.c
index c296275c1..8faddfea6 100755
--- a/utils.c
+++ b/utils.c
@@ -430,3 +430,29 @@ char *ast_strcasestr(const char *haystack, const char *needle)
}
#endif
+
+/*--- ast_print_group: Print call group and pickup group ---*/
+char *ast_print_group(char *buf, int buflen, unsigned int group)
+{
+ unsigned int i;
+ int first=1;
+ char num[3];
+
+ buf[0] = '\0';
+
+ if (!group) /* Return empty string if no group */
+ return(buf);
+
+ for (i=0; i<=31; i++) { /* Max group is 31 */
+ if (group & (1 << i)) {
+ if (!first) {
+ strncat(buf, ", ", buflen);
+ } else {
+ first=0;
+ }
+ snprintf(num, sizeof(num), "%u", i);
+ strncat(buf, num, buflen);
+ }
+ }
+ return(buf);
+}