[asterisk-commits] branch oej/astum - r8515 in /team/oej/astum: ./
apps/ channels/ configs/ func...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jan 24 03:22:15 MST 2006
Author: oej
Date: Tue Jan 24 04:22:07 2006
New Revision: 8515
URL: http://svn.digium.com/view/asterisk?rev=8515&view=rev
Log:
Merged revisions 8438,8443,8446-8447,8463-8465,8471,8481-8483,8489-8490,8492-8493,8495,8500,8505,8514 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r8438 | russell | 2006-01-22 18:53:14 +0100 (Sun, 22 Jan 2006) | 10 lines
Merged revisions 8437 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r8437 | russell | 2006-01-22 12:47:13 -0500 (Sun, 22 Jan 2006) | 2 lines
fix MixMonitor crash (issue #6321, probably others)
........
................
r8443 | russell | 2006-01-22 19:42:06 +0100 (Sun, 22 Jan 2006) | 2 lines
eliminate some compiler warnings
................
r8446 | russell | 2006-01-22 20:04:37 +0100 (Sun, 22 Jan 2006) | 1 line
................
r8447 | russell | 2006-01-22 20:09:50 +0100 (Sun, 22 Jan 2006) | 2 lines
fix memory leak from not freeing the list of queue members when freeing a queue
................
r8463 | oej | 2006-01-23 13:19:16 +0100 (Mon, 23 Jan 2006) | 2 lines
Remove javadoc doxygen format...
................
r8464 | oej | 2006-01-23 13:32:43 +0100 (Mon, 23 Jan 2006) | 2 lines
Spelling fix undetected by kpfleming in rev 8150 ;-)
................
r8465 | oej | 2006-01-23 13:44:53 +0100 (Mon, 23 Jan 2006) | 2 lines
Use doxygen for todo's! :-)
................
r8471 | oej | 2006-01-23 14:11:04 +0100 (Mon, 23 Jan 2006) | 3 lines
- Adding some white space from my white space reservoir
- Fixing some comment formatting (doxygen fix)
................
r8481 | oej | 2006-01-23 17:21:51 +0100 (Mon, 23 Jan 2006) | 2 lines
Re-instate sip_addheader() while waiting for a dialplan function. (Issue 6317)
................
r8482 | oej | 2006-01-23 17:27:01 +0100 (Mon, 23 Jan 2006) | 2 lines
Doxygen update
................
r8483 | oej | 2006-01-23 17:41:48 +0100 (Mon, 23 Jan 2006) | 3 lines
- Debug output fixes
- Whitespace fixes
................
r8489 | oej | 2006-01-23 18:08:19 +0100 (Mon, 23 Jan 2006) | 6 lines
- Change "call" to "dialog" where use of "call" is confusing, since it may be a register transaction or a subscription.
The word dialog is defined as "a peer-to-peer SIP relationship between two UAs that persist for some time" in RFC 3261.
- Whitespace fixes
- Debugging fixes (adding check of option_debug)
................
r8490 | oej | 2006-01-23 18:12:44 +0100 (Mon, 23 Jan 2006) | 3 lines
Finally removing SIPDUMPER that hasn't been used for ages. If anyone needs this for some reason,
please tell me and I'll put it back :-)
................
r8492 | oej | 2006-01-23 18:17:56 +0100 (Mon, 23 Jan 2006) | 2 lines
Doxygen updates
................
r8493 | oej | 2006-01-23 18:19:03 +0100 (Mon, 23 Jan 2006) | 2 lines
Remove more unused defines.
................
r8495 | mogorman | 2006-01-23 18:23:22 +0100 (Mon, 23 Jan 2006) | 3 lines
changed some settings to app_args and some code
cleaning patch 6267
................
r8500 | oej | 2006-01-23 18:51:15 +0100 (Mon, 23 Jan 2006) | 2 lines
Remove redundant default default/global settings from declaration, settings are done in reload_config()
................
r8505 | mogorman | 2006-01-23 19:07:12 +0100 (Mon, 23 Jan 2006) | 3 lines
code clean up and macro implementation from
bug 6247
................
r8514 | oej | 2006-01-24 11:19:13 +0100 (Tue, 24 Jan 2006) | 9 lines
- Adding doxygen comments
- Changing default values set in reload_config to DEFAULT_ #defines to make it more clear what defaults are
- Cleaning up global_ and default_ variable naming.
- Moving variable and #defines together in the source, adding comments to explain sections
Global_ is used for channel settings that does not apply to peers or users as defaults for their settings
default_ is used both as a channel setting for unknown callers, as well as defaults for peers and users
................
Modified:
team/oej/astum/ (props changed)
team/oej/astum/Makefile
team/oej/astum/apps/app_queue.c
team/oej/astum/apps/app_random.c
team/oej/astum/apps/app_voicemail.c
team/oej/astum/channel.c
team/oej/astum/channels/chan_sip.c
team/oej/astum/configs/queues.conf.sample
team/oej/astum/funcs/func_db.c
team/oej/astum/funcs/func_rand.c
team/oej/astum/include/asterisk/astosp.h
team/oej/astum/manager.c
team/oej/astum/res/res_osp.c
Propchange: team/oej/astum/
------------------------------------------------------------------------------
--- svnmerge-blocked (original)
+++ svnmerge-blocked Tue Jan 24 04:22:07 2006
@@ -1,1 +1,1 @@
-/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8394,8412,8418
+/branches/1.2:7490,7497,7517,7529,7546,7550,7552,7557,7580,7586,7595,7605,7641,7663,7706,7738,7771,7792,7812,7870-7871,7898-7900,7915,7960,7965,7970,7976,8047,8112,8394,8412,8418,8445
Propchange: team/oej/astum/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jan 24 04:22:07 2006
@@ -1,1 +1,1 @@
-/trunk:1-8437
+/trunk:1-8514
Modified: team/oej/astum/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/astum/Makefile?rev=8515&r1=8514&r2=8515&view=diff
==============================================================================
--- team/oej/astum/Makefile (original)
+++ team/oej/astum/Makefile Tue Jan 24 04:22:07 2006
@@ -106,7 +106,7 @@
# Detect the busy signal looking only at tone lengths
# For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
BUSYDETECT+= #-DBUSYDETECT_TONEONLY
-# Enforce the detection of busy singal (get rid of false hangups)
+# Enforce the detection of busy signal (get rid of false hangups)
# Don't use together with -DBUSYDETECT_TONEONLY
BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
Modified: team/oej/astum/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/apps/app_queue.c?rev=8515&r1=8514&r2=8515&view=diff
==============================================================================
--- team/oej/astum/apps/app_queue.c (original)
+++ team/oej/astum/apps/app_queue.c Tue Jan 24 04:22:07 2006
@@ -787,6 +787,30 @@
}
}
+static void free_members(struct ast_call_queue *q, int all)
+{
+ /* Free non-dynamic members */
+ struct member *curm, *next, *prev = NULL;
+
+ for (curm = q->members; curm; curm = next) {
+ next = curm->next;
+ if (all || !curm->dynamic) {
+ if (prev)
+ prev->next = next;
+ else
+ q->members = next;
+ free(curm);
+ } else
+ prev = curm;
+ }
+}
+
+static void destroy_queue(struct ast_call_queue *q)
+{
+ free_members(q, 1);
+ ast_mutex_destroy(&q->lock);
+ free(q);
+}
/*!\brief Reload a single queue via realtime.
\return Return the queue, or NULL if it doesn't exist.
@@ -838,7 +862,7 @@
/* Delete. */
AST_LIST_REMOVE(&queues, q, list);
ast_mutex_unlock(&q->lock);
- free(q);
+ destroy_queue(q);
} else
ast_mutex_unlock(&q->lock);
}
@@ -1022,37 +1046,6 @@
return res;
}
-static void free_members(struct ast_call_queue *q, int all)
-{
- /* Free non-dynamic members */
- struct member *curm, *next, *prev;
-
- curm = q->members;
- prev = NULL;
- while(curm) {
- next = curm->next;
- if (all || !curm->dynamic) {
- if (prev)
- prev->next = next;
- else
- q->members = next;
- free(curm);
- } else
- prev = curm;
- curm = next;
- }
-}
-
-static void destroy_queue(struct ast_call_queue *q)
-{
- AST_LIST_LOCK(&queues);
- AST_LIST_REMOVE(&queues, q, list);
- AST_LIST_UNLOCK(&queues);
- free_members(q, 1);
- ast_mutex_destroy(&q->lock);
- free(q);
-}
-
static int play_file(struct ast_channel *chan, char *filename)
{
int res;
@@ -1260,6 +1253,9 @@
ast_mutex_unlock(&q->lock);
if (q->dead && !q->count) {
/* It's dead and nobody is in it, so kill it */
+ AST_LIST_LOCK(&queues);
+ AST_LIST_REMOVE(&queues, q, list);
+ AST_LIST_UNLOCK(&queues);
destroy_queue(q);
}
}
@@ -2648,14 +2644,12 @@
return -1;
}
+ if (!(parse = ast_strdupa(data)))
+ return -1;
+
+ AST_STANDARD_APP_ARGS(args, parse);
+
LOCAL_USER_ADD(u);
-
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
-
- AST_STANDARD_APP_ARGS(args, parse);
if (args.options) {
if (strchr(args.options, 'j'))
@@ -2703,14 +2697,12 @@
return -1;
}
+ if (!(parse = ast_strdupa(data)))
+ return -1;
+
+ AST_STANDARD_APP_ARGS(args, parse);
+
LOCAL_USER_ADD(u);
-
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
-
- AST_STANDARD_APP_ARGS(args, parse);
if (args.options) {
if (strchr(args.options, 'j'))
@@ -2760,14 +2752,12 @@
return -1;
}
+ if (!(parse = ast_strdupa(data)))
+ return -1;
+
+ AST_STANDARD_APP_ARGS(args, parse);
+
LOCAL_USER_ADD(u);
-
- if (!(parse = ast_strdupa(data))) {
- LOCAL_USER_REMOVE(u);
- return -1;
- }
-
- AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.interface)) {
args.interface = ast_strdupa(chan->name);
@@ -2827,11 +2817,12 @@
return -1;
}
+ if (!(parse = ast_strdupa(data)))
+ return -1;
+
+ AST_STANDARD_APP_ARGS(args, parse);
+
LOCAL_USER_ADD(u);
-
- parse = ast_strdupa(data);
-
- AST_STANDARD_APP_ARGS(args, parse);
if (ast_strlen_zero(args.interface)) {
args.interface = ast_strdupa(chan->name);
@@ -2885,22 +2876,24 @@
int res=-1;
int ringing=0;
struct localuser *u;
- char *queuename;
- char info[512];
- char *info_ptr = info;
- char *options = NULL;
- char *url = NULL;
- char *announceoverride = NULL;
const char *user_priority;
const char *max_penalty_str;
int prio;
int max_penalty;
- char *queuetimeoutstr = NULL;
enum queue_result reason = QUEUE_UNKNOWN;
/* whether to exit Queue application after the timeout hits */
int go_on = 0;
+ char *parse;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(queuename);
+ AST_APP_ARG(options);
+ AST_APP_ARG(url);
+ AST_APP_ARG(announceoverride);
+ AST_APP_ARG(queuetimeoutstr);
+ );
+
/* Our queue entry */
struct queue_ent qe;
@@ -2908,24 +2901,23 @@
ast_log(LOG_WARNING, "Queue requires an argument: queuename[|options[|URL][|announceoverride][|timeout]]\n");
return -1;
}
+
+ parse = ast_strdupa(data);
+ if (!parse) {
+ ast_log(LOG_ERROR, "Out of memory!\n");
+ return -1;
+ }
+ AST_STANDARD_APP_ARGS(args, parse);
LOCAL_USER_ADD(u);
/* Setup our queue entry */
memset(&qe, 0, sizeof(qe));
qe.start = time(NULL);
-
- /* Parse our arguments XXX Check for failure XXX */
- ast_copy_string(info, (char *) data, sizeof(info));
- queuename = strsep(&info_ptr, "|");
- options = strsep(&info_ptr, "|");
- url = strsep(&info_ptr, "|");
- announceoverride = strsep(&info_ptr, "|");
- queuetimeoutstr = info_ptr;
/* set the expire time based on the supplied timeout; */
- if (queuetimeoutstr)
- qe.expire = qe.start + atoi(queuetimeoutstr);
+ if (args.queuetimeoutstr)
+ qe.expire = qe.start + atoi(args.queuetimeoutstr);
else
qe.expire = 0;
@@ -2962,12 +2954,12 @@
max_penalty = 0;
}
- if (options && (strchr(options, 'r')))
+ if (args.options && (strchr(args.options, 'r')))
ringing = 1;
if (option_debug)
ast_log(LOG_DEBUG, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n",
- queuename, options, url, announceoverride, (long)qe.expire, prio);
+ args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio);
qe.chan = chan;
qe.prio = prio;
@@ -2976,8 +2968,8 @@
qe.last_pos = 0;
qe.last_periodic_announce_time = time(NULL);
qe.last_periodic_announce_sound = 0;
- if (!join_queue(queuename, &qe, &reason)) {
- ast_queue_log(queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s", url ? url : "",
+ if (!join_queue(args.queuename, &qe, &reason)) {
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s", args.url ? args.url : "",
chan->cid.cid_num ? chan->cid.cid_num : "");
check_turns:
if (ringing) {
@@ -2993,9 +2985,9 @@
if (res < 0) {
/* Record this abandoned call */
record_abandoned(&qe);
- ast_queue_log(queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
if (option_verbose > 2) {
- ast_verbose(VERBOSE_PREFIX_3 "User disconnected from queue %s while waiting their turn\n", queuename);
+ ast_verbose(VERBOSE_PREFIX_3 "User disconnected from queue %s while waiting their turn\n", args.queuename);
res = -1;
}
break;
@@ -3003,7 +2995,7 @@
if (!res)
break;
if (valid_exit(&qe, res)) {
- ast_queue_log(queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
break;
}
}
@@ -3022,7 +3014,7 @@
record_abandoned(&qe);
reason = QUEUE_TIMEOUT;
res = 0;
- ast_queue_log(queuename, chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
break;
}
@@ -3031,7 +3023,7 @@
if (qe.parent->announcefrequency && !ringing)
res = say_position(&qe);
if (res && valid_exit(&qe, res)) {
- ast_queue_log(queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
break;
}
@@ -3043,20 +3035,21 @@
res = say_periodic_announcement(&qe);
if (res && valid_exit(&qe, res)) {
- ast_queue_log(queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%c|%d", res, qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%c|%d", res, qe.pos);
break;
}
/* Try calling all queue members for 'timeout' seconds */
- res = try_calling(&qe, options, announceoverride, url, &go_on);
+ res = try_calling(&qe, args.options, args.announceoverride, args.url, &go_on);
+
if (res) {
if (res < 0) {
if (!qe.handled) {
record_abandoned(&qe);
- ast_queue_log(queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
}
} else if (res > 0)
- ast_queue_log(queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
break;
}
@@ -3083,7 +3076,7 @@
record_abandoned(&qe);
reason = QUEUE_TIMEOUT;
res = 0;
- ast_queue_log(queuename, chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
break;
}
@@ -3091,15 +3084,15 @@
res = wait_a_bit(&qe);
if (res < 0) {
record_abandoned(&qe);
- ast_queue_log(queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ABANDON", "%d|%d|%ld", qe.pos, qe.opos, (long)time(NULL) - qe.start);
if (option_verbose > 2) {
- ast_verbose(VERBOSE_PREFIX_3 "User disconnected from queue %s when they almost made it\n", queuename);
+ ast_verbose(VERBOSE_PREFIX_3 "User disconnected from queue %s when they almost made it\n", args.queuename);
res = -1;
}
break;
}
if (res && valid_exit(&qe, res)) {
- ast_queue_log(queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", "%s|%d", qe.digits, qe.pos);
break;
}
/* exit after 'timeout' cycle if 'n' option enabled */
@@ -3108,7 +3101,7 @@
ast_verbose(VERBOSE_PREFIX_3 "Exiting on time-out cycle\n");
res = -1;
}
- ast_queue_log(queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
+ ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos);
record_abandoned(&qe);
reason = QUEUE_TIMEOUT;
res = 0;
@@ -3140,7 +3133,7 @@
if (reason != QUEUE_UNKNOWN)
set_queue_result(chan, reason);
} else {
- ast_log(LOG_WARNING, "Unable to join queue '%s'\n", queuename);
+ ast_log(LOG_WARNING, "Unable to join queue '%s'\n", args.queuename);
set_queue_result(chan, reason);
res = 0;
}
@@ -3155,16 +3148,16 @@
struct localuser *u;
struct member *m;
- LOCAL_USER_ACF_ADD(u);
ast_copy_string(buf, "0", len);
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd);
- LOCAL_USER_REMOVE(u);
return buf;
}
+ LOCAL_USER_ACF_ADD(u);
+
AST_LIST_LOCK(&queues);
/* Find the right queue */
@@ -3201,7 +3194,7 @@
/* Ensure an otherwise empty list doesn't return garbage */
buf[0] = '\0';
- if (!data || ast_strlen_zero(data)) {
+ if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "QUEUE_MEMBER_LIST requires an argument: queuename\n");
return buf;
}
@@ -3371,10 +3364,10 @@
AST_LIST_TRAVERSE_SAFE_BEGIN(&queues, q, list) {
if (q->dead) {
AST_LIST_REMOVE_CURRENT(&queues, list);
- if (!q->count) {
- free(q);
- } else
- ast_log(LOG_WARNING, "XXX Leaking a little memory :( XXX\n");
+ if (!q->count)
+ destroy_queue(q);
+ else
+ ast_log(LOG_DEBUG, "XXX Leaking a little memory :( XXX\n");
} else {
for (cur = q->members; cur; cur = cur->next)
cur->status = ast_device_state(cur->interface);
Modified: team/oej/astum/apps/app_random.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/apps/app_random.c?rev=8515&r1=8514&r2=8515&view=diff
==============================================================================
--- team/oej/astum/apps/app_random.c (original)
+++ team/oej/astum/apps/app_random.c Tue Jan 24 04:22:07 2006
@@ -39,7 +39,7 @@
#include "asterisk/pbx.h"
#include "asterisk/module.h"
-/* TODO This app should be removed from trunk following the release of 1.4 */
+/*! \todo The Random() app should be removed from trunk following the release of 1.4 */
static char *tdesc = "Random goto";
Modified: team/oej/astum/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/apps/app_voicemail.c?rev=8515&r1=8514&r2=8515&view=diff
==============================================================================
--- team/oej/astum/apps/app_voicemail.c (original)
+++ team/oej/astum/apps/app_voicemail.c Tue Jan 24 04:22:07 2006
@@ -780,13 +780,13 @@
return snprintf(dest, len, "%s/msg%04d", dir, num);
}
-/** basically mkdir -p $dest/$context/$ext/$mailbox
- * @dest String. base directory.
- * @context String. Ignored if is null or empty string.
- * @ext String. Ignored if is null or empty string.
- * @mailbox String. Ignored if is null or empty string.
- * @returns 0 on failure, 1 on success.
- * */
+/*! \brief basically mkdir -p $dest/$context/$ext/$mailbox
+ * \param dest String. base directory.
+ * \param context String. Ignored if is null or empty string.
+ * \param ext String. Ignored if is null or empty string.
+ * \param mailbox String. Ignored if is null or empty string.
+ * \return 0 on failure, 1 on success.
+ */
static int create_dirpath(char *dest, int len, char *context, char *ext, char *mailbox)
{
mode_t mode = VOICEMAIL_DIR_MODE;
Modified: team/oej/astum/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/channel.c?rev=8515&r1=8514&r2=8515&view=diff
==============================================================================
--- team/oej/astum/channel.c (original)
+++ team/oej/astum/channel.c Tue Jan 24 04:22:07 2006
@@ -3911,7 +3911,7 @@
}
tocopy = (f->samples > samples) ? samples : f->samples;
- bytestocopy = ast_codec_get_len(queue->format, samples);
+ bytestocopy = ast_codec_get_len(queue->format, tocopy);
memcpy(buf, f->data, bytestocopy);
samples -= tocopy;
buf += tocopy;
Modified: team/oej/astum/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/channels/chan_sip.c?rev=8515&r1=8514&r2=8515&view=diff
==============================================================================
--- team/oej/astum/channels/chan_sip.c (original)
+++ team/oej/astum/channels/chan_sip.c Tue Jan 24 04:22:07 2006
@@ -92,18 +92,21 @@
#include "asterisk/astosp.h"
#endif
-#ifndef DEFAULT_USERAGENT
-#define DEFAULT_USERAGENT "Asterisk PBX"
+#ifndef FALSE
+#define FALSE 0
+#endif
+
+#ifndef TRUE
+#define TRUE 1
#endif
-#define VIDEO_CODEC_MASK 0x1fc0000 /* Video codecs from H.261 thru AST_FORMAT_MAX_VIDEO */
+#define VIDEO_CODEC_MASK 0x1fc0000 /*!< Video codecs from H.261 thru AST_FORMAT_MAX_VIDEO */
#ifndef IPTOS_MINCOST
#define IPTOS_MINCOST 0x02
#endif
/* #define VOCAL_DATA_HACK */
-#define SIPDUMPER
#define DEFAULT_DEFAULT_EXPIRY 120
#define DEFAULT_MIN_EXPIRY 60
#define DEFAULT_MAX_EXPIRY 3600
@@ -112,19 +115,21 @@
/* guard limit must be larger than guard secs */
/* guard min must be < 1000, and should be >= 250 */
-#define EXPIRY_GUARD_SECS 15 /* How long before expiry do we reregister */
-#define EXPIRY_GUARD_LIMIT 30 /* Below here, we use EXPIRY_GUARD_PCT instead of
- EXPIRY_GUARD_SECS */
-#define EXPIRY_GUARD_MIN 500 /* This is the minimum guard time applied. If
- GUARD_PCT turns out to be lower than this, it
- will use this time instead.
- This is in milliseconds. */
-#define EXPIRY_GUARD_PCT 0.20 /* Percentage of expires timeout to use when
- below EXPIRY_GUARD_LIMIT */
-
-static int min_expiry = DEFAULT_MIN_EXPIRY;
-static int max_expiry = DEFAULT_MAX_EXPIRY;
+#define EXPIRY_GUARD_SECS 15 /*!< How long before expiry do we reregister */
+#define EXPIRY_GUARD_LIMIT 30 /*!< Below here, we use EXPIRY_GUARD_PCT instead of
+ EXPIRY_GUARD_SECS */
+#define EXPIRY_GUARD_MIN 500 /*!< This is the minimum guard time applied. If
+ GUARD_PCT turns out to be lower than this, it
+ will use this time instead.
+ This is in milliseconds. */
+#define EXPIRY_GUARD_PCT 0.20 /*!< Percentage of expires timeout to use when
+ below EXPIRY_GUARD_LIMIT */
+#define DEFAULT_EXPIRY 900 /*!< Expire slowly */
+
+static int min_expiry = DEFAULT_MIN_EXPIRY; /*!< Minimum accepted registration time */
+static int max_expiry = DEFAULT_MAX_EXPIRY; /*!< Maximum accepted registration time */
static int default_expiry = DEFAULT_DEFAULT_EXPIRY;
+static int expiry = DEFAULT_EXPIRY;
#ifndef MAX
#define MAX(a,b) ((a) > (b) ? (a) : (b))
@@ -134,18 +139,17 @@
-#define DEFAULT_MAXMS 2000 /* Must be faster than 2 seconds by default */
-#define DEFAULT_FREQ_OK 60 * 1000 /* How often to check for the host to be up */
-#define DEFAULT_FREQ_NOTOK 10 * 1000 /* How often to check, if the host is down... */
-
-#define DEFAULT_RETRANS 1000 /* How frequently to retransmit */
- /* 2 * 500 ms in RFC 3261 */
-#define MAX_RETRANS 6 /* Try only 6 times for retransmissions, a total of 7 transmissions */
-#define MAX_AUTHTRIES 3 /* Try authentication three times, then fail */
-
-
-#define DEBUG_READ 0 /* Recieved data */
-#define DEBUG_SEND 1 /* Transmit data */
+#define DEFAULT_MAXMS 2000 /*!< Qualification: Must be faster than 2 seconds by default */
+#define DEFAULT_FREQ_OK 60 * 1000 /*!< Qualification: How often to check for the host to be up */
+#define DEFAULT_FREQ_NOTOK 10 * 1000 /*!< Qualification: How often to check, if the host is down... */
+
+#define DEFAULT_RETRANS 1000 /*!< How frequently to retransmit Default: 2 * 500 ms in RFC 3261 */
+#define MAX_RETRANS 6 /*!< Try only 6 times for retransmissions, a total of 7 transmissions */
+#define MAX_AUTHTRIES 3 /*!< Try authentication three times, then fail */
+
+#define SIP_MAX_HEADERS 64 /*!< Max amount of SIP headers to read */
+#define SIP_MAX_LINES 64 /*!< Max amount of lines in SIP attachment (like SDP) */
+
static const char desc[] = "Session Initiation Protocol (SIP)";
static const char channeltype[] = "SIP";
@@ -331,71 +335,92 @@
/*! \brief SIP Extensions we support */
#define SUPPORTED_EXTENSIONS "replaces"
+#define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */
+
+/* Default values, set and reset in reload_config before reading configuration */
+/* These are default values in the source. There are other recommended values in the
+ sip.conf.sample for new installations. These may differ to keep backwards compatibility,
+ yet encouraging new behaviour on new installations
+ */
#define DEFAULT_SIP_PORT 5060 /*!< From RFC 3261 (former 2543) */
-#define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */
-
-static char default_useragent[AST_MAX_EXTENSION] = DEFAULT_USERAGENT;
-
-#define DEFAULT_CONTEXT "default"
-static char default_context[AST_MAX_CONTEXT] = DEFAULT_CONTEXT;
+#define DEFAULT_CONTEXT "default"
+#define DEFAULT_MUSICCLASS "default"
+#define DEFAULT_VMEXTEN "asterisk"
+#define DEFAULT_CALLERID "asterisk"
+#define DEFAULT_NOTIFYMIME "application/simple-message-summary"
+#define DEFAULT_MWITIME 10
+#define DEFAULT_ALLOWGUEST TRUE
+#define DEFAULT_VIDEOSUPPORT FALSE
+#define DEFAULT_SRVLOOKUP FALSE /*!< Recommended setting is ON */
+#define DEFAULT_COMPACTHEADERS FALSE
+#define DEFAULT_TOS FALSE
+#define DEFAULT_ALLOW_EXT_DOM TRUE
+#define DEFAULT_REALM "asterisk"
+#define DEFAULT_NOTIFYRINGING TRUE
+#define DEFAULT_PEDANTIC FALSE
+#define DEFAULT_AUTOCREATEPEER FALSE
+#define DEFAULT_QUALIFY FALSE
+#ifndef DEFAULT_USERAGENT
+#define DEFAULT_USERAGENT "Asterisk PBX" /*!< Default Useragent: header unless re-defined in sip.conf */
+#endif
+
+/* Default setttings are used as a channel setting and as a default when
+ configuring devices */
+static char default_context[AST_MAX_CONTEXT];
static char default_subscribecontext[AST_MAX_CONTEXT];
-
-#define DEFAULT_VMEXTEN "asterisk"
-static char global_vmexten[AST_MAX_EXTENSION] = DEFAULT_VMEXTEN;
-
-static char default_language[MAX_LANGUAGE] = "";
-
-#define DEFAULT_CALLERID "asterisk"
-static char default_callerid[AST_MAX_EXTENSION] = DEFAULT_CALLERID;
-
-static char default_fromdomain[AST_MAX_EXTENSION] = "";
-
-#define DEFAULT_NOTIFYMIME "application/simple-message-summary"
-static char default_notifymime[AST_MAX_EXTENSION] = DEFAULT_NOTIFYMIME;
-
-static int global_notifyringing = 1; /*!< Send notifications on ringing */
-
-static int default_qualify = 0; /*!< Default Qualify= setting */
+static char default_language[MAX_LANGUAGE];
+static char default_callerid[AST_MAX_EXTENSION];
+static char default_fromdomain[AST_MAX_EXTENSION];
+static char default_notifymime[AST_MAX_EXTENSION];
+static int default_qualify; /*!< Default Qualify= setting */
+static char default_vmexten[AST_MAX_EXTENSION];
+static char default_musicclass[MAX_MUSICCLASS]; /*!< Global music on hold class */
+
+/* Global settings only apply to the channel */
+static int global_notifyringing; /*!< Send notifications on ringing */
+static int srvlookup; /*!< SRV Lookup on or off. Default is off, RFC behavior is on */
+static int pedanticsipchecking; /*!< Extra checking ? Default off */
+static int autocreatepeer; /*!< Auto creation of peers at registration? Default off. */
+static int relaxdtmf; /*!< Relax DTMF */
+static int global_rtptimeout; /*!< Time out call if no RTP */
+static int global_rtpholdtimeout;
+static int global_rtpkeepalive; /*!< Send RTP keepalives */
+static int global_reg_timeout;
+static int global_regattempts_max; /*!< Registration attempts before giving up */
+static int global_allowguest; /*!< allow unauthenticated users/peers to connect? */
+static int global_mwitime; /*!< Time between MWI checks for peers */
+static int global_tos; /*!< IP Type of service */
+static int global_videosupport; /*!< Videosupport on or off */
+static int compactheaders; /*!< send compact sip headers */
+static int recordhistory; /*!< Record SIP history. Off by default */
+static int dumphistory; /*!< Dump history to verbose before destroying SIP dialog */
+static char global_realm[MAXHOSTNAMELEN]; /*!< Default realm */
+static char regcontext[AST_MAX_CONTEXT]; /*!< Context for auto-extensions */
+static char global_useragent[AST_MAX_EXTENSION]; /*!< Useragent for the SIP channel */
+static int allow_external_domains; /*!< Accept calls to external SIP domains? */
+
+/*! \brief Codecs that we support by default: */
+static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
+static int noncodeccapability = AST_RTP_DTMF;
+
+/* Object counters */
+static int suserobjs = 0; /*!< Static users */
+static int ruserobjs = 0; /*!< Realtime users */
+static int speerobjs = 0; /*!< Statis peers */
+static int rpeerobjs = 0; /*!< Realtime peers */
+static int apeerobjs = 0; /*!< Autocreated peer objects */
+static int regobjs = 0; /*!< Registry objects */
static struct ast_flags global_flags = {0}; /*!< global SIP_ flags */
static struct ast_flags global_flags_page2 = {0}; /*!< more global SIP_ flags */
-static int srvlookup = 0; /*!< SRV Lookup on or off. Default is off, RFC behavior is on */
-
-static int pedanticsipchecking = 0; /*!< Extra checking ? Default off */
-
-static int autocreatepeer = 0; /*!< Auto creation of peers at registration? Default off. */
-
-static int relaxdtmf = 0;
-
-static int global_rtptimeout = 0;
-
-static int global_rtpholdtimeout = 0;
-
-static int global_rtpkeepalive = 0;
-
-static int global_reg_timeout = DEFAULT_REGISTRATION_TIMEOUT;
-static int global_regattempts_max = 0;
-
-/* Object counters */
-static int suserobjs = 0;
-static int ruserobjs = 0;
-static int speerobjs = 0;
-static int rpeerobjs = 0;
-static int apeerobjs = 0;
-static int regobjs = 0;
-
-static int global_allowguest = 1; /*!< allow unauthenticated users/peers to connect? */
-
-#define DEFAULT_MWITIME 10
-static int global_mwitime = DEFAULT_MWITIME; /*!< Time between MWI checks for peers */
-
static int usecnt =0;
+
AST_MUTEX_DEFINE_STATIC(usecnt_lock);
-AST_MUTEX_DEFINE_STATIC(rand_lock);
-
-/*! \brief Protect the interface list (of sip_pvt's) */
+AST_MUTEX_DEFINE_STATIC(rand_lock); /*!< Lock for thread-safe random generator */
+
+/*! \brief Protect the SIP dialog list (of sip_pvt's) */
AST_MUTEX_DEFINE_STATIC(iflock);
/*! \brief Protect the monitoring thread, so only one process can kill or start it, and not
@@ -410,38 +435,16 @@
static int restart_monitor(void);
-/*! \brief Codecs that we support by default: */
-static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
-static int noncodeccapability = AST_RTP_DTMF;
static struct in_addr __ourip;
static struct sockaddr_in outboundproxyip;
static int ourport;
-
static struct sockaddr_in debugaddr;
-static int tos = 0;
-
-static int videosupport = 0;
-
-static int compactheaders = 0; /*!< send compact sip headers */
-
-static int recordhistory = 0; /*!< Record SIP history. Off by default */
-static int dumphistory = 0; /*!< Dump history to verbose before destroying SIP dialog */
-
-static char global_musicclass[MAX_MUSICCLASS] = ""; /*!< Global music on hold class */
-#define DEFAULT_REALM "asterisk"
-static char global_realm[MAXHOSTNAMELEN] = DEFAULT_REALM; /*!< Default realm */
-static char regcontext[AST_MAX_CONTEXT] = ""; /*!< Context for auto-extensions */
-
-#define DEFAULT_EXPIRY 900 /*!< Expire slowly */
-static int expiry = DEFAULT_EXPIRY;
static struct sched_context *sched;
static struct io_context *io;
-#define SIP_MAX_HEADERS 64 /*!< Max amount of SIP headers to read */
-#define SIP_MAX_LINES 64 /*!< Max amount of lines in SIP attachment (like SDP) */
#define DEC_CALL_LIMIT 0
#define INC_CALL_LIMIT 1
@@ -469,7 +472,7 @@
/*! \brief Parameters to the transmit_invite function */
struct sip_invite_param {
const char *distinctive_ring; /*!< Distinctive ring header */
- char *osptoken; /*!< OSP token for this call */
+ const char *osptoken; /*!< OSP token for this call */
int addsipheaders; /*!< Add extra SIP headers */
const char *uri_options; /*!< URI options to add to the URI */
const char *vxml_url; /*!< VXML url for Cisco phones */
@@ -497,7 +500,6 @@
static AST_LIST_HEAD_STATIC(domain_list, domain); /*!< The SIP domain list */
-int allow_external_domains; /*!< Accept calls to external SIP domains? */
/*! \brief sip_history: Structure for saving transactions within a SIP dialog */
struct sip_history {
@@ -595,10 +597,10 @@
static int global_rtautoclear = 120;
-/*! \brief sip_pvt: PVT structures are used for each SIP conversation, ie. a call */
+/*! \brief sip_pvt: PVT structures are used for each SIP dialog, ie. a call, a registration, a subscribe */
static struct sip_pvt {
- ast_mutex_t lock; /*!< Channel private lock */
- int method; /*!< SIP method of this packet */
+ ast_mutex_t lock; /*!< Dialog private lock */
+ int method; /*!< SIP method that opened this dialog */
AST_DECLARE_STRING_FIELDS(
AST_STRING_FIELD(callid); /*!< Global CallID */
AST_STRING_FIELD(randdata); /*!< Random data */
@@ -690,35 +692,35 @@
int rtptimeout; /*!< RTP timeout time */
int rtpholdtimeout; /*!< RTP timeout when on hold */
int rtpkeepalive; /*!< Send RTP packets for keepalive */
- enum subscriptiontype subscribed; /*!< Is this call a subscription? */
+ enum subscriptiontype subscribed; /*!< Is this dialog a subscription? */
int stateid;
int laststate; /*!< Last known extension state */
int dialogver;
struct ast_dsp *vad; /*!< Voice Activation Detection dsp */
- struct sip_peer *peerpoke; /*!< If this calls is to poke a peer, which one */
- struct sip_registry *registry; /*!< If this is a REGISTER call, to which registry */
+ struct sip_peer *peerpoke; /*!< If this dialog is to poke a peer, which one */
+ struct sip_registry *registry; /*!< If this is a REGISTER dialog, to which registry */
struct ast_rtp *rtp; /*!< RTP Session */
struct ast_rtp *vrtp; /*!< Video RTP session */
struct sip_pkt *packets; /*!< Packets scheduled for re-transmission */
struct sip_history_head *history; /*!< History of this SIP dialog */
struct ast_variable *chanvars; /*!< Channel variables to set for call */
- struct sip_pvt *next; /*!< Next call in chain */
+ struct sip_pvt *next; /*!< Next dialog in chain */
struct sip_invite_param *options; /*!< Options for INVITE */
} *iflist = NULL;
#define FLAG_RESPONSE (1 << 0)
#define FLAG_FATAL (1 << 1)
-/*! \brief sip packet - read in sipsock_read, transmitted in send_request */
+/*! \brief sip packet - read in sipsock_read(), transmitted in send_request() */
struct sip_pkt {
struct sip_pkt *next; /*!< Next packet */
int retrans; /*!< Retransmission number */
int method; /*!< SIP method for this packet */
int seqno; /*!< Sequence number */
unsigned int flags; /*!< non-zero if this is a response packet (e.g. 200 OK) */
- struct sip_pvt *owner; /*!< Owner call */
+ struct sip_pvt *owner; /*!< Owner AST call */
int retransid; /*!< Retransmission ID */
int timer_a; /*!< SIP timer A, retransmission timer */
int timer_t1; /*!< SIP Timer T1, estimated RTT or 500 ms */
@@ -848,7 +850,7 @@
int regattempts; /*!< Number of attempts (since the last success) */
int timeout; /*!< sched id of sip_reg_timeout */
int refresh; /*!< How often to refresh */
- struct sip_pvt *call; /*!< create a sip_pvt structure for each outbound "registration call" in progress */
+ struct sip_pvt *call; /*!< create a sip_pvt structure for each outbound "registration dialog" in progress */
int regstate; /*!< Registration state (see above) */
int callid_valid; /*!< 0 means we haven't chosen callid for this registry yet. */
unsigned int ocseq; /*!< Sequence number we got to for REGISTERs for this registry */
@@ -857,17 +859,17 @@
char lastmsg[256]; /*!< Last Message sent/received */
};
-/*! \brief The user list: Users and friends ---*/
+/*! \brief The user list: Users and friends */
static struct ast_user_list {
ASTOBJ_CONTAINER_COMPONENTS(struct sip_user);
} userl;
-/*! \brief The peer list: Peers and Friends ---*/
+/*! \brief The peer list: Peers and Friends */
static struct ast_peer_list {
ASTOBJ_CONTAINER_COMPONENTS(struct sip_peer);
} peerl;
-/*! \brief The register list: Other SIP proxys we register with and call ---*/
+/*! \brief The register list: Other SIP proxys we register with and place calls to */
static struct ast_register_list {
ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry);
int recheck;
@@ -1068,7 +1070,7 @@
}
-/*! \brief __sip_xmit: Transmit SIP message ---*/
+/*! \brief __sip_xmit: Transmit SIP message */
static int __sip_xmit(struct sip_pvt *p, char *data, int len)
{
int res;
@@ -1087,7 +1089,7 @@
static void sip_destroy(struct sip_pvt *p);
-/*! \brief build_via: Build a Via header for a request ---*/
+/*! \brief build_via: Build a Via header for a request */
static void build_via(struct sip_pvt *p)
{
char iabuf[INET_ADDRSTRLEN];
@@ -1099,7 +1101,7 @@
ast_inet_ntoa(iabuf, sizeof(iabuf), p->ourip), ourport, p->branch, rport);
}
-/*! \brief ast_sip_ouraddrfor: NAT fix - decide which IP address to use for ASterisk server? ---*/
+/*! \brief ast_sip_ouraddrfor: NAT fix - decide which IP address to use for ASterisk server? */
/* Only used for outbound registrations */
static int ast_sip_ouraddrfor(struct in_addr *them, struct in_addr *us)
{
@@ -1175,7 +1177,7 @@
return 0;
}
-/*! \brief retrans_pkt: Retransmit SIP message if no answer ---*/
+/*! \brief retrans_pkt: Retransmit SIP message if no answer */
static int retrans_pkt(void *data)
{
struct sip_pkt *pkt=data, *prev, *cur = NULL;
@@ -1273,7 +1275,7 @@
return 0;
}
-/*! \brief __sip_reliable_xmit: transmit packet with retransmits ---*/
+/*! \brief __sip_reliable_xmit: transmit packet with retransmits */
static int __sip_reliable_xmit(struct sip_pvt *p, int seqno, int resp, char *data, int len, int fatal, int sipmethod)
{
struct sip_pkt *pkt;
@@ -1310,7 +1312,7 @@
return 0;
}
-/*! \brief __sip_autodestruct: Kill a call (called by scheduler) ---*/
+/*! \brief __sip_autodestruct: Kill a SIP dialog (called by scheduler) */
static int __sip_autodestruct(void *data)
{
struct sip_pvt *p = data;
@@ -1328,7 +1330,7 @@
ast_log(LOG_DEBUG, "Auto destroying call '%s'\n", p->callid);
append_history(p, "AutoDestroy", "");
if (p->owner) {
- ast_log(LOG_WARNING, "Autodestruct on call '%s' with owner in place\n", p->callid);
+ ast_log(LOG_WARNING, "Autodestruct on dialog '%s' with owner in place (Method: %s)\n", p->callid, sip_methods[p->method].text);
ast_queue_hangup(p->owner);
} else {
sip_destroy(p);
@@ -1336,11 +1338,11 @@
return 0;
}
-/*! \brief sip_scheddestroy: Schedule destruction of SIP call ---*/
+/*! \brief sip_scheddestroy: Schedule destruction of SIP call */
static int sip_scheddestroy(struct sip_pvt *p, int ms)
{
if (sip_debug_test_pvt(p))
- ast_verbose("Scheduling destruction of call '%s' in %d ms\n", p->callid, ms);
+ ast_verbose("Scheduling destruction of SIP dialog '%s' in %d ms (Method: %s)\n", p->callid, ms, sip_methods[p->method].text);
if (recordhistory)
append_history(p, "SchedDestroy", "%d ms", ms);
@@ -1350,7 +1352,7 @@
[... 2289 lines stripped ...]
More information about the asterisk-commits
mailing list