Browse code

uac: call event route for uac_req_send() for second response

- done in case the request is resent after a 401/407
- GH #1598

Daniel-Constantin Mierla authored on 23/07/2018 11:58:12
Showing 1 changed files
... ...
@@ -656,7 +656,35 @@ void uac_req_run_event_route(sip_msg_t *msg, uac_send_info_t *tp, int rcode)
656 656
 }
657 657
 
658 658
 /**
659
- * TM callback function
659
+ * TM resend callback function
660
+ */
661
+void uac_resend_tm_callback(struct cell *t, int type, struct tmcb_params *ps)
662
+{
663
+	uac_send_info_t *tp = NULL;
664
+
665
+	LM_DBG("tm callback with status %d\n", ps->code);
666
+
667
+	if(ps->param==NULL || *ps->param==0)
668
+	{
669
+		LM_DBG("callback param with message id not received\n");
670
+		goto done;
671
+	}
672
+	tp = (uac_send_info_t*)(*ps->param);
673
+
674
+	if(tp->evroute!=0) {
675
+		uac_req_run_event_route((ps->rpl==FAKED_REPLY)?NULL:ps->rpl,
676
+				tp, ps->code);
677
+	}
678
+
679
+done:
680
+	if(tp!=NULL)
681
+		shm_free(tp);
682
+	return;
683
+
684
+}
685
+
686
+/**
687
+ * TM send callback function
660 688
  */
661 689
 void uac_send_tm_callback(struct cell *t, int type, struct tmcb_params *ps)
662 690
 {
... ...
@@ -753,6 +781,12 @@ void uac_send_tm_callback(struct cell *t, int type, struct tmcb_params *ps)
753 781
 	uac_r.ssock = (tp->s_sock.len <= 0) ? NULL : &tp->s_sock;
754 782
 	uac_r.dialog = &tmdlg;
755 783
 	uac_r.cb_flags = TMCB_LOCAL_COMPLETED;
784
+	if(tp->evroute!=0) {
785
+		/* Callback function */
786
+		uac_r.cb  = uac_resend_tm_callback;
787
+		/* Callback parameter */
788
+		uac_r.cbp = (void*)tp;
789
+	}
756 790
 	ret = tmb.t_request_within(&uac_r);
757 791
 
758 792
 	if(ret<0) {
... ...
@@ -760,6 +794,10 @@ void uac_send_tm_callback(struct cell *t, int type, struct tmcb_params *ps)
760 794
 		goto error;
761 795
 	}
762 796
 
797
+	if(tp->evroute!=0) {
798
+		return;
799
+	}
800
+
763 801
 done:
764 802
 error:
765 803
 	if(tp!=NULL)