#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include "str.h"
#include "dprint.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 net * | mk_net (struct ip_addr *ip, struct ip_addr *mask) |
| struct net * | mk_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) | |
Definition in file ip_addr.h.
| #define AF2PF | ( | af | ) | (((af)==AF_INET)?PF_INET:(af)) |
| #define BUFFER_INCREMENT 2048 |
| #define HEXDIG | ( | x | ) | (((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)
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 |
| #define ip_addr_cmp | ( | ip1, | |||
| ip2 | ) |
Value:
(((ip1)->af==(ip2)->af)&& \
(memcmp((ip1)->u.addr, (ip2)->u.addr, (ip1)->len)==0))
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 |
| #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().
| enum si_flags |
| enum sip_protos |
| 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!
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
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] |
fast ip_addr -> string converter; it uses an internal buffer
Definition at line 397 of file ip_addr.h.
References ip_addr::addr, ip_addr::addr16, ip_addr::af, HEXDIG, IP_ADDR_MAX_STR_SIZE, LM_CRIT, and ip_addr::u.
Referenced by add_interfaces(), addr_hash_table_mi_print(), allow_trusted_0(), append_fixed_vars(), check_our_gws(), check_via_address(), comp_ip(), create_rcv_uri(), decode_avp_value(), fix_nated_contact_f(), fix_socket_list(), FixContact(), force_rtp_proxy(), force_rtp_proxy1_f(), get_local_contact(), get_signaling_ip(), get_source_uri(), gw_set_state(), init_tls_domains(), mi_print_blacklists(), mi_print_gws(), pike_check_req(), prepend_path(), received_builder(), replace_sdp_ip(), rtpproxy_answer1_f(), rtpproxy_offer1_f(), sip_trace(), subnet_table_mi_print(), tls_accept(), tls_connect(), tls_new_server_domain(), tls_tcpconn_init(), tlsops_alt(), trace_onreply_in(), trace_onreply_out(), trace_onreq_out(), trace_sl_onreply_out(), and udp_rcv_loop().
converts an ip_addr structure to a hostent
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().
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().
Definition at line 43 of file ip_addr.c.
References ip_addr::addr32, ip_addr::af, net::ip, ip_addr::len, LM_CRIT, LM_WARN, net::mask, pkg_malloc, print_ip(), and ip_addr::u.
Referenced by mk_net_bitlen().
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] |
inits an ip_addr pointer from a sockaddr_union ip address
Definition at line 297 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 check_blacklists(), get_out_socket(), trace_onreply_out(), trace_onreq_out(), trace_sl_onreply_out(), and udp_rcv_loop().
| 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.
1.5.6