! \brief inits an ip_addr pointer from a sockaddr_union ip address */
| 330 | |
| 331 | /*! \brief inits an ip_addr pointer from a sockaddr_union ip address */ |
| 332 | static inline void su2ip_addr(struct ip_addr* ip, const union sockaddr_union* su) |
| 333 | { |
| 334 | switch(su->s.sa_family){ |
| 335 | case AF_INET: |
| 336 | ip->af=AF_INET; |
| 337 | ip->len=4; |
| 338 | memcpy(ip->u.addr, &su->sin.sin_addr, 4); |
| 339 | break; |
| 340 | case AF_INET6: |
| 341 | ip->af=AF_INET6; |
| 342 | ip->len=16; |
| 343 | memcpy(ip->u.addr, &su->sin6.sin6_addr, 16); |
| 344 | break; |
| 345 | default: |
| 346 | LM_CRIT("Unknown address family %d\n", su->s.sa_family); |
| 347 | ip->af=0; |
| 348 | ip->len=0; |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | |
| 353 | /*! \brief ip_addr2su -> the same as \ref init_su() */ |
no outgoing calls
no test coverage detected