aboutsummaryrefslogtreecommitdiffstats
path: root/channels/chan_sip.c
diff options
context:
space:
mode:
authordvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-24 17:59:47 +0000
committerdvossel <dvossel@f38db490-d61c-443f-a65b-d21fe96a405b>2010-09-24 17:59:47 +0000
commitfadb5166743726ef53661bc8ad5cc74ae2633907 (patch)
tree3111a004d4ee6d3151cfcaaa560bef7b4f122510 /channels/chan_sip.c
parentb0fdf6e176808d8326a935dce9ea35dfac90776a (diff)
Merged revisions 288852 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r288852 | dvossel | 2010-09-24 12:58:57 -0500 (Fri, 24 Sep 2010) | 5 lines Append Retry-After header on 500 error response to Re-INVITE according to RFC3261 section 14.2. ABE-2301 ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@288853 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_sip.c')
-rw-r--r--channels/chan_sip.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/channels/chan_sip.c b/channels/chan_sip.c
index 01f184fec..06e26c98b 100644
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -9883,6 +9883,15 @@ static void append_date(struct sip_request *req)
add_header(req, "Date", tmpdat);
}
+/*! \brief Append Retry-After header field when transmitting response */
+static int transmit_response_with_retry_after(struct sip_pvt *p, const char *msg, const struct sip_request *req, const char *seconds)
+{
+ struct sip_request resp;
+ respprep(&resp, p, msg, req);
+ add_header(&resp, "Retry-After", seconds);
+ return send_response(p, &resp, XMIT_UNRELIABLE, 0);
+}
+
/*! \brief Append date and content length before transmitting response */
static int transmit_response_with_date(struct sip_pvt *p, const char *msg, const struct sip_request *req)
{
@@ -23609,10 +23618,16 @@ static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct as
if (p->icseq && (p->icseq > seqno) ) {
if (p->pendinginvite && seqno == p->pendinginvite && (req->method == SIP_ACK || req->method == SIP_CANCEL)) {
ast_debug(2, "Got CANCEL or ACK on INVITE with transactions in between.\n");
- } else {
+ } else {
ast_debug(1, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
- if (req->method != SIP_ACK)
+ if (req->method == SIP_INVITE) {
+ unsigned int ran = (ast_random() % 10) + 1;
+ char seconds[4];
+ snprintf(seconds, sizeof(seconds), "%u", ran);
+ transmit_response_with_retry_after(p, "500 Server error", req, seconds); /* respond according to RFC 3261 14.2 with Retry-After betwewn 0 and 10 */
+ } else if (req->method != SIP_ACK) {
transmit_response(p, "500 Server error", req); /* We must respond according to RFC 3261 sec 12.2 */
+ }
return -1;
}
} else if (p->icseq &&