[svn-commits] oej: branch oej/codename-pineapple r47601 - in /team/oej/codename-pineapple/c...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Nov 14 07:15:41 MST 2006


Author: oej
Date: Tue Nov 14 08:15:40 2006
New Revision: 47601

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47601
Log:
Update

Modified:
    team/oej/codename-pineapple/channels/chan_sip3.c
    team/oej/codename-pineapple/channels/sip3/sip3_dialog.c
    team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
    team/oej/codename-pineapple/channels/sip3/sip3_services.c
    team/oej/codename-pineapple/channels/sip3/sip3funcs.h

Modified: team/oej/codename-pineapple/channels/chan_sip3.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/chan_sip3.c?view=diff&rev=47601&r1=47600&r2=47601
==============================================================================
--- team/oej/codename-pineapple/channels/chan_sip3.c (original)
+++ team/oej/codename-pineapple/channels/chan_sip3.c Tue Nov 14 08:15:40 2006
@@ -6076,6 +6076,7 @@
 	const char *event = get_header(req, "Event");	/* Get Event package name */
 	const char *accept = get_header(req, "Accept");
 	int resubscribe = (p->subscribed != NONE);
+	static int subscribe_counter = 0;
 
 	if (p->initreq.headers) {	
 		/* We already have a dialog */
@@ -6104,6 +6105,10 @@
 		transmit_final_response(p, "403 Forbidden (policy)", req, XMIT_UNRELIABLE);
 		return 0;
 	}
+	subscribe_counter ++;
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "-SUBSCRIPTIONS- Concurrent counter: %d\n", subscribe_counter);
+
 
 	if (!ast_test_flag(req, SIP_PKT_IGNORE) && !p->initreq.headers) {	/* Set up dialog, new subscription */
 		/* Use this as the basis */
@@ -6126,6 +6131,7 @@
 	if (res == AUTH_CHALLENGE_SENT) {
 		if (authpeer)
 			ASTOBJ_UNREF(authpeer, sip_destroy_device);
+		subscribe_counter--;
 		return 0;
 	}
 	if (res < 0) {
@@ -6138,6 +6144,7 @@
 		}
 		if (authpeer)
 			ASTOBJ_UNREF(authpeer, sip_destroy_device);
+		subscribe_counter--;
 		return 0;
 	}
 
@@ -6146,6 +6153,7 @@
 		transmit_final_response(p, "403 Forbidden (policy)", req, XMIT_UNRELIABLE);
 		if (authpeer)
 			ASTOBJ_UNREF(authpeer, sip_destroy_device);
+		subscribe_counter--;
 		return 0;
 	}
 
@@ -6167,6 +6175,7 @@
 		transmit_final_response(p, "404 Not Found", req, XMIT_UNRELIABLE);
 		if (authpeer)
 			ASTOBJ_UNREF(authpeer, sip_destroy_device);
+		subscribe_counter--;
 		return 0;
 	} else {
 		/* XXX reduce nesting here */
@@ -6196,17 +6205,17 @@
 			} else {
  				/* Can't find a format for events that we know about */
 				transmit_final_response(p, "489 Bad Event", req, XMIT_UNRELIABLE);
+				subscribe_counter--;
  				return 0;
  			}
  		} else if (!strcmp(event, "message-summary")) { 
+			char *resp = NULL;
+			int error = FALSE;
 			if (!ast_strlen_zero(accept) && strcmp(accept, "application/simple-message-summary")) {
 				/* Format requested that we do not support */
-				transmit_final_response(p, "406 Not Acceptable", req, XMIT_UNRELIABLE);
+				resp = "406 Not acceptable";
 				if (option_debug > 1)
 					ast_log(LOG_DEBUG, "Received SIP mailbox subscription for unknown format: %s\n", accept);
-				if (authpeer)
-					ASTOBJ_UNREF(authpeer, sip_destroy_device);
-				return 0;
 			}
 			/* Looks like they actually want a mailbox status 
 			  This version of Asterisk supports mailbox subscriptions
@@ -6214,10 +6223,15 @@
 			  In most devices, this is configurable to the voicemailmain extension you use
 			*/
 			if (!authpeer || ast_strlen_zero(authpeer->mailbox)) {
-				transmit_final_response(p, "403 Not found (no mailbox)", req, XMIT_UNRELIABLE);
+				resp = "404 Not found (no mailbox)";
 				ast_log(LOG_NOTICE, "Received SIP subscribe for peer without mailbox: %s\n", authpeer ? authpeer->name : "<no peername>");
+				return 0;
+			}
+			if (error) {
+				transmit_final_response(p, resp, req, XMIT_UNRELIABLE);
 				if (authpeer)
 					ASTOBJ_UNREF(authpeer, sip_destroy_device);
+				subscribe_counter--;
 				return 0;
 			}
 
@@ -6233,6 +6247,7 @@
 				ast_log(LOG_DEBUG, "Received SIP subscribe for unknown event package: %s\n", event);
 			if (authpeer)
 				ASTOBJ_UNREF(authpeer, sip_destroy_device);
+			subscribe_counter--;
 			return 0;
 		}
 		/* Now, subscribe to status events from the PBX core */
@@ -6247,6 +6262,7 @@
 	if (p->expiry < expiry.min_expiry && p->expiry > 0) {
 		transmit_response_with_attachment(WITH_MINEXPIRY, p, "423 Interval too small", req, XMIT_UNRELIABLE);
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
+		subscribe_counter--;
 		return 0;
 	}
 	
@@ -6282,48 +6298,48 @@
 
 				ast_log(LOG_ERROR, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension\n", p->exten, p->context, ast_inet_ntoa(p->sa.sin_addr));
 				transmit_final_response(p, "404 Not Found", req, XMIT_UNRELIABLE);
+				subscribe_counter--;
 				return 0;
-			} else {
-				/* XXX reduce nesting here */
-				struct sip_dialog *p_old;
-	
-				transmit_response(p, "200 OK", req);
-				dialogstatechange(p, DIALOG_STATE_CONFIRMED);
-				transmit_state_notify(p, firststate, 1, FALSE);	/* Send first notification */
-				append_history(p, "Subscribestatus", "%s", ast_extension_state2str(firststate));
-				/* hide the 'complete' exten/context in the refer_to field for later display */
-				ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);
-
-				/* remove any old subscription from this peer for the same exten/context,
-			   	as the peer has obviously forgotten about it and it's wasteful to wait
-			   	for it to expire and send NOTIFY messages to the peer only to have them
-			   	ignored (or generate errors)
-				*/
-				dialoglist_lock();
-				for (p_old = dialoglist; p_old; p_old = p_old->next) {
-					if (p_old == p)
-						continue;
-					if (p_old->initreq.method != SIP_SUBSCRIBE)
-						continue;
-					if (p_old->subscribed == NONE)
-						continue;
-					dialog_lock(p_old, TRUE);
-					if (!strcmp(p_old->peername, p->peername)) {
-						if (!strcmp(p_old->exten, p->exten) &&
-						    !strcmp(p_old->context, p->context)) {
-							ast_set_flag(&p_old->flags[0], SIP_NEEDDESTROY);
-							dialog_lock(p_old, FALSE);
-							break;
-						}
+			} 
+			struct sip_dialog *p_old;
+
+			transmit_response(p, "200 OK", req);
+			dialogstatechange(p, DIALOG_STATE_CONFIRMED);
+			transmit_state_notify(p, firststate, 1, FALSE);	/* Send first notification */
+			append_history(p, "Subscribestatus", "%s", ast_extension_state2str(firststate));
+			/* hide the 'complete' exten/context in the refer_to field for later display */
+			ast_string_field_build(p, subscribeuri, "%s@%s", p->exten, p->context);
+
+			/* remove any old subscription from this peer for the same exten/context,
+		   	as the peer has obviously forgotten about it and it's wasteful to wait
+		   	for it to expire and send NOTIFY messages to the peer only to have them
+		   	ignored (or generate errors)
+			*/
+			dialoglist_lock();
+			for (p_old = dialoglist; p_old; p_old = p_old->next) {
+				if (p_old == p)
+					continue;
+				if (p_old->initreq.method != SIP_SUBSCRIBE)
+					continue;
+				if (p_old->subscribed == NONE)
+					continue;
+				dialog_lock(p_old, TRUE);
+				if (!strcmp(p_old->peername, p->peername)) {
+					if (!strcmp(p_old->exten, p->exten) &&
+					    !strcmp(p_old->context, p->context)) {
+						ast_set_flag(&p_old->flags[0], SIP_NEEDDESTROY);
+						dialog_lock(p_old, FALSE);
+						break;
 					}
-					dialog_lock(p_old, FALSE);
 				}
-				dialoglist_unlock();
+				dialog_lock(p_old, FALSE);
 			}
+			dialoglist_unlock();
 		}
 		if (!p->expiry)
 			ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);
 	}
+	subscribe_counter--;
 	return 1;
 }
 
@@ -6331,6 +6347,12 @@
 static int handle_request_register(struct sip_dialog *p, struct sip_request *req, struct sockaddr_in *sin, char *e)
 {
 	enum check_auth_result res;
+
+	static int register_counter = 0;
+
+	register_counter ++;
+	if (option_debug > 3)
+		ast_log(LOG_DEBUG, "-REGISTRATIONS- register counter %d\n", register_counter);
 
 	/* Use this as the basis */
 	if (ast_test_flag(req, SIP_PKT_DEBUG))
@@ -6366,6 +6388,7 @@
 		sip_scheddestroy(p, DEFAULT_TRANS_TIMEOUT);
 	}
 	append_history(p, "RegRequest", "%s : Account %s", res ? "Failed": "Succeeded", get_header(req, "To"));
+	register_counter--;
 	return res;
 }
 

Modified: team/oej/codename-pineapple/channels/sip3/sip3_dialog.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_dialog.c?view=diff&rev=47601&r1=47600&r2=47601
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_dialog.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_dialog.c Tue Nov 14 08:15:40 2006
@@ -962,6 +962,21 @@
 
 	tag = (req->method == SIP_RESPONSE) ? totag : fromtag;
 
+	/* All messages must always have From: tag */
+	if (ast_strlen_zero(fromtag)) {
+		if (option_debug > 4 ) 
+			ast_log(LOG_DEBUG, "%s request has no from tag, dropping callid: %s from: %s\n", sip_methods[req->method].text, req->callid, req->from );
+		return NULL;
+	}
+	/* reject requests that must always have a To: tag */
+	if (ast_strlen_zero(totag) && (req->method == SIP_ACK || req->method == SIP_BYE || req->method == SIP_INFO )) {
+		if (option_debug > 4) 
+			ast_log(LOG_DEBUG, "%s must have a to tag. dropping callid: %s from: %s\n", sip_methods[req->method].text, req->callid, req->from );
+		return NULL;
+ 	}
+ 
+ 	dialoglist_lock();
+
 	if (option_debug > 4 )
 		ast_log(LOG_DEBUG, "= Looking for  Call ID: %s (Checking %s) --From tag %s --To-tag %s  \n", req->callid, req->method==SIP_RESPONSE ? "To" : "From", fromtag, totag);
 

Modified: team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c?view=diff&rev=47601&r1=47600&r2=47601
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_sdprtp.c Tue Nov 14 08:15:40 2006
@@ -425,10 +425,6 @@
 				/* SRTP stuff, not yet supported */
 				if (debug)
 					ast_verbose("Got unsupported a:crypto in SDP offer \n");
-				breakout = TRUE;
-			} else if (!strncasecmp(a, "ptime:", (size_t) 6)) {
-				if (debug)
-					ast_verbose("Got unsupported a:ptime in SDP offer \n");
 				breakout = TRUE;
 			}
 			if (breakout)	/* We have a match, skip to next header */

Modified: team/oej/codename-pineapple/channels/sip3/sip3_services.c
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3_services.c?view=diff&rev=47601&r1=47600&r2=47601
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3_services.c (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3_services.c Tue Nov 14 08:15:40 2006
@@ -363,7 +363,7 @@
 	} else {
 		r->regstate = REG_STATE_UNREGISTERED;
 		r->timeout = -1;
-		res=transmit_register(r, SIP_REGISTER, NULL, NULL);
+		res = transmit_register(r, SIP_REGISTER, NULL, NULL);
 	}
 	manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelDriver: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
 	ASTOBJ_UNREF(r, sip_registry_destroy);

Modified: team/oej/codename-pineapple/channels/sip3/sip3funcs.h
URL: http://svn.digium.com/view/asterisk/team/oej/codename-pineapple/channels/sip3/sip3funcs.h?view=diff&rev=47601&r1=47600&r2=47601
==============================================================================
--- team/oej/codename-pineapple/channels/sip3/sip3funcs.h (original)
+++ team/oej/codename-pineapple/channels/sip3/sip3funcs.h Tue Nov 14 08:15:40 2006
@@ -172,6 +172,7 @@
 GNURK struct sip_auth *add_realm_authentication(struct sip_auth *authlist, char *configuration, int lineno);
 
 /* sip3_sdprtp.c */
+GNURK struct ast_frame *sip_read(struct ast_channel *ast);
 GNURK void register_rtp_and_udptl(void);
 GNURK void unregister_rtp_and_udptl(void);
 GNURK char *get_body(struct sip_request *req, char *name);



More information about the svn-commits mailing list