| 160 | */ |
| 161 | |
| 162 | static int getaddr_info_single_addr(const char *service, |
| 163 | uint32 addr, |
| 164 | const struct addrinfo *hints, |
| 165 | struct addrinfo **res) |
| 166 | { |
| 167 | |
| 168 | struct addrinfo *ai = NULL; |
| 169 | struct in_addr ip; |
| 170 | unsigned short port = 0; |
| 171 | |
| 172 | if (service) { |
| 173 | port = (unsigned short)atoi(service); |
| 174 | } |
| 175 | ip.s_addr = htonl(addr); |
| 176 | |
| 177 | ai = alloc_entry(hints, ip, port); |
| 178 | if (!ai) { |
| 179 | return EAI_MEMORY; |
| 180 | } |
| 181 | |
| 182 | /* If we're asked for the canonical name, |
| 183 | * make sure it returns correctly. */ |
| 184 | if (!(hints->ai_flags & AI_NUMERICSERV) && |
| 185 | hints->ai_flags & AI_CANONNAME) { |
| 186 | int err; |
| 187 | if (addr == INADDR_LOOPBACK || addr == INADDR_ANY) { |
| 188 | ai->ai_canonname = get_my_canon_name(&err); |
| 189 | } else { |
| 190 | ai->ai_canonname = |
| 191 | get_canon_name_from_addr(ip,&err); |
| 192 | } |
| 193 | if (ai->ai_canonname == NULL) { |
| 194 | freeaddrinfo(ai); |
| 195 | return err; |
| 196 | } |
| 197 | } |
| 198 | |
| 199 | *res = ai; |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | /* |
| 204 | * get address info for multiple ipv4 addresses. |
no test coverage detected