summaryrefslogtreecommitdiff
path: root/channels
diff options
context:
space:
mode:
authorDavid Vossel <dvossel@digium.com>2010-07-21 18:52:14 +0000
committerDavid Vossel <dvossel@digium.com>2010-07-21 18:52:14 +0000
commit318798e93236e24cd5820ee23a15561ba9b54b9e (patch)
tree67a798bbfa0fabf2bc18c1a6200d95751ae8671c /channels
parent16b48135994a3ec78f0ea8ac7855a2aa878443d2 (diff)
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]. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@278536 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'channels')
-rw-r--r--channels/chan_sip.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 6a624f374..af8745ef9 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -9619,6 +9619,18 @@ static int transmit_response_with_allow(struct sip_pvt *p, const char *msg, cons
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 @@ static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req,
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) {