proxy.c File Reference

Functions related to proxy lists, that stores informations about hosts. More...

#include "config.h"
#include "globals.h"
#include "proxy.h"
#include "error.h"
#include "dprint.h"
#include "mem/mem.h"
#include "mem/shm_mem.h"
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include "resolve.h"
#include "ip_addr.h"

Include dependency graph for proxy.c:

Go to the source code of this file.

Functions

struct proxy_ladd_proxy (str *name, unsigned short port, unsigned short proto)
 Add a proxy to beginning of the global list, if not already there.
static struct proxy_lfind_proxy (str *name, unsigned short port, int proto)
 Searches for a certan proxy.
void free_hostent (struct hostent *dst)
 Free a hostent structure in pkg memory.
void free_proxy (struct proxy_l *p)
 Free proxy in pkg memory.
void free_shm_hostent (struct hostent *dst)
 Frees a hostent structure in shared memory.
void free_shm_proxy (struct proxy_l *p)
 Free proxy in shared memory.
int hostent_cpy (struct hostent *dst, struct hostent *src)
 Copies a hostent structure.
int hostent_shm_cpy (struct hostent *dst, struct hostent *src)
 Copies a hostent structure in shared memory.
struct proxy_lmk_proxy (str *name, unsigned short port, unsigned short proto, int is_sips)
 Create a new proxy, but don't add it to the global list.
struct proxy_lmk_proxy_from_ip (struct ip_addr *ip, unsigned short port, unsigned short proto)
 Create a new proxy, but don't add it to the global list.
struct proxy_lmk_shm_proxy (str *name, unsigned short port, unsigned short proto, int is_sips)
 Create a new proxy, but don't add it to the global list.

Variables

int disable_dns_failover = 0
struct proxy_lproxies = 0


Detailed Description

Functions related to proxy lists, that stores informations about hosts.

Definition in file proxy.c.


Function Documentation

struct proxy_l* add_proxy ( str name,
unsigned short  port,
unsigned short  proto 
) [read]

Add a proxy to beginning of the global list, if not already there.

Parameters:
name proxy name
port proxy port
proto proxy protocol
Returns:
pointer to the new created proxy, or zero on error

Definition at line 250 of file proxy.c.

References find_proxy(), mk_proxy(), and proxy_l::next.

Referenced by fix_actions().

static struct proxy_l* find_proxy ( str name,
unsigned short  port,
int  proto 
) [static, read]

Searches for a certan proxy.

Search for the proxy named 'name', on port 'port' with proto 'proto'.

Note:
Use proto==0 for a proto wildcard (this will match any proto)
Parameters:
name proxy name
port proxy port
proto proxy protocol
Returns:
pointer to proxy_l on success or 0 if not found

Definition at line 76 of file proxy.c.

References _str::len, proxy_l::name, proxy_l::next, proxy_l::port, proxy_l::proto, PROTO_NONE, and _str::s.

Referenced by add_proxy().

void free_hostent ( struct hostent *  dst  ) 

Free a hostent structure in pkg memory.

Parameters:
dst freed hostent

Definition at line 224 of file proxy.c.

References pkg_free.

Referenced by free_proxy(), and get_next_su().

void free_proxy ( struct proxy_l p  ) 

Free proxy in pkg memory.

Definition at line 365 of file proxy.c.

References free_dns_res(), free_hostent(), and proxy_l::host.

Referenced by ac_sl_msg(), add_uac(), do_action(), t_relay_to(), trace_send_duplicate(), and uri2su().

void free_shm_hostent ( struct hostent *  dst  ) 

Frees a hostent structure in shared memory.

Parameters:
dst freed hostent

Definition at line 127 of file proxy.c.

References shm_free.

Referenced by free_shm_proxy(), get_next_su(), and shm_clone_proxy().

void free_shm_proxy ( struct proxy_l p  ) 

Free proxy in shared memory.

Definition at line 377 of file proxy.c.

References free_dns_res(), free_shm_hostent(), and proxy_l::host.

Referenced by conf_destroy(), and update_proxy().

int hostent_cpy ( struct hostent *  dst,
struct hostent *  src 
)

Copies a hostent structure.

Parameters:
dst destination
src source
Returns:
0 on success, <0 on error

Definition at line 140 of file proxy.c.

References E_OUT_OF_MEM, len, LM_CRIT, pkg_free, pkg_malloc, and ser_error.

Referenced by get_next_su(), and mk_proxy().

int hostent_shm_cpy ( struct hostent *  dst,
struct hostent *  src 
)

Copies a hostent structure in shared memory.

Parameters:
dst destination
src source
Returns:
0 on success, -1 on error

Definition at line 95 of file proxy.c.

References NULL, and shm_malloc().

Referenced by get_next_su(), mk_shm_proxy(), and shm_clone_proxy().

struct proxy_l* mk_proxy ( str name,
unsigned short  port,
unsigned short  proto,
int  is_sips 
) [read]

Create a new proxy, but don't add it to the global list.

Create a new proxy in private memory, but don't add it to the global list. This also uses SRV for lookup if possible & port==0 (quick hack).

Note:
this is the same as add proxy, but don't add the proxy to the list
Parameters:
name proxy hostname
port proxy port
proto proxy protocol
is_sips set to 1 if you use SIPS
Returns:
pointer to the proxy, or zero on error

Definition at line 279 of file proxy.c.

References disable_dns_failover, proxy_l::dn, E_BAD_ADDRESS, E_OUT_OF_MEM, free_dns_res(), proxy_l::host, hostent_cpy(), _str::len, LM_CRIT, LM_DBG, proxy_l::name, pkg_free, pkg_malloc, proxy_l::port, proxy_l::proto, _str::s, ser_error, and sip_resolvehost().

Referenced by add_proxy(), do_action(), fixup_phostport2proxy(), trace_send_duplicate(), and uri2proxy().

struct proxy_l* mk_proxy_from_ip ( struct ip_addr ip,
unsigned short  port,
unsigned short  proto 
) [read]

Create a new proxy, but don't add it to the global list.

Create a new proxy in private memory, but don't add it to the global list. This also uses SRV for lookup if possible & port==0 (quick hack).

Note:
this is the same as mk_proxy, but get the host as an ip
Parameters:
ip proxy name as IP address
port proxy port
proto proxy protocol
Returns:
pointer to the proxy, or zero on error

Definition at line 327 of file proxy.c.

References ip_addr::addr, ip_addr::af, proxy_l::host, ip_addr::len, LM_CRIT, pkg_free, pkg_malloc, proxy_l::port, proxy_l::proto, and ip_addr::u.

struct proxy_l* mk_shm_proxy ( str name,
unsigned short  port,
unsigned short  proto,
int  is_sips 
) [read]

Create a new proxy, but don't add it to the global list.

Create a new proxy in shared memory, but don't add it to the global list. This also uses SRV for lookup if possible & port==0 (quick hack).

Note:
this is the same as add_proxy, but don't add the proxy to the list and also works in shared memory
Parameters:
name proxy hostname
port proxy port
proto proxy protocol
is_sips set to 1 if you use SIPS
Returns:
pointer to the proxy, or zero on error

Definition at line 399 of file proxy.c.

References disable_dns_failover, proxy_l::dn, E_BAD_ADDRESS, E_OUT_OF_MEM, free_dns_res(), proxy_l::host, hostent_shm_cpy(), _str::len, LM_CRIT, LM_DBG, proxy_l::name, proxy_l::port, proxy_l::proto, _str::s, ser_error, shm_free, shm_malloc(), and sip_resolvehost().

Referenced by update_proxy().


Variable Documentation

disable the DNS failover

Definition at line 63 of file proxy.c.

Referenced by mk_proxy(), and mk_shm_proxy().

struct proxy_l* proxies = 0

list of proxies

Definition at line 60 of file proxy.c.


Generated on Thu May 24 08:01:15 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6