mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 10:42:12 -04:00
Merge branch '590-win32-sample-gai-c-should-call-wsastartup' into 'master'
Resolve "[Win32] sample-gai.c should call WSAStartup()" Closes #590 See merge request isc-projects/bind9!1340
This commit is contained in:
commit
f056d04eed
2 changed files with 36 additions and 7 deletions
3
CHANGES
3
CHANGES
|
|
@ -1,3 +1,6 @@
|
|||
5134. [bug] win32: WSAStartup was not called before getservbyname
|
||||
was called. [GL #590]
|
||||
|
||||
5133. [bug] 'rndc managed-keys' didn't handle class and view
|
||||
correctly and failed to add new lines between each
|
||||
view. [GL !1327]
|
||||
|
|
|
|||
|
|
@ -126,6 +126,12 @@
|
|||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#include <isc/app.h>
|
||||
#include <isc/buffer.h>
|
||||
#include <isc/lib.h>
|
||||
|
|
@ -339,25 +345,45 @@ getaddrinfo(const char *hostname, const char *servname,
|
|||
|
||||
port = strtol(servname, &e, 10);
|
||||
if (*e == '\0') {
|
||||
if (socktype == 0)
|
||||
if (socktype == 0) {
|
||||
return (EAI_SOCKTYPE);
|
||||
if (port < 0 || port > 65535)
|
||||
}
|
||||
if (port < 0 || port > 65535) {
|
||||
return (EAI_SERVICE);
|
||||
}
|
||||
port = htons((unsigned short) port);
|
||||
} else {
|
||||
#ifdef _WIN32
|
||||
WORD wVersionRequested;
|
||||
WSADATA wsaData;
|
||||
|
||||
wVersionRequested = MAKEWORD(2, 0);
|
||||
|
||||
err = WSAStartup(wVersionRequested, &wsaData );
|
||||
if (err != 0) {
|
||||
return (EAI_FAIL);
|
||||
}
|
||||
#endif
|
||||
sp = getservbyname(servname, proto);
|
||||
if (sp == NULL)
|
||||
if (sp != NULL)
|
||||
port = sp->s_port;
|
||||
#ifdef _WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
if (sp == NULL) {
|
||||
return (EAI_SERVICE);
|
||||
port = sp->s_port;
|
||||
}
|
||||
if (socktype == 0) {
|
||||
if (strcmp(sp->s_proto, "tcp") == 0)
|
||||
if (strcmp(sp->s_proto, "tcp") == 0) {
|
||||
socktype = SOCK_STREAM;
|
||||
else if (strcmp(sp->s_proto, "udp") == 0)
|
||||
} else if (strcmp(sp->s_proto, "udp") == 0) {
|
||||
socktype = SOCK_DGRAM;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
} else {
|
||||
port = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Next, deal with just a service name, and no hostname.
|
||||
|
|
|
|||
Loading…
Reference in a new issue