#include <string.h>
#ifdef _WIN32
#include <windows.h>
-#include <winsock.h>
+#include <winsock2.h>
#else
#include <assert.h>
#include <unistd.h>
#include <gssapi/gssapi_krb5.h>
#include <gssapi/gssapi_ext.h>
#include "gss-misc.h"
+#include "port-sockets.h"
static int verbose = 1;
static int spnego = 0;
struct sockaddr_in saddr;
struct hostent *hp;
int s;
+#ifdef _WIN32
+ WSADATA wsadata;
+ int wsastartuperror = WSAStartup(0x202, &wsadata);
+ if (wsastartuperror)
+ {
+ fprintf(stderr, "WSAStartup error: %x\n", wsastartuperror);
+ return -1;
+ }
+#endif
if ((hp = gethostbyname(host)) == NULL) {
fprintf(stderr, "Unknown host: %s\n", host);
}
if (connect(s, (struct sockaddr *) &saddr, sizeof(saddr)) < 0) {
perror("connecting to server");
- (void) close(s);
+ (void) closesocket(s);
return -1;
}
return s;
if (client_establish_context(s, service_name, gss_flags, auth_flag,
v1_format, oid, username, password,
&context, &ret_flags) < 0) {
- (void) close(s);
+ (void) closesocket(s);
return -1;
}
&in_buf, &state, &out_buf);
if (maj_stat != GSS_S_COMPLETE) {
display_status("wrapping message", maj_stat, min_stat);
- (void) close(s);
+ (void) closesocket(s);
(void) gss_delete_sec_context(&min_stat, &context,
GSS_C_NO_BUFFER);
return -1;
(encrypt_flag ? TOKEN_ENCRYPTED : 0) |
(mic_flag ? TOKEN_SEND_MIC : 0))),
&out_buf) < 0) {
- (void) close(s);
+ (void) closesocket(s);
(void) gss_delete_sec_context(&min_stat, &context,
GSS_C_NO_BUFFER);
return -1;
/* Read signature block into out_buf */
if (recv_token(s, &token_flags, &out_buf) < 0) {
- (void) close(s);
+ (void) closesocket(s);
(void) gss_delete_sec_context(&min_stat, &context,
GSS_C_NO_BUFFER);
return -1;
&out_buf, &qop_state);
if (maj_stat != GSS_S_COMPLETE) {
display_status("verifying signature", maj_stat, min_stat);
- (void) close(s);
+ (void) closesocket(s);
(void) gss_delete_sec_context(&min_stat, &context,
GSS_C_NO_BUFFER);
return -1;
maj_stat = gss_delete_sec_context(&min_stat, &context, &out_buf);
if (maj_stat != GSS_S_COMPLETE) {
display_status("deleting context", maj_stat, min_stat);
- (void) close(s);
+ (void) closesocket(s);
(void) gss_delete_sec_context(&min_stat, &context,
GSS_C_NO_BUFFER);
return -1;
(void) gss_release_buffer(&min_stat, &out_buf);
}
- (void) close(s);
+ (void) closesocket(s);
return 0;
}