[asterisk-commits] branch rizzo/base r8943 - in /team/rizzo/base: ./ apps/ channels/ configs/ fu...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 31 14:21:00 MST 2006


Author: rizzo
Date: Mon Jan 30 16:46:56 2006
New Revision: 8943

URL: http://svn.digium.com/view/asterisk?rev=8943&view=rev
Log:
synchronize with trunk #8938


Modified:
    team/rizzo/base/UPGRADE.txt
    team/rizzo/base/apps/app_meetme.c
    team/rizzo/base/channel.c
    team/rizzo/base/channels/chan_oss.c
    team/rizzo/base/channels/chan_sip.c
    team/rizzo/base/channels/chan_zap.c
    team/rizzo/base/configs/sip.conf.sample
    team/rizzo/base/funcs/func_md5.c
    team/rizzo/base/include/asterisk/channel.h

Modified: team/rizzo/base/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/UPGRADE.txt?rev=8943&r1=8942&r2=8943&view=diff
==============================================================================
--- team/rizzo/base/UPGRADE.txt (original)
+++ team/rizzo/base/UPGRADE.txt Mon Jan 30 16:46:56 2006
@@ -21,6 +21,7 @@
 * app_read has been updated to use the newer options codes, using "skip" or
   "noanswer" will not work.  Use s or n.  Also there is a new feature i, for
   using indication tones, so typing in skip would give you unexpected results.
+
 Variables:
 
 * The builtin variables ${CALLERID}, ${CALLERIDNAME}, ${CALLERIDNUM},
@@ -29,6 +30,21 @@
   functions.  You are encouraged to move towards the associated dialplan
   function, as these variables will be removed in a future release.
 
+Functions:
+
+* The function ${CHECK_MD5()} has been deprecated in favor of using an
+  expression: $[${MD5(<string>)} = ${saved_md5}].
+
 The SIP channel:
 
 * The "incominglimit" setting is replaced by the "call-limit" setting in sip.conf.
+
+Installation:
+
+* On BSD systems, the installation directories have changed to more "FreeBSDish" directories. On startup, Asterisk will look for the main configuration in /usr7local/etc/asterisk/asterisk.conf
+If you have an old installation, you might want to remove the binaries and move the configuration files to the new locations. The following directories are now default:
+	ASTLIBDIR	/usr/local/lib/asterisk
+	ASTVARLIBDIR	/usr/local/share/asterisk
+	ASTETCDIR	/usr/local/etc/asterisk
+	ASTBINDIR	/usr/local/bin/asterisk
+	ASTSBINDIR	/usr/local/sbin/asterisk

Modified: team/rizzo/base/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/apps/app_meetme.c?rev=8943&r1=8942&r2=8943&view=diff
==============================================================================
--- team/rizzo/base/apps/app_meetme.c (original)
+++ team/rizzo/base/apps/app_meetme.c Mon Jan 30 16:46:56 2006
@@ -426,8 +426,6 @@
 	unsigned char *data;
 	int len;
 	int res = -1;
-	short *data2;
-	int x;
 
 	if (!chan->_softhangup)
 		res = ast_autoservice_start(chan);
@@ -448,10 +446,7 @@
 		len = 0;
 	}
 	if (data) {
-		data2 = alloca(len * 2);
-		for (x=0;x<len;x++)
-			data2[x] = AST_MULAW(data[x]);
-		careful_write(conf->fd, (unsigned char *)data2, len << 1, 1);
+		careful_write(conf->fd, data, len, 1);
 	}
 
 	AST_LIST_UNLOCK(&confs);

Modified: team/rizzo/base/channel.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/channel.c?rev=8943&r1=8942&r2=8943&view=diff
==============================================================================
--- team/rizzo/base/channel.c (original)
+++ team/rizzo/base/channel.c Mon Jan 30 16:46:56 2006
@@ -618,7 +618,11 @@
 		return NULL;
 	}
 	
-	for (x=0; x<AST_MAX_FDS; x++)
+	/* Don't bother initializing the last two FD here, because they
+	   will *always* be set just a few lines down (AST_TIMING_FD,
+	   AST_ALERT_FD). */
+	/* XXX it's for safety! */
+	for (x=0; x<AST_MAX_FDS - 2; x++)
 		tmp->fds[x] = -1;
 
 #ifdef ZAPTEL_OPTIMIZATIONS
@@ -1490,24 +1494,10 @@
 	return res;
 }
 
-/* if fd is a valid descriptor, set *pfd with the descriptor
- * Return 1 (not -1!) if added, 0 otherwise (so we can add the
- * return value to the index into the array)
- */
-static int add_fd(struct pollfd *pfd, int fd)
-{
-	if (fd < 0)
-		return 0;
-	pfd->fd = fd;
-	pfd->events = POLLIN | POLLPRI;
-	return 1;
-}
-
 /*! \brief Wait for x amount of time on a file descriptor to have input.  */
 int ast_waitfor_n_fd(int *fds, int n, int *ms, int *exception)
 {
 	int winner = -1;
-
 	ast_waitfor_nandfds(NULL, 0, fds, n, exception, &winner, ms);
 	return winner;
 }
@@ -1518,39 +1508,34 @@
 {
 	struct timeval start = { 0 , 0 };
 	struct pollfd *pfds;
+	int res;
+	long rms;
+	int x, y, max;
+	int sz;
+	time_t now = 0;
+	long whentohangup = 0, diff;
 	struct ast_channel *winner = NULL;
-	int x, max, res, rms, sz;
-	time_t t0 = 0; /* timeout, 0 means unset */
-	int *ci, *fdno; /* map pfds entries to channel index and fd index */
+	struct fdmap {
+		int chan;
+		int fdno;
+	} *fdmap;
 
 	if (outfd)
-		*outfd = -1;
+		*outfd = -1;	/* XXX was -99999 */
 	if (exception)
 		*exception = 0;
-
-	/*
-	 * allocate array of poll file descriptors, and auxiliary arrays to
-	 * map the poll descriptors to channels and file descriptors, to speed up
-	 * the decoding of the poll() results.
-	 */
-	sz = (n * AST_MAX_FDS + nfds);
+	sz = n * AST_MAX_FDS + nfds;
 	pfds = alloca(sizeof(struct pollfd) * sz);
-	ci = alloca(sizeof(int *) * sz);	/* pfds to channel map */
-	fdno = alloca(sizeof(int *) * sz);	/* pfds to fd index */
-
-	if (!pfds || !ci || !fdno) {
+	fdmap = alloca(sizeof(struct fdmap) * sz);
+	if (!pfds || !fdmap) {
 		ast_log(LOG_ERROR, "Out of memory\n");
 		return NULL;
 	}
-	for (x=0; x < sz; x++)
-		ci[x] = -1;		/* no channel linked to this pfd */
 
 	/*
 	 * Perform any pending masquerades, and take the min timeout in t0
 	 */
 	for (x=0; x<n; x++) {
-		time_t t;
-
 		ast_mutex_lock(&c[x]->lock);
 		if (c[x]->masq) {
 			if (ast_do_masquerade(c[x])) {
@@ -1560,15 +1545,25 @@
 				return NULL;
 			}
 		}
-		t = c[x]->whentohangup;
-		if (t > 0 && (t0 == 0 || t < t0))
-			t0 = t;
+		if (c[x]->whentohangup) {
+			if (!whentohangup)
+				time(&now);
+			diff = c[x]->whentohangup - now;
+			if (diff < 1) {
+				/* Should already be hungup */
+				c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
+				ast_mutex_unlock(&c[x]->lock);
+				return c[x];
+			}
+			if (!whentohangup || (diff < whentohangup))
+				whentohangup = diff;
+		}
 		ast_mutex_unlock(&c[x]->lock);
 	}
-	if (t0 == 0)	/* no timeout, use *ms */
-		rms = *ms;
-	else {
-		rms = (t0 - time(NULL)) * 1000;	/* timeout in milliseconds */
+	/* Wait full interval */
+	rms = *ms;
+	if (whentohangup) {
+		rms = (whentohangup - now) * 1000;	/* timeout in milliseconds */
 		if (*ms >= 0 && *ms < rms)		/* original *ms still smaller */
 			rms =  *ms;
 	}
@@ -1579,18 +1574,18 @@
 	 */
 	max = 0;
 	for (x=0; x<n; x++) {
-		int y;
-
-		for (y=0; y<AST_MAX_FDS; y++)
-			if (add_fd(&pfds[max], c[x]->fds[y])) {
-				fdno[max] = y;  /* fd y is linked to this pfds */
-				ci[max++] = x;  /* channel x is linked to this pfds */
-			}
+		for (y=0; y<AST_MAX_FDS; y++) {
+			fdmap[max].fdno = y;  /* fd y is linked to this pfds */
+			fdmap[max].chan = x;  /* channel x is linked to this pfds */
+			max += ast_add_fd(&pfds[max], c[x]->fds[y]);
+		}
 		CHECK_BLOCKING(c[x]);
 	}
-	/* add the individual fds */
-	for (x=0; x<nfds; x++)
-		max += add_fd(&pfds[max], fds[x]);
+	/* Add the individual fds */
+	for (x=0; x<nfds; x++) {
+		fdmap[max].chan = -1;
+		max += ast_add_fd(&pfds[max], fds[x]);
+	}
 
 	if (*ms > 0) 
 		start = ast_tvnow();
@@ -1613,10 +1608,10 @@
 		*ms = (errno != EINTR) ? -1 : 0;
 		return NULL;
 	}
-	if (t0 > 0) {   /* if we have a timeout, check who expired */
-		time(&t0);
+	if (whentohangup) {   /* if we have a timeout, check who expired */
+		time(&now);
 		for (x=0; x<n; x++) {
-			if (c[x]->whentohangup && t0 > c[x]->whentohangup) {
+			if (c[x]->whentohangup && now >= c[x]->whentohangup) {
 				c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
 				if (winner == NULL)
 					winner = c[x];
@@ -1636,13 +1631,13 @@
 		res = pfds[x].revents;
 		if (res == 0)
 			continue;
-		if (ci[x] >= 0) {	/* this is a channel */
-			winner = c[ci[x]];	/* override previous winners */
+		if (fdmap[x].chan >= 0) {	/* this is a channel */
+			winner = c[fdmap[x].chan];	/* override previous winners */
 			if (res & POLLPRI)
 				ast_set_flag(winner, AST_FLAG_EXCEPTION);
 			else
 				ast_clear_flag(winner, AST_FLAG_EXCEPTION);
-			winner->fdno = fdno[x];
+			winner->fdno = fdmap[x].fdno;
 		} else {			/* this is an fd */
 			if (outfd)
 				*outfd = pfds[x].fd;
@@ -1669,8 +1664,8 @@
 	int oldms = ms;	/* -1 if no timeout */
 
 	ast_waitfor_nandfds(&c, 1, NULL, 0, NULL, NULL, &ms);
-	if (ms < 0)			/* !EINTR */
-		return (oldms < 0) ? 0 : -1;
+	if ((ms < 0) && (oldms < 0))
+		ms = 0;
 	return ms;
 }
 
@@ -1829,7 +1824,6 @@
 #ifdef ZAPTEL_OPTIMIZATIONS
 	if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD && ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
 		int res;
-
 		ast_clear_flag(chan, AST_FLAG_EXCEPTION);
 		blah = -1;
 		/* IF we can't get event, assume it's an expired as-per the old interface */
@@ -1860,15 +1854,17 @@
 			return &null_frame;
 		} else
 			ast_log(LOG_NOTICE, "No/unknown event '%d' on timer for '%s'?\n", blah, chan->name);
-	}
+	} else
 #endif
-	/* check for pending generator call */
+	/* Check for AST_GENERATOR_FD if not null.  If so, call generator with -1
+	   arguments now so it can do whatever it needs to. */
 	if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) {
 		void *tmp = chan->generatordata;
-
 		chan->generatordata = NULL;     /* reset to let ast_write get through */
-		chan->generator->generate(chan, tmp, 0, 160);
+		chan->generator->generate(chan, tmp, -1, -1);
 		chan->generatordata = tmp;
+		f = &null_frame;
+		return f;
 	}
 
 	/* Check for pending read queue */
@@ -3042,9 +3038,10 @@
 	
 	/* Keep the same language.  */
 	ast_copy_string(original->language, clone->language, sizeof(original->language));
-	/* Copy the FD's */
+	/* Copy the FD's other than the generator fd */
 	for (x = 0; x < AST_MAX_FDS; x++) {
-		original->fds[x] = clone->fds[x];
+		if (x != AST_GENERATOR_FD)
+			original->fds[x] = clone->fds[x];
 	}
 	clone_variables(original, clone);
 	AST_LIST_HEAD_INIT_NOLOCK(&clone->varshead);

Modified: team/rizzo/base/channels/chan_oss.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/channels/chan_oss.c?rev=8943&r1=8942&r2=8943&view=diff
==============================================================================
--- team/rizzo/base/channels/chan_oss.c (original)
+++ team/rizzo/base/channels/chan_oss.c Mon Jan 30 16:46:56 2006
@@ -368,11 +368,13 @@
 static struct chan_oss_pvt *find_desc(char *dev)
 {
 	struct chan_oss_pvt *o;
-
-	for (o = oss_default.next; o && strcmp(o->name, dev) != 0; o = o->next)
+	if (dev == NULL)
+		ast_log(LOG_WARNING, "null dev\n");
+
+	for (o = oss_default.next; o && (o->name && dev && strcmp(o->name, dev) != 0); o = o->next)
 		;
 	if (o == NULL)
-		ast_log(LOG_WARNING, "could not find <%s>\n", dev);
+		ast_log(LOG_WARNING, "could not find <%s>\n", dev ? dev : "--no-device--");
 	return o;
 }
 

Modified: team/rizzo/base/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/channels/chan_sip.c?rev=8943&r1=8942&r2=8943&view=diff
==============================================================================
--- team/rizzo/base/channels/chan_sip.c (original)
+++ team/rizzo/base/channels/chan_sip.c Mon Jan 30 16:46:56 2006
@@ -364,6 +364,7 @@
 #define DEFAULT_PEDANTIC	FALSE
 #define DEFAULT_AUTOCREATEPEER	FALSE
 #define DEFAULT_QUALIFY		FALSE
+#define DEFAULT_T1MIN		100		/*!< 100 MS for minimal roundtrip time */
 #ifndef DEFAULT_USERAGENT
 #define DEFAULT_USERAGENT "Asterisk PBX"	/*!< Default Useragent: header unless re-defined in sip.conf */
 #endif
@@ -404,6 +405,7 @@
 static char global_useragent[AST_MAX_EXTENSION];	/*!< Useragent for the SIP channel */
 static int allow_external_domains;	/*!< Accept calls to external SIP domains? */
 static int global_callevents;		/*!< Whether we send manager events or not */
+static int global_t1min;		/*!< T1 roundtrip time minimum */
 
 /*! \brief Codecs that we support by default: */
 static int global_capability = AST_FORMAT_ULAW | AST_FORMAT_ALAW | AST_FORMAT_GSM | AST_FORMAT_H263;
@@ -482,6 +484,13 @@
  *	rlPart1 = SIP/2.0; rlPart2 = code + description;
  *
  */
+
+/*! \brief structure used in transfers */
+struct sip_dual {
+	struct ast_channel *chan1;
+	struct ast_channel *chan2;
+	struct sip_request req;
+};
 
 struct sip_pkt;
 
@@ -936,7 +945,6 @@
 static struct sip_user *build_user(const char *name, struct ast_variable *v, int realtime);
 static int sip_do_reload(enum channelreloadreason reason);
 static int expire_register(void *data);
-
 static struct ast_channel *sip_request_call(const char *type, int format, void *data, int *cause);
 static int sip_devicestate(void *data);
 static int sip_sendtext(struct ast_channel *ast, const char *text);
@@ -952,6 +960,9 @@
 static int clear_realm_authentication(struct sip_auth *authlist);                            /* Clear realm authentication list (at reload) */
 static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno);   /* Add realm authentication in list */
 static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, const char *realm);         /* Find authentication for a specific realm */
+static int check_auth(struct sip_pvt *p, struct sip_request *req, const char *username,
+		      const char *secret, const char *md5secret, int sipmethod,
+		      char *uri, int reliable, int ignore);
 static int check_sip_domain(const char *domain, char *context, size_t len); /* Check if domain is one of our local domains */
 static void append_date(struct sip_request *req);	/* Append date to SIP packet */
 static int determine_firstline_parts(struct sip_request *req);
@@ -969,6 +980,12 @@
 static int sip_poke_peer(struct sip_peer *peer);
 static int __sip_do_register(struct sip_registry *r);
 static int restart_monitor(void);
+
+/*----- RTP interface functions */
+static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active);
+static struct ast_rtp *sip_get_rtp_peer(struct ast_channel *chan);
+static struct ast_rtp *sip_get_vrtp_peer(struct ast_channel *chan);
+static int sip_get_codec(struct ast_channel *chan);
 
 /*! \brief Definition of this channel for PBX channel registration */
 static const struct ast_channel_tech sip_tech = {
@@ -1001,6 +1018,16 @@
 		(head) = (element)->next;	\
 	} while (0)				\
 
+/*! \brief Interface structure with callbacks used to connect to RTP module */
+static struct ast_rtp_protocol sip_rtp = {
+	type: channeltype,
+	get_rtp_info: sip_get_rtp_peer,
+	get_vrtp_info: sip_get_vrtp_peer,
+	set_rtp_peer: sip_set_rtp_peer,
+	get_codec: sip_get_codec,
+};
+
+
 /*!
   \brief Thread-safe random number generator
   \return a random number
@@ -1931,8 +1958,9 @@
 	r->callgroup = peer->callgroup;
 	r->pickupgroup = peer->pickupgroup;
 	/* Set timer T1 to RTT for this peer (if known by qualify=) */
+	/* Minimum is settable or default to 100 ms */
 	if (peer->maxms && peer->lastms)
-		r->timer_t1 = peer->lastms;
+		r->timer_t1 = peer->lastms < global_t1min ? global_t1min : peer->lastms;
 	if ((ast_test_flag(r, SIP_DTMF) == SIP_DTMF_RFC2833) || (ast_test_flag(r, SIP_DTMF) == SIP_DTMF_AUTO))
 		r->noncodeccapability |= AST_RTP_DTMF;
 	else
@@ -5984,12 +6012,14 @@
 
 /*! \brief  Check user authorization from peer definition 
 	Some actions, like REGISTER and INVITEs from peers require
-	authentication (if peer have secret set) */
+	authentication (if peer have secret set) 
+	\return -1 on Error, 0 on success, 1 on challenge sent
+	
+*/
 static int check_auth(struct sip_pvt *p, struct sip_request *req, const char *username,
 		      const char *secret, const char *md5secret, int sipmethod,
 		      char *uri, int reliable, int ignore)
 {
-	int res = -1;
 	const char *response = "407 Proxy Authentication Required";
 	const char *reqheader = "Proxy-Authorization";
 	const char *respheader = "Proxy-Authenticate";
@@ -6014,30 +6044,29 @@
 #ifdef OSP_SUPPORT
 	else {
 		char *osptoken;
-		ast_log (LOG_DEBUG, "Checking OSP Authentication!\n");
+		if (option_debug)
+			ast_log (LOG_DEBUG, "Checking OSP Authentication!\n");
 		osptoken = get_header (req, "P-OSP-Auth-Token");
 		switch (ast_test_flag (p, SIP_OSPAUTH)) {
 			case SIP_OSPAUTH_NO:
 				break;
 			case SIP_OSPAUTH_GATEWAY:
-				if (ast_strlen_zero (osptoken)) {
+				if (ast_strlen_zero(osptoken)) {
 					if (ast_strlen_zero(secret) && ast_strlen_zero (md5secret))
 						return 0;
 				} else {
-					return check_osptoken (p, osptoken);
+					return check_osptoken(p, osptoken);
 				}
 				break;
 			case SIP_OSPAUTH_PROXY:
-				if (ast_strlen_zero (osptoken))
+				if (ast_strlen_zero(osptoken))
 					return 0;
-				else
-					return check_osptoken (p, osptoken);
+				return check_osptoken(p, osptoken);
 				break;
 			case SIP_OSPAUTH_EXCLUSIVE:
-				if (ast_strlen_zero (osptoken))
+				if (ast_strlen_zero(osptoken))
 					return -1;
-				else
-					return check_osptoken (p, osptoken);
+				return check_osptoken(p, osptoken);
 				break;
 			default:
 				return -1;
@@ -6048,25 +6077,24 @@
 	if (ignore && !ast_strlen_zero(p->randdata) && ast_strlen_zero(authtoken)) {
 		/* This is a retransmitted invite/register/etc, don't reconstruct authentication
 		   information */
-		if (!ast_strlen_zero(p->randdata)) {
-			if (!reliable) {
-				/* Resend message if this was NOT a reliable delivery.   Otherwise the
-				   retransmission should get it */
-				transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
-				/* Schedule auto destroy in 15 seconds */
-				sip_scheddestroy(p, 15000);
-			}
-			res = 1;
-		}
+		if (!reliable) {
+			/* Resend message if this was NOT a reliable delivery.   Otherwise the
+			   retransmission should get it */
+			transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
+			/* Schedule auto destroy in 32 seconds (according to RFC 3261) */
+			sip_scheddestroy(p, 32000);
+		}
+		return 1;	/* Auth sent */
 	} else if (ast_strlen_zero(p->randdata) || ast_strlen_zero(authtoken)) {
-		ast_string_field_build(p, randdata, "%08x", thread_safe_rand());
+		/* We have no auth, so issue challenge and request authentication */
+		ast_string_field_build(p, randdata, "%08x", thread_safe_rand());	/* Create nonce for challenge */
 		transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
-		/* Schedule auto destroy in 15 seconds */
-		sip_scheddestroy(p, 15000);
-		res = 1;
-	} else {
+		/* Schedule auto destroy in 32 seconds */
+		sip_scheddestroy(p, 32000);
+		return 1;	/* Auth sent */
+	} else {	/* We have auth, so check it */
 		/* Whoever came up with the authentication section of SIP can suck my %&#$&* for not putting
-		   an example in the spec of just what it is you're doing a hash on. */
+	   	an example in the spec of just what it is you're doing a hash on. */
 		char a1_hash[256];
 		char resp_hash[256]="";
 		char tmp[256];
@@ -6162,15 +6190,21 @@
 				transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
 			}
 
-			/* Schedule auto destroy in 15 seconds */
-			sip_scheddestroy(p, 15000);
+			/* Schedule auto destroy in 32 seconds */
+			sip_scheddestroy(p, 32000);
 			return 1;	/* XXX should it be -1 ? */
 		} 
 		if (good_response) /* Auth is OK */
-			res = 0;
-	}
-	/* Failure */
-	return res;
+			return 0;
+
+		/* XXX is this needed ? */
+		/* Ok, we have a bad username/secret pair */
+		/* Challenge again, and again, and again */
+		transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
+		sip_scheddestroy(p, 32000);
+		return 1;		/* Challenge sent */
+
+	}
 }
 
 /*! \brief Callback for the devicestate notification (SUBSCRIBE) support subsystem
@@ -8052,6 +8086,7 @@
 	ast_cli(fd, "  Codecs:                 ");
 	print_codec_to_cli(fd, &prefs);
 	ast_cli(fd, "\n");
+	ast_cli(fd, "  T1 minimum:             %d\n", global_t1min);
 	ast_cli(fd, "  Relax DTMF:             %s\n", global_relaxdtmf ? "Yes" : "No");
 	ast_cli(fd, "  Compact SIP headers:    %s\n", compactheaders ? "Yes" : "No");
 	ast_cli(fd, "  RTP Timeout:            %d %s\n", global_rtptimeout, global_rtptimeout ? "" : "(Disabled)" );
@@ -9858,13 +9893,8 @@
 	}
 }
 
-struct sip_dual {
-	struct ast_channel *chan1;
-	struct ast_channel *chan2;
-	struct sip_request req;
-};
-
-/*! \brief  sip_park_thread: Park SIP call support function */
+
+/*! \brief Park SIP call support function */
 static void *sip_park_thread(void *stuff)
 {
 	struct ast_channel *chan1, *chan2;
@@ -9887,7 +9917,7 @@
 	return NULL;
 }
 
-/*! \brief  sip_park: Park a call */
+/*! \brief Park a call */
 static int sip_park(struct ast_channel *chan1, struct ast_channel *chan2, struct sip_request *req)
 {
 	struct sip_dual *d;
@@ -9943,7 +9973,7 @@
 	return -1;
 }
 
-/*! \brief  ast_quiet_chan: Turn off generator data */
+/*! \brief Turn off generator data */
 static void ast_quiet_chan(struct ast_channel *chan) 
 {
 	if (chan && chan->_state == AST_STATE_UP) {
@@ -9952,7 +9982,7 @@
 	}
 }
 
-/*! \brief  attempt_transfer: Attempt transfer of SIP call */
+/*! \brief Attempt transfer of SIP call */
 static int attempt_transfer(struct sip_pvt *p1, struct sip_pvt *p2)
 {
 	int res = 0;
@@ -10044,7 +10074,7 @@
 	return thetag;	/* XXX maybe this should be tagbuf instead ? */
 }
 
-/*! \brief  handle_request_options: Handle incoming OPTIONS request */
+/*! \brief Handle incoming OPTIONS request */
 static int handle_request_options(struct sip_pvt *p, struct sip_request *req, int debug)
 {
 	int res;
@@ -10068,7 +10098,7 @@
 	return res;
 }
 
-/*! \brief  handle_request_invite: Handle incoming INVITE request */
+/*! \brief Handle incoming INVITE request */
 static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, struct sockaddr_in *sin, int *recount, char *e)
 {
 	int res = 1;
@@ -10305,7 +10335,7 @@
 	return res;
 }
 
-/*! \brief  handle_request_refer: Handle incoming REFER request */
+/*! \brief Handle incoming REFER request */
 static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, int *nounlock)
 {
 	struct ast_channel *c=NULL;
@@ -10372,7 +10402,7 @@
 	}
 	return res;
 }
-/*! \brief  handle_request_cancel: Handle incoming CANCEL request */
+/*! \brief Handle incoming CANCEL request */
 static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req, int debug, int ignore)
 {
 		
@@ -10401,7 +10431,7 @@
 	}
 }
 
-/*! \brief  handle_request_bye: Handle incoming BYE request */
+/*! \brief Handle incoming BYE request */
 static int handle_request_bye(struct sip_pvt *p, struct sip_request *req, int debug, int ignore)
 {
 	struct ast_channel *c=NULL;
@@ -10454,7 +10484,7 @@
 	return 1;
 }
 
-/*! \brief  handle_request_message: Handle incoming MESSAGE request */
+/*! \brief Handle incoming MESSAGE request */
 static int handle_request_message(struct sip_pvt *p, struct sip_request *req, int debug, int ignore)
 {
 	if (!ignore) {
@@ -10654,7 +10684,7 @@
 	return 1;
 }
 
-/*! \brief  handle_request_register: Handle incoming REGISTER request */
+/*! \brief Handle incoming REGISTER request */
 static int handle_request_register(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, struct sockaddr_in *sin, char *e)
 {
 	int res = 0;
@@ -10675,8 +10705,8 @@
 	return res;
 }
 
-/*! \brief  handle_request: Handle SIP requests (methods) */
-/*      this is where all incoming requests go first   */
+/*! \brief Handle incoming SIP requests (methods) 
+\note	This is where all incoming requests go first   */
 /* called with p and p->owner locked */
 static int handle_request(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int *recount, int *nounlock)
 {
@@ -10879,8 +10909,8 @@
 	return res;
 }
 
-/*! \brief  sipsock_read: Read data from SIP socket */
-/*    Successful messages is connected to SIP call and forwarded to handle_request() */
+/*! \brief Read data from SIP socket
+\note Successful messages is connected to SIP call and forwarded to handle_request() */
 static int sipsock_read(int *id, int fd, short events, void *ignore)
 {
 	struct sip_request req;
@@ -10967,7 +10997,7 @@
 	return 1;
 }
 
-/*! \brief  sip_send_mwi_to_peer: Send message waiting indication */
+/*! \brief Send message waiting indication to alert peer that they've got voicemail */
 static int sip_send_mwi_to_peer(struct sip_peer *peer)
 {
 	/* Called with peerl lock, but releases it */
@@ -11005,7 +11035,7 @@
 	return 0;
 }
 
-/*! \brief  do_monitor: The SIP monitoring thread */
+/*! \brief The SIP monitoring thread */
 static void *do_monitor(void *data)
 {
 	int res;
@@ -11136,7 +11166,7 @@
 	
 }
 
-/*! \brief  restart_monitor: Start the channel monitor thread */
+/*! \brief Start the channel monitor thread */
 static int restart_monitor(void)
 {
 	pthread_attr_t attr;
@@ -11169,7 +11199,7 @@
 	return 0;
 }
 
-/*! \brief  sip_poke_noanswer: No answer to Qualify poke */
+/*! \brief React to lack of answer to Qualify poke */
 static int sip_poke_noanswer(void *data)
 {
 	struct sip_peer *peer = data;
@@ -11189,9 +11219,9 @@
 	return 0;
 }
 
-/*! \brief  sip_poke_peer: Check availability of peer, also keep NAT open */
-/*	This is done with the interval in qualify= option in sip.conf */
-/*	Default is 2 seconds */
+/*! \brief Check availability of peer, also keep NAT open
+\note	This is done with the interval in qualify= configuration option
+	Default is 2 seconds */
 static int sip_poke_peer(struct sip_peer *peer)
 {
 	struct sip_pvt *p;
@@ -11251,20 +11281,21 @@
 	return 0;
 }
 
-/*! \brief  sip_devicestate: Part of PBX channel interface */
-
-/* Return values:---
+/*! \brief Part of PBX channel interface
+\note
+\par	Return values:---
+
 	If we have qualify on and the device is not reachable, regardless of registration
 	state we return AST_DEVICE_UNAVAILABLE
 
 	For peers with call limit:
-		not registered			AST_DEVICE_UNAVAILABLE
-		registered, no call		AST_DEVICE_NOT_INUSE
-		registered, calls possible	AST_DEVICE_INUSE
-		registered, call limit reached	AST_DEVICE_BUSY
+		- not registered			AST_DEVICE_UNAVAILABLE
+		- registered, no call		AST_DEVICE_NOT_INUSE
+		- registered, calls possible	AST_DEVICE_INUSE
+		- registered, call limit reached	AST_DEVICE_BUSY
 	For peers without call limit:
-		not registered			AST_DEVICE_UNAVAILABLE
-		registered			AST_DEVICE_UNKNOWN
+		- not registered			AST_DEVICE_UNAVAILABLE
+		- registered			AST_DEVICE_UNKNOWN
 */
 static int sip_devicestate(void *data)
 {
@@ -11316,7 +11347,7 @@
 	return res;
 }
 
-/*! \brief  sip_request: PBX interface function -build SIP pvt structure */
+/*! \brief PBX interface function -build SIP pvt structure */
 /* SIP calls initiated by the PBX arrive here */
 static struct ast_channel *sip_request_call(const char *type, int format, void *data, int *cause)
 {
@@ -11391,7 +11422,7 @@
 	return tmpc;
 }
 
-/*! \brief  handle_common_options: Handle flag-type options common to users and peers */
+/*! \brief Handle flag-type options common to users and peers */
 static int handle_common_options(struct ast_flags *flags, struct ast_flags *mask, struct ast_variable *v)
 {
 	int res = 0;
@@ -11500,7 +11531,7 @@
 	return res;
 }
 
-/*! \brief  add_sip_domain: Add SIP domain to list of domains we are responsible for */
+/*! \brief Add SIP domain to list of domains we are responsible for */
 static int add_sip_domain(const char *domain, const enum domain_mode mode, const char *context)
 {
 	struct domain *d;
@@ -11552,7 +11583,7 @@
 	return result;
 }
 
-/*! \brief  clear_sip_domains: Clear our domain list (at reload) */
+/*! \brief Clear our domain list (at reload) */
 static void clear_sip_domains(void)
 {
 	struct domain *d;
@@ -11564,7 +11595,7 @@
 }
 
 
-/*! \brief  add_realm_authentication: Add realm authentication in list */
+/*! \brief Add realm authentication in list */
 static struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno)
 {
 	char authcopy[256];
@@ -11626,7 +11657,7 @@
 
 }
 
-/*! \brief  clear_realm_authentication: Clear realm authentication list (at reload) */
+/*! \brief Clear realm authentication list (at reload) */
 static int clear_realm_authentication(struct sip_auth *authlist)
 {
 	struct sip_auth *a = authlist;
@@ -11641,7 +11672,7 @@
 	return 1;
 }
 
-/*! \brief  find_realm_authentication: Find authentication for a specific realm */
+/*! \brief Find authentication for a specific realm */
 static struct sip_auth *find_realm_authentication(struct sip_auth *authlist, const char *realm)
 {
 	struct sip_auth *a;
@@ -11652,7 +11683,7 @@
 	return a;
 }
 
-/*! \brief  build_user: Initiate a SIP user structure from sip.conf */
+/*! \brief Initiate a SIP user structure from configuration (configuration or realtime) */
 static struct sip_user *build_user(const char *name, struct ast_variable *v, int realtime)
 {
 	struct sip_user *user;
@@ -11742,7 +11773,7 @@
 	return user;
 }
 
-/*! \brief  temp_peer: Create temporary peer (used in autocreatepeer mode) */
+/*! \brief Create temporary peer (used in autocreatepeer mode) */
 static struct sip_peer *temp_peer(const char *name)
 {
 	struct sip_peer *peer;
@@ -11775,7 +11806,7 @@
 	return peer;
 }
 
-/*! \brief  build_peer: Build peer from config file */
+/*! \brief Build peer from configuration (file or realtime static/dynamic) */
 static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime)
 {
 	struct sip_peer *peer = NULL;
@@ -12033,8 +12064,8 @@
 	return peer;
 }
 
-/*! \brief  reload_config: Re-read SIP.conf config file */
-/*	This function reloads all config data, except for
+/*! \brief Re-read SIP.conf config file
+\note	This function reloads all config data, except for
 	active peers (with registrations). They will only
 	change configuration data at restart, not at reload.
 	SIP debug and recordhistory state will not change
@@ -12123,6 +12154,7 @@
 	/* Misc settings for the channel */
 	global_relaxdtmf = FALSE;
 	global_callevents = FALSE;
+	global_t1min = DEFAULT_T1MIN;		
 
 	/* Read the [general] config section of sip.conf (or from realtime config) */
 	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
@@ -12143,6 +12175,8 @@
 			ast_set2_flag((&global_flags_page2), ast_true(v->value), SIP_PAGE2_RTUPDATE);	
 		} else if (!strcasecmp(v->name, "ignoreregexpire")) {
 			ast_set2_flag((&global_flags_page2), ast_true(v->value), SIP_PAGE2_IGNOREREGEXPIRE);	
+		} else if (!strcasecmp(v->name, "t1min")) {
+			global_t1min = atoi(v->value);
 		} else if (!strcasecmp(v->name, "rtautoclear")) {
 			int i = atoi(v->value);
 			if (i > 0)
@@ -12452,7 +12486,7 @@
 	return 0;
 }
 
-/*! \brief  sip_get_rtp_peer: Returns null if we can't reinvite (part of RTP interface) */
+/*! \brief Returns null if we can't reinvite (part of RTP interface) */
 static struct ast_rtp *sip_get_rtp_peer(struct ast_channel *chan)
 {
 	struct sip_pvt *p;
@@ -12467,7 +12501,7 @@
 	return rtp;
 }
 
-/*! \brief  sip_get_vrtp_peer: Returns null if we can't reinvite video (part of RTP interface) */
+/*! \brief Returns null if we can't reinvite video (part of RTP interface) */
 static struct ast_rtp *sip_get_vrtp_peer(struct ast_channel *chan)
 {
 	struct sip_pvt *p;
@@ -12483,7 +12517,7 @@
 	return rtp;
 }
 
-/*! \brief  sip_set_rtp_peer: Set the RTP peer for this call */
+/*! \brief Set the RTP peer for this call */
 static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active)
 {
 	struct sip_pvt *p;
@@ -12543,7 +12577,7 @@
 "Always returns 0\n";
 
 
-/*! \brief  sip_dtmfmode: change the DTMFmode for a SIP call (application) */
+/*! \brief Set the DTMFmode for an outbound SIP call (application) */
 static int sip_dtmfmode(struct ast_channel *chan, void *data)
 {
 	struct sip_pvt *p;
@@ -12593,7 +12627,7 @@
 	return 0;
 }
 
-/*! \brief  sip_addheader: Add a SIP header */
+/*! \brief Add a SIP header to an outbound INVITE */
 static int sip_addheader(struct ast_channel *chan, void *data)
 {
 	int no = 0;
@@ -12626,11 +12660,11 @@
 	return 0;
 }
 
-/*! \brief  sip_sipredirect: Transfer call before connect with a 302 redirect
- * Called by the transfer() dialplan application through the sip_transfer()
- * pbx interface function if the call is in ringing state 
- * \todo Fix this function so that we wait for reply to the REFER and
- * 	 react to errors, denials or other issues the other end might have.
+/*! \brief Transfer call before connect with a 302 redirect
+\note	Called by the transfer() dialplan application through the sip_transfer()
+	pbx interface function if the call is in ringing state 
+\todo	Fix this function so that we wait for reply to the REFER and
+	react to errors, denials or other issues the other end might have.
  */
 static int sip_sipredirect(struct sip_pvt *p, const char *dest)
 {
@@ -12687,23 +12721,14 @@
 	return -1;
 }
 
-/*! \brief  sip_get_codec: Return SIP UA's codec (part of the RTP interface) */
+/*! \brief Return SIP UA's codec (part of the RTP interface) */
 static int sip_get_codec(struct ast_channel *chan)
 {
 	struct sip_pvt *p = chan->tech_pvt;
 	return p->peercapability;	
 }
 
-/*! \brief  sip_rtp: Interface structure with callbacks used to connect to rtp module */
-static struct ast_rtp_protocol sip_rtp = {
-	type: channeltype,
-	get_rtp_info: sip_get_rtp_peer,
-	get_vrtp_info: sip_get_vrtp_peer,
-	set_rtp_peer: sip_set_rtp_peer,
-	get_codec: sip_get_codec,
-};
-
-/*! \brief  sip_poke_all_peers: Send a poke to all known peers */
+/*! \brief Send a poke to all known peers */
 static void sip_poke_all_peers(void)
 {
 	ASTOBJ_CONTAINER_TRAVERSE(&peerl, 1, do {
@@ -12714,7 +12739,7 @@
 	);
 }
 
-/*! \brief  sip_send_all_registers: Send all known registrations */
+/*! \brief Send all known registrations */
 static void sip_send_all_registers(void)
 {
 	int ms;
@@ -12736,7 +12761,7 @@
 	);
 }
 
-/*! \brief  sip_do_reload: Reload module */
+/*! \brief Reload module */
 static int sip_do_reload(enum channelreloadreason reason)
 {
 	if (option_debug > 3)
@@ -12786,7 +12811,7 @@
 	return 0;
 }
 
-/*! \brief  sip_reload: Force reload of module from cli */
+/*! \brief Force reload of module from cli */
 static int sip_reload(int fd, int argc, char *argv[])
 {
 

Modified: team/rizzo/base/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/base/channels/chan_zap.c?rev=8943&r1=8942&r2=8943&view=diff
==============================================================================
--- team/rizzo/base/channels/chan_zap.c (original)
+++ team/rizzo/base/channels/chan_zap.c Mon Jan 30 16:46:56 2006
@@ -110,6 +110,9 @@
 #define ZT_EVENT_DTMFDOWN 0
 #define ZT_EVENT_DTMFUP 0
 #endif
+
+/* define this to send PRI user-user information elements */
+#undef SUPPORT_USERUSER
 
 /*! 
  * \note Define ZHONE_HACK to cause us to go off hook and then back on hook when
@@ -2013,7 +2016,9 @@
 #ifdef ZAPATA_PRI
 	if (p->pri) {
 		struct pri_sr *sr;
+#ifdef SUPPORT_USERUSER
 		const char *useruser;
+#endif
 		int pridialplan;
 		int dp_strip;
 		int prilocaldialplan;
@@ -2127,11 +2132,14 @@
 					l ? (p->use_callingpres ? ast->cid.cid_pres : PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN) : 
 						 PRES_NUMBER_NOT_AVAILABLE);
 		pri_sr_set_redirecting(sr, ast->cid.cid_rdnis, p->pri->localdialplan - 1, PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, PRI_REDIR_UNCONDITIONAL);
+
+#ifdef SUPPORT_USERUSER
 		/* User-user info */
 		useruser = pbx_builtin_getvar_helper(p->owner, "USERUSERINFO");
 
 		if (useruser)
 			pri_sr_set_useruser(sr, useruser);
+#endif
 
 		if (pri_setup(p->pri->pri, p->call,  sr)) {
  			ast_log(LOG_WARNING, "Unable to setup call to %s (using %s)\n", 
@@ -2519,13 +2527,20 @@
 		/* Perform low level hangup if no owner left */
 #ifdef ZAPATA_PRI
 		if (p->pri) {
+#ifdef SUPPORT_USERUSER
 			const char *useruser = pbx_builtin_getvar_helper(ast,"USERUSERINFO");
+#endif
+
 			/* Make sure we have a call (or REALLY have a call in the case of a PRI) */
 			if (p->call && (!p->bearer || (p->bearer->call == p->call))) {
 				if (!pri_grab(p, p->pri)) {
 					if (p->alreadyhungup) {
 						ast_log(LOG_DEBUG, "Already hungup...  Calling hangup once, and clearing call\n");
+
+#ifdef SUPPORT_USERUSER
 						pri_call_set_useruser(p->call, useruser);
+#endif
+
 						pri_hangup(p->pri->pri, p->call, -1);
 						p->call = NULL;
 						if (p->bearer) 
@@ -2534,7 +2549,11 @@
 						const char *cause = pbx_builtin_getvar_helper(ast,"PRI_CAUSE");
 						int icause = ast->hangupcause ? ast->hangupcause : -1;
 						ast_log(LOG_DEBUG, "Not yet hungup...  Calling hangup once with icause, and clearing call\n");
+
+#ifdef SUPPORT_USERUSER
 						pri_call_set_useruser(p->call, useruser);
+#endif
+
 						p->alreadyhungup = 1;
 						if (p->bearer)
 							p->bearer->alreadyhungup = 1;
@@ -8652,9 +8671,13 @@
 								snprintf(ani2str, 5, "%.2d", e->ring.ani2);
 								pbx_builtin_setvar_helper(c, "ANI2", ani2str);
 							}
+
+#ifdef SUPPORT_USERUSER
 							if (!ast_strlen_zero(e->ring.useruserinfo)) {
 								pbx_builtin_setvar_helper(c, "USERUSERINFO", e->ring.useruserinfo);
 							}
+#endif
+
 							snprintf(calledtonstr, sizeof(calledtonstr)-1, "%d", e->ring.calledplan);
 							pbx_builtin_setvar_helper(c, "CALLEDTON", calledtonstr);
 							if (e->ring.redirectingreason >= 0)
@@ -8687,9 +8710,13 @@
 									snprintf(ani2str, 5, "%d", e->ring.ani2);
 									pbx_builtin_setvar_helper(c, "ANI2", ani2str);
 								}
+
+#ifdef SUPPORT_USERUSER
 								if (!ast_strlen_zero(e->ring.useruserinfo)) {
 									pbx_builtin_setvar_helper(c, "USERUSERINFO", e->ring.useruserinfo);
 								}
+#endif
+
 								if (e->ring.redirectingreason >= 0)
 									pbx_builtin_setvar_helper(c, "PRIREDIRECTREASON", redirectingreason2str(e->ring.redirectingreason));
 							
@@ -8755,9 +8782,13 @@
 								pri->pvts[chanpos]->dsp_features = 0;
 							}
 						}
+
+#ifdef SUPPORT_USERUSER
 						if (!ast_strlen_zero(e->ringing.useruserinfo)) {
 							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->ringing.useruserinfo);
 						}
+#endif
+
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
@@ -8912,9 +8943,13 @@
 							/* Enable echo cancellation if it's not on already */
 							zt_enable_ec(pri->pvts[chanpos]);
 						}
+
+#ifdef SUPPORT_USERUSER
 						if (!ast_strlen_zero(e->answer.useruserinfo)) {
 							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->answer.useruserinfo);
 						}
+#endif
+
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
@@ -8972,9 +9007,13 @@
 							if (option_verbose > 2)
 								ast_verbose(VERBOSE_PREFIX_3 "Channel %d/%d, span %d received AOC-E charging %d unit%s\n",
 									pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span, (int)e->hangup.aoc_units, (e->hangup.aoc_units == 1) ? "" : "s");
+
+#ifdef SUPPORT_USERUSER
 						if (!ast_strlen_zero(e->hangup.useruserinfo)) {
 							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->hangup.useruserinfo);
 						}
+#endif
+
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					} else {
 						ast_log(LOG_WARNING, "Hangup on bad channel %d/%d on span %d\n", 
@@ -9032,9 +9071,13 @@
 							pri_reset(pri->pri, PVT_TO_CHANNEL(pri->pvts[chanpos]));
 							pri->pvts[chanpos]->resetting = 1;
 						}
+
+#ifdef SUPPORT_USERUSER
 						if (!ast_strlen_zero(e->hangup.useruserinfo)) {
 							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->hangup.useruserinfo);
 						}
+#endif
+
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					} else {
 						ast_log(LOG_WARNING, "Hangup REQ on bad channel %d/%d on span %d\n", PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
@@ -9058,9 +9101,13 @@
 							if (option_verbose > 2) 

[... 97 lines stripped ...]


More information about the asterisk-commits mailing list