--- chan_sip.c.orig 2012-02-24 19:23:28.000000000 +0100 +++ chan_sip.c 2012-03-31 17:58:03.000000000 +0200 @@ -592,7 +592,8 @@ {INV_COMPLETED, "Completed (done)"}, {INV_CONFIRMED, "Confirmed (up)"}, {INV_TERMINATED, "Done"}, - {INV_CANCELLED, "Cancelled"} + {INV_CANCELLED, "Cancelled"}, + {INV_REINVITE, "Re-Invite"} }; /*! \brief Subscription types that we support. We support @@ -11848,6 +11849,7 @@ /* Use this as the basis */ initialize_initreq(p, &req); p->lastinvite = p->ocseq; + p->invitestate = INV_REINVITE; ast_set_flag(&p->flags[0], SIP_OUTGOING); /* Change direction of this dialog */ return send_request(p, &req, XMIT_CRITICAL, p->ocseq); @@ -12961,6 +12963,8 @@ || ast_strlen_zero(p->owner->connected.id.number.str)) { return; } + // If test if directmedia with re-invite is OK. In this case not send INVITE to change rpid + // append_history(p, "ConnectedLine", "%s party is now %s <%s>", ast_test_flag(&p->flags[0], SIP_OUTGOING) ? "Calling" : "Called", @@ -12970,9 +12974,9 @@ if (p->owner->_state == AST_STATE_UP || ast_test_flag(&p->flags[0], SIP_OUTGOING)) { struct sip_request req; - if (p->invitestate == INV_CONFIRMED || p->invitestate == INV_TERMINATED) { - reqprep(&req, p, ast_test_flag(&p->flags[0], SIP_REINVITE_UPDATE) ? SIP_UPDATE : SIP_INVITE, 0, 1); - + if ((p->invitestate == INV_CONFIRMED || p->invitestate == INV_TERMINATED)) { + reqprep(&req, p, ast_test_flag(&p->flags[0], SIP_REINVITE_UPDATE) ? SIP_UPDATE : SIP_INVITE, 0, 1); + add_header(&req, "Allow", ALLOWED_METHODS); add_supported_header(p, &req); add_rpid(&req, p); @@ -12983,7 +12987,7 @@ ast_set_flag(&p->flags[0], SIP_OUTGOING); p->invitestate = INV_CALLING; send_request(p, &req, XMIT_CRITICAL, p->ocseq); - } else if ((is_method_allowed(&p->allowed_methods, SIP_UPDATE)) && (!ast_strlen_zero(p->okcontacturi))) { + } else if ((is_method_allowed(&p->allowed_methods, SIP_UPDATE)) && (!ast_strlen_zero(p->okcontacturi)) && (p->invitestate != INV_REINVITE)) { reqprep(&req, p, SIP_UPDATE, 0, 1); add_rpid(&req, p); add_header(&req, "X-Asterisk-rpid-update", "Yes"); @@ -20235,6 +20239,7 @@ /* If I understand this right, the branch is different for a non-200 ACK only */ + ast_debug(1,"TNE p->invitestate %d \n",p->invitestate); p->invitestate = INV_TERMINATED; ast_set_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED); xmitres = transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, TRUE); @@ -29547,7 +29552,7 @@ /* For now, when we receive an INVITE just take the first successful crypto line */ if ((*srtp)->crypto && !ast_test_flag(&p->flags[0], SIP_OUTGOING)) { ast_debug(3, "We've already processed a crypto attribute, skipping '%s'\n", a); - return FALSE; + // TNE BUG srtp/crypto sur Aastra return FALSE; } if (!(*srtp)->crypto && !((*srtp)->crypto = sdp_crypto_setup())) {