[svn-commits] branch oej/sipregister - r8516 in /team/oej/sipregister: ./ apps/ channels/ c...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jan 24 03:27:44 MST 2006


Author: oej
Date: Tue Jan 24 04:27:37 2006
New Revision: 8516

URL: http://svn.digium.com/view/asterisk?rev=8516&view=rev
Log:
Merged revisions 8463-8465,8471,8481-8483,8489-8490,8492-8493,8495,8500,8505,8514 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

........
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/sipregister/   (props changed)
    team/oej/sipregister/Makefile
    team/oej/sipregister/apps/app_queue.c
    team/oej/sipregister/apps/app_random.c
    team/oej/sipregister/apps/app_voicemail.c
    team/oej/sipregister/channels/chan_sip.c
    team/oej/sipregister/configs/queues.conf.sample
    team/oej/sipregister/funcs/func_db.c
    team/oej/sipregister/funcs/func_rand.c
    team/oej/sipregister/manager.c

Propchange: team/oej/sipregister/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jan 24 04:27:37 2006
@@ -1,1 +1,1 @@
-/trunk:1-8461
+/trunk:1-8515

Modified: team/oej/sipregister/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/Makefile?rev=8516&r1=8515&r2=8516&view=diff
==============================================================================
--- team/oej/sipregister/Makefile (original)
+++ team/oej/sipregister/Makefile Tue Jan 24 04:27:37 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/sipregister/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/apps/app_queue.c?rev=8516&r1=8515&r2=8516&view=diff
==============================================================================
--- team/oej/sipregister/apps/app_queue.c (original)
+++ team/oej/sipregister/apps/app_queue.c Tue Jan 24 04:27:37 2006
@@ -2644,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'))
@@ -2699,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'))
@@ -2756,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);
@@ -2823,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);
@@ -2881,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;
 	
@@ -2904,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;
 
@@ -2958,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;
@@ -2972,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) {
@@ -2989,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;
@@ -2999,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;
 			}
 		}
@@ -3018,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;
 				}
 
@@ -3027,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;
 					}
 
@@ -3039,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;
 				}
 
@@ -3079,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;
 				}
 
@@ -3087,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 */
@@ -3104,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;
@@ -3136,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;
 	}
@@ -3151,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 */
@@ -3197,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;
 	}

Modified: team/oej/sipregister/apps/app_random.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/apps/app_random.c?rev=8516&r1=8515&r2=8516&view=diff
==============================================================================
--- team/oej/sipregister/apps/app_random.c (original)
+++ team/oej/sipregister/apps/app_random.c Tue Jan 24 04:27:37 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/sipregister/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/apps/app_voicemail.c?rev=8516&r1=8515&r2=8516&view=diff
==============================================================================
--- team/oej/sipregister/apps/app_voicemail.c (original)
+++ team/oej/sipregister/apps/app_voicemail.c Tue Jan 24 04:27:37 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/sipregister/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sipregister/channels/chan_sip.c?rev=8516&r1=8515&r2=8516&view=diff
==============================================================================
--- team/oej/sipregister/channels/chan_sip.c (original)
+++ team/oej/sipregister/channels/chan_sip.c Tue Jan 24 04:27:37 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
@@ -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 @@
 	return 0;
 }
 
-/*! \brief  sip_cancel_destroy: Cancel destruction of SIP call ---*/
+/*! \brief  sip_cancel_destroy: Cancel destruction of SIP dialog */
 static int sip_cancel_destroy(struct sip_pvt *p)
 {
 	if (p->autokillid > -1)
@@ -1360,7 +1362,7 @@
 	return 0;
 }
 
-/*! \brief  __sip_ack: Acknowledges receipt of a packet and stops retransmission ---*/
+/*! \brief  __sip_ack: Acknowledges receipt of a packet and stops retransmission */
 static int __sip_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
 {
 	struct sip_pkt *cur, *prev = NULL;
@@ -1429,7 +1431,7 @@
 	return 0;
 }
 
-/*! \brief  __sip_semi_ack: Acks receipt of packet, keep it around (used for provisional responses) ---*/
+/*! \brief  __sip_semi_ack: Acks receipt of packet, keep it around (used for provisional responses) */
 static int __sip_semi_ack(struct sip_pvt *p, int seqno, int resp, int sipmethod)
 {
 	struct sip_pkt *cur;
@@ -1470,7 +1472,7 @@
 	parse_request(dst);
 }
 
-/*! \brief  send_response: Transmit response on SIP request---*/
+/*! \brief  send_response: Transmit response on SIP request*/
 static int send_response(struct sip_pvt *p, struct sip_request *req, int reliable, int seqno)
 {
 	int res;
@@ -1495,7 +1497,7 @@
 	return res;
 }
 
-/*! \brief  send_request: Send SIP Request to the other part of the dialogue ---*/
+/*! \brief  send_request: Send SIP Request to the other part of the dialogue */
 static int send_request(struct sip_pvt *p, struct sip_request *req, int reliable, int seqno)
 {
 	int res;
@@ -1518,7 +1520,7 @@
 	return res;
 }
 
-/*! \brief  get_in_brackets: Pick out text in brackets from character string ---*/
+/*! \brief  get_in_brackets: Pick out text in brackets from character string */
 /* returns pointer to terminated stripped string. modifies input string. */
 static char *get_in_brackets(char *tmp)
 {
@@ -1560,7 +1562,7 @@
 	}
 }
 
-/*! \brief  sip_sendtext: Send SIP MESSAGE text within a call ---*/
+/*! \brief  sip_sendtext: Send SIP MESSAGE text within a call */
 /*      Called from PBX core text message functions */
 static int sip_sendtext(struct ast_channel *ast, const char *text)
 {
@@ -1579,7 +1581,7 @@
 	return 0;	
 }
 
-/*! \brief  realtime_update_peer: Update peer object in realtime storage ---*/
+/*! \brief  realtime_update_peer: Update peer object in realtime storage */
 static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, const char *username, const char *fullcontact, int expirey)
 {
 	char port[10];
@@ -1600,7 +1602,7 @@
 		ast_update_realtime("sippeers", "name", peername, "ipaddr", ipaddr, "port", port, "regseconds", regseconds, "username", username, NULL);
 }
 
-/*! \brief  register_peer_exten: Automatically add peer extension to dial plan ---*/
+/*! \brief  register_peer_exten: Automatically add peer extension to dial plan */
 static void register_peer_exten(struct sip_peer *peer, int onoff)
 {
 	char multi[256];
@@ -1646,7 +1648,7 @@
 	free(peer);
 }
 
-/*! \brief  update_peer: Update peer data in database (if used) ---*/
+/*! \brief  update_peer: Update peer data in database (if used) */
 static void update_peer(struct sip_peer *p, int expiry)
 {
 	int rtcachefriends = ast_test_flag(&(p->flags_page2), SIP_PAGE2_RTCACHEFRIENDS);
@@ -1721,7 +1723,7 @@
 	return peer;
 }
 
-/*! \brief  sip_addrcmp: Support routine for find_peer ---*/
+/*! \brief  sip_addrcmp: Support routine for find_peer */
 static int sip_addrcmp(char *name, struct sockaddr_in *sin)
 {
 	/* We know name is the first field, so we can cast */
@@ -1749,7 +1751,7 @@
 	return p;
 }
 
-/*! \brief  sip_destroy_user: Remove user object from in-memory storage ---*/
+/*! \brief  sip_destroy_user: Remove user object from in-memory storage */
 static void sip_destroy_user(struct sip_user *user)
 {
 	ast_free_ha(user->ha);
@@ -1821,7 +1823,7 @@
 	return u;
 }
 
-/*! \brief  create_addr_from_peer: create address structure from peer reference ---*/
+/*! \brief  create_addr_from_peer: create address structure from peer reference */
 static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
 {
 	if ((peer->addr.sin_addr.s_addr || peer->defaddr.sin_addr.s_addr) &&
@@ -1969,7 +1971,7 @@
 	}
 }
 
-/*! \brief  auto_congest: Scheduled congestion on a call ---*/
+/*! \brief  auto_congest: Scheduled congestion on a call */
 static int auto_congest(void *nothing)
 {
 	struct sip_pvt *p = nothing;
@@ -2042,7 +2044,8 @@
 #ifdef OSP_SUPPORT
 	if (!p->options->osptoken || !osphandle || (sscanf(osphandle, "%d", &p->osphandle) != 1)) {
 		/* Force Disable OSP support */

[... 2122 lines stripped ...]


More information about the svn-commits mailing list