#include "globals.h"
#include "parser/msg_parser.h"
#include "route.h"
#include "proxy.h"
#include "ip_addr.h"
#include "udp_server.h"


Go to the source code of this file.
Defines | |
| #define | update_sock_struct_from_ip(to, msg) |
| use src_ip, port=src_port if rport, via port if via port, 5060 otherwise | |
Functions | |
| int | check_self (str *host, unsigned short port, unsigned short proto) |
| checks if the proto: host:port is one of the address we listen on | |
| int | forward_reply (struct sip_msg *msg) |
| Forward reply. | |
| int | forward_request (struct sip_msg *msg, struct proxy_l *p) |
| Forward a request. | |
| struct socket_info * | get_out_socket (union sockaddr_union *to, int proto) |
| return a socket_info_pointer to the sending socket | |
| struct socket_info * | get_send_socket (struct sip_msg *msg, union sockaddr_union *su, int proto) |
| returns a socket_info pointer to the sending socket or 0 on error | |
| static int | msg_send (struct socket_info *send_sock, int proto, union sockaddr_union *to, int id, char *buf, int len) |
| int | update_sock_struct_from_via (union sockaddr_union *to, struct sip_msg *msg, struct via_body *via) |
Definition in file forward.h.
| #define update_sock_struct_from_ip | ( | to, | |||
| msg | ) |
Value:
init_su((to), &(msg)->rcv.src_ip, \ (((msg)->via1->rport)||((msg)->msg_flags&FL_FORCE_RPORT))? \ (msg)->rcv.src_port: \ ((msg)->via1->port)?(msg)->via1->port: SIP_PORT )
Definition at line 67 of file forward.h.
Referenced by init_rb(), and sl_send_reply_helper().
| int check_self | ( | str * | host, | |
| unsigned short | port, | |||
| unsigned short | proto | |||
| ) |
checks if the proto: host:port is one of the address we listen on
if port==0, the port number is ignored if proto==0 (PROTO_NONE) the protocol is ignored returns 1 if true, 0 if false, -1 on error WARNING: uses str2ip6 so it will overwrite any previous unsaved result of this function (static buffer)
Definition at line 253 of file forward.c.
References grep_aliases(), grep_sock_info(), _str::len, LM_DBG, and _str::s.
Referenced by check_self_op(), forward_reply(), is_myself(), ospGetNextHop(), and ospGetRouteParameters().
| int forward_reply | ( | struct sip_msg * | msg | ) |
Forward reply.
Forward reply, removes first via & sends msg to the second.
| msg | SIP message |
Definition at line 488 of file forward.c.
References build_res_buf_from_sip_res(), check_self(), check_via, via_body::error, sr_module::exports, get_send_socket(), HDR_VIA2_F, via_body::host, via_body::i, id, _str::len, len, LM_DBG, LM_ERR, modules, msg_send(), module_exports::name, sr_module::next, parse_headers(), PARSE_OK, pkg_free, pkg_malloc, via_body::port, via_body::proto, PROTO_TCP, PROTO_TLS, module_exports::response_f, reverse_hex2int(), _str::s, s, SIP_PORT, update_sock_struct_from_via(), update_stat, via_param::value, sip_msg::via1, and sip_msg::via2.
Referenced by receive_msg().
Forward a request.
Forward a request, get the send socket, create a temporary buffer and send this out. Checks blacklists before sending.
| msg | SIP message | |
| p | Proxy |
Definition at line 328 of file forward.c.
References sip_msg::add_to_branch_len, sip_msg::add_to_branch_s, proxy_l::addr_idx, buf, build_req_buf_from_sip_req(), check_blacklists(), E_IP_BLOCKED, E_NO_SOCKET, E_SEND, get_next_su(), get_send_socket(), get_sl_branch(), proxy_l::host, hostent2su(), sip_msg::len, _str::len, len, LM_DBG, LM_ERR, msg_send(), pkg_free, proxy_l::port, proxy_l::proto, sockaddr_union::s, _str::s, ser_error, SIP_PORT, and update_stat.
Referenced by do_action(), and t_relay_to().
| struct socket_info* get_out_socket | ( | union sockaddr_union * | to, | |
| int | proto | |||
| ) | [read] |
return a socket_info_pointer to the sending socket
Definition at line 90 of file forward.c.
References find_si(), len, LM_CRIT, LM_DBG, LM_ERR, PROTO_UDP, sockaddr_union::s, sockaddru_len, and su2ip_addr().
Referenced by get_send_socket().
| struct socket_info* get_send_socket | ( | struct sip_msg * | msg, | |
| union sockaddr_union * | to, | |||
| int | proto | |||
| ) | [read] |
returns a socket_info pointer to the sending socket or 0 on error
| msg | SIP message (can be null) | |
| to | destination socket_union pointer | |
| proto | protocol |
Definition at line 138 of file forward.c.
References socket_info::address, ip_addr::af, bind_address, find_si(), sip_msg::force_send_socket, get_out_socket(), LM_CRIT, LM_DBG, LM_ERR, LM_WARN, mhomed, socket_info::port_no, socket_info::proto, PROTO_SCTP, PROTO_TCP, PROTO_TLS, PROTO_UDP, sockaddr_union::s, sendipv4, sendipv6, and socket_info::socket.
Referenced by forward_reply(), forward_request(), forward_sl_request(), msg_send(), nh_timer(), trace_send_duplicate(), update_uac_dst(), uri2sock(), and utils_forward().
| static int msg_send | ( | struct socket_info * | send_sock, | |
| int | proto, | |||
| union sockaddr_union * | to, | |||
| int | id, | |||
| char * | buf, | |||
| int | len | |||
| ) | [inline, static] |
| send_sock | = 0 if already known (e.g. for udp in some cases), non-0 otherwise | |
| proto | =TCP|UDP | |
| to | = destination, | |
| id | - only used on tcp, it will force sending on connection "id" if id!=0 and the connection exists, else it will send to "to" (useful for sending replies on the same connection as the request that generated them; use 0 if you don't want this) | |
| buf | ??? | |
| len | ??? |
Definition at line 90 of file forward.h.
References get_send_socket(), LM_CRIT, LM_ERR, LM_WARN, PROTO_SCTP, PROTO_TCP, PROTO_TLS, PROTO_UDP, tcp_send(), and udp_send().
Referenced by do_action(), forward_reply(), forward_request(), forward_sl_request(), send_pr_buffer(), sl_send_reply_helper(), trace_send_duplicate(), and utils_forward().
| int update_sock_struct_from_via | ( | union sockaddr_union * | to, | |
| struct sip_msg * | msg, | |||
| struct via_body * | via | |||
| ) |
Definition at line 420 of file forward.c.
References FL_FORCE_RPORT, via_body::host, hostent2su(), _str::len, LM_DBG, LM_NOTICE, via_body::maddr, sip_msg::msg_flags, via_body::port, port, via_body::proto, sip_msg::rcv, via_body::received, via_body::rport, _str::s, SIP_PORT, sip_resolvehost(), receive_info::src_port, str2s(), via_param::value, and sip_msg::via1.
Referenced by forward_reply(), init_rb(), and sl_send_reply_helper().
1.5.6