[asterisk-commits] tilghman: branch group/dialplan_aesthetics r76615 - in /team/group/dialplan_a...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Jul 23 12:19:49 CDT 2007
Author: tilghman
Date: Mon Jul 23 12:19:49 2007
New Revision: 76615
URL: http://svn.digium.com/view/asterisk?view=rev&rev=76615
Log:
Merged revisions 76547,76555,76558-76559,76562-76564 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r76547 | rizzo | 2007-07-23 09:18:04 -0500 (Mon, 23 Jul 2007) | 11 lines
introduce two functions, map_x_s() and map_s_x(), to map
between integers and strings using a single translation table,
and use them in a few places instead of ad-hoc routines
that duplicate the table.
On passing, note that REFER_CONFIRMED is never used, and add a
few comments.
Nothing to backport here.
................
r76555 | russell | 2007-07-23 09:21:41 -0500 (Mon, 23 Jul 2007) | 29 lines
(closes issue #10192)
Reported by: bbryant
Patches:
20070720__core_debug_by_file.patch uploaded by bbryant (license 36)
(with some modifications by me)
Tested by: russell, bbryant
This set of changes introduces the ability to set the core debug or verbose
levels on a per-file basis. Interestingly enough, in 1.4, you have the ability
to set core debug for a single file, but that functionality was accidentally
lost in the conversion of the CLI commands to the new format.
This patch improves upon what was in 1.4 by letting you set it for more than 1
file, and by also supporting verbose.
*** Janitor Project ***
This patch also introduces a new macro, ast_verb(), which is similar
to ast_debug(). Setting the per file verbose value only works for messages that
use this macro. Converting existing uses of ast_verbose() can be done like:
if (option_debug > 2)
ast_verbose(VERBOSE_PREFIX_3 "Something useful\n");
...
ast_verb(3, "Something useful\n");
................
r76558 | russell | 2007-07-23 09:23:47 -0500 (Mon, 23 Jul 2007) | 1 line
note the debug and verbose changes in CHANGES
................
r76559 | russell | 2007-07-23 09:32:04 -0500 (Mon, 23 Jul 2007) | 7 lines
(closes issue #10271)
Reported by: snuffy
Patches:
doxygen-updates.diff uploaded by snuffy (license 35)
Another big batch of doxygen documentation updates
................
r76562 | russell | 2007-07-23 09:37:26 -0500 (Mon, 23 Jul 2007) | 3 lines
Mark str2dtmfmode() as currently unused to resolve a compiler warning and
allow building under dev mode
................
r76563 | file | 2007-07-23 09:38:35 -0500 (Mon, 23 Jul 2007) | 22 lines
Merged revisions 76561 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
................
r76561 | file | 2007-07-23 11:34:21 -0300 (Mon, 23 Jul 2007) | 14 lines
Merged revisions 76560 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r76560 | file | 2007-07-23 11:32:07 -0300 (Mon, 23 Jul 2007) | 6 lines
(closes issue #10236)
Reported by: homesick
Patches:
rpid_1.4_75840.patch uploaded by homesick (license 91)
Accept Remote Party ID on guest calls.
........
................
................
r76564 | rizzo | 2007-07-23 09:45:22 -0500 (Mon, 23 Jul 2007) | 16 lines
add two missing entries in the replica of the sip_tech that
does not use DTMF BEGIN frames.
1.4 seems correct (it does not have the two fields).
However, as this bug shows, the current way of creating the sip_tech
replica is too error-prone, one can easily forget to update one of
the two entries. Perhaps it would be better to create sip_tech_info
expliclty at module load, by doing
sip_tech_info = sip_tech;
sip_tech_info.send_digit_begin = NULL
(in this case, this is something applicable to 1.4 as well).
................
Modified:
team/group/dialplan_aesthetics/ (props changed)
team/group/dialplan_aesthetics/CHANGES
team/group/dialplan_aesthetics/channels/chan_sip.c
team/group/dialplan_aesthetics/include/asterisk.h
team/group/dialplan_aesthetics/include/asterisk/doxyref.h
team/group/dialplan_aesthetics/include/asterisk/file.h
team/group/dialplan_aesthetics/include/asterisk/logger.h
team/group/dialplan_aesthetics/include/asterisk/options.h
team/group/dialplan_aesthetics/include/jitterbuf.h
team/group/dialplan_aesthetics/main/asterisk.c
team/group/dialplan_aesthetics/main/cli.c
team/group/dialplan_aesthetics/main/devicestate.c
team/group/dialplan_aesthetics/main/enum.c
team/group/dialplan_aesthetics/main/logger.c
team/group/dialplan_aesthetics/main/pbx.c
team/group/dialplan_aesthetics/res/res_clioriginate.c
team/group/dialplan_aesthetics/res/res_config_odbc.c
team/group/dialplan_aesthetics/res/res_config_sqlite.c
team/group/dialplan_aesthetics/res/res_convert.c
team/group/dialplan_aesthetics/res/res_crypto.c
team/group/dialplan_aesthetics/res/res_indications.c
team/group/dialplan_aesthetics/res/res_monitor.c
team/group/dialplan_aesthetics/res/res_snmp.c
Propchange: team/group/dialplan_aesthetics/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.
Propchange: team/group/dialplan_aesthetics/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jul 23 12:19:49 2007
@@ -1,1 +1,1 @@
-/trunk:1-76530
+/trunk:1-76614
Modified: team/group/dialplan_aesthetics/CHANGES
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/CHANGES?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/CHANGES (original)
+++ team/group/dialplan_aesthetics/CHANGES Mon Jul 23 12:19:49 2007
@@ -38,6 +38,7 @@
-----------
* New CLI command "core show settings"
* Added 'core show channels count' CLI command.
+ * Added the ability to set the core debug and verbose values on a per-file basis.
SIP changes
-----------
Modified: team/group/dialplan_aesthetics/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/channels/chan_sip.c?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/channels/chan_sip.c (original)
+++ team/group/dialplan_aesthetics/channels/chan_sip.c Mon Jul 23 12:19:49 2007
@@ -799,6 +799,7 @@
#define SIP_CAN_REINVITE_NAT (2 << 20) /*!< DP: allow media reinvite when new peer is behind NAT */
#define SIP_REINVITE_UPDATE (4 << 20) /*!< DP: use UPDATE (RFC3311) when reinviting this peer */
/* "insecure" settings */
+#define SIP_INSECURE (3 << 23) /*!< DP: two bits used */
#define SIP_INSECURE_PORT (1 << 23) /*!< DP: don't require matching port for incoming requests */
#define SIP_INSECURE_INVITE (1 << 24) /*!< DP: don't require authentication for incoming INVITEs */
/* Sending PROGRESS in-band settings */
@@ -928,7 +929,7 @@
REFER_IDLE, /*!< No REFER is in progress */
REFER_SENT, /*!< Sent REFER to transferee */
REFER_RECEIVED, /*!< Received REFER from transferrer */
- REFER_CONFIRMED, /*!< Refer confirmed with a 100 TRYING */
+ REFER_CONFIRMED, /*!< Refer confirmed with a 100 TRYING (unused) */
REFER_ACCEPTED, /*!< Accepted by transferee */
REFER_RINGING, /*!< Target Ringing */
REFER_200OK, /*!< Answered by transfer target */
@@ -936,19 +937,28 @@
REFER_NOAUTH /*!< We had no auth for REFER */
};
-static const struct c_referstatusstring {
- enum referstatus status;
- char *text;
-} referstatusstrings[] = {
+/*! \brief generic struct to map between strings and integers.
+ * Fill it with x-s pairs, terminate with an entry with s = NULL;
+ * Then you can call map_x_s(...) to map an integer to a string,
+ * and map_s_x() for the string -> integer mapping.
+ */
+struct _map_x_s {
+ int x;
+ const char *s;
+};
+
+static const struct _map_x_s referstatusstrings[] = {
{ REFER_IDLE, "<none>" },
{ REFER_SENT, "Request sent" },
{ REFER_RECEIVED, "Request received" },
+ { REFER_CONFIRMED, "Confirmed" },
{ REFER_ACCEPTED, "Accepted" },
{ REFER_RINGING, "Target ringing" },
{ REFER_200OK, "Done" },
{ REFER_FAILED, "Failed" },
- { REFER_NOAUTH, "Failed - auth failure" }
-} ;
+ { REFER_NOAUTH, "Failed - auth failure" },
+ { -1, NULL} /* terminator */
+};
/*! \brief Structure to handle SIP transfers. Dynamically allocated when needed
\note OEJ: Should be moved to string fields */
@@ -963,13 +973,19 @@
char replaces_callid[BUFSIZ]; /*!< Replace info: callid */
char replaces_callid_totag[BUFSIZ/2]; /*!< Replace info: to-tag */
char replaces_callid_fromtag[BUFSIZ/2]; /*!< Replace info: from-tag */
- struct sip_pvt *refer_call; /*!< Call we are referring */
+ struct sip_pvt *refer_call; /*!< Call we are referring. This is just a reference to a
+ * dialog owned by someone else, so we should not destroy
+ * it when the sip_refer object goes.
+ */
int attendedtransfer; /*!< Attended or blind transfer? */
int localtransfer; /*!< Transfer to local domain? */
enum referstatus status; /*!< REFER status */
};
-/*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe */
+/*! \brief sip_pvt: structures used for each SIP dialog, ie. a call, a registration, a subscribe.
+ * Created and initialized by sip_alloc(), the descriptor goes into the list of
+ * descriptors (dialoglist).
+ */
struct sip_pvt {
ast_mutex_t pvt_lock; /*!< Dialog private lock */
enum invitestates invitestate; /*!< Track state of SIP_INVITEs */
@@ -1524,7 +1540,7 @@
static const char *sip_nat_mode(const struct sip_pvt *p);
static int sip_show_inuse(int fd, int argc, char *argv[]);
static char *transfermode2str(enum transfermodes mode) attribute_const;
-static char *nat2str(int nat) attribute_const;
+static const char *nat2str(int nat) attribute_const;
static int peer_status(struct sip_peer *peer, char *status, int statuslen);
static int sip_show_users(int fd, int argc, char *argv[]);
static int _sip_show_peers(int fd, int *total, struct mansession *s, const struct message *m, int argc, const char *argv[]);
@@ -1532,7 +1548,8 @@
static int sip_show_objects(int fd, int argc, char *argv[]);
static void print_group(int fd, ast_group_t group, int crlf);
static const char *dtmfmode2str(int mode) attribute_const;
-static const char *insecure2str(int port, int invite) attribute_const;
+static int str2dtmfmode(const char *str) attribute_unused;
+static const char *insecure2str(int mode) attribute_const;
static void cleanup_stale_contexts(char *new, char *old);
static void print_codec_to_cli(int fd, struct ast_codec_pref *pref);
static const char *domain_mode_to_text(const enum domain_mode mode);
@@ -1607,7 +1624,7 @@
static void ast_sip_ouraddrfor(struct in_addr *them, struct sockaddr_in *us);
static void sip_registry_destroy(struct sip_registry *reg);
static int sip_register(char *value, int lineno);
-static char *regstate2str(enum sipregistrystate regstate) attribute_const;
+static const char *regstate2str(enum sipregistrystate regstate) attribute_const;
static int sip_reregister(void *data);
static int __sip_do_register(struct sip_registry *r);
static int sip_reg_timeout(void *data);
@@ -1751,17 +1768,45 @@
.read = sip_read,
.write = sip_write,
.write_video = sip_write,
+ .write_text = sip_write,
.indicate = sip_indicate,
.transfer = sip_transfer,
.fixup = sip_fixup,
.send_digit_end = sip_senddigit_end,
.bridge = ast_rtp_bridge,
+ .early_bridge = ast_rtp_early_bridge,
.send_text = sip_sendtext,
.func_channel_read = acf_channel_read,
};
/* wrapper macro to tell whether t points to one of the sip_tech descriptors */
#define IS_SIP_TECH(t) ((t) == &sip_tech || (t) == &sip_tech_info)
+
+/*! \begin map from an integer value to a string.
+ * If no match is found, return errorstring
+ */
+static const char *map_x_s(const struct _map_x_s *table, int x, const char *errorstring)
+{
+ const struct _map_x_s *cur;
+
+ for (cur = table; cur->s; cur++)
+ if (cur->x == x)
+ return cur->s;
+ return errorstring;
+}
+
+/*! \begin map from a string to an integer value, case insensitive.
+ * If no match is found, return errorvalue.
+ */
+static int map_s_x(const struct _map_x_s *table, const char *s, int errorvalue)
+{
+ const struct _map_x_s *cur;
+
+ for (cur = table; cur->s; cur++)
+ if (!strcasecmp(cur->s, s))
+ return cur->x;
+ return errorvalue;
+}
/**--- some list management macros. **/
@@ -1840,14 +1885,7 @@
/*! \brief Convert transfer status to string */
static const char *referstatus2str(enum referstatus rstatus)
{
- int i = (sizeof(referstatusstrings) / sizeof(referstatusstrings[0]));
- int x;
-
- for (x = 0; x < i; x++) {
- if (referstatusstrings[x].status == rstatus)
- return referstatusstrings[x].text;
- }
- return "";
+ return map_x_s(referstatusstrings, rstatus, "");
}
/*! \brief Initialize the initital request packet in the pvt structure.
@@ -7838,29 +7876,22 @@
return send_request(p, &req, XMIT_RELIABLE, p->ocseq);
}
+static const struct _map_x_s regstatestrings[] = {
+ { REG_STATE_FAILED, "Failed" },
+ { REG_STATE_UNREGISTERED, "Unregistered"},
+ { REG_STATE_REGSENT, "Request Sent"},
+ { REG_STATE_AUTHSENT, "Auth. Sent"},
+ { REG_STATE_REGISTERED, "Registered"},
+ { REG_STATE_REJECTED, "Rejected"},
+ { REG_STATE_TIMEOUT, "Timeout"},
+ { REG_STATE_NOAUTH, "No Authentication"},
+ { -1, NULL } /* terminator */
+};
+
/*! \brief Convert registration state status to string */
-static char *regstate2str(enum sipregistrystate regstate)
-{
- switch(regstate) {
- case REG_STATE_FAILED:
- return "Failed";
- case REG_STATE_UNREGISTERED:
- return "Unregistered";
- case REG_STATE_REGSENT:
- return "Request Sent";
- case REG_STATE_AUTHSENT:
- return "Auth. Sent";
- case REG_STATE_REGISTERED:
- return "Registered";
- case REG_STATE_REJECTED:
- return "Rejected";
- case REG_STATE_TIMEOUT:
- return "Timeout";
- case REG_STATE_NOAUTH:
- return "No Authentication";
- default:
- return "Unknown";
- }
+static const char *regstate2str(enum sipregistrystate regstate)
+{
+ return map_x_s(regstatestrings, regstate, "Unknown");
}
/*! \brief Update registration with SIP Proxy.
@@ -10176,9 +10207,10 @@
return res;
/* Finally, apply the guest policy */
- if (global_allowguest)
+ if (global_allowguest) {
+ replace_cid(p, rpid_num, calleridname);
res = AUTH_SUCCESSFUL;
- else if (global_alwaysauthreject)
+ } else if (global_alwaysauthreject)
res = AUTH_FAKE_AUTH; /* reject with fake authorization request */
else
res = AUTH_SECRET_FAILED; /* we don't want any guests, authentication will fail */
@@ -10314,21 +10346,18 @@
return "strict";
}
+static struct _map_x_s natmodes[] = {
+ { SIP_NAT_NEVER, "No"},
+ { SIP_NAT_ROUTE, "Route"},
+ { SIP_NAT_ALWAYS, "Always"},
+ { SIP_NAT_RFC3581, "RFC3581"},
+ { -1, NULL}, /* terminator */
+};
+
/*! \brief Convert NAT setting to text string */
-static char *nat2str(int nat)
-{
- switch(nat) {
- case SIP_NAT_NEVER:
- return "No";
- case SIP_NAT_ROUTE:
- return "Route";
- case SIP_NAT_ALWAYS:
- return "Always";
- case SIP_NAT_RFC3581:
- return "RFC3581";
- default:
- return "Unknown";
- }
+static const char *nat2str(int nat)
+{
+ return map_x_s(natmodes, nat, "Unknown");
}
/*! \brief Report Peer status in character string
@@ -10605,33 +10634,39 @@
ast_cli(fd, crlf ? "%s\r\n" : "%s\n", ast_print_group(buf, sizeof(buf), group) );
}
+/*! \brief mapping between dtmf flags and strings */
+static struct _map_x_s dtmfstr[] = {
+ { SIP_DTMF_RFC2833, "rfc2833" },
+ { SIP_DTMF_INFO, "info" },
+ { SIP_DTMF_INBAND, "inband" },
+ { SIP_DTMF_AUTO, "auto" },
+ { -1, NULL }, /* terminator */
+};
+
/*! \brief Convert DTMF mode to printable string */
static const char *dtmfmode2str(int mode)
{
- switch (mode) {
- case SIP_DTMF_RFC2833:
- return "rfc2833";
- case SIP_DTMF_INFO:
- return "info";
- case SIP_DTMF_INBAND:
- return "inband";
- case SIP_DTMF_AUTO:
- return "auto";
- }
- return "<error>";
-}
+ return map_x_s(dtmfstr, mode, "<error>");
+}
+
+/*! \brief maps a string to dtmfmode, returns -1 on error */
+static int str2dtmfmode(const char *str)
+{
+ return map_s_x(dtmfstr, str, -1);
+}
+
+static struct _map_x_s insecurestr[] = {
+ { SIP_INSECURE_PORT, "port" },
+ { SIP_INSECURE_INVITE, "invite" },
+ { SIP_INSECURE_PORT | SIP_INSECURE_INVITE, "port,invite" },
+ { 0, "no" },
+ { -1, NULL }, /* terminator */
+};
/*! \brief Convert Insecure setting to printable string */
-static const char *insecure2str(int port, int invite)
-{
- if (port && invite)
- return "port,invite";
- else if (port)
- return "port";
- else if (invite)
- return "invite";
- else
- return "no";
+static const char *insecure2str(int mode)
+{
+ return map_x_s(insecurestr, mode, "<error>");
}
/*! \brief Destroy disused contexts between reloads
@@ -10977,7 +11012,7 @@
ast_cli(fd, " Callerid : %s\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, "<unspecified>"));
ast_cli(fd, " MaxCallBR : %d kbps\n", peer->maxcallbitrate);
ast_cli(fd, " Expire : %ld\n", ast_sched_when(sched, peer->expire));
- ast_cli(fd, " Insecure : %s\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT), ast_test_flag(&peer->flags[0], SIP_INSECURE_INVITE)));
+ ast_cli(fd, " Insecure : %s\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE)));
ast_cli(fd, " Nat : %s\n", nat2str(ast_test_flag(&peer->flags[0], SIP_NAT)));
ast_cli(fd, " ACL : %s\n", (peer->ha?"Yes":"No"));
ast_cli(fd, " T38 pt UDPTL : %s\n", ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT_UDPTL)?"Yes":"No");
@@ -11070,7 +11105,7 @@
astman_append(s, "Dynamic: %s\r\n", (ast_test_flag(&peer->flags[1], SIP_PAGE2_DYNAMIC)?"Y":"N"));
astman_append(s, "Callerid: %s\r\n", ast_callerid_merge(cbuf, sizeof(cbuf), peer->cid_name, peer->cid_num, ""));
astman_append(s, "RegExpire: %ld seconds\r\n", ast_sched_when(sched,peer->expire));
- astman_append(s, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE_PORT), ast_test_flag(&peer->flags[0], SIP_INSECURE_INVITE)));
+ astman_append(s, "SIP-AuthInsecure: %s\r\n", insecure2str(ast_test_flag(&peer->flags[0], SIP_INSECURE)));
astman_append(s, "SIP-NatSupport: %s\r\n", nat2str(ast_test_flag(&peer->flags[0], SIP_NAT)));
astman_append(s, "ACL: %s\r\n", (peer->ha?"Y":"N"));
astman_append(s, "SIP-CanReinvite: %s\r\n", (ast_test_flag(&peer->flags[0], SIP_CAN_REINVITE)?"Y":"N"));
@@ -13483,7 +13518,7 @@
if (p->owner)
ast_queue_control(p->owner, AST_CONTROL_BUSY);
break;
- case 482: /*
+ case 482: /*!
\note SIP is incapable of performing a hairpin call, which
is yet another failure of not having a layer 2 (again, YAY
IETF for thinking ahead). So we treat this as a call
Modified: team/group/dialplan_aesthetics/include/asterisk.h
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/include/asterisk.h?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/include/asterisk.h (original)
+++ team/group/dialplan_aesthetics/include/asterisk.h Mon Jul 23 12:19:49 2007
@@ -105,9 +105,10 @@
* \note Modules are reloaded using their reload() functions, not unloading
* them and loading them again.
*
- * \return Zero if the specified module was not found, 1 if the module was
- * found but cannot be reloaded, -1 if a reload operation is already in
- * progress, and 2 if the specfied module was found and reloaded.
+ * \return 0 if the specified module was not found.
+ * \retval 1 if the module was found but cannot be reloaded.
+ * \retval -1 if a reload operation is already in progress.
+ * \retval 2 if the specfied module was found and reloaded.
*/
int ast_module_reload(const char *name);
@@ -115,7 +116,8 @@
* \brief Register a function to be executed before Asterisk exits.
* \param func The callback function to use.
*
- * \return Zero on success, -1 on error.
+ * \retval 0 on success.
+ * \retval -1 on error.
*/
int ast_register_atexit(void (*func)(void));
Modified: team/group/dialplan_aesthetics/include/asterisk/doxyref.h
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/include/asterisk/doxyref.h?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/include/asterisk/doxyref.h (original)
+++ team/group/dialplan_aesthetics/include/asterisk/doxyref.h Mon Jul 23 12:19:49 2007
@@ -551,4 +551,3 @@
* \arg \link Config_ami Configuration file \endlink
* \verbinclude ajam.txt
*/
-
Modified: team/group/dialplan_aesthetics/include/asterisk/file.h
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/include/asterisk/file.h?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/include/asterisk/file.h (original)
+++ team/group/dialplan_aesthetics/include/asterisk/file.h Mon Jul 23 12:19:49 2007
@@ -107,7 +107,7 @@
* When allocating a buffer, remember to leave AST_FRIENDLY_OFFSET
* spare bytes at the bginning.
*/
- int buf_size; /* size of frame buffer, if any, aligned to 8 bytes. */
+ int buf_size; /*!< size of frame buffer, if any, aligned to 8 bytes. */
int desc_size; /*!< size of private descriptor, if any */
struct ast_module *module;
@@ -134,9 +134,9 @@
int lasttimeout;
struct ast_channel *owner;
FILE *f;
- struct ast_frame fr; /* frame produced by read, typically */
- char *buf; /* buffer pointed to by ast_frame; */
- void *private; /* pointer to private buffer */
+ struct ast_frame fr; /*!< frame produced by read, typically */
+ char *buf; /*!< buffer pointed to by ast_frame; */
+ void *private; /*!< pointer to private buffer */
};
#define SEEK_FORCECUR 10
Modified: team/group/dialplan_aesthetics/include/asterisk/logger.h
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/include/asterisk/logger.h?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/include/asterisk/logger.h (original)
+++ team/group/dialplan_aesthetics/include/asterisk/logger.h Mon Jul 23 12:19:49 2007
@@ -59,6 +59,7 @@
\param function Will be provided by the LOG_* macro
\param fmt This is what is important. The format is the same as your favorite breed of printf. You know how that works, right? :-)
*/
+
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)
__attribute__ ((format (printf, 5, 6)));
@@ -130,14 +131,42 @@
#define LOG_DTMF __LOG_DTMF, _A_
/*!
+ * \brief Get the debug level for a file
+ * \arg file the filename
+ * \return the debug level
+ */
+unsigned int ast_debug_get_by_file(const char *file);
+
+/*!
+ * \brief Get the debug level for a file
+ * \arg file the filename
+ * \return the debug level
+ */
+unsigned int ast_verbose_get_by_file(const char *file);
+
+/*!
* \brief Log a DEBUG message
* \param level The minimum value of option_debug for this message
* to get logged
*/
#define ast_debug(level, ...) do { \
- if (option_debug >= (level)) { \
+ if (option_debug >= (level) || (ast_opt_dbg_file && ast_debug_get_by_file(__FILE__) >= (level)) ) \
ast_log(LOG_DEBUG, __VA_ARGS__); \
- } \
+} while (0)
+
+#define ast_verb(level, ...) do { \
+ if (option_verbose >= (level) || (ast_opt_verb_file && ast_verbose_get_by_file(__FILE__) >= (level)) ) { \
+ if (level >= 4) \
+ ast_verbose(VERBOSE_PREFIX_4 __VA_ARGS__); \
+ else if (level == 3) \
+ ast_verbose(VERBOSE_PREFIX_3 __VA_ARGS__); \
+ else if (level == 2) \
+ ast_verbose(VERBOSE_PREFIX_2 __VA_ARGS__); \
+ else if (level == 1) \
+ ast_verbose(VERBOSE_PREFIX_1 __VA_ARGS__); \
+ else \
+ ast_verbose(__VA_ARGS__); \
+ } \
} while (0)
#if defined(__cplusplus) || defined(c_plusplus)
Modified: team/group/dialplan_aesthetics/include/asterisk/options.h
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/include/asterisk/options.h?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/include/asterisk/options.h (original)
+++ team/group/dialplan_aesthetics/include/asterisk/options.h Mon Jul 23 12:19:49 2007
@@ -75,7 +75,11 @@
/*! Always fork, even if verbose or debug settings are non-zero */
AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
/*! Disable log/verbose output to remote consoles */
- AST_OPT_FLAG_MUTE = (1 << 22)
+ AST_OPT_FLAG_MUTE = (1 << 22),
+ /*! There is a per-file debug setting */
+ AST_OPT_FLAG_DEBUG_FILE = (1 << 23),
+ /*! There is a per-file verbose setting */
+ AST_OPT_FLAG_VERBOSE_FILE = (1 << 24),
};
/*! These are the options that set by default when Asterisk starts */
@@ -103,6 +107,8 @@
#define ast_opt_internal_timing ast_test_flag(&ast_options, AST_OPT_FLAG_INTERNAL_TIMING)
#define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
#define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
+#define ast_opt_dbg_file ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_FILE)
+#define ast_opt_verb_file ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_FILE)
extern struct ast_flags ast_options;
@@ -121,7 +127,6 @@
extern pid_t ast_mainpid;
extern char record_cache_dir[AST_CACHE_DIR_LEN];
-extern char debug_filename[AST_FILENAME_MAX];
extern int ast_language_is_prefix;
Modified: team/group/dialplan_aesthetics/include/jitterbuf.h
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/include/jitterbuf.h?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/include/jitterbuf.h (original)
+++ team/group/dialplan_aesthetics/include/jitterbuf.h Mon Jul 23 12:19:49 2007
@@ -21,18 +21,18 @@
#endif
/* configuration constants */
- /* Number of historical timestamps to use in calculating jitter and drift */
+ /*! Number of historical timestamps to use in calculating jitter and drift */
#define JB_HISTORY_SZ 500
- /* what percentage of timestamps should we drop from the history when we examine it;
+ /*! what percentage of timestamps should we drop from the history when we examine it;
* this might eventually be something made configurable */
#define JB_HISTORY_DROPPCT 3
- /* the maximum droppct we can handle (say it was configurable). */
+ /*! the maximum droppct we can handle (say it was configurable). */
#define JB_HISTORY_DROPPCT_MAX 4
- /* the size of the buffer we use to keep the top and botton timestamps for dropping */
+ /*! the size of the buffer we use to keep the top and botton timestamps for dropping */
#define JB_HISTORY_MAXBUF_SZ JB_HISTORY_SZ * JB_HISTORY_DROPPCT_MAX / 100
- /* amount of additional jitterbuffer adjustment */
+ /*! amount of additional jitterbuffer adjustment */
#define JB_TARGET_EXTRA 40
- /* ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */
+ /*! ms between growing and shrinking; may not be honored if jitterbuffer runs out of space */
#define JB_ADJUST_DELAY 40
enum jb_return_code {
@@ -55,36 +55,36 @@
typedef struct jb_conf {
/* settings */
- long max_jitterbuf; /* defines a hard clamp to use in setting the jitter buffer delay */
- long resync_threshold; /* the jb will resync when delay increases to (2 * jitter) + this param */
- long max_contig_interp; /* the max interp frames to return in a row */
- long target_extra ; /* amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */
+ long max_jitterbuf; /*!< defines a hard clamp to use in setting the jitter buffer delay */
+ long resync_threshold; /*!< the jb will resync when delay increases to (2 * jitter) + this param */
+ long max_contig_interp; /*!< the max interp frames to return in a row */
+ long target_extra ; /*!< amount of additional jitterbuffer adjustment, overrides JB_TARGET_EXTRA */
} jb_conf;
typedef struct jb_info {
jb_conf conf;
/* statistics */
- long frames_in; /* number of frames input to the jitterbuffer.*/
- long frames_out; /* number of frames output from the jitterbuffer.*/
- long frames_late; /* number of frames which were too late, and dropped.*/
- long frames_lost; /* number of missing frames.*/
- long frames_dropped; /* number of frames dropped (shrinkage) */
- long frames_ooo; /* number of frames received out-of-order */
- long frames_cur; /* number of frames presently in jb, awaiting delivery.*/
- long jitter; /* jitter measured within current history interval*/
- long min; /* minimum lateness within current history interval */
- long current; /* the present jitterbuffer adjustment */
- long target; /* the target jitterbuffer adjustment */
- long losspct; /* recent lost frame percentage (* 1000) */
- long next_voice_ts; /* the ts of the next frame to be read from the jb - in receiver's time */
- long last_voice_ms; /* the duration of the last voice frame */
- long silence_begin_ts; /* the time of the last CNG frame, when in silence */
- long last_adjustment; /* the time of the last adjustment */
- long last_delay; /* the last now added to history */
- long cnt_delay_discont; /* the count of discontinuous delays */
- long resync_offset; /* the amount to offset ts to support resyncs */
- long cnt_contig_interp; /* the number of contiguous interp frames returned */
+ long frames_in; /*!< number of frames input to the jitterbuffer.*/
+ long frames_out; /*!< number of frames output from the jitterbuffer.*/
+ long frames_late; /*!< number of frames which were too late, and dropped.*/
+ long frames_lost; /*!< number of missing frames.*/
+ long frames_dropped; /*!< number of frames dropped (shrinkage) */
+ long frames_ooo; /*!< number of frames received out-of-order */
+ long frames_cur; /*!< number of frames presently in jb, awaiting delivery.*/
+ long jitter; /*!< jitter measured within current history interval*/
+ long min; /*!< minimum lateness within current history interval */
+ long current; /*!< the present jitterbuffer adjustment */
+ long target; /*!< the target jitterbuffer adjustment */
+ long losspct; /*!< recent lost frame percentage (* 1000) */
+ long next_voice_ts; /*!< the ts of the next frame to be read from the jb - in receiver's time */
+ long last_voice_ms; /*!< the duration of the last voice frame */
+ long silence_begin_ts; /*!< the time of the last CNG frame, when in silence */
+ long last_adjustment; /*!< the time of the last adjustment */
+ long last_delay; /*!< the last now added to history */
+ long cnt_delay_discont; /*!< the count of discontinuous delays */
+ long resync_offset; /*!< the amount to offset ts to support resyncs */
+ long cnt_contig_interp; /*!< the number of contiguous interp frames returned */
} jb_info;
typedef struct jb_frame {
@@ -99,15 +99,15 @@
jb_info info;
/* history */
- long history[JB_HISTORY_SZ]; /* history */
- int hist_ptr; /* points to index in history for next entry */
- long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /* a sorted buffer of the max delays (highest first) */
- long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /* a sorted buffer of the min delays (lowest first) */
- int hist_maxbuf_valid; /* are the "maxbuf"/minbuf valid? */
- unsigned int dropem:1; /* flag to indicate dropping frames (overload) */
+ long history[JB_HISTORY_SZ]; /*!< history */
+ int hist_ptr; /*!< points to index in history for next entry */
+ long hist_maxbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the max delays (highest first) */
+ long hist_minbuf[JB_HISTORY_MAXBUF_SZ]; /*!< a sorted buffer of the min delays (lowest first) */
+ int hist_maxbuf_valid; /*!< are the "maxbuf"/minbuf valid? */
+ unsigned int dropem:1; /*!< flag to indicate dropping frames (overload) */
- jb_frame *frames; /* queued frames */
- jb_frame *free; /* free frames (avoid malloc?) */
+ jb_frame *frames; /*!< queued frames */
+ jb_frame *free; /*!< free frames (avoid malloc?) */
} jitterbuf;
@@ -146,10 +146,10 @@
* This value may change as frames are added (esp non-audio frames) */
long jb_next(jitterbuf *jb);
-/* get jitterbuf info: only "statistics" may be valid */
+/*! get jitterbuf info: only "statistics" may be valid */
enum jb_return_code jb_getinfo(jitterbuf *jb, jb_info *stats);
-/* set jitterbuf conf */
+/*! set jitterbuf conf */
enum jb_return_code jb_setconf(jitterbuf *jb, jb_conf *conf);
typedef void (*jb_output_function_t)(const char *fmt, ...);
Modified: team/group/dialplan_aesthetics/main/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/main/asterisk.c?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/main/asterisk.c (original)
+++ team/group/dialplan_aesthetics/main/asterisk.c Mon Jul 23 12:19:49 2007
@@ -153,9 +153,9 @@
"production installations.\n");
/*! \defgroup main_options Main Configuration Options
- \brief Main configuration options from \ref Config_ast "asterisk.conf" or
- the operating system command line when starting Asterisk
- Some of them can be changed in the CLI
+ * \brief Main configuration options from asterisk.conf or OS command line on starting Asterisk.
+ * \arg \ref Config_ast "asterisk.conf"
+ * \note Some of them can be changed in the CLI
*/
/*! @{ */
@@ -163,7 +163,6 @@
int option_verbose; /*!< Verbosity level */
int option_debug; /*!< Debug level */
-
double option_maxload; /*!< Max load avg on system */
int option_maxcalls; /*!< Max number of active calls */
int option_maxfiles; /*!< Max number of open file handles (files, sockets) */
@@ -174,7 +173,6 @@
/*! @} */
char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
-char debug_filename[AST_FILENAME_MAX] = "";
static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */
static int ast_consock = -1; /*!< UNIX Socket for controlling another asterisk */
Modified: team/group/dialplan_aesthetics/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/group/dialplan_aesthetics/main/cli.c?view=diff&rev=76615&r1=76614&r2=76615
==============================================================================
--- team/group/dialplan_aesthetics/main/cli.c (original)
+++ team/group/dialplan_aesthetics/main/cli.c Mon Jul 23 12:19:49 2007
@@ -49,6 +49,22 @@
#include "editline/readline/readline.h"
#include "asterisk/threadstorage.h"
+/*!
+ * \brief map a debug or verbose value to a filename
+ */
+struct ast_debug_file {
+ unsigned int level;
+ AST_RWLIST_ENTRY(ast_debug_file) entry;
+ char filename[0];
+};
+
+AST_RWLIST_HEAD(debug_file_list, ast_debug_file);
+
+/*! list of filenames and their debug settings */
+static struct debug_file_list debug_files;
+/*! list of filenames and their verbose settings */
+static struct debug_file_list verbose_files;
+
AST_THREADSTORAGE(ast_cli_buf);
/*! \brief Initial buffer size for resulting strings in ast_cli() */
@@ -69,6 +85,40 @@
if (res != AST_DYNSTR_BUILD_FAILED)
ast_carefulwrite(fd, buf->str, strlen(buf->str), 100);
+}
+
+unsigned int ast_debug_get_by_file(const char *file)
+{
+ struct ast_debug_file *adf;
+ unsigned int res = 0;
+
+ AST_RWLIST_RDLOCK(&debug_files);
+ AST_LIST_TRAVERSE(&debug_files, adf, entry) {
+ if (!strncasecmp(adf->filename, file, strlen(adf->filename))) {
+ res = adf->level;
+ break;
+ }
+ }
+ AST_RWLIST_UNLOCK(&debug_files);
+
+ return res;
+}
+
+unsigned int ast_verbose_get_by_file(const char *file)
+{
+ struct ast_debug_file *adf;
+ unsigned int res = 0;
+
+ AST_RWLIST_RDLOCK(&verbose_files);
+ AST_LIST_TRAVERSE(&verbose_files, adf, entry) {
+ if (!strncasecmp(adf->filename, file, strlen(file))) {
+ res = adf->level;
+ break;
+ }
+ }
+ AST_RWLIST_UNLOCK(&verbose_files);
+
+ return res;
}
static AST_LIST_HEAD_STATIC(helpers, ast_cli_entry);
@@ -184,6 +234,23 @@
return s;
}
+/*!
+ * \brief Find the debug or verbose file setting
+ * \arg debug 1 for debug, 0 for verbose
+ */
+static struct ast_debug_file *find_debug_file(const char *fn, unsigned int debug)
+{
+ struct ast_debug_file *df = NULL;
+ struct debug_file_list *dfl = debug ? &debug_files : &verbose_files;
+
+ AST_LIST_TRAVERSE(dfl, df, entry) {
+ if (!strcasecmp(df->filename, fn))
+ break;
+ }
+
+ return df;
+}
+
static char *handle_verbose(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
int oldval;
@@ -194,14 +261,18 @@
char **argv = a->argv;
int *dst;
char *what;
+ struct debug_file_list *dfl;
+ struct ast_debug_file *adf;
+ char *fn;
switch (cmd) {
case CLI_INIT:
e->command = "core set {debug|verbose} [off|atleast]";
e->usage =
- "Usage: core set {debug|verbose} [atleast] <level>\n"
+ "Usage: core set {debug|verbose} [atleast] <level> [filename]\n"
" core set {debug|verbose} off\n"
- " Sets level of debug or verbose messages to be displayed.\n"
+ " Sets level of debug or verbose messages to be displayed or \n"
+ " sets a filename to display debug messages from.\n"
" 0 or off means no messages should be displayed.\n"
" Equivalent to -d[d[...]] or -v[v[v...]] on startup\n";
return NULL;
@@ -225,15 +296,67 @@
what = "Verbosity";
}
if (argc == e->args && !strcasecmp(argv[e->args - 1], "off")) {
+ unsigned int debug = (*what == 'C');
newlevel = 0;
+
+ dfl = debug ? &debug_files : &verbose_files;
+
+ AST_RWLIST_WRLOCK(dfl);
+ while ((adf = AST_RWLIST_REMOVE_HEAD(dfl, entry)))
+ ast_free(adf);
+ ast_clear_flag(&ast_options, debug ? AST_OPT_FLAG_DEBUG_FILE : AST_OPT_FLAG_VERBOSE_FILE);
+ AST_RWLIST_UNLOCK(dfl);
+
goto done;
}
if (!strcasecmp(argv[e->args-1], "atleast"))
atleast = 1;
- if (argc != e->args + atleast)
+ if (argc != e->args + atleast && argc != e->args + atleast + 1)
return CLI_SHOWUSAGE;
if (sscanf(argv[e->args + atleast - 1], "%d", &newlevel) != 1)
return CLI_SHOWUSAGE;
+ if (argc == e->args + atleast + 1) {
+ unsigned int debug = (*what == 'C');
+ dfl = debug ? &debug_files : &verbose_files;
+
+ fn = argv[e->args + atleast];
+
+ AST_RWLIST_WRLOCK(dfl);
+
+ if ((adf = find_debug_file(fn, debug)) && !newlevel) {
+ AST_RWLIST_REMOVE(dfl, adf, entry);
+ if (AST_RWLIST_EMPTY(dfl))
+ ast_clear_flag(&ast_options, debug ? AST_OPT_FLAG_DEBUG_FILE : AST_OPT_FLAG_VERBOSE_FILE);
+ AST_RWLIST_UNLOCK(dfl);
+ ast_cli(fd, "%s was %d and has been set to 0 for '%s'\n", what, adf->level, fn);
+ ast_free(adf);
+ return CLI_SUCCESS;
+ }
+
+ if (adf) {
+ if ((atleast && newlevel < adf->level) || adf->level == newlevel) {
+ ast_cli(fd, "%s is %d for '%s'\n", what, adf->level, fn);
+ AST_RWLIST_UNLOCK(dfl);
+ return CLI_SUCCESS;
+ }
+ } else if (!(adf = ast_calloc(1, sizeof(*adf) + strlen(fn) + 1))) {
+ AST_RWLIST_UNLOCK(dfl);
+ return CLI_FAILURE;
+ }
+
+ oldval = adf->level;
+ adf->level = newlevel;
+ strcpy(adf->filename, fn);
+
+ ast_set_flag(&ast_options, debug ? AST_OPT_FLAG_DEBUG_FILE : AST_OPT_FLAG_VERBOSE_FILE);
+
+ AST_RWLIST_INSERT_TAIL(dfl, adf, entry);
+ AST_RWLIST_UNLOCK(dfl);
+
[... 1411 lines stripped ...]
More information about the asterisk-commits
mailing list