[svn-commits] rizzo: branch rizzo/astobj2 r47941 -
/team/rizzo/astobj2/channels/chan_sip.c
svn-commits at lists.digium.com
svn-commits at lists.digium.com
Wed Nov 22 14:07:22 MST 2006
Author: rizzo
Date: Wed Nov 22 15:07:22 2006
New Revision: 47941
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47941
Log:
use 0xffffffff instead of 0 as a marker for 'uninitialized' icseq,
as 0 is a legal cseq value.
Modified:
team/rizzo/astobj2/channels/chan_sip.c
Modified: team/rizzo/astobj2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/rizzo/astobj2/channels/chan_sip.c?view=diff&rev=47941&r1=47940&r2=47941
==============================================================================
--- team/rizzo/astobj2/channels/chan_sip.c (original)
+++ team/rizzo/astobj2/channels/chan_sip.c Wed Nov 22 15:07:22 2006
@@ -208,6 +208,7 @@
#define SIP_MAX_PACKET 4096 /*!< Also from RFC 3261 (2543), should sub headers tho */
#define INITIAL_CSEQ 101 /*!< our initial sip sequence number */
+#define UNINITIALIZED_ICSEQ ((unsigned int)0xffffffff) /*!< marker for not-initialized ICSEQ */
/*! \brief Global jitterbuffer configuration - by default, jb is disabled */
static struct ast_jb_conf default_jbconf =
@@ -4499,6 +4500,7 @@
p->branch = ast_random();
make_our_tag(p->tag, sizeof(p->tag));
p->ocseq = INITIAL_CSEQ;
+ p->icseq = UNINITIALIZED_ICSEQ; /* not initialized - any incoming value is good */
if (sip_methods[intended_method].need_rtp) {
p->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
@@ -15043,29 +15045,30 @@
if (option_debug > 3)
ast_log(LOG_DEBUG, "**** Received %s (%d) - Command in SIP %s\n", sip_methods[p->method].text, sip_methods[p->method].id, req->rlPart1);
- if (p->icseq && (p->icseq > seqno)) {
+ if (p->icseq == UNINITIALIZED_ICSEQ) { /* not initialized - anything is good */
+ p->icseq = seqno;
+ } else if (seqno < p->icseq) { /* old packet */
if (option_debug)
ast_log(LOG_DEBUG, "Ignoring too old SIP packet packet %d (expecting >= %d)\n", seqno, p->icseq);
if (req->method != SIP_ACK)
transmit_response(p, "503 Server error", req); /* We must respond according to RFC 3261 sec 12.2 */
return -1;
- } else if (p->icseq &&
- p->icseq == seqno &&
- req->method != SIP_ACK &&
+ } else if (p->icseq == seqno && req->method != SIP_ACK &&
(p->method != SIP_CANCEL || ast_test_flag(&p->flags[0], SIP_ALREADYGONE))) {
- /* ignore means "don't do anything with it" but still have to
- respond appropriately. We do this if we receive a repeat of
- the last sequence number */
+ /* Duplicate of the last sequence. Set the SIP_PKT_IGNORE flag, meaning
+ * "don't do anything with it" (because we have already performed the
+ * required action), but still have to respond appropriately, as the other
+ * side might have lost our message.
+ */
ast_set_flag(req, SIP_PKT_IGNORE);
if (option_debug > 2)
ast_log(LOG_DEBUG, "Ignoring SIP message because of retransmit (%s Seqno %d, ours %d)\n", sip_methods[p->method].text, p->icseq, seqno);
- }
-
- if (seqno >= p->icseq)
- /* Next should follow monotonically (but not necessarily
- incrementally -- thanks again to the genius authors of SIP --
- increasing */
+ } else {
+ /* Good sequence number - record it. It can be anything larger than the
+ * previous sequence number, not necessarily incremented by 1.
+ */
p->icseq = seqno;
+ }
/* Find their tag if we haven't got it */
if (ast_strlen_zero(p->theirtag)) {
More information about the svn-commits
mailing list