Index: b/channels/chan_sip.c
===================================================================
--- a/channels/chan_sip.c
+++ b/channels/chan_sip.c
@@ -12327,7 +12327,7 @@ static int respprep(struct sip_request *
 	add_supported(p, resp);
 
 	/* If this is an invite, add Session-Timers related headers if the feature is active for this session */
-	if (p->method == SIP_INVITE && p->stimer && p->stimer->st_active == TRUE) {
+	if (req->method == SIP_INVITE && p->stimer && p->stimer->st_active == TRUE) {
 		char se_hdr[256];
 		snprintf(se_hdr, sizeof(se_hdr), "%d;refresher=%s", p->stimer->st_interval,
 			p->stimer->st_ref == SESSION_TIMER_REFRESHER_US ? "uas" : "uac");
@@ -12349,21 +12349,21 @@ static int respprep(struct sip_request *
 		}
 	}
 
-	if (msg[0] == '2' && (p->method == SIP_SUBSCRIBE || p->method == SIP_REGISTER || p->method == SIP_PUBLISH)) {
+	if (msg[0] == '2' && (req->method == SIP_SUBSCRIBE || req->method == SIP_REGISTER || req->method == SIP_PUBLISH)) {
 		/* For registration responses, we also need expiry and
 		   contact info */
 		add_expires(resp, p->expiry);
 		if (p->expiry) {	/* Only add contact if we have an expiry time */
 			char contact[SIPBUFSIZE];
-			const char *contact_uri = p->method == SIP_SUBSCRIBE ? p->our_contact : p->fullcontact;
+			const char *contact_uri = req->method == SIP_SUBSCRIBE ? p->our_contact : p->fullcontact;
 			char *brackets = strchr(contact_uri, '<');
 			snprintf(contact, sizeof(contact), "%s%s%s;expires=%d", brackets ? "" : "<", contact_uri, brackets ? "" : ">", p->expiry);
 			add_header(resp, "Contact", contact);	/* Not when we unregister */
 		}
-		if (p->method == SIP_REGISTER && ast_test_flag(&p->flags[0], SIP_USEPATH)) {
+		if (req->method == SIP_REGISTER && ast_test_flag(&p->flags[0], SIP_USEPATH)) {
 			copy_header(resp, req, "Path");
 		}
-	} else if (!ast_strlen_zero(p->our_contact) && resp_needs_contact(msg, p->method)) {
+	} else if (!ast_strlen_zero(p->our_contact) && resp_needs_contact(msg, req->method)) {
 		add_header(resp, "Contact", p->our_contact);
 	}
 
@@ -12568,7 +12568,7 @@ static int __transmit_response(struct si
 
 	/* If we are cancelling an incoming invite for some reason, add information
 		about the reason why we are doing this in clear text */
-	if (p->method == SIP_INVITE && msg[0] != '1') {
+	if (req->method == SIP_INVITE && msg[0] != '1') {
 		char buf[20];
 
 		if (ast_test_flag(&p->flags[1], SIP_PAGE2_Q850_REASON)) {
