mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-08 00:02:03 -04:00
vici: Add Windows support
This commit is contained in:
parent
7659f67af3
commit
dfb23fa159
@ -43,7 +43,7 @@ typedef struct {
|
||||
typedef enum {
|
||||
WAIT_IDLE = 0,
|
||||
WAIT_SUCCESS,
|
||||
WAIT_FAILED,
|
||||
WAIT_FAILURE,
|
||||
WAIT_READ_ERROR,
|
||||
} wait_state_t;
|
||||
|
||||
@ -242,7 +242,7 @@ CALLBACK(on_read, bool,
|
||||
return wait_result(conn, WAIT_SUCCESS);
|
||||
case VICI_CMD_UNKNOWN:
|
||||
case VICI_EVENT_UNKNOWN:
|
||||
return wait_result(conn, WAIT_FAILED);
|
||||
return wait_result(conn, WAIT_FAILURE);
|
||||
case VICI_CMD_REQUEST:
|
||||
case VICI_EVENT_REGISTER:
|
||||
case VICI_EVENT_UNREGISTER:
|
||||
@ -403,7 +403,7 @@ vici_res_t* vici_submit(vici_req_t *req, vici_conn_t *conn)
|
||||
case WAIT_READ_ERROR:
|
||||
errno = conn->error;
|
||||
break;
|
||||
case WAIT_FAILED:
|
||||
case WAIT_FAILURE:
|
||||
default:
|
||||
errno = ENOENT;
|
||||
break;
|
||||
@ -712,7 +712,7 @@ int vici_register(vici_conn_t *conn, char *name, vici_event_cb_t cb, void *user)
|
||||
case WAIT_READ_ERROR:
|
||||
errno = conn->error;
|
||||
break;
|
||||
case WAIT_FAILED:
|
||||
case WAIT_FAILURE:
|
||||
default:
|
||||
errno = ENOENT;
|
||||
break;
|
||||
|
@ -20,7 +20,11 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define URI "unix:///tmp/strongswan-vici-event-test"
|
||||
#ifdef WIN32
|
||||
# define URI "tcp://127.0.0.1:6543"
|
||||
#else /* !WIN32 */
|
||||
# define URI "unix:///tmp/strongswan-vici-event-test"
|
||||
#endif /* !WIN32 */
|
||||
|
||||
static void event_cb(void *user, char *name, vici_res_t *ev)
|
||||
{
|
||||
|
@ -20,7 +20,11 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#define URI "unix:///tmp/strongswan-vici-request-test"
|
||||
#ifdef WIN32
|
||||
# define URI "tcp://127.0.0.1:6543"
|
||||
#else /* !WIN32 */
|
||||
# define URI "unix:///tmp/strongswan-vici-request-test"
|
||||
#endif /* !WIN32 */
|
||||
|
||||
static void encode_section(vici_req_t *req)
|
||||
{
|
||||
|
@ -61,11 +61,13 @@ static struct {
|
||||
{ "tcp://127.0.0.1:6543", 2 },
|
||||
{ "tcp://127.0.0.1:6543", 3 },
|
||||
{ "tcp://127.0.0.1:6543", 7 },
|
||||
#ifndef WIN32
|
||||
{ "unix:///tmp/strongswan-tests-vici-socket", ~0 },
|
||||
{ "unix:///tmp/strongswan-tests-vici-socket", 1 },
|
||||
{ "unix:///tmp/strongswan-tests-vici-socket", 2 },
|
||||
{ "unix:///tmp/strongswan-tests-vici-socket", 3 },
|
||||
{ "unix:///tmp/strongswan-tests-vici-socket", 7 },
|
||||
#endif /* !WIN32 */
|
||||
};
|
||||
|
||||
START_TEST(test_echo)
|
||||
|
@ -24,7 +24,6 @@
|
||||
#include <collections/linked_list.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
|
||||
/**
|
||||
* Magic value for an undefined lifetime
|
||||
|
@ -29,7 +29,11 @@ typedef enum vici_operation_t vici_operation_t;
|
||||
/**
|
||||
* Default socket URI of vici service
|
||||
*/
|
||||
#define VICI_DEFAULT_URI "unix://" IPSEC_PIDDIR "/charon.vici"
|
||||
#ifdef WIN32
|
||||
# define VICI_DEFAULT_URI "tcp://127.0.0.1:4502"
|
||||
#else
|
||||
# define VICI_DEFAULT_URI "unix://" IPSEC_PIDDIR "/charon.vici"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Kind of vici operation
|
||||
|
@ -17,7 +17,9 @@
|
||||
#include "vici_builder.h"
|
||||
|
||||
#include <inttypes.h>
|
||||
#ifndef WIN32
|
||||
#include <sys/utsname.h>
|
||||
#endif
|
||||
|
||||
#include <daemon.h>
|
||||
|
||||
@ -786,7 +788,6 @@ CALLBACK(list_certs, vici_message_t*,
|
||||
CALLBACK(version, vici_message_t*,
|
||||
private_vici_query_t *this, char *name, u_int id, vici_message_t *request)
|
||||
{
|
||||
struct utsname utsname;
|
||||
vici_builder_t *b;
|
||||
|
||||
b = vici_builder_create();
|
||||
@ -794,13 +795,40 @@ CALLBACK(version, vici_message_t*,
|
||||
b->add_kv(b, "daemon", "%s", lib->ns);
|
||||
b->add_kv(b, "version", "%s", VERSION);
|
||||
|
||||
if (uname(&utsname) == 0)
|
||||
#ifdef WIN32
|
||||
{
|
||||
b->add_kv(b, "sysname", "%s", utsname.sysname);
|
||||
b->add_kv(b, "release", "%s", utsname.release);
|
||||
b->add_kv(b, "machine", "%s", utsname.machine);
|
||||
}
|
||||
OSVERSIONINFOEX osvie;
|
||||
|
||||
memset(&osvie, 0, sizeof(osvie));
|
||||
osvie.dwOSVersionInfoSize = sizeof(osvie);
|
||||
|
||||
if (GetVersionEx((LPOSVERSIONINFO)&osvie))
|
||||
{
|
||||
b->add_kv(b, "sysname", "Windows %s",
|
||||
osvie.wProductType == VER_NT_WORKSTATION ? "Client" : "Server");
|
||||
b->add_kv(b, "release", "%d.%d.%d (SP %d.%d)",
|
||||
osvie.dwMajorVersion, osvie.dwMinorVersion, osvie.dwBuildNumber,
|
||||
osvie.wServicePackMajor, osvie.wServicePackMinor);
|
||||
b->add_kv(b, "machine", "%s",
|
||||
#ifdef WIN64
|
||||
"x86_64");
|
||||
#else
|
||||
"x86");
|
||||
#endif /* !WIN64 */
|
||||
}
|
||||
}
|
||||
#else /* !WIN32 */
|
||||
{
|
||||
struct utsname utsname;
|
||||
|
||||
if (uname(&utsname) == 0)
|
||||
{
|
||||
b->add_kv(b, "sysname", "%s", utsname.sysname);
|
||||
b->add_kv(b, "release", "%s", utsname.release);
|
||||
b->add_kv(b, "machine", "%s", utsname.machine);
|
||||
}
|
||||
}
|
||||
#endif /* !WIN32 */
|
||||
return b->finalize(b);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user