Index: channels/chan_sip.c =================================================================== --- channels/chan_sip.c (revision 140937) +++ channels/chan_sip.c (working copy) @@ -972,6 +972,7 @@ int authtries; /*!< Times we've tried to authenticate */ int expiry; /*!< How long we take to expire */ long branch; /*!< The branch identifier of this session */ + long invite_branch; /*!< The branch used when we sent the initial INVITE */ char tag[11]; /*!< Our tag for this session */ int sessionid; /*!< SDP Session ID */ int sessionversion; /*!< SDP Session Version */ @@ -5974,7 +5975,10 @@ seqno = p->ocseq; } - if (newbranch) { + if (sipmethod == SIP_CANCEL) { + p->branch = p->invite_branch; + build_via(p); + } else if (newbranch) { p->branch ^= ast_random(); build_via(p); } @@ -7122,6 +7126,7 @@ if (init) { /* Seems like init always is 2 */ /* Bump branch even on initial requests */ p->branch ^= ast_random(); + p->invite_branch = p->branch; build_via(p); if (init > 1) initreqprep(&req, p, sipmethod);