/* This file is part of the YAZ toolkit.
- * Copyright (C) 1995-2009 Index Data
+ * Copyright (C) 1995-2010 Index Data
* See the file LICENSE for details.
*/
/**
#include <yaz/tcpip.h>
#include <yaz/errno.h>
-static int tcpip_close(COMSTACK h);
+static void tcpip_close(COMSTACK h);
static int tcpip_put(COMSTACK h, char *buf, int size);
static int tcpip_get(COMSTACK h, char **buf, int *bufsize);
static int tcpip_put_connect(COMSTACK h, char *buf, int size);
#endif
static COMSTACK tcpip_accept(COMSTACK h);
-static char *tcpip_addrstr(COMSTACK h);
+static const char *tcpip_addrstr(COMSTACK h);
static void *tcpip_straddr(COMSTACK h, const char *str);
#if 0
p->state = s < 0 ? CS_ST_UNBND : CS_ST_IDLE; /* state of line */
p->event = CS_NONE;
p->cerrno = 0;
- p->stackerr = 0;
p->user = 0;
#if HAVE_GNUTLS_H
#define CERTF "ztest.pem"
#define KEYF "ztest.pem"
-static void tcpip_setsockopt(int fd)
-{
-#if 0
- int len = 4096;
- int set = 1;
-
- if (setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (char*)&set, sizeof(int)))
- {
- yaz_log(LOG_WARN|LOG_ERRNO, "setsockopt TCP_NODELAY");
- }
- if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, (char*)&len, sizeof(int)))
- {
- yaz_log(LOG_WARN|LOG_ERRNO, "setsockopt SNDBUF");
- }
- if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, (char*)&len, sizeof(int)))
- {
- yaz_log(LOG_WARN|LOG_ERRNO, "setsockopt RCVBUF");
- }
-#endif
-}
-
static int tcpip_bind(COMSTACK h, void *address, int mode)
{
int r;
return -1;
}
#endif
- tcpip_setsockopt(h->iofile);
#if HAVE_GETADDRINFO
r = bind(h->iofile, ai->ai_addr, ai->ai_addrlen);
freeaddrinfo(sp->ai);
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;
- tcpip_setsockopt(h->newfd);
return 0;
}
}
#endif
-int tcpip_close(COMSTACK h)
+void tcpip_close(COMSTACK h)
{
tcpip_state *sp = (struct tcpip_state *)h->cprivate;
xfree(sp->connect_response_buf);
xfree(sp);
xfree(h);
- return 0;
}
-char *tcpip_addrstr(COMSTACK h)
+const char *tcpip_addrstr(COMSTACK h)
{
tcpip_state *sp = (struct tcpip_state *)h->cprivate;
char *r = 0, *buf = sp->buf;