[svn-commits] mmichelson: branch group/CCSS r229749 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 12 16:40:37 CST 2009


Author: mmichelson
Date: Thu Nov 12 16:40:33 2009
New Revision: 229749

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=229749
Log:
Add code to transmit proper responses to PUBLISH.

With this, I will say that the ESC component of PUBLISH
support is complete. Now to recede to my lair to plan
the EPA portion, which should hopefully be simpler than
the ESC.


Modified:
    team/group/CCSS/channels/chan_sip.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=229749&r1=229748&r2=229749
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Thu Nov 12 16:40:33 2009
@@ -22550,11 +22550,16 @@
 	int res = 0;
 
 	if (!esc_entry) {
+		transmit_response(p, "503 Internal Server Failure", req);
 		return -1;
 	}
 
 	if (esc->callbacks->initial_handler) {
 		res = esc->callbacks->initial_handler(p, req, esc, esc_entry);
+	}
+
+	if (!res) {
+		transmit_response_with_sip_etag(p, "200 OK", req, esc_entry);
 	}
 
 	ao2_ref(esc_entry, -1);
@@ -22566,11 +22571,9 @@
 	struct sip_esc_entry *esc_entry = get_esc_entry(etag, esc);
 	int expires_ms = expires * 1000;
 	int res = 0;
-	/* A refresh is pretty simple. We need to verify that the etag corresponds to an esc entry of ours.
-	 * If it does, great. We just reschedule destruction of the entry for later.
-	 */
 
 	if (!esc_entry) {
+		transmit_response(p, "412 Conditional Request Failed", req);
 		return -1;
 	}
 
@@ -22583,6 +22586,10 @@
 		res = esc->callbacks->refresh_handler(p, req, esc, esc_entry);
 	}
 
+	if (!res) {
+		transmit_response_with_sip_etag(p, "200 OK", req, esc_entry);
+	}
+
 	ao2_ref(esc_entry, -1);
 	return res;
 }
@@ -22594,6 +22601,7 @@
 	int res = 0;
 
 	if (!esc_entry) {
+		transmit_response(p, "412 Conditional Request Failed", req);
 		return -1;
 	}
 
@@ -22606,6 +22614,10 @@
 		res = esc->callbacks->modify_handler(p, req, esc, esc_entry);
 	}
 
+	if (!res) {
+		transmit_response_with_sip_etag(p, "200 OK", req, esc_entry);
+	}
+
 	return res;
 }
 
@@ -22615,6 +22627,7 @@
 	int res = 0;
 
 	if (!esc_entry) {
+		transmit_response(p, "412 Conditional Request Failed", req);
 		return -1;
 	}
 
@@ -22624,6 +22637,10 @@
 	if (esc->callbacks->remove_handler) {
 		res = esc->callbacks->remove_handler(p, req, esc, esc_entry);
 	}
+
+	if (!res) {
+		transmit_response_with_sip_etag(p, "200 OK", req, esc_entry);
+	} 
 
 	ao2_ref(esc_entry, -1);
 	return res;
@@ -22637,7 +22654,8 @@
 	enum sip_publish_type publish_type;
 	const char *expires_str = get_header(req, "Expires");
 	int expires_int;
-	int res;
+	int auth_result;
+	int handler_result = -1;
 
 	if (ast_strlen_zero(event)) {
 		transmit_response(p, "489 Bad Event", req);
@@ -22649,11 +22667,11 @@
 		return -1;
 	}
 
-	res = check_user(p, req, SIP_PUBLISH, uri, XMIT_RELIABLE, sin);
-	if (res == AUTH_CHALLENGE_SENT) {
+	auth_result = check_user(p, req, SIP_PUBLISH, uri, XMIT_RELIABLE, sin);
+	if (auth_result == AUTH_CHALLENGE_SENT) {
 		return 0;
 	} else if (res < 0) {
-		if (res == AUTH_FAKE_AUTH) {
+		if (auth_result == AUTH_FAKE_AUTH) {
 			ast_log(LOG_NOTICE, "Sending fake auth rejection for device %s\n", get_header(req, "From"));
 			transmit_fake_auth_response(p, SIP_INVITE, req, XMIT_RELIABLE);
 		} else {
@@ -22667,27 +22685,31 @@
 
 	publish_type = determine_sip_publish_type(req, event, etag, expires_str);
 
+	/* It is the responsibility of these handlers to formulate any response
+	 * sent for a PUBLISH
+	 */
 	switch (publish_type) {
 	case SIP_PUBLISH_UNKNOWN:
 		transmit_response(p, "400 Bad Request", req);
 		break;
 	case SIP_PUBLISH_INITIAL:
-		handle_sip_publish_initial(p, req, esc, expires_int);
+		handler_result = handle_sip_publish_initial(p, req, esc, expires_int);
 		break;
 	case SIP_PUBLISH_REFRESH:
-		handle_sip_publish_refresh(p, req, esc, etag, expires_int);
+		handler_result = handle_sip_publish_refresh(p, req, esc, etag, expires_int);
 		break;
 	case SIP_PUBLISH_MODIFY:
-		handle_sip_publish_modify(p, req, esc, etag, expires_int);
+		handler_result = handle_sip_publish_modify(p, req, esc, etag, expires_int);
 		break;
 	case SIP_PUBLISH_REMOVE:
-		handle_sip_publish_remove(p, req, esc, etag);
+		handler_result = handle_sip_publish_remove(p, req, esc, etag);
 		break;
 	default:
+		transmit_response(p, "400 Impossible Condition", req);
 		break;
 	}
 
-	return 0;
+	return handler_result;
 }
 
 static void add_peer_mwi_subs(struct sip_peer *peer)




More information about the svn-commits mailing list