| 194 | * uses also SRV if possible & port==0 (quick hack) */ |
| 195 | |
| 196 | struct proxy_l* mk_proxy(str* name, unsigned short port, unsigned short proto, |
| 197 | int is_sips) |
| 198 | { |
| 199 | struct proxy_l* p; |
| 200 | struct hostent* he; |
| 201 | |
| 202 | p=(struct proxy_l*) pkg_malloc(sizeof(struct proxy_l)); |
| 203 | if (p==0){ |
| 204 | ser_error=E_OUT_OF_MEM; |
| 205 | LM_CRIT("pkg memory allocation failure\n"); |
| 206 | goto error; |
| 207 | } |
| 208 | memset(p,0,sizeof(struct proxy_l)); |
| 209 | p->name=*name; |
| 210 | p->port=port; |
| 211 | p->proto=proto; |
| 212 | |
| 213 | LM_DBG("doing DNS lookup...\n"); |
| 214 | he = sip_resolvehost(name, &(p->port), &p->proto, is_sips, |
| 215 | disable_dns_failover?0:&p->dn ); |
| 216 | if (!he || !he->h_addr_list[0]) { |
| 217 | ser_error=E_BAD_ADDRESS; |
| 218 | LM_CRIT("could not resolve hostname: \"%.*s\"%s\n", |
| 219 | name->len, name->s, he ? " (0 results)" : ""); |
| 220 | pkg_free(p); |
| 221 | goto error; |
| 222 | } |
| 223 | if (hostent_cpy(&(p->host), he)!=0){ |
| 224 | free_dns_res( p ); |
| 225 | pkg_free(p); |
| 226 | goto error; |
| 227 | } |
| 228 | return p; |
| 229 | error: |
| 230 | return 0; |
| 231 | } |
| 232 | |
| 233 | |
| 234 |
no test coverage detected