aboutsummaryrefslogtreecommitdiffstats
path: root/channels
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-21 18:52:14 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-07-21 18:52:14 +0000
commitfe09035019d8f513addec09466170dfc180a1de3 (patch)
tree67a798bbfa0fabf2bc18c1a6200d95751ae8671c /channels
parent45ef2c791eef54779cb211ea5fb6d16bb21c6bc7 (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: http://svn.digium.com/svn/asterisk/trunk@278536 f38db490-d61c-443f-a65b-d21fe96a405b
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) {