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

Function sockaddr2ip_addr

ip_addr.h:246–268  ·  view source on GitHub ↗

! \brief inits an ip_addr pointer from a sockaddr structure*/

Source from the content-addressed store, hash-verified

244
245/*! \brief inits an ip_addr pointer from a sockaddr structure*/
246static inline void sockaddr2ip_addr(struct ip_addr* ip, const struct sockaddr* sa)
247{
248 void *copyfrom;
249
250 switch(sa->sa_family){
251 case AF_INET:
252 ip->af=AF_INET;
253 ip->len=4;
254 copyfrom = &((struct sockaddr_in*)(void *)sa)->sin_addr;
255 break;
256 case AF_INET6:
257 ip->af=AF_INET6;
258 ip->len=16;
259 copyfrom = &((struct sockaddr_in6*)(void *)sa)->sin6_addr;
260 break;
261 default:
262 LM_CRIT("unknown address family %d\n", sa->sa_family);
263 /* clear the structure to prevent uninitialized warnings */
264 ip->af=sa->sa_family;
265 return;
266 }
267 memcpy(ip->u.addr, copyfrom, ip->len);
268}
269
270
271

Callers 4

expand_interfaceFunction · 0.85
tcp_mgm_get_profileFunction · 0.85
run_mi_reg_listFunction · 0.85
proto_ipsec_sendFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected