| 34 | }; |
| 35 | |
| 36 | static int check_sockaddr(struct sockaddr_in *in) |
| 37 | { |
| 38 | struct in_addr expected; |
| 39 | |
| 40 | inet_pton(AF_INET, "127.0.0.1", &expected); |
| 41 | if (in->sin_family != AF_INET) { |
| 42 | fprintf(stderr, "bad family %d\n", (int)htons(in->sin_family)); |
| 43 | return -1; |
| 44 | } |
| 45 | if (memcmp(&expected, &in->sin_addr, sizeof(in->sin_addr))) { |
| 46 | char buff[256]; |
| 47 | const char *addr = inet_ntop(AF_INET, &in->sin_addr, buff, sizeof(buff)); |
| 48 | |
| 49 | fprintf(stderr, "unexpected address %s\n", addr ? addr : "INVALID"); |
| 50 | return -1; |
| 51 | } |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | static int test(struct args *args) |
| 56 | { |