ip_addr.h File Reference

ip address family related structures More...

#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include "str.h"
#include "dprint.h"

Include dependency graph for ip_addr.h:

Go to the source code of this file.

Data Structures

struct  dest_info
struct  ip_addr
struct  net
struct  receive_info
union  sockaddr_union
struct  socket_id
struct  socket_info

Defines

#define AF2PF(af)   (((af)==AF_INET)?PF_INET:(af))
#define BUFFER_INCREMENT   2048
#define HEXDIG(x)   (((x)>=10)?(x)-10+'A':(x)+'0')
#define hostent2ip_addr(ip, he, addr_no)
 inits an ip_addr with the addr. info from a hostent structure ip = struct ip_addr* he= struct hostent*
#define ip_addr2su   init_su
 ip_addr2su -> the same as init_su()
#define ip_addr_cmp(ip1, ip2)
 compare 2 ip_addrs (both args are pointers)
#define IP_ADDR_MAX_STR_SIZE   40
 maximum size of a str returned by ip_addr2a (including \0')
#define MAX_RECV_BUFFER_SIZE   256*1024
#define sockaddru_len(su)   sizeof(struct sockaddr_in)

Enumerations

enum  si_flags { SI_NONE = 0, SI_IS_IP = 1, SI_IS_LO = 2, SI_IS_MCAST = 4 }
enum  sip_protos {
  PROTO_NONE, PROTO_UDP, PROTO_TCP, PROTO_TLS,
  PROTO_SCTP
}

Functions

static int hostent2su (union sockaddr_union *su, struct hostent *he, unsigned int idx, unsigned short port)
 inits a struct sockaddr_union from a struct hostent, an address index in the hostent structure and a port no. (host byte order) WARNING: no index overflow checks!
static int init_su (union sockaddr_union *su, struct ip_addr *ip, unsigned short port)
 inits a struct sockaddr_union from a struct ip_addr and a port no
static char * ip_addr2a (struct ip_addr *ip)
 fast ip_addr -> string converter; it uses an internal buffer
static struct hostent * ip_addr2he (str *name, struct ip_addr *ip)
 converts an ip_addr structure to a hostent
static int matchnet (struct ip_addr *ip, struct net *net)
 returns 1 if ip & net.mask == net.ip ; 0 otherwise & -1 on error [ diff. address families ])
struct netmk_net (struct ip_addr *ip, struct ip_addr *mask)
struct netmk_net_bitlen (struct ip_addr *ip, unsigned int bitlen)
void print_ip (char *prefix, struct ip_addr *ip, char *suffix)
void print_net (struct net *net)
static void sockaddr2ip_addr (struct ip_addr *ip, struct sockaddr *sa)
 inits an ip_addr pointer from a sockaddr structure
void stdout_print_ip (struct ip_addr *ip)
static void su2ip_addr (struct ip_addr *ip, union sockaddr_union *su)
 inits an ip_addr pointer from a sockaddr_union ip address
static int su_cmp (union sockaddr_union *s1, union sockaddr_union *s2)
 compare 2 sockaddr_unions
static unsigned short su_getport (union sockaddr_union *su)
 gets the port number (host byte order)
static void su_setport (union sockaddr_union *su, unsigned short port)
 sets the port number (host byte order)


Detailed Description

ip address family related structures

Definition in file ip_addr.h.


Define Documentation

#define AF2PF ( af   )     (((af)==AF_INET)?PF_INET:(af))

Definition at line 166 of file ip_addr.h.

Referenced by open_server_sockets(), and udp_init().

#define BUFFER_INCREMENT   2048

Definition at line 49 of file ip_addr.h.

Referenced by probe_max_receive_buffer().

#define HEXDIG (  )     (((x)>=10)?(x)-10+'A':(x)+'0')

Referenced by ip_addr2a().

#define hostent2ip_addr ( ip,
he,
addr_no   ) 

Value:

do{ \
      (ip)->af=(he)->h_addrtype; \
      (ip)->len=(he)->h_length;  \
      memcpy((ip)->u.addr, (he)->h_addr_list[(addr_no)], (ip)->len); \
   }while(0)
inits an ip_addr with the addr. info from a hostent structure ip = struct ip_addr* he= struct hostent*

Definition at line 150 of file ip_addr.h.

Referenced by add_dest2list(), fix_actions(), fix_socket_list(), get_next_su(), is_from_user_enum_2(), and seas_init().

#define ip_addr2su   init_su

ip_addr2su -> the same as init_su()

Definition at line 319 of file ip_addr.h.

#define ip_addr_cmp ( ip1,
ip2   ) 

Value:

(((ip1)->af==(ip2)->af)&& \
      (memcmp((ip1)->u.addr, (ip2)->u.addr, (ip1)->len)==0))
compare 2 ip_addrs (both args are pointers)

Definition at line 232 of file ip_addr.h.

Referenced by ds_is_from_list(), find_si(), grep_sock_info(), is_from_user_enum_2(), lump_check_opt(), tls_find_client_domain(), tls_find_server_domain(), and tls_new_server_domain().

#define IP_ADDR_MAX_STR_SIZE   40

maximum size of a str returned by ip_addr2a (including \0')

Definition at line 392 of file ip_addr.h.

Referenced by force_rtp_proxy1_f(), ip_addr2a(), prepend_path(), rtpproxy_answer1_f(), rtpproxy_offer1_f(), sip_trace(), trace_onreply_in(), trace_onreply_out(), trace_onreq_out(), and trace_sl_onreply_out().

#define MAX_RECV_BUFFER_SIZE   256*1024

Definition at line 48 of file ip_addr.h.

Referenced by print_ct_constants().

#define sockaddru_len ( su   )     sizeof(struct sockaddr_in)

Definition at line 142 of file ip_addr.h.

Referenced by get_out_socket(), mi_init_datagram_server(), udp_init(), udp_rcv_loop(), and udp_send().


Enumeration Type Documentation

enum si_flags

Enumerator:
SI_NONE 
SI_IS_IP 
SI_IS_LO 
SI_IS_MCAST 

Definition at line 84 of file ip_addr.h.

enum sip_protos

Enumerator:
PROTO_NONE 
PROTO_UDP 
PROTO_TCP 
PROTO_TLS 
PROTO_SCTP 

Definition at line 51 of file ip_addr.h.


Function Documentation

static int hostent2su ( union sockaddr_union su,
struct hostent *  he,
unsigned int  idx,
unsigned short  port 
) [inline, static]

inits a struct sockaddr_union from a struct hostent, an address index in the hostent structure and a port no. (host byte order) WARNING: no index overflow checks!

Returns:
0 if ok, -1 on error (unknown address family)

Definition at line 360 of file ip_addr.h.

References LM_CRIT, sockaddr_union::s, and sockaddr_union::sin.

Referenced by add_uac(), do_action(), forward_request(), forward_sl_request(), get_next_su(), mi_mod_init(), nh_timer(), trace_send_duplicate(), update_sock_struct_from_via(), uri2su(), and utils_forward().

static int init_su ( union sockaddr_union su,
struct ip_addr ip,
unsigned short  port 
) [inline, static]

inits a struct sockaddr_union from a struct ip_addr and a port no

Returns:
0 if ok, -1 on error (unknown address family)
Note:
the port number is in host byte order

Definition at line 324 of file ip_addr.h.

References ip_addr::addr, ip_addr::af, ip_addr::len, LM_CRIT, sockaddr_union::s, sockaddr_union::sin, and ip_addr::u.

Referenced by open_server_sockets(), and udp_init().

static char* ip_addr2a ( struct ip_addr ip  )  [inline, static]

static struct hostent* ip_addr2he ( str name,
struct ip_addr ip 
) [static, read]

converts an ip_addr structure to a hostent

Returns:
pointer to internal statical structure

Definition at line 525 of file ip_addr.h.

References ip_addr::addr, ip_addr::af, ip_addr::len, _str::len, len, _str::s, and ip_addr::u.

Referenced by resolvehost(), and sip_resolvehost().

static int matchnet ( struct ip_addr ip,
struct net net 
) [inline, static]

returns 1 if ip & net.mask == net.ip ; 0 otherwise & -1 on error [ diff. address families ])

Definition at line 186 of file ip_addr.h.

References ip_addr::addr32, ip_addr::af, net::ip, ip_addr::len, net::mask, and ip_addr::u.

Referenced by check_against_rule_list(), and comp_ip().

struct net* mk_net ( struct ip_addr ip,
struct ip_addr mask 
) [read]

struct net* mk_net_bitlen ( struct ip_addr ip,
unsigned int  bitlen 
) [read]

Definition at line 81 of file ip_addr.c.

References ip_addr::addr, ip_addr::af, ip_addr::len, LM_CRIT, mk_net(), and ip_addr::u.

void print_ip ( char *  prefix,
struct ip_addr ip,
char *  suffix 
)

Definition at line 103 of file ip_addr.c.

References ip_addr::addr, ip_addr::addr16, ip_addr::af, LM_DBG, and ip_addr::u.

Referenced by comp_ip(), mk_net(), print_action(), print_expr(), and print_net().

void print_net ( struct net net  ) 

Definition at line 162 of file ip_addr.c.

References net::ip, LM_WARN, net::mask, and print_ip().

Referenced by print_expr().

static void sockaddr2ip_addr ( struct ip_addr ip,
struct sockaddr *  sa 
) [inline, static]

inits an ip_addr pointer from a sockaddr structure

Definition at line 209 of file ip_addr.h.

References ip_addr::addr, ip_addr::af, ip_addr::len, LM_CRIT, and ip_addr::u.

Referenced by add_interfaces().

void stdout_print_ip ( struct ip_addr ip  ) 

Definition at line 135 of file ip_addr.c.

References ip_addr::addr, ip_addr::addr16, ip_addr::af, LM_DBG, and ip_addr::u.

static void su2ip_addr ( struct ip_addr ip,
union sockaddr_union su 
) [inline, static]

static int su_cmp ( union sockaddr_union s1,
union sockaddr_union s2 
) [inline, static]

compare 2 sockaddr_unions

Definition at line 239 of file ip_addr.h.

References LM_CRIT, sockaddr_union::s, and sockaddr_union::sin.

static unsigned short su_getport ( union sockaddr_union su  )  [inline, static]

gets the port number (host byte order)

Definition at line 261 of file ip_addr.h.

References LM_CRIT, sockaddr_union::s, and sockaddr_union::sin.

Referenced by check_blacklists(), trace_onreply_out(), trace_onreq_out(), trace_sl_onreply_out(), and udp_rcv_loop().

static void su_setport ( union sockaddr_union su,
unsigned short  port 
) [inline, static]

sets the port number (host byte order)

Definition at line 280 of file ip_addr.h.

References LM_CRIT, sockaddr_union::s, and sockaddr_union::sin.


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