diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-07-23 05:01:15 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2003-07-23 05:01:15 +0000 |
commit | 51fd3c0f51951808d61c7e9903ad32eb39d35bb6 (patch) | |
tree | 88f8992dd81f5abc74886d9b605f8ff2cb8d1f6f /capture.c | |
parent | a209d0767c882aaaeb258e72eaaebe44462b583e (diff) |
Give a more detailed message when WSAStartup fails.
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@8069 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'capture.c')
-rw-r--r-- | capture.c | 51 |
1 files changed, 42 insertions, 9 deletions
@@ -1,7 +1,7 @@ /* capture.c * Routines for packet capture windows * - * $Id: capture.c,v 1.207 2003/05/15 13:33:53 deniel Exp $ + * $Id: capture.c,v 1.208 2003/07/23 05:01:15 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -1398,8 +1398,8 @@ capture(gboolean *stats_known, struct pcap_stat *stats) #define N_COUNTS (sizeof counts / sizeof counts[0]) #ifdef _WIN32 - WORD wVersionRequested; - WSADATA wsaData; + WORD wVersionRequested; + WSADATA wsaData; #else static const char ppamsg[] = "can't find PPA for "; char *libpcap_warn; @@ -1420,12 +1420,45 @@ capture(gboolean *stats_known, struct pcap_stat *stats) /* Initialize Windows Socket if we are in a WIN32 OS This needs to be done before querying the interface for network/netmask */ #ifdef _WIN32 - wVersionRequested = MAKEWORD( 1, 1 ); - err = WSAStartup( wVersionRequested, &wsaData ); - if (err!=0) { - snprintf(errmsg, sizeof errmsg, - "Couldn't initialize Windows Sockets."); - pch=NULL; + /* XXX - do we really require 1.1 or earlier? + Are there any versions that support only 2.0 or higher? */ + wVersionRequested = MAKEWORD(1, 1); + err = WSAStartup(wVersionRequested, &wsaData); + if (err != 0) { + switch (err) { + + case WSASYSNOTREADY: + snprintf(errmsg, sizeof errmsg, + "Couldn't initialize Windows Sockets: Network system not ready for network communication"); + break; + + case WSAVERNOTSUPPORTED: + snprintf(errmsg, sizeof errmsg, + "Couldn't initialize Windows Sockets: Windows Sockets version %u.%u not supported", + LOBYTE(wVersionRequested), HIBYTE(wVersionRequested)); + break; + + case WSAEINPROGRESS: + snprintf(errmsg, sizeof errmsg, + "Couldn't initialize Windows Sockets: Blocking operation is in progress"); + break; + + case WSAEPROCLIM: + snprintf(errmsg, sizeof errmsg, + "Couldn't initialize Windows Sockets: Limit on the number of tasks supported by this WinSock implementation has been reached"); + break; + + case WSAEFAULT: + snprintf(errmsg, sizeof errmsg, + "Couldn't initialize Windows Sockets: Bad pointer passed to WSAStartup"); + break; + + default: + snprintf(errmsg, sizeof errmsg, + "Couldn't initialize Windows Sockets: error %d", err); + break; + } + pch = NULL; goto error; } #endif |