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

Function hostent2su

ip_addr.h:393–420  ·  view source on GitHub ↗

! \brief 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! * \return 0 if ok, -1 on error (unknown address family) */

Source from the content-addressed store, hash-verified

391 * WARNING: no index overflow checks!
392 * \return 0 if ok, -1 on error (unknown address family) */
393static inline int hostent2su( union sockaddr_union* su,
394 const struct hostent* he,
395 unsigned int idx,
396 unsigned short port )
397{
398 memset(su, 0, sizeof(union sockaddr_union)); /*needed on freebsd*/
399 su->s.sa_family=he->h_addrtype;
400 switch(he->h_addrtype){
401 case AF_INET6:
402 memcpy(&su->sin6.sin6_addr, he->h_addr_list[idx], he->h_length);
403 #ifdef HAVE_SOCKADDR_SA_LEN
404 su->sin6.sin6_len=sizeof(struct sockaddr_in6);
405 #endif
406 su->sin6.sin6_port=htons(port);
407 break;
408 case AF_INET:
409 memcpy(&su->sin.sin_addr, he->h_addr_list[idx], he->h_length);
410 #ifdef HAVE_SOCKADDR_SA_LEN
411 su->sin.sin_len=sizeof(struct sockaddr_in);
412 #endif
413 su->sin.sin_port=htons(port);
414 break;
415 default:
416 LM_CRIT("unknown address family %d\n", he->h_addrtype);
417 return -1;
418 }
419 return 0;
420}
421
422/*! \brief maximum size of a str returned by ip_addr2a (including \\0') */
423#define IP_ADDR_MAX_STR_SIZE 40 /* 1234:5678:9012:3456:7890:1234:5678:9012\0 */

Callers 15

w_sendFunction · 0.85
forward_requestFunction · 0.85
get_next_suFunction · 0.85
send_keepaliveFunction · 0.85
datagram_parseFunction · 0.85
stream_parseFunction · 0.85
nh_timerFunction · 0.85
trace_send_duplicateFunction · 0.85
w_hep_relayFunction · 0.85
jsonrpc_get_dstFunction · 0.85
mi_mod_initFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected