MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / get_next_su

Function get_next_su

resolve.c:2048–2097  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2046
2047
2048int get_next_su(struct proxy_l *p, union sockaddr_union* su, int add_to_bl)
2049{
2050 struct hostent *he;
2051 struct bl_rule *list;
2052 struct net ip_net;
2053 int n;
2054
2055 if (failover_bl && add_to_bl) {
2056 memset( &ip_net, 0xff , sizeof(struct net));
2057 hostent2ip_addr( &ip_net.ip, &p->host, p->addr_idx);
2058 ip_net.mask.af = ip_net.ip.af;
2059 ip_net.mask.len = ip_net.ip.len;
2060 list = 0;
2061 n = add_rule_to_list( &list, &list, &ip_net, 0, p->port, p->proto, 0);
2062 if (n!=0) {
2063 LM_ERR("failed to build bl rule\n");
2064 } else {
2065 add_list_to_head( failover_bl, list, list, 0, DNS_BL_EXPIRE);
2066 }
2067 }
2068
2069 /* any more available IPs in he ? */
2070 if ( p->host.h_addr_list[++p->addr_idx] ) {
2071 /* yes -> return the IP*/
2072 hostent2su( su, &p->host, p->addr_idx, (p->port)?p->port:SIP_PORT);
2073 return 0;
2074 }
2075
2076 /* get a new he from DNS */
2077 he = get_next_he( &p->dn, &p->proto, &p->port);
2078 if (he==NULL)
2079 return -1;
2080
2081 /* replace the current he */
2082 if (p->flags&PROXY_SHM_FLAG) {
2083 free_shm_hostent( &p->host );
2084 n = hostent_shm_cpy(&(p->host), he);
2085 } else {
2086 free_hostent( &p->host );
2087 n = hostent_cpy(&(p->host), he);
2088 }
2089 if (n!=0) {
2090 free_dns_res( p );
2091 return -1;
2092 }
2093
2094 hostent2su( su, &p->host, 0, (p->port)?p->port:SIP_PORT);
2095 p->addr_idx = 0;
2096 return 0;
2097}
2098
2099
2100

Callers 9

forward_requestFunction · 0.85
add_dest2listFunction · 0.85
add_lb_dsturiFunction · 0.85
trace_send_duplicateFunction · 0.85
w_hep_relayFunction · 0.85
do_dns_failoverFunction · 0.85
t_forward_nonackFunction · 0.85
add_dstFunction · 0.85
send_hep_messageFunction · 0.85

Calls 9

add_rule_to_listFunction · 0.85
add_list_to_headFunction · 0.85
hostent2suFunction · 0.85
get_next_heFunction · 0.85
free_shm_hostentFunction · 0.85
hostent_shm_cpyFunction · 0.85
free_hostentFunction · 0.85
hostent_cpyFunction · 0.85
free_dns_resFunction · 0.85

Tested by

no test coverage detected