39 |
|
#include <sys/socket.h> |
40 |
|
#include <netinet/in.h> |
41 |
|
#include <arpa/inet.h> |
42 |
– |
#include <netdb.h> |
42 |
|
|
43 |
|
#ifdef TIME_WITH_SYS_TIME |
44 |
|
# include <sys/time.h> |
258 |
|
/* Bind */ |
259 |
|
if (!EmptyString(IRCItem->vhost)) |
260 |
|
{ |
262 |
– |
struct addrinfo hints, *res; |
261 |
|
int bindret = 0; |
262 |
|
|
263 |
< |
memset(&hints, 0, sizeof(hints)); |
266 |
< |
hints.ai_family = AF_INET; |
267 |
< |
hints.ai_socktype = SOCK_STREAM; |
268 |
< |
hints.ai_flags = AI_PASSIVE | AI_NUMERICHOST; |
269 |
< |
|
270 |
< |
if (getaddrinfo(IRCItem->vhost, NULL, &hints, &res)) |
263 |
> |
if (inet_pton(AF_INET, IRCItem->vhost, &(IRC_LOCAL.in4.s_addr)) <= 0) |
264 |
|
{ |
265 |
|
log_printf("IRC -> bind(): %s is an invalid address", IRCItem->vhost); |
266 |
|
exit(EXIT_FAILURE); |
267 |
|
} |
268 |
|
|
276 |
– |
memcpy(&IRC_LOCAL.in4.s_addr, &((struct sockaddr_in *)res->ai_addr)->sin_addr, sizeof(struct in_addr)); |
277 |
– |
freeaddrinfo(res); |
278 |
– |
|
269 |
|
bsaddr.sa4.sin_addr.s_addr = IRC_LOCAL.in4.s_addr; |
270 |
|
bsaddr.sa4.sin_family = AF_INET; |
271 |
|
bsaddr.sa4.sin_port = htons(0); |