소스 검색

tm: enhanced local request API to set send socket

Daniel-Constantin Mierla 12 년 전
부모
커밋
9a3aa5e6e7
2개의 변경된 파일20개의 추가작업 그리고 0개의 파일을 삭제
  1. 19 0
      modules/tm/uac.c
  2. 1 0
      modules/tm/uac.h

+ 19 - 0
modules/tm/uac.c

@@ -701,6 +701,12 @@ int req_within(uac_req_t *uac_r)
 		goto err;
 	}
 
+	if(uac_r->ssock!=NULL && uac_r->ssock->len>0
+			&& uac_r->dialog->send_sock==NULL) {
+		/* set local send socket */
+		uac_r->dialog->send_sock = lookup_local_socket(uac_r->ssock);
+	}
+
 	if ((uac_r->method->len == 3) && (!memcmp("ACK", uac_r->method->s, 3))) goto send;
 	if ((uac_r->method->len == 6) && (!memcmp("CANCEL", uac_r->method->s, 6))) goto send;
 	uac_r->dialog->loc_seq.value++; /* Increment CSeq */
@@ -741,6 +747,12 @@ int req_outside(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop)
 	if (next_hop) uac_r->dialog->dst_uri = *next_hop;
 	w_calculate_hooks(uac_r->dialog);
 
+	if(uac_r->ssock!=NULL && uac_r->ssock->len>0
+			&& uac_r->dialog->send_sock==NULL) {
+		/* set local send socket */
+		uac_r->dialog->send_sock = lookup_local_socket(uac_r->ssock);
+	}
+
 	return t_uac(uac_r);
 
  err:
@@ -794,6 +806,13 @@ int request(uac_req_t *uac_r, str* ruri, str* to, str* from, str *next_hop)
 	 * before freeing dialog here must be removed
 	 */
 	uac_r->dialog = dialog;
+
+	if(uac_r->ssock!=NULL && uac_r->ssock->len>0
+			&& uac_r->dialog->send_sock==NULL) {
+		/* set local send socket */
+		uac_r->dialog->send_sock = lookup_local_socket(uac_r->ssock);
+	}
+
 	res = t_uac(uac_r);
 	dialog->rem_target.s = 0;
 	dialog->dst_uri.s = 0;

+ 1 - 0
modules/tm/uac.h

@@ -54,6 +54,7 @@ typedef struct uac_req {
 	str	*method;
 	str	*headers;
 	str	*body;
+	str *ssock;
 	dlg_t	*dialog;
 	int	cb_flags;
 	transaction_cb	*cb;