aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouni Malinen <j@w1.fi>2005-06-18 19:42:25 (GMT)
committerJouni Malinen <j@w1.fi>2005-06-18 19:42:25 (GMT)
commitd73d3dc22092da421ffa29bdb22fb737fb07d69a (patch)
treee04d08655fedddb7bc5f2dad5e8377936a3812ad
parent3103945ffc6673ebe14af22882f2f9f81dcc2dfa (diff)
downloadhostap-history-d73d3dc22092da421ffa29bdb22fb737fb07d69a.zip
hostap-history-d73d3dc22092da421ffa29bdb22fb737fb07d69a.tar.gz
hostap-history-d73d3dc22092da421ffa29bdb22fb737fb07d69a.tar.bz2
Moved different l2_packet implementations into separate files. This
replaces l2_packet.c with l2_packet_linux.c (Linux packet sockets) and l2_packet_pcap.c (libpcap/libdnet/WinPcap). Makefile is used to select which implementation is linked in.
-rwxr-xr-xbuild_gpl_release2
-rw-r--r--hostapd/Makefile8
-rw-r--r--wpa_supplicant/ChangeLog2
-rw-r--r--wpa_supplicant/Makefile5
-rw-r--r--wpa_supplicant/doc/code_structure.doxygen11
-rw-r--r--wpa_supplicant/l2_packet.h16
-rw-r--r--wpa_supplicant/l2_packet_linux.c208
-rw-r--r--wpa_supplicant/l2_packet_pcap.c (renamed from wpa_supplicant/l2_packet.c)197
8 files changed, 253 insertions, 196 deletions
diff --git a/build_gpl_release b/build_gpl_release
index 4e40f66..30b71da 100755
--- a/build_gpl_release
+++ b/build_gpl_release
@@ -66,7 +66,7 @@ cd ..
tar czf $RELDIR/wpa_supplicant-$VER.tar.gz wpa_supplicant-$VER
mv $DIR/hostapd hostapd-$VER
-cp wpa_supplicant-$VER/l2_packet.[ch] hostapd-$VER
+cp wpa_supplicant-$VER/l2_packet*.[ch] hostapd-$VER
cp wpa_supplicant-$VER/{,eap_}defs.h hostapd-$VER
cp wpa_supplicant-$VER/{tls.h,tls_openssl.c,tls_none.c} hostapd-$VER
cp wpa_supplicant-$VER/ms_funcs.[ch] hostapd-$VER
diff --git a/hostapd/Makefile b/hostapd/Makefile
index d566be1..9a891ca 100644
--- a/hostapd/Makefile
+++ b/hostapd/Makefile
@@ -68,13 +68,15 @@ OBJS += driver_test.o
endif
ifdef CONFIG_L2_PACKET
-OBJS += $(DIR_WPA_SUPPLICANT)/l2_packet.o
-endif
-
ifdef CONFIG_DNET_PCAP
CFLAGS += -DUSE_DNET_PCAP
LIBS +=-ldnet -lpcap
+OBJS += $(DIR_WPA_SUPPLICANT)/l2_packet_pcap.o
+else
+OBJS += $(DIR_WPA_SUPPLICANT)/l2_packet_linux.o
endif
+endif
+
ifdef CONFIG_EAP_MD5
CFLAGS += -DEAP_MD5
diff --git a/wpa_supplicant/ChangeLog b/wpa_supplicant/ChangeLog
index f165eab..c8db8fe 100644
--- a/wpa_supplicant/ChangeLog
+++ b/wpa_supplicant/ChangeLog
@@ -6,6 +6,8 @@ ChangeLog for wpa_supplicant
anymore and is unlikely to be used by anyone
* driver_ndis: fixed WinPcap 3.0 support
* fixed build with CONFIG_DNET_PCAP=y on Linux
+ * l2_packet: moved different implementations into separate files
+ (l2_packet_*.c)
2005-06-12 - v0.4.2
* driver_ipw: updated driver structures to match with ipw2200-1.0.4
diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile
index e45494c..d6dcf40 100644
--- a/wpa_supplicant/Makefile
+++ b/wpa_supplicant/Makefile
@@ -35,7 +35,7 @@ install: all
mkdir -p $(DESTDIR)/usr/local/sbin/
for i in $(ALL); do cp $$i $(DESTDIR)/usr/local/sbin/$$i; done
-OBJS = config.o l2_packet.o \
+OBJS = config.o \
../hostapd/eloop.o ../hostapd/common.o ../hostapd/md5.o \
../hostapd/rc4.o ../hostapd/sha1.o ../hostapd/aes_wrap.o
OBJS_p = wpa_passphrase.o ../hostapd/sha1.o ../hostapd/md5.o
@@ -131,6 +131,9 @@ LIBS_w += -lwpcap
else
LIBS += -ldnet -lpcap
endif
+OBJS += l2_packet_pcap.o
+else
+OBJS += l2_packet_linux.o
endif
ifdef CONFIG_EAP_TLS
diff --git a/wpa_supplicant/doc/code_structure.doxygen b/wpa_supplicant/doc/code_structure.doxygen
index 4a2358a..9aa3886 100644
--- a/wpa_supplicant/doc/code_structure.doxygen
+++ b/wpa_supplicant/doc/code_structure.doxygen
@@ -62,11 +62,14 @@ defs.h
hostap_common.h
Definitions shared with the Host AP driver
-l2_packet.c and l2_packet.h
+l2_packet.h, l2_packet_linux.c, and l2_packet_pcap.c
Layer 2 (link) access wrapper (includes native Linux implementation
- and wrappers for libdnet/libpcap). These files may need to be changed
- when porting to new operating systems that are not supported by
- libdnet/libpcap.
+ and wrappers for libdnet/libpcap). A new l2_packet implementation
+ may need to be added when porting to new operating systems that are
+ not supported by libdnet/libpcap. Makefile can be used to select which
+ l2_packet implementation is included. l2_packet_linux.c uses Linux
+ packet sockets and l2_packet_pcap.c has a more portable version using
+ libpcap and libdnet.
pcsc_funcs.c and pcsc_funcs.h
Wrapper for PC/SC lite SIM and smart card readers
diff --git a/wpa_supplicant/l2_packet.h b/wpa_supplicant/l2_packet.h
index 008a343..2c64d94 100644
--- a/wpa_supplicant/l2_packet.h
+++ b/wpa_supplicant/l2_packet.h
@@ -12,10 +12,10 @@
* See README and COPYING for more details.
*
* This file defines an interface for layer 2 (link layer) packet sending and
- * receiving. l2_packet.c is one implementation for such a layer 2
- * implementation using Linux packet sockets. When porting %wpa_supplicant to
- * other operating systems, a nnew l2_packet implementation may need to be
- * added.
+ * receiving. l2_packet_linux.c is one implementation for such a layer 2
+ * implementation using Linux packet sockets and l2_packet_pcap.c another one
+ * using libpcap and libdnet. When porting %wpa_supplicant to other operating
+ * systems, a new l2_packet implementation may need to be added.
*/
#ifndef L2_PACKET_H
@@ -32,6 +32,14 @@
#define ETH_P_RSN_PREAUTH 0x88c7
#endif
+/**
+ * struct l2_packet_data - Internal l2_packet data structure
+ *
+ * This structure is used by the l2_packet implementation to store its private
+ * data. Other files use a pointer to this data when calling the l2_packet
+ * functions, but the contents of this structure should not be used directly
+ * outside l2_packet implementation.
+ */
struct l2_packet_data;
struct l2_ethhdr {
diff --git a/wpa_supplicant/l2_packet_linux.c b/wpa_supplicant/l2_packet_linux.c
new file mode 100644
index 0000000..f6769d7
--- /dev/null
+++ b/wpa_supplicant/l2_packet_linux.c
@@ -0,0 +1,208 @@
+/*
+ * WPA Supplicant - Layer2 packet handling with Linux packet sockets
+ * Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.fi>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * Alternatively, this software may be distributed under the terms of BSD
+ * license.
+ *
+ * See README and COPYING for more details.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netpacket/packet.h>
+#include <net/if.h>
+#include <arpa/inet.h>
+
+#include "common.h"
+#include "eloop.h"
+#include "l2_packet.h"
+
+
+struct l2_packet_data {
+ int fd; /* packet socket for EAPOL frames */
+ char ifname[17];
+ u8 own_addr[IFNAMSIZ + 1];
+ void (*rx_callback)(void *ctx, unsigned char *src_addr,
+ unsigned char *buf, size_t len);
+ void *rx_callback_ctx;
+ int rx_l2_hdr; /* whether to include layer 2 (Ethernet) header in calls
+ * to rx_callback */
+};
+
+
+int l2_packet_get_own_addr(struct l2_packet_data *l2, u8 *addr)
+{
+ memcpy(addr, l2->own_addr, ETH_ALEN);
+ return 0;
+}
+
+
+void l2_packet_set_rx_l2_hdr(struct l2_packet_data *l2, int rx_l2_hdr)
+{
+ l2->rx_l2_hdr = rx_l2_hdr;
+}
+
+
+int l2_packet_send(struct l2_packet_data *l2, u8 *buf, size_t len)
+{
+ int ret;
+ if (l2 == NULL)
+ return -1;
+ ret = send(l2->fd, buf, len, 0);
+ if (ret < 0)
+ perror("l2_packet_send - send");
+ return ret;
+}
+
+
+static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx)
+{
+ struct l2_packet_data *l2 = eloop_ctx;
+ u8 buf[2300];
+ int res;
+ struct l2_ethhdr *ethhdr;
+ unsigned char *pos;
+ size_t len;
+
+ res = recv(sock, buf, sizeof(buf), 0);
+ if (res < 0) {
+ perror("l2_packet_receive - recv");
+ return;
+ }
+ if (res < sizeof(*ethhdr)) {
+ printf("l2_packet_receive: Dropped too short %d packet\n",
+ res);
+ return;
+ }
+
+ ethhdr = (struct l2_ethhdr *) buf;
+
+ if (l2->rx_l2_hdr) {
+ pos = (unsigned char *) buf;
+ len = res;
+ } else {
+ pos = (unsigned char *) (ethhdr + 1);
+ len = res - sizeof(*ethhdr);
+ }
+ l2->rx_callback(l2->rx_callback_ctx, ethhdr->h_source, pos, len);
+}
+
+
+struct l2_packet_data * l2_packet_init(
+ const char *ifname, const u8 *own_addr, unsigned short protocol,
+ void (*rx_callback)(void *ctx, unsigned char *src_addr,
+ unsigned char *buf, size_t len),
+ void *rx_callback_ctx)
+{
+ struct l2_packet_data *l2;
+ struct ifreq ifr;
+ struct sockaddr_ll ll;
+
+ l2 = malloc(sizeof(struct l2_packet_data));
+ if (l2 == NULL)
+ return NULL;
+ memset(l2, 0, sizeof(*l2));
+ strncpy(l2->ifname, ifname, sizeof(l2->ifname));
+ l2->rx_callback = rx_callback;
+ l2->rx_callback_ctx = rx_callback_ctx;
+
+ l2->fd = socket(PF_PACKET, SOCK_RAW, htons(protocol));
+ if (l2->fd < 0) {
+ perror("socket(PF_PACKET, SOCK_RAW)");
+ free(l2);
+ return NULL;
+ }
+ strncpy(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name));
+ if (ioctl(l2->fd, SIOCGIFINDEX, &ifr) < 0) {
+ perror("ioctl[SIOCGIFINDEX]");
+ close(l2->fd);
+ free(l2);
+ return NULL;
+ }
+
+ memset(&ll, 0, sizeof(ll));
+ ll.sll_family = PF_PACKET;
+ ll.sll_ifindex = ifr.ifr_ifindex;
+ ll.sll_protocol = htons(protocol);
+ if (bind(l2->fd, (struct sockaddr *) &ll, sizeof(ll)) < 0) {
+ perror("bind[PF_PACKET]");
+ close(l2->fd);
+ free(l2);
+ return NULL;
+ }
+
+ if (ioctl(l2->fd, SIOCGIFHWADDR, &ifr) < 0) {
+ perror("ioctl[SIOCGIFHWADDR]");
+ close(l2->fd);
+ free(l2);
+ return NULL;
+ }
+ memcpy(l2->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
+
+ eloop_register_read_sock(l2->fd, l2_packet_receive, l2, NULL);
+
+ return l2;
+}
+
+
+void l2_packet_deinit(struct l2_packet_data *l2)
+{
+ if (l2 == NULL)
+ return;
+
+ if (l2->fd >= 0) {
+ eloop_unregister_read_sock(l2->fd);
+ close(l2->fd);
+ }
+
+ free(l2);
+}
+
+
+void * l2_packet_set_ethhdr(struct l2_ethhdr *ethhdr, const u8 *dest,
+ const u8 *source, u16 proto)
+{
+ memcpy(ethhdr->h_dest, dest, ETH_ALEN);
+ memcpy(ethhdr->h_source, source, ETH_ALEN);
+ ethhdr->h_proto = htons(proto);
+ return (void *) (ethhdr + 1);
+}
+
+
+int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
+{
+ int s;
+ struct ifreq ifr;
+ struct sockaddr_in *saddr;
+
+ s = socket(PF_INET, SOCK_DGRAM, 0);
+ if (s < 0) {
+ perror("socket");
+ return -1;
+ }
+ memset(&ifr, 0, sizeof(ifr));
+ strncpy(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name));
+ if (ioctl(s, SIOCGIFADDR, &ifr) < 0) {
+ perror("ioctl[SIOCGIFADDR]");
+ close(s);
+ return -1;
+ }
+ close(s);
+ saddr = (struct sockaddr_in *) &ifr.ifr_addr;
+ if (saddr->sin_family != AF_INET)
+ return -1;
+ snprintf(buf, len, "%s", inet_ntoa(saddr->sin_addr));
+ return 0;
+}
diff --git a/wpa_supplicant/l2_packet.c b/wpa_supplicant/l2_packet_pcap.c
index 2619fff..6287e79 100644
--- a/wpa_supplicant/l2_packet.c
+++ b/wpa_supplicant/l2_packet_pcap.c
@@ -1,5 +1,5 @@
/*
- * WPA Supplicant - Layer2 packet handling
+ * WPA Supplicant - Layer2 packet handling with libpcap/libdnet and WinPcap
* Copyright (c) 2003-2005, Jouni Malinen <jkmaline@cc.hut.fi>
*
* This program is free software; you can redistribute it and/or modify
@@ -19,19 +19,10 @@
#include <sys/ioctl.h>
#endif /* CONFIG_NATIVE_WINDOWS */
#include <errno.h>
-#ifdef USE_DNET_PCAP
#include <pcap.h>
#ifndef CONFIG_WINPCAP
#include <dnet.h>
-#endif
-#else /* USE_DNET_PCAP */
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netpacket/packet.h>
-#include <net/if.h>
-#endif /* USE_DNET_PCAP */
+#endif /* CONFIG_WINPCAP */
#ifdef __linux__
#include <arpa/inet.h>
#endif /* __linux__ */
@@ -41,23 +32,11 @@
#include "l2_packet.h"
-/**
- * struct l2_packet_data - Internal l2_packet data structure
- *
- * This structure is used by the l2_packet implementation to store its private
- * data. Other files use a pointer to this data when calling the l2_packet
- * functions, but the contents of this structure should not be used directly
- * outside l2_packet implementation.
- */
struct l2_packet_data {
-#ifdef USE_DNET_PCAP
pcap_t *pcap;
#ifndef CONFIG_WINPCAP
eth_t *eth;
-#endif
-#else /* USE_DNET_PCAP */
- int fd; /* packet socket for EAPOL frames */
-#endif /* USE_DNET_PCAP */
+#endif /* CONFIG_WINPCAP */
char ifname[100];
u8 own_addr[ETH_ALEN];
void (*rx_callback)(void *ctx, unsigned char *src_addr,
@@ -81,8 +60,6 @@ void l2_packet_set_rx_l2_hdr(struct l2_packet_data *l2, int rx_l2_hdr)
}
-#ifdef USE_DNET_PCAP
-
#ifndef CONFIG_WINPCAP
static int l2_packet_init_libdnet(struct l2_packet_data *l2)
{
@@ -107,12 +84,12 @@ static int l2_packet_init_libdnet(struct l2_packet_data *l2)
return 0;
}
-#endif
+#endif /* CONFIG_WINPCAP */
#ifdef CONFIG_WINPCAP
int pcap_sendpacket(pcap_t *p, u_char *buf, int size);
-#endif
+#endif /* CONFIG_WINPCAP */
int l2_packet_send(struct l2_packet_data *l2, u8 *buf, size_t len)
{
@@ -120,9 +97,9 @@ int l2_packet_send(struct l2_packet_data *l2, u8 *buf, size_t len)
return -1;
#ifdef CONFIG_WINPCAP
return pcap_sendpacket(l2->pcap, buf, len);
-#else
+#else /* CONFIG_WINPCAP */
return eth_send(l2->eth, buf, len);
-#endif
+#endif /* CONFIG_WINPCAP */
}
@@ -228,10 +205,10 @@ static int l2_packet_init_libpcap(struct l2_packet_data *l2,
#ifdef CONFIG_WINPCAP
eloop_register_timeout(0, 100000, l2_packet_receive_timeout,
l2, l2->pcap);
-#else
+#else /* CONFIG_WINPCAP */
eloop_register_read_sock(pcap_get_selectable_fd(l2->pcap),
l2_packet_receive, l2, l2->pcap);
-#endif
+#endif /* CONFIG_WINPCAP */
return 0;
}
@@ -257,15 +234,15 @@ struct l2_packet_data * l2_packet_init(
#ifdef CONFIG_WINPCAP
if (own_addr)
memcpy(l2->own_addr, own_addr, ETH_ALEN);
-#else
+#else /* CONFIG_WINPCAP */
if (l2_packet_init_libdnet(l2))
return NULL;
-#endif
+#endif /* CONFIG_WINPCAP */
if (l2_packet_init_libpcap(l2, protocol)) {
#ifndef CONFIG_WINPCAP
eth_close(l2->eth);
-#endif
+#endif /* CONFIG_WINPCAP */
free(l2);
return NULL;
}
@@ -283,132 +260,13 @@ void l2_packet_deinit(struct l2_packet_data *l2)
pcap_close(l2->pcap);
#ifdef CONFIG_WINPCAP
eloop_cancel_timeout(l2_packet_receive_timeout, l2, l2->pcap);
-#else
+#else /* CONFIG_WINPCAP */
if (l2->eth)
eth_close(l2->eth);
-#endif
- free(l2);
-}
-
-#else /* USE_DNET_PCAP */
-
-int l2_packet_send(struct l2_packet_data *l2, u8 *buf, size_t len)
-{
- int ret;
- if (l2 == NULL)
- return -1;
- ret = send(l2->fd, buf, len, 0);
- if (ret < 0)
- perror("l2_packet_send - send");
- return ret;
-}
-
-
-static void l2_packet_receive(int sock, void *eloop_ctx, void *sock_ctx)
-{
- struct l2_packet_data *l2 = eloop_ctx;
- u8 buf[2300];
- int res;
- struct l2_ethhdr *ethhdr;
- unsigned char *pos;
- size_t len;
-
- res = recv(sock, buf, sizeof(buf), 0);
- if (res < 0) {
- perror("l2_packet_receive - recv");
- return;
- }
- if (res < sizeof(*ethhdr)) {
- printf("l2_packet_receive: Dropped too short %d packet\n",
- res);
- return;
- }
-
- ethhdr = (struct l2_ethhdr *) buf;
-
- if (l2->rx_l2_hdr) {
- pos = (unsigned char *) buf;
- len = res;
- } else {
- pos = (unsigned char *) (ethhdr + 1);
- len = res - sizeof(*ethhdr);
- }
- l2->rx_callback(l2->rx_callback_ctx, ethhdr->h_source, pos, len);
-}
-
-
-struct l2_packet_data * l2_packet_init(
- const char *ifname, const u8 *own_addr, unsigned short protocol,
- void (*rx_callback)(void *ctx, unsigned char *src_addr,
- unsigned char *buf, size_t len),
- void *rx_callback_ctx)
-{
- struct l2_packet_data *l2;
- struct ifreq ifr;
- struct sockaddr_ll ll;
-
- l2 = malloc(sizeof(struct l2_packet_data));
- if (l2 == NULL)
- return NULL;
- memset(l2, 0, sizeof(*l2));
- strncpy(l2->ifname, ifname, sizeof(l2->ifname));
- l2->rx_callback = rx_callback;
- l2->rx_callback_ctx = rx_callback_ctx;
-
- l2->fd = socket(PF_PACKET, SOCK_RAW, htons(protocol));
- if (l2->fd < 0) {
- perror("socket(PF_PACKET, SOCK_RAW)");
- free(l2);
- return NULL;
- }
- strncpy(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name));
- if (ioctl(l2->fd, SIOCGIFINDEX, &ifr) < 0) {
- perror("ioctl[SIOCGIFINDEX]");
- close(l2->fd);
- free(l2);
- return NULL;
- }
-
- memset(&ll, 0, sizeof(ll));
- ll.sll_family = PF_PACKET;
- ll.sll_ifindex = ifr.ifr_ifindex;
- ll.sll_protocol = htons(protocol);
- if (bind(l2->fd, (struct sockaddr *) &ll, sizeof(ll)) < 0) {
- perror("bind[PF_PACKET]");
- close(l2->fd);
- free(l2);
- return NULL;
- }
-
- if (ioctl(l2->fd, SIOCGIFHWADDR, &ifr) < 0) {
- perror("ioctl[SIOCGIFHWADDR]");
- close(l2->fd);
- free(l2);
- return NULL;
- }
- memcpy(l2->own_addr, ifr.ifr_hwaddr.sa_data, ETH_ALEN);
-
- eloop_register_read_sock(l2->fd, l2_packet_receive, l2, NULL);
-
- return l2;
-}
-
-
-void l2_packet_deinit(struct l2_packet_data *l2)
-{
- if (l2 == NULL)
- return;
-
- if (l2->fd >= 0) {
- eloop_unregister_read_sock(l2->fd);
- close(l2->fd);
- }
-
+#endif /* CONFIG_WINPCAP */
free(l2);
}
-#endif /* USE_DNET_PCAP */
-
void * l2_packet_set_ethhdr(struct l2_ethhdr *ethhdr, const u8 *dest,
const u8 *source, u16 proto)
@@ -422,7 +280,6 @@ void * l2_packet_set_ethhdr(struct l2_ethhdr *ethhdr, const u8 *dest,
int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
{
-#if defined(USE_DNET_PCAP)
pcap_if_t *devs, *dev;
struct pcap_addr *addr;
struct sockaddr_in *saddr;
@@ -454,30 +311,4 @@ int l2_packet_get_ip_addr(struct l2_packet_data *l2, char *buf, size_t len)
pcap_freealldevs(devs);
return found ? 0 : -1;
-#elif defined(__linux__)
- int s;
- struct ifreq ifr;
- struct sockaddr_in *saddr;
-
- s = socket(PF_INET, SOCK_DGRAM, 0);
- if (s < 0) {
- perror("socket");
- return -1;
- }
- memset(&ifr, 0, sizeof(ifr));
- strncpy(ifr.ifr_name, l2->ifname, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFADDR, &ifr) < 0) {
- perror("ioctl[SIOCGIFADDR]");
- close(s);
- return -1;
- }
- close(s);
- saddr = (struct sockaddr_in *) &ifr.ifr_addr;
- if (saddr->sin_family != AF_INET)
- return -1;
- snprintf(buf, len, "%s", inet_ntoa(saddr->sin_addr));
- return 0;
-#else
- return -1;
-#endif
}