This repository has been archived by the owner on Nov 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updates vmci_client C library for DLL generation
esx_vmdkcmd.go uses CGO for making vmci_client calls to communicate with the VMDKOps service on ESXi. By default, CGO supports gcc, which creates compatibility issues on Windows, because, the vmci_client implementation depends on libraries provided by Microsoft Build Tools. This commit enables exporting of the vmci_client library as a Windows DLL, which can then be used with the regular MinGW-w64 gcc on Windows for making calls via CGO. * Extracted header file from vmci_client.c * Updated vmci_client impl to support Winsock * Added vmci_client.def for DLL export
- Loading branch information
1 parent
6289773
commit c4a14c5
Showing
3 changed files
with
115 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
; Copyright 2017 VMware, Inc. All Rights Reserved. | ||
; | ||
; Licensed under the Apache License, Version 2.0 (the "License"); | ||
; you may not use this file except in compliance with the License. | ||
; You may obtain a copy of the License at | ||
; | ||
; http://www.apache.org/licenses/LICENSE-2.0 | ||
; | ||
; Unless required by applicable law or agreed to in writing, software | ||
; distributed under the License is distributed on an "AS IS" BASIS, | ||
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
; See the License for the specific language governing permissions and | ||
; limitations under the License. | ||
; | ||
; This file defines the APIs exported by the vmci_client.dll. | ||
; Only Vmci_GetReply and Vmci_FreeBuf functions are exported. | ||
|
||
EXPORTS | ||
Vmci_GetReply | ||
Vmci_FreeBuf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Copyright 2017 VMware, Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
|
||
// | ||
// VMCI sockets communication - client side. | ||
// | ||
// API: Exposes Vmci_GetReply and Vmci_FreeBuf. | ||
// | ||
|
||
#include <stdlib.h> | ||
#include <errno.h> | ||
#include <stdint.h> | ||
|
||
#include "vmci_sockets.h" | ||
#include "connection_types.h" | ||
|
||
#define ERR_BUF_LEN 512 | ||
#define MAXBUF 1024 * 1024 // Safety limit. We do not expect json string > 1M | ||
#define MAX_CLIENT_PORT 1023 // Last privileged port | ||
#define START_CLIENT_PORT 100 // Where to start client port | ||
#define BIND_RETRY_COUNT (MAX_CLIENT_PORT - START_CLIENT_PORT) // Retry entire range on bind failures | ||
|
||
// Operations status. 0 is OK | ||
typedef int be_sock_status; | ||
|
||
// | ||
// Booking structure for opened VMCI / vSocket | ||
// | ||
typedef struct { | ||
int sock_id; // socket id for socket APIs | ||
struct sockaddr_vm addr; // held here for bookkeeping and reporting | ||
} be_sock_id; | ||
|
||
// | ||
// Protocol message structure: request and reply | ||
// | ||
typedef struct be_request { | ||
uint32_t mlen; // length of message (including trailing \0) | ||
const char *msg; // null-terminated immutable JSON string. | ||
} be_request; | ||
|
||
typedef struct be_answer { | ||
char *buf; // response buffer | ||
char errBuf[ERR_BUF_LEN]; // error response buffer | ||
} be_answer; | ||
|
||
// | ||
// Entry point for vsocket requests. | ||
// Returns NULL for success, -1 for err, and sets errno if needed | ||
// <ans> is allocated upstairs | ||
// | ||
const be_sock_status | ||
Vmci_GetReply(int port, const char* json_request, const char* be_name, be_answer* ans); | ||
|
||
// | ||
// Frees a be_answer instance. | ||
// | ||
void | ||
Vmci_FreeBuf(be_answer *ans); |