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

Function init_su

ip_addr.h:359–385  ·  view source on GitHub ↗

! \brief inits a struct sockaddr_union from a struct ip_addr and a port no * \return 0 if ok, -1 on error (unknown address family) * \note the port number is in host byte order */

Source from the content-addressed store, hash-verified

357 * \return 0 if ok, -1 on error (unknown address family)
358 * \note the port number is in host byte order */
359static inline int init_su( union sockaddr_union* su,
360 const struct ip_addr* ip,
361 unsigned short port )
362{
363 memset(su, 0, sizeof(union sockaddr_union));/*needed on freebsd*/
364 su->s.sa_family=ip->af;
365 switch(ip->af){
366 case AF_INET6:
367 memcpy(&su->sin6.sin6_addr, ip->u.addr, ip->len);
368 #ifdef HAVE_SOCKADDR_SA_LEN
369 su->sin6.sin6_len=sizeof(struct sockaddr_in6);
370 #endif
371 su->sin6.sin6_port=htons(port);
372 break;
373 case AF_INET:
374 memcpy(&su->sin.sin_addr, ip->u.addr, ip->len);
375 #ifdef HAVE_SOCKADDR_SA_LEN
376 su->sin.sin_len=sizeof(struct sockaddr_in);
377 #endif
378 su->sin.sin_port=htons(port);
379 break;
380 default:
381 LM_CRIT("unknown address family %d\n", ip->af);
382 return -1;
383 }
384 return 0;
385}
386
387
388

Callers 10

trace_xlogFunction · 0.85
proto_sctp_init_listenerFunction · 0.85
raw_capture_socketFunction · 0.85
smpp_connectFunction · 0.85
cgrc_connFunction · 0.85
cgrates_set_engineFunction · 0.85
_build_transactionFunction · 0.85
udp_init_listenerFunction · 0.85
tcp_init_listenerFunction · 0.85
tcpconn2suFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected