Преглед на файлове

tm: support for changing the reply status in the script

The reply status code is re-read after the onreply_route block
is executed which makes possile to change the status code from the script.
The status code shall be rewritten directly in the message buffer
and in the parsed structure, and the class of provisional and
positive final replies cannot be changed.
Miklos Tirpak преди 15 години
родител
ревизия
4cca625ce8
променени са 1 файла, в които са добавени 11 реда и са изтрити 0 реда
  1. 11 0
      modules/tm/t_reply.c

+ 11 - 0
modules/tm/t_reply.c

@@ -2129,6 +2129,17 @@ int reply_received( struct sip_msg  *p_msg )
 			stop_rb_timers(&uac->request);
 			stop_rb_timers(&uac->request);
 	 	}
 	 	}
 #endif /* TM_ONREPLY_FINAL_DROP_OK */
 #endif /* TM_ONREPLY_FINAL_DROP_OK */
+		/* Re-read the status code, it can be changed in the route block. */
+#ifdef EXTRA_DEBUG
+		/* The class of provisional and positive final replies cannot be changed. */
+		if (((msg_status < 300) || (p_msg->REPLY_STATUS < 300))
+			&& (msg_status/100 != p_msg->REPLY_STATUS/100)
+		) {
+			LOG(L_ERR, "ERROR: The class of provisional and "
+				"positive final replies should not be changed!\n");
+		}
+#endif /* EXTRA_DEBUG */
+		msg_status=p_msg->REPLY_STATUS;
 	}
 	}
 #ifdef USE_DST_BLACKLIST
 #ifdef USE_DST_BLACKLIST
 		/* add temporary to the blacklist the source of a 503 reply */
 		/* add temporary to the blacklist the source of a 503 reply */