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

Function mk_proxy

proxy.c:196–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

194 * uses also SRV if possible & port==0 (quick hack) */
195
196struct 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;
229error:
230 return 0;
231}
232
233
234

Callers 10

fixup_destinationFunction · 0.85
w_forwardFunction · 0.85
add_dest2listFunction · 0.85
add_lb_dsturiFunction · 0.85
trace_send_duplicateFunction · 0.85
w_hep_relayFunction · 0.85
uri2proxyFunction · 0.85
fixup_phostport2proxyFunction · 0.85
add_dstFunction · 0.85
send_hep_messageFunction · 0.85

Calls 3

sip_resolvehostFunction · 0.85
hostent_cpyFunction · 0.85
free_dns_resFunction · 0.85

Tested by

no test coverage detected