MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / t_relay_to

Function t_relay_to

modules/tm/t_funcs.c:203–282  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

201
202
203int t_relay_to( struct sip_msg *p_msg , struct proxy_l *proxy, int flags)
204{
205 int ret;
206 int new_tran;
207 int reply_ret;
208 struct cell *t;
209
210 ret=0;
211
212 new_tran = t_newtran( p_msg, 1/*full UAS cloning*/ );
213
214 /* parsing error, memory alloc, whatever ... */
215 if (new_tran<0) {
216 ret = new_tran;
217 goto done;
218 }
219 /* if that was a retransmission, break from script */
220 if (new_tran==0) {
221 goto done;
222 }
223
224 /* new transaction */
225
226 /* ACKs do not establish a transaction and are fwd-ed statelessly */
227 if ( p_msg->REQ_METHOD==METHOD_ACK) {
228 LM_DBG("forwarding ACK\n");
229 /* send it out */
230 if (proxy==0) {
231 proxy=uri2proxy(GET_NEXT_HOP(p_msg),
232 p_msg->force_send_socket ?
233 p_msg->force_send_socket->proto : PROTO_NONE );
234 if (proxy==0) {
235 ret=E_BAD_ADDRESS;
236 goto done;
237 }
238 ret=forward_request( p_msg , proxy);
239 if (ret>=0) ret=1;
240 free_proxy( proxy );
241 pkg_free( proxy );
242 } else {
243 ret=forward_request( p_msg , proxy);
244 if (ret>=0) ret=1;
245 }
246 goto done;
247 }
248
249 /* if replication flag is set, mark the transaction as local
250 so that replies will not be relaied */
251 t=get_t();
252 if (flags&TM_T_RELAY_repl_FLAG) t->flags|=T_IS_LOCAL_FLAG;
253 if (flags&TM_T_RELAY_nodnsfo_FLAG) t->flags|=T_NO_DNS_FAILOVER_FLAG;
254 if (flags&TM_T_RELAY_reason_FLAG) t->flags|=T_CANCEL_REASON_FLAG;
255 if ((flags&TM_T_RELAY_do_cancel_dis_FLAG) &&
256 tm_has_request_disponsition_no_cancel(p_msg)==0 )
257 t->flags|=T_MULTI_200OK_FLAG;
258
259 /* now go ahead and forward ... */
260 ret=t_forward_nonack( t, p_msg, proxy, 0/*no reset*/, 0/*unlocked*/);

Callers 4

w_t_relayFunction · 0.85
tm_repl_cancelFunction · 0.85
tm_anycast_cancelFunction · 0.85
t_replicateFunction · 0.85

Calls 8

t_newtranFunction · 0.85
uri2proxyFunction · 0.85
forward_requestFunction · 0.85
free_proxyFunction · 0.85
get_tFunction · 0.85
t_forward_nonackFunction · 0.85
kill_transactionFunction · 0.85

Tested by

no test coverage detected