projects
/
silc.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added SILC Server library.
[silc.git]
/
lib
/
silcutil
/
win32
/
silcwin32net.c
diff --git
a/lib/silcutil/win32/silcwin32net.c
b/lib/silcutil/win32/silcwin32net.c
index 98b80a19bf3cfffe81f2d95a56c9bca1b1774a98..818945e0c0ec769a0cd9e6bf4f9b4d3c9d3c5ec9 100644
(file)
--- a/
lib/silcutil/win32/silcwin32net.c
+++ b/
lib/silcutil/win32/silcwin32net.c
@@
-4,12
+4,11
@@
Author: Pekka Riikonen <priikone@silcnet.org>
Author: Pekka Riikonen <priikone@silcnet.org>
- Copyright (C) 1997 - 200
1
Pekka Riikonen
+ Copyright (C) 1997 - 200
5
Pekka Riikonen
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+ the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@
-19,7
+18,9
@@
*/
/* $Id$ */
*/
/* $Id$ */
-#include "silcincludes.h"
+/* XXX IPv6 support missing */
+
+#include "silc.h"
#include "silcnet.h"
/* This function creates server or daemon or listener or what ever. This
#include "silcnet.h"
/* This function creates server or daemon or listener or what ever. This
@@
-28,7
+29,7
@@
If argument `ip_addr' is NULL `any' address will be used. Returns
the created socket or -1 on error. */
If argument `ip_addr' is NULL `any' address will be used. Returns
the created socket or -1 on error. */
-int silc_net_create_server(int port, char *ip_addr)
+int silc_net_create_server(int port, c
onst c
har *ip_addr)
{
SOCKET sock;
int rval;
{
SOCKET sock;
int rval;
@@
-99,7
+100,8
@@
void silc_net_close_server(int sock)
socket or -1 on error. This blocks the process while trying to create
the connection. */
socket or -1 on error. This blocks the process while trying to create
the connection. */
-int silc_net_create_connection(int port, char *host)
+int silc_net_create_connection(const char *local_ip, int port,
+ const char *host)
{
SOCKET sock;
int rval, err;
{
SOCKET sock;
int rval, err;
@@
-111,7
+113,8
@@
int silc_net_create_connection(int port, char *host)
/* Do host lookup */
dest = gethostbyname(host);
if (!dest) {
/* Do host lookup */
dest = gethostbyname(host);
if (!dest) {
- SILC_LOG_ERROR(("Network (%s) unreachable", host));
+ SILC_LOG_ERROR(("Network (%s) unreachable: could not resolve the "
+ "IP address", host));
return -1;
}
return -1;
}
@@
-139,7
+142,9
@@
int silc_net_create_connection(int port, char *host)
}
/* Set appropriate options */
}
/* Set appropriate options */
+#if defined(TCP_NODELAY)
silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1);
silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1);
+#endif
silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1);
SILC_LOG_DEBUG(("Connection created"));
silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1);
SILC_LOG_DEBUG(("Connection created"));
@@
-152,7
+157,8
@@
int silc_net_create_connection(int port, char *host)
connection returns directly. To get the result of the connect() one
must select() the socket and read the result after it's ready. */
connection returns directly. To get the result of the connect() one
must select() the socket and read the result after it's ready. */
-int silc_net_create_connection_async(int port, char *host)
+int silc_net_create_connection_async(const char *local_ip, int port,
+ const char *host)
{
SOCKET sock;
int rval, err;
{
SOCKET sock;
int rval, err;
@@
-165,7
+171,8
@@
int silc_net_create_connection_async(int port, char *host)
/* Do host lookup */
dest = gethostbyname(host);
if (!dest) {
/* Do host lookup */
dest = gethostbyname(host);
if (!dest) {
- SILC_LOG_ERROR(("Network (%s) unreachable", host));
+ SILC_LOG_ERROR(("Network (%s) unreachable: could not resolve the "
+ "IP address", host));
return -1;
}
return -1;
}
@@
-196,7
+203,9
@@
int silc_net_create_connection_async(int port, char *host)
silc_net_set_socket_nonblock(sock);
/* Set appropriate options */
silc_net_set_socket_nonblock(sock);
/* Set appropriate options */
+#if defined(TCP_NODELAY)
silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1);
silc_net_set_socket_opt(sock, IPPROTO_TCP, TCP_NODELAY, 1);
+#endif
silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1);
SILC_LOG_DEBUG(("Connection created"));
silc_net_set_socket_opt(sock, SOL_SOCKET, SO_KEEPALIVE, 1);
SILC_LOG_DEBUG(("Connection created"));
@@
-214,8
+223,7
@@
void silc_net_close_connection(int sock)
/* Converts the IP number string from numbers-and-dots notation to
binary form. */
/* Converts the IP number string from numbers-and-dots notation to
binary form. */
-bool silc_net_addr2bin(const char *addr, unsigned char *bin,
- uint32 bin_len)
+SilcBool silc_net_addr2bin(const char *addr, void *bin, SilcUInt32 bin_len)
{
unsigned long ret;
{
unsigned long ret;
@@
-224,8
+232,7
@@
bool silc_net_addr2bin(const char *addr, unsigned char *bin,
if (bin_len < 4)
return FALSE;
if (bin_len < 4)
return FALSE;
- SILC_PUT32_LSB(ret, bin);
-
+ memcpy(bin, (unsigned char *)&ret, 4);
return ret != INADDR_NONE;
}
return ret != INADDR_NONE;
}
@@
-239,7
+246,7
@@
int silc_net_set_socket_nonblock(int sock)
/* Init Winsock2. */
/* Init Winsock2. */
-
b
ool silc_net_win32_init(void)
+
SilcB
ool silc_net_win32_init(void)
{
int ret, sopt = SO_SYNCHRONOUS_NONALERT;
WSADATA wdata;
{
int ret, sopt = SO_SYNCHRONOUS_NONALERT;
WSADATA wdata;