"Usage: show version\n"
" Shows Asterisk version information.\n ";
+static char *format_uptimestr(time_t timeval)
+{
+ int years = 0, weeks = 0, days = 0, hours = 0, mins = 0, secs = 0;
+ char timestr[256];
+ int pos = 0;
+#define SECOND (1)
+#define MIN (SECOND*60)
+#define HOUR (MIN*60)
+#define DAY (HOUR*24)
+#define WEEK (DAY*7)
+#define YEAR (DAY*365)
+
+ if (timeval > YEAR) {
+ years = (timeval / YEAR);
+ timeval -= (years * YEAR);
+ if (years > 1)
+ pos += sprintf(timestr + pos, "%d years, ", years);
+ else
+ pos += sprintf(timestr + pos, "1 year, ");
+ }
+ if (timeval > WEEK) {
+ weeks = (timeval / WEEK);
+ timeval -= (weeks * WEEK);
+ if (weeks > 1)
+ pos += sprintf(timestr + pos, "%d weeks, ", weeks);
+ else
+ pos += sprintf(timestr + pos, "1 week, ");
+ }
+ if (timeval > DAY) {
+ days = (timeval / DAY);
+ timeval -= (days * DAY);
+ if (days > 1)
+ pos += sprintf(timestr + pos, "%d days, ", days);
+ else
+ pos += sprintf(timestr + pos, "1 day, ");
+
+ }
+ if (timeval > HOUR) {
+ hours = (timeval / HOUR);
+ timeval -= (hours * HOUR);
+ if (hours > 1)
+ pos += sprintf(timestr + pos, "%d hours, ", hours);
+ else
+ pos += sprintf(timestr + pos, "1 hour, ");
+ }
+ if (timeval > MIN) {
+ mins = (timeval / MIN);
+ timeval -= (mins * MIN);
+ if (mins > 1)
+ pos += sprintf(timestr + pos, "%d minutes, ", mins);
+ else if (mins > 0)
+ pos += sprintf(timestr + pos, "1 minute, ");
+ }
+ secs = timeval;
+
+ if (secs > 0)
+ pos += sprintf(timestr + pos, "%d seconds", secs);
+
+ return timestr ? strdup(timestr) : NULL;
+}
+
+static int handle_showuptime(int fd, int argc, char *argv[])
+{
+ time_t curtime, tmptime;
+ char *timestr;
+
+ time(&curtime);
+ if (ast_startuptime) {
+ tmptime = curtime - ast_startuptime;
+ timestr = format_uptimestr(tmptime);
+ if (timestr) {
+ ast_cli(fd, "System uptime: %s\n", timestr);
+ free(timestr);
+ }
+ }
+ if (ast_lastreloadtime) {
+ tmptime = curtime - ast_lastreloadtime;
+ timestr = format_uptimestr(tmptime);
+ if (timestr) {
+ ast_cli(fd, "Last reload: %s\n", timestr);
+ free(timestr);
+ }
+ }
+ return RESULT_SUCCESS;
+}
+
static int handle_modlist(int fd, int argc, char *argv[])
{
if (argc != 2)
{ { "show", "channel", NULL }, handle_showchan, "Display information on a specific channel", showchan_help, complete_ch },
{ { "show", "channels", NULL }, handle_chanlist, "Display information on channels", chanlist_help },
{ { "show", "modules", NULL }, handle_modlist, "List modules and info", modlist_help },
+ { { "show", "uptime", NULL }, handle_showuptime, "Show uptime information", modlist_help },
{ { "show", "version", NULL }, handle_version, "Display version info", version_help },
{ { "soft", "hangup", NULL }, handle_softhangup, "Request a hangup on a given channel", softhangup_help, complete_ch },
{ { "unload", NULL }, handle_unload, "Unload a dynamic module by name", unload_help, complete_fn },
}
+static struct ast_frame *process_cisco_dtmf(struct ast_rtp *rtp, unsigned char *data, int len)
+{
+ unsigned int event;
+ char resp = 0;
+ struct ast_frame *f = NULL;
+ event = ntohl(*((unsigned int *)(data)));
+ event &= 0x001F;
+#if 0
+ printf("Cisco Digit: %08x (len = %d)\n", event, len);
+#endif
+ if (event < 10) {
+ resp = '0' + event;
+ } else if (event < 11) {
+ resp = '*';
+ } else if (event < 12) {
+ resp = '#';
+ } else if (event < 16) {
+ resp = 'A' + (event - 12);
+ }
+ if (rtp->resp && (rtp->resp != resp)) {
+ f = send_dtmf(rtp);
+ }
+ rtp->resp = resp;
+ rtp->dtmfcount = dtmftimeout;
+ return f;
+}
+
static struct ast_frame *process_rfc2833(struct ast_rtp *rtp, unsigned char *data, int len)
{
unsigned int event;
/* It's special -- rfc2833 process it */
f = process_rfc2833(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
if (f) return f; else return &null_frame;
+ } else if (rtpPT.code == AST_RTP_CISCO_DTMF) {
+ /* It's really special -- process it the Cisco way */
+ f = process_cisco_dtmf(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
+ if (f) return f; else return &null_frame;
} else if (rtpPT.code == AST_RTP_CN) {
/* Comfort Noise */
f = process_rfc3389(rtp, rtp->rawdata + AST_FRIENDLY_OFFSET + hdrlen, res - hdrlen);
{{1, AST_FORMAT_SPEEX}, "audio", "SPEEX"},
{{1, AST_FORMAT_ILBC}, "audio", "iLBC"},
{{0, AST_RTP_DTMF}, "audio", "telephone-event"},
+ {{0, AST_RTP_CISCO_DTMF}, "audio", "bastard-telephone-event"},
{{0, AST_RTP_CN}, "audio", "CN"},
{{1, AST_FORMAT_JPEG}, "video", "JPEG"},
{{1, AST_FORMAT_PNG}, "video", "PNG"},
[97] = {1, AST_FORMAT_ILBC},
[101] = {0, AST_RTP_DTMF},
[110] = {1, AST_FORMAT_SPEEX},
+ [121] = {0, AST_RTP_CISCO_DTMF}, // Must be type 121
};
void ast_rtp_pt_clear(struct ast_rtp* rtp)