/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2010 Index Data
+ * Copyright (C) 1995-2011 Index Data
* See the file LICENSE for details.
*/
/**
* \file tcpip.c
* \brief Implements TCP/IP + SSL COMSTACK.
*/
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
#include <stdio.h>
#include <string.h>
if (!strcmp("@", host))
{
hints.ai_flags = AI_PASSIVE;
+ hints.ai_family = AF_INET;
+ error = getaddrinfo(0, port, &hints, &res);
+ }
+ else if (!strcmp("@6", host))
+ {
+ hints.ai_flags = AI_PASSIVE;
+ hints.ai_family = AF_INET6;
error = getaddrinfo(0, port, &hints, &res);
}
else
if (sp->ai && h->state == CS_ST_UNBND)
{
int s = -1;
- /* try to make IPV6 socket first */
for (ai = sp->ai; ai; ai = ai->ai_next)
{
- if (ai->ai_family == AF_INET6)
- {
- s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (s != -1)
- break;
- }
- }
- if (s == -1)
- {
- /* no IPV6 could be made.. Try them all */
- for (ai = sp->ai; ai; ai = ai->ai_next)
- {
- s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
- if (s != -1)
- break;
- }
+ s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
+ if (s != -1)
+ break;
}
if (s == -1)
return 0;
int (*check_ip)(void *cd, const char *a, int len, int t),
void *cd)
{
+#ifdef WIN32
+ /* we don't get peer address on Windows (via accept) */
+#else
struct sockaddr_in addr;
YAZ_SOCKLEN_T len = sizeof(addr);
+#endif
TRC(fprintf(stderr, "tcpip_listen pid=%d\n", getpid()));
if (h->state != CS_ST_IDLE)
}
return -1;
}
+#ifdef WIN32
+ if (addrlen)
+ *addrlen = 0;
+#else
if (addrlen && (size_t) (*addrlen) >= sizeof(struct sockaddr_in))
memcpy(raddr, &addr, *addrlen = sizeof(struct sockaddr_in));
else if (addrlen)
h->newfd = -1;
return -1;
}
+#endif
h->state = CS_ST_INCON;
return 0;
}