[svn-commits] branch oej/multiparking r8971 - in /team/oej/multiparking: ./ apps/ channels/...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jan 31 14:21:13 MST 2006


Author: oej
Date: Tue Jan 31 01:33:17 2006
New Revision: 8971

URL: http://svn.digium.com/view/asterisk?rev=8971&view=rev
Log:
Merged revisions 8896,8906,8919,8925-8926,8932,8938,8948-8949,8961 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r8896 | oej | 2006-01-30 15:12:39 +0100 (Mon, 30 Jan 2006) | 2 lines

Document installation changes for BSD users.

................
r8906 | kpfleming | 2006-01-30 18:09:55 +0100 (Mon, 30 Jan 2006) | 10 lines

Merged revisions 8905 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r8905 | kpfleming | 2006-01-30 11:08:28 -0600 (Mon, 30 Jan 2006) | 2 lines

disable buggy PRI user-user code until it can be fixed

........

................
r8919 | oej | 2006-01-30 19:51:02 +0100 (Mon, 30 Jan 2006) | 6 lines

Issue #5793 
- simplification of check_auth
- constifications
- whitespace changes
Rizzo's patch with some changes

................
r8925 | oej | 2006-01-30 20:09:08 +0100 (Mon, 30 Jan 2006) | 3 lines

Issue #6035 - Don't send 403 on bad auth (correcting one of my old mistakes...) Reported by maik.
Patch inspired by, but not the patch in the bug tracker.

................
r8926 | oej | 2006-01-30 20:50:39 +0100 (Mon, 30 Jan 2006) | 2 lines

Issue 5892: Set a minimum T1 timer for calls. Reporter: twisted

................
r8932 | oej | 2006-01-30 21:36:38 +0100 (Mon, 30 Jan 2006) | 8 lines

- Doxygen and comments updates
- Moving structure declarations to top of file with the rest
- Adding some forward declarations for RTP interface functions

(All these changes to position in file are in preparation for splitting chan_sip up
into several files at some point in the future)


................
r8938 | mogorman | 2006-01-30 22:16:43 +0100 (Mon, 30 Jan 2006) | 3 lines

reverting  blocks 9 and 10 from revision 7547
fixes bug 6080

................
r8948 | kpfleming | 2006-01-31 01:17:43 +0100 (Tue, 31 Jan 2006) | 2 lines

increment for recent ast_channel change

................
r8949 | russell | 2006-01-31 01:24:34 +0100 (Tue, 31 Jan 2006) | 3 lines

add a note to hopefully decrease the chance that someone forgets to increment
.cleancount after changing the ast_channel structure

................
r8961 | kpfleming | 2006-01-31 04:45:09 +0100 (Tue, 31 Jan 2006) | 2 lines

Yes Virginia, Zaptel does support native ALAW

................

Modified:
    team/oej/multiparking/   (props changed)
    team/oej/multiparking/.cleancount
    team/oej/multiparking/UPGRADE.txt
    team/oej/multiparking/apps/app_meetme.c
    team/oej/multiparking/channels/chan_sip.c
    team/oej/multiparking/channels/chan_zap.c
    team/oej/multiparking/configs/sip.conf.sample
    team/oej/multiparking/include/asterisk/channel.h

Propchange: team/oej/multiparking/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jan 31 01:33:17 2006
@@ -1,1 +1,1 @@
-/trunk:1-8892
+/trunk:1-8970

Modified: team/oej/multiparking/.cleancount
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/.cleancount?rev=8971&r1=8970&r2=8971&view=diff
==============================================================================
--- team/oej/multiparking/.cleancount (original)
+++ team/oej/multiparking/.cleancount Tue Jan 31 01:33:17 2006
@@ -1,1 +1,1 @@
-8
+9

Modified: team/oej/multiparking/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/UPGRADE.txt?rev=8971&r1=8970&r2=8971&view=diff
==============================================================================
--- team/oej/multiparking/UPGRADE.txt (original)
+++ team/oej/multiparking/UPGRADE.txt Tue Jan 31 01:33:17 2006
@@ -38,3 +38,13 @@
 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/oej/multiparking/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/apps/app_meetme.c?rev=8971&r1=8970&r2=8971&view=diff
==============================================================================
--- team/oej/multiparking/apps/app_meetme.c (original)
+++ team/oej/multiparking/apps/app_meetme.c Tue Jan 31 01:33:17 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/oej/multiparking/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/channels/chan_sip.c?rev=8971&r1=8970&r2=8971&view=diff
==============================================================================
--- team/oej/multiparking/channels/chan_sip.c (original)
+++ team/oej/multiparking/channels/chan_sip.c Tue Jan 31 01:33:17 2006
@@ -363,6 +363,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 int allow_external_domains;	/*!< Accept calls to external SIP domains? */
 static char default_parkinglot[AST_MAX_EXTENSION];	/*!< Default parking lot */
 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;
@@ -463,6 +465,13 @@
 	char data[SIP_MAX_PACKET];
 	int debug;		/*!< Debug flag for this packet */
 	unsigned int flags;	/*!< SIP_PKT Flags for this packet */
+};
+
+/*! \brief structure used in transfers */
+struct sip_dual {
+	struct ast_channel *chan1;
+	struct ast_channel *chan2;
+	struct sip_request req;
 };
 
 struct sip_pkt;
@@ -901,7 +910,7 @@
 static int transmit_response(struct sip_pvt *p, char *msg, struct sip_request *req);
 static int transmit_response_with_sdp(struct sip_pvt *p, char *msg, struct sip_request *req, int retrans);
 static int transmit_response_with_unsupported(struct sip_pvt *p, char *msg, struct sip_request *req, char *unsupported);
-static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, const char *rand, int reliable, char *header, int stale);
+static int transmit_response_with_auth(struct sip_pvt *p, const char *msg, struct sip_request *req, const char *rand, int reliable, const char *header, int stale);
 static int transmit_request(struct sip_pvt *p, int sipmethod, int inc, int reliable, int newbranch);
 static int transmit_request_with_auth(struct sip_pvt *p, int sipmethod, int inc, int reliable, int newbranch);
 static int transmit_invite(struct sip_pvt *p, int sipmethod, int sendsdp, int init);
@@ -920,7 +929,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);
@@ -936,6 +944,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);
@@ -947,13 +958,19 @@
 static unsigned int parse_sip_options(struct sip_pvt *pvt, char *supported);
 static void sip_destroy(struct sip_pvt *p);
 static void parse_request(struct sip_request *req);
-static char *get_header(struct sip_request *req, char *name);
+static char *get_header(struct sip_request *req, const char *name);
 static void copy_request(struct sip_request *dst,struct sip_request *src);
 static int transmit_response_reliable(struct sip_pvt *p, char *msg, struct sip_request *req, int fatal);
 static int transmit_register(struct sip_registry *r, int sipmethod, char *auth, char *authheader);
 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 = {
@@ -976,6 +993,16 @@
 	.bridge = ast_rtp_bridge,
 	.send_text = sip_sendtext,
 };
+
+/*! \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
@@ -1919,8 +1946,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
@@ -2976,7 +3004,7 @@
 	return _default;
 }
 
-static char *__get_header(struct sip_request *req, char *name, int *start)
+static char *__get_header(struct sip_request *req, const char *name, int *start)
 {
 	int pass;
 
@@ -3012,7 +3040,7 @@
 }
 
 /*! \brief Get header from SIP request */
-static char *get_header(struct sip_request *req, char *name)
+static char *get_header(struct sip_request *req, const char *name)
 {
 	int start = 0;
 	return __get_header(req, name, &start);
@@ -4052,7 +4080,7 @@
 }
 
 /*! \brief Initialize SIP response, based on SIP request */
-static int init_resp(struct sip_request *req, char *resp, struct sip_request *orig)
+static int init_resp(struct sip_request *req, const char *resp, struct sip_request *orig)
 {
 	/* Initialize a response */
 	if (req->headers || req->len) {
@@ -4085,7 +4113,7 @@
 
 
 /*! \brief Prepare SIP response packet */
-static int respprep(struct sip_request *resp, struct sip_pvt *p, char *msg, struct sip_request *req)
+static int respprep(struct sip_request *resp, struct sip_pvt *p, const char *msg, struct sip_request *req)
 {
 	char newto[256], *ot;
 
@@ -4316,7 +4344,7 @@
 }
 
 /*! \brief Respond with authorization request */
-static int transmit_response_with_auth(struct sip_pvt *p, char *msg, struct sip_request *req, const char *randdata, int reliable, char *header, int stale)
+static int transmit_response_with_auth(struct sip_pvt *p, const char *msg, struct sip_request *req, const char *randdata, int reliable, const char *header, int stale)
 {
 	struct sip_request resp;
 	char tmp[256];
@@ -6191,19 +6219,19 @@
 
 /*! \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;
-	char *response = "407 Proxy Authentication Required";
-	char *reqheader = "Proxy-Authorization";
-	char *respheader = "Proxy-Authenticate";
-	char *authtoken;
-#ifdef OSP_SUPPORT
-	char *osptoken;
-#endif
+	const char *response = "407 Proxy Authentication Required";
+	const char *reqheader = "Proxy-Authorization";
+	const char *respheader = "Proxy-Authenticate";
+	const char *authtoken;
+
 	/* Always OK if no secret */
 	if (ast_strlen_zero(secret) && ast_strlen_zero(md5secret)
 #ifdef OSP_SUPPORT
@@ -6222,36 +6250,30 @@
 	}
 #ifdef OSP_SUPPORT
 	else {
-		ast_log (LOG_DEBUG, "Checking OSP Authentication!\n");
+		char *osptoken;
+		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 (secret) && ast_strlen_zero (md5secret)) {
+				if (ast_strlen_zero(osptoken)) {
+					if (ast_strlen_zero(secret) && ast_strlen_zero (md5secret))
 						return 0;
-					}
-				}
-				else {
-					return check_osptoken (p, osptoken);
+				} else {
+					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;
@@ -6262,134 +6284,108 @@
 	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. */
-		char a1[256];
-		char a2[256];
+	   	an example in the spec of just what it is you're doing a hash on. */
 		char a1_hash[256];
-		char a2_hash[256];
-		char resp[256];
 		char resp_hash[256]="";
 		char tmp[256];
 		char *c;
-		char *z;
-		char *ua_hash ="";
-		char *resp_uri ="";
-		char *nonce = "";
-		char *digestusername = "";
 		int  wrongnonce = FALSE;
-		const char *usednonce = p->randdata;
-
-		/* Find their response among the mess that we'r sent for comparison */
+		int  good_response;
+		const char *usednonce = p->randdata; /* XXX check */
+
+		/* table of recognised keywords, and their value in the digest */
+		enum keys { K_RESP, K_URI, K_USER, K_NONCE, K_LAST };
+		struct x {
+			const char *key;
+			const char *s;
+		} *i, keys[] = {
+			[K_RESP] = { "response=", "" },
+			[K_URI] = { "uri=", "" },
+			[K_USER] = { "username=", "" },
+			[K_NONCE] = { "nonce=", "" },
+			[K_LAST] = { NULL, NULL}
+		};
+
+		/* Make a copy of the response and parse it */
 		ast_copy_string(tmp, authtoken, sizeof(tmp));
 		c = tmp;
 
-		while(c) {
-			c = ast_skip_blanks(c);
-			if (!*c)
+		while(c && *(c = ast_skip_blanks(c)) ) { /* lookup for keys */
+			for (i = keys; i->key != NULL; i++) {
+				const char *separator = ",";	/* default */
+
+				if (strncasecmp(c, i->key, strlen(i->key)) != 0)
+					continue;
+				/* Found. Skip keyword, take text in quotes or up to the separator. */
+				c += strlen(i->key);
+				if (*c == '"') { /* in quotes. Skip first and look for last */
+					c++;
+					separator = "\"";
+				}
+				i->s = c;
+				strsep(&c, separator);
 				break;
-			if (!strncasecmp(c, "response=", strlen("response="))) {
-				c+= strlen("response=");
-				if ((*c == '\"')) {
-					ua_hash=++c;
-					if ((c = strchr(c,'\"')))
-						*c = '\0';
-
-				} else {
-					ua_hash=c;
-					if ((c = strchr(c,',')))
-						*c = '\0';
-				}
-
-			} else if (!strncasecmp(c, "uri=", strlen("uri="))) {
-				c+= strlen("uri=");
-				if ((*c == '\"')) {
-					resp_uri=++c;
-					if ((c = strchr(c,'\"')))
-						*c = '\0';
-				} else {
-					resp_uri=c;
-					if ((c = strchr(c,',')))
-						*c = '\0';
-				}
-
-			} else if (!strncasecmp(c, "username=", strlen("username="))) {
-				c+= strlen("username=");
-				if ((*c == '\"')) {
-					digestusername=++c;
-					if((c = strchr(c,'\"')))
-						*c = '\0';
-				} else {
-					digestusername=c;
-					if((c = strchr(c,',')))
-						*c = '\0';
-				}
-			} else if (!strncasecmp(c, "nonce=", strlen("nonce="))) {
-				c+= strlen("nonce=");
-				if ((*c == '\"')) {
-					nonce=++c;
-					if ((c = strchr(c,'\"')))
-						*c = '\0';
-				} else {
-					nonce=c;
-					if ((c = strchr(c,',')))
-						*c = '\0';
-				}
-
-			} else
-				if ((z = strchr(c,' ')) || (z = strchr(c,','))) c=z;
-			if (c)
-				c++;
+			}
+			if (i->key == NULL) /* not found, jump after space or comma */
+				strsep(&c, " ,");
 		}
 		/* Verify that digest username matches  the username we auth as */
-		if (strcmp(username, digestusername)) {
+		if (strcmp(username, keys[K_USER].s)) {
+			ast_log(LOG_WARNING, "username mismatch, have <%s>, digest has <%s>\n",
+				username, keys[K_USER].s);
 			/* Oops, we're trying something here */
 			return -2;
 		}
 
 		/* Verify nonce from request matches our nonce.  If not, send 401 with new nonce */
-		if (strcasecmp(p->randdata, nonce)) {
+		if (strcasecmp(p->randdata, keys[K_NONCE].s)) { /* XXX it was 'n'casecmp ? */
 			wrongnonce = TRUE;
-			usednonce = nonce;
-		}
-
-		snprintf(a1, sizeof(a1), "%s:%s:%s", username, global_realm, secret);
-
-		if (!ast_strlen_zero(resp_uri))
-			snprintf(a2, sizeof(a2), "%s:%s", sip_methods[sipmethod].text, resp_uri);
-		else
-			snprintf(a2, sizeof(a2), "%s:%s", sip_methods[sipmethod].text, uri);
+			usednonce = keys[K_NONCE].s;
+		}
 
 		if (!ast_strlen_zero(md5secret))
-			snprintf(a1_hash, sizeof(a1_hash), "%s", md5secret);
-		else
+			ast_copy_string(a1_hash, md5secret, sizeof(a1_hash));
+		else {
+			char a1[256];
+			snprintf(a1, sizeof(a1), "%s:%s:%s", username, global_realm, secret);
 			ast_md5_hash(a1_hash, a1);
-
-		ast_md5_hash(a2_hash, a2);
-
-		snprintf(resp, sizeof(resp), "%s:%s:%s", a1_hash, usednonce, a2_hash);
-		ast_md5_hash(resp_hash, resp);
-
+		}
+
+		/* compute the expected response to compare with what we received */
+		{
+			char a2[256];
+			char a2_hash[256];
+			char resp[256];
+
+			snprintf(a2, sizeof(a2), "%s:%s", sip_methods[sipmethod].text,
+					!ast_strlen_zero(keys[K_URI].s) ? keys[K_URI].s : uri);
+			ast_md5_hash(a2_hash, a2);
+			snprintf(resp, sizeof(resp), "%s:%s:%s", a1_hash, usednonce, a2_hash);
+			ast_md5_hash(resp_hash, resp);
+		}
+
+		good_response = keys[K_RESP].s &&
+				!strncasecmp(keys[K_RESP].s, resp_hash, strlen(resp_hash));
 		if (wrongnonce) {
 			ast_string_field_build(p, randdata, "%08x", thread_safe_rand());
-			if (ua_hash && !strncasecmp(ua_hash, resp_hash, strlen(resp_hash))) {
+			if (good_response) {
 				if (sipdebug)
 					ast_log(LOG_NOTICE, "stale nonce received from '%s'\n", get_header(req, "To"));
 				/* We got working auth token, based on stale nonce . */
@@ -6401,18 +6397,20 @@
 				transmit_response_with_auth(p, response, req, p->randdata, reliable, respheader, 0);
 			}
 
-			/* Schedule auto destroy in 15 seconds */
-			sip_scheddestroy(p, 15000);
-			return 1;
+			/* Schedule auto destroy in 32 seconds */
+			sip_scheddestroy(p, 32000);
+			return 1;	/* Challenge sent */
 		} 
-		/* resp_hash now has the expected response, compare the two */
-		if (ua_hash && !strncasecmp(ua_hash, resp_hash, strlen(resp_hash))) {
-			/* Auth is OK */
-			res = 0;
-		}
-	}
-	/* Failure */
-	return res;
+		if (good_response) /* Auth is OK */
+			return 0;
+
+		/* 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
@@ -8328,6 +8326,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)" );
@@ -10150,13 +10149,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;
@@ -10179,7 +10173,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;
@@ -10235,7 +10229,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) {
@@ -10244,7 +10238,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;
@@ -10335,7 +10329,7 @@
 	return thetag;
 }
 
-/*! \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;
@@ -10359,7 +10353,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;
@@ -10616,7 +10610,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;
@@ -10683,7 +10677,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)
 {
 		
@@ -10712,7 +10706,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;
@@ -10765,7 +10759,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) {
@@ -10972,7 +10966,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;
@@ -10993,8 +10987,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   */
 static int handle_request(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int *recount, int *nounlock)
 {
 	/* Called with p->lock held, as well as p->owner->lock if appropriate, keeping things
@@ -11196,8 +11190,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;
@@ -11283,7 +11277,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 */
@@ -11321,7 +11315,7 @@
 	return 0;
 }
 
-/*! \brief  do_monitor: The SIP monitoring thread */
+/*! \brief The SIP monitoring thread */
 static void *do_monitor(void *data)
 {
 	int res;
@@ -11452,7 +11446,7 @@
 	
 }
 
-/*! \brief  restart_monitor: Start the channel monitor thread */
+/*! \brief Start the channel monitor thread */
 static int restart_monitor(void)
 {
 	pthread_attr_t attr;
@@ -11485,7 +11479,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;
@@ -11505,9 +11499,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;
@@ -11567,20 +11561,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)
 {
@@ -11632,7 +11627,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)
 {
@@ -11708,7 +11703,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;
@@ -11817,7 +11812,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;
@@ -11869,7 +11864,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;
@@ -11881,7 +11876,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];
@@ -11944,7 +11939,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;
@@ -11959,7 +11954,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;
@@ -11972,7 +11967,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;
@@ -12065,7 +12060,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;
@@ -12099,7 +12094,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;
@@ -12362,8 +12357,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
@@ -12453,6 +12448,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) {
@@ -12473,6 +12469,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)
@@ -12787,7 +12785,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;
@@ -12802,7 +12800,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;
@@ -12818,7 +12816,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;
@@ -12879,7 +12877,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;
@@ -12929,7 +12927,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;
@@ -12962,11 +12960,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)
 {
@@ -13023,23 +13021,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 {
@@ -13050,7 +13039,7 @@
 	);
 }
 
-/*! \brief  sip_send_all_registers: Send all known registrations */
+/*! \brief Send all known registrations */
 static void sip_send_all_registers(void)
 {
 	int ms;
@@ -13072,7 +13061,7 @@
 	);
 }
 
-/*! \brief  sip_do_reload: Reload module */
+/*! \brief Reload module */
 static int sip_do_reload(enum channelreloadreason reason)
 {
 	if (option_debug > 3)
@@ -13122,7 +13111,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/oej/multiparking/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/multiparking/channels/chan_zap.c?rev=8971&r1=8970&r2=8971&view=diff
==============================================================================
--- team/oej/multiparking/channels/chan_zap.c (original)
+++ team/oej/multiparking/channels/chan_zap.c Tue Jan 31 01:33:17 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
@@ -709,7 +712,7 @@
 static const struct ast_channel_tech zap_tech = {
 	.type = type,
 	.description = tdesc,
-	.capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW,
+	.capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
 	.requester = zt_request,
 	.send_digit = zt_digit,
 	.send_text = zt_sendtext,
@@ -2014,7 +2017,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;
@@ -2128,11 +2133,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", 
@@ -2520,13 +2528,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) 
@@ -2535,7 +2550,11 @@

[... 141 lines stripped ...]


More information about the svn-commits mailing list