forward.h File Reference

Kamailio Stateless forward support. More...

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

Include dependency graph for forward.h:

This graph shows which files directly or indirectly include this file:

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_infoget_out_socket (union sockaddr_union *to, int proto)
 return a socket_info_pointer to the sending socket
struct socket_infoget_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)


Detailed Description

Kamailio Stateless forward support.

Definition in file forward.h.


Define Documentation

#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 )
use src_ip, port=src_port if rport, via port if via port, 5060 otherwise

Definition at line 67 of file forward.h.

Referenced by init_rb(), and sl_send_reply_helper().


Function Documentation

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  ) 

int forward_request ( struct sip_msg msg,
struct proxy_l p 
)

Forward a request.

Forward a request, get the send socket, create a temporary buffer and send this out. Checks blacklists before sending.

Parameters:
msg SIP message
p Proxy
Returns:
0 on success, -1 on errors

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

Note:
As opposed to get_send_socket(), which returns process's default socket, get_out_socket attempts to determine the outbound interface which will be used; it creates a temporary connected socket to determine it; it will be very likely noticeably slower, but it can deal better with multihomed hosts

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

Parameters:
msg SIP message (can be null)
to destination socket_union pointer
proto protocol
Note:
if msg!=null and msg->force_send_socket, the force_send_socket will be used

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]

Parameters:
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 ???
Returns:
0 if ok, -1 on error

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 
)


Generated on Wed May 23 06:01:03 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6