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

Function get_next_he

resolve.c:1953–2031  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1951
1952
1953static inline struct hostent* get_next_he(struct dns_node **node,
1954 unsigned short *proto, unsigned short *port)
1955{
1956 struct hostent *he;
1957 struct dns_node *n;
1958 struct dns_node *last_srv;
1959 struct dns_node *dn;
1960
1961 if (node==NULL || *node==NULL)
1962 return 0;
1963
1964 n = *node;
1965 last_srv = NULL;
1966 he = 0;
1967
1968 do {
1969 switch (n->type) {
1970 case DNS_NODE_SRV:
1971 last_srv = n;
1972 if (n->kids==NULL) {
1973 /* need to resolve this SRV and get all the AAA records */
1974 do {
1975 dn = 0;
1976 he = do_srv_lookup( n->vals[n->idx].sval, port, &dn);
1977 if (he) {
1978 *proto = n->vals[n->idx].ival;
1979 n->idx++;
1980 break;
1981 }
1982 n->idx++;
1983 } while(n->idx<n->no);
1984 if (he==NULL || (he && n->idx==n->no) ) {
1985 /* colapse the SRV node */
1986 shm_free(n);
1987 *node = dn;
1988 return he;
1989 }
1990 n->kids = dn;
1991 return he;
1992 }
1993 /* go for the AAA records */
1994 n = n->kids;
1995 break;
1996 case DNS_NODE_A:
1997 /* do resolve until success */
1998 do {
1999 he = resolvehost(n->vals[n->idx].sval,1);
2000 if (he) {
2001 *port = n->vals[n->idx].ival;
2002 n->idx++;
2003 break;
2004 }
2005 n->idx++;
2006 }while(n->idx<n->no);
2007 /* found something? */
2008 if (he==NULL || (he && n->idx==n->no)) {
2009 shm_free(n);
2010 /* any SRV level? */

Callers 1

get_next_suFunction · 0.85

Calls 3

do_srv_lookupFunction · 0.85
shm_freeFunction · 0.85
resolvehostFunction · 0.85

Tested by

no test coverage detected