| 518 | |
| 519 | #ifdef LUASOCKET_INET_PTON |
| 520 | int inet_pton(int af, const char *src, void *dst) |
| 521 | { |
| 522 | struct addrinfo hints, *res; |
| 523 | int ret = 1; |
| 524 | memset(&hints, 0, sizeof(struct addrinfo)); |
| 525 | hints.ai_family = af; |
| 526 | hints.ai_flags = AI_NUMERICHOST; |
| 527 | if (getaddrinfo(src, NULL, &hints, &res) != 0) return -1; |
| 528 | if (af == AF_INET) { |
| 529 | struct sockaddr_in *in = (struct sockaddr_in *) res->ai_addr; |
| 530 | memcpy(dst, &in->sin_addr, sizeof(in->sin_addr)); |
| 531 | } else if (af == AF_INET6) { |
| 532 | struct sockaddr_in6 *in = (struct sockaddr_in6 *) res->ai_addr; |
| 533 | memcpy(dst, &in->sin6_addr, sizeof(in->sin6_addr)); |
| 534 | } else { |
| 535 | ret = -1; |
| 536 | } |
| 537 | freeaddrinfo(res); |
| 538 | return ret; |
| 539 | } |
| 540 | |
| 541 | #endif |
no outgoing calls
no test coverage detected