diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 40054a30555e2390ee836964ac9c6f4305e7254d..87af90bc5dc4c446bed768bcb83ba6788787538e 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1316,6 +1316,7 @@ struct sip_pvt { 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 */ @@ -7715,7 +7716,10 @@ static int reqprep(struct sip_request *req, struct sip_pvt *p, int sipmethod, in 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); } @@ -9088,6 +9092,7 @@ static int transmit_invite(struct sip_pvt *p, int sipmethod, int sdp, int init) req.method = sipmethod; if (init) {/* Bump branch even on initial requests */ p->branch ^= ast_random(); + p->invite_branch = p->branch; build_via(p); } if (init > 1)