forward.c File Reference

Kamailio Stateless forward support. More...

#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "forward.h"
#include "parser/msg_parser.h"
#include "dprint.h"
#include "ut.h"
#include "mem/mem.h"
#include "msg_translator.h"
#include "sr_module.h"
#include "ip_addr.h"
#include "resolve.h"
#include "name_alias.h"
#include "socket_info.h"
#include "core_stats.h"
#include "blacklists.h"

Include dependency graph for forward.c:

Go to the source code of this file.

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 *to, int proto)
 returns a socket_info pointer to the sending socket or 0 on error
static strget_sl_branch (struct sip_msg *msg)
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.c.


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 str* get_sl_branch ( struct sip_msg msg  )  [inline, static]

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