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

Function forward_request

forward.c:333–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

331
332
333int forward_request( struct sip_msg* msg, struct proxy_l * p)
334{
335 union sockaddr_union to;
336 str buf;
337 const struct socket_info* send_sock;
338 const struct socket_info* last_sock;
339
340 buf.s=NULL;
341
342 /* calculate branch for outbound request - if the branch buffer is already
343 * set (maybe by an upper level as TM), used it; otherwise computes
344 * the branch for stateless fwd. . According to the latest discussions
345 * on the topic, you should reuse the latest statefull branch
346 * --bogdan */
347 if ( msg->add_to_branch_len==0 ) {
348 if (set_sl_branch(msg)!=0) {
349 LM_ERR("unable to compute and add stateless VIA branch\n");
350 goto error;
351 }
352 }
353
354 msg_callback_process(msg, REQ_PRE_FORWARD, (void *)p);
355
356 hostent2su( &to, &p->host, p->addr_idx, (p->port)?p->port:SIP_PORT);
357 last_sock = 0;
358
359 if (getb0flags(msg) & tcp_no_new_conn_bflag)
360 tcp_no_new_conn = 1;
361
362 do {
363 send_sock=get_send_socket( msg, &to, p->proto);
364 if (send_sock==0){
365 LM_ERR("cannot forward to af %d, proto %d no corresponding"
366 "listening socket\n", to.s.sa_family, p->proto);
367 ser_error=E_NO_SOCKET;
368 continue;
369 }
370
371 if ( last_sock!=send_sock ) {
372
373 if (buf.s)
374 pkg_free(buf.s);
375
376 buf.s = build_req_buf_from_sip_req( msg, (unsigned int*)&buf.len,
377 send_sock, p->proto, NULL, 0 /*flags*/);
378 if (!buf.s){
379 LM_ERR("building req buf failed\n");
380 tcp_no_new_conn = 0;
381 goto error;
382 }
383
384 last_sock = send_sock;
385 }
386
387 if (check_blacklists( p->proto, &to, buf.s, buf.len)) {
388 LM_DBG("blocked by blacklists\n");
389 ser_error=E_IP_BLOCKED;
390 continue;

Callers 2

w_forwardFunction · 0.85
t_relay_toFunction · 0.85

Calls 9

set_sl_branchFunction · 0.85
msg_callback_processFunction · 0.85
hostent2suFunction · 0.85
get_send_socketFunction · 0.85
check_blacklistsFunction · 0.85
msg_sendFunction · 0.85
slcb_run_req_outFunction · 0.85
get_next_suFunction · 0.85

Tested by

no test coverage detected