[svn-commits] dvossel: trunk r278536 - /trunk/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Jul 21 13:52:19 CDT 2010


Author: dvossel
Date: Wed Jul 21 13:52:14 2010
New Revision: 278536

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278536
Log:
send "423 Interval too small" Response to Subscribe with Expires less that min allowed

[RFC3265]3.1.6.1....
   The notifier MAY also check that the duration in the "Expires" header
   is not too small.  If and only if the expiration interval is greater
   than zero AND smaller than one hour AND less than a notifier-
   configured minimum, the notifier MAY return a "423 Interval too
   small" error which contains a "Min-Expires" header field.  The "Min-
   Expires" header field is described in SIP [1].



Modified:
    trunk/channels/chan_sip.c

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=278536&r1=278535&r2=278536
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Wed Jul 21 13:52:14 2010
@@ -9619,6 +9619,18 @@
 	return send_response(p, &resp, reliable, 0);
 }
 
+/*! \brief Append Min-Expires header, content length before transmitting response */
+static int transmit_response_with_minexpires(struct sip_pvt *p, const char *msg, const struct sip_request *req)
+{
+	struct sip_request resp;
+	char tmp[32];
+
+	snprintf(tmp, sizeof(tmp), "%d", min_expiry);
+	respprep(&resp, p, msg, req);
+	add_header(&resp, "Min-Expires", tmp);
+	return send_response(p, &resp, XMIT_UNRELIABLE, 0);
+}
+
 /*! \brief Respond with authorization request */
 static int transmit_response_with_auth(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *randdata, enum xmittype reliable, const char *header, int stale)
 {
@@ -23145,10 +23157,15 @@
 		p->expiry = atoi(get_header(req, "Expires"));
 
 		/* check if the requested expiry-time is within the approved limits from sip.conf */
-		if (p->expiry > max_expiry)
+		if (p->expiry > max_expiry) {
 			p->expiry = max_expiry;
-		if (p->expiry < min_expiry && p->expiry > 0)
+		} else if (p->expiry < min_expiry && p->expiry > 0) {
 			p->expiry = min_expiry;
+			transmit_response_with_minexpires(p, "423 Interval too small", req);
+			ast_debug(2, "Received SIP subscribe with Expire header less that our minexpires limit.\n");
+			pvt_set_needdestroy(p, "Expires is less that the min expires allowed. ");
+			return 0;
+		}
 
 		if (sipdebug) {
 			if (p->subscribed == MWI_NOTIFICATION && p->relatedpeer) {




More information about the svn-commits mailing list