1 | /* $Id: svchlp.h 62679 2016-07-29 12:52:10Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | *
|
---|
4 | * Declaration of SVC Helper Process control routines.
|
---|
5 | */
|
---|
6 |
|
---|
7 | /*
|
---|
8 | * Copyright (C) 2006-2016 Oracle Corporation
|
---|
9 | *
|
---|
10 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | * available from http://www.virtualbox.org. This file is free software;
|
---|
12 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | * General Public License (GPL) as published by the Free Software
|
---|
14 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | */
|
---|
18 |
|
---|
19 | #ifndef __VBox_svchlp_h__
|
---|
20 | #define __VBox_svchlp_h__
|
---|
21 |
|
---|
22 | #include "VBox/com/string.h"
|
---|
23 | #include "VBox/com/guid.h"
|
---|
24 |
|
---|
25 | #include <VBox/err.h>
|
---|
26 |
|
---|
27 | #include <iprt/win/windows.h>
|
---|
28 |
|
---|
29 | struct SVCHlpMsg
|
---|
30 | {
|
---|
31 | enum Code
|
---|
32 | {
|
---|
33 | Null = 0, /* no parameters */
|
---|
34 | OK, /* no parameters */
|
---|
35 | Error, /* Utf8Str string (may be null but must present) */
|
---|
36 |
|
---|
37 | CreateHostOnlyNetworkInterface = 100, /* see usage in code */
|
---|
38 | CreateHostOnlyNetworkInterface_OK, /* see usage in code */
|
---|
39 | RemoveHostOnlyNetworkInterface, /* see usage in code */
|
---|
40 | EnableDynamicIpConfig, /* see usage in code */
|
---|
41 | EnableStaticIpConfig, /* see usage in code */
|
---|
42 | EnableStaticIpConfigV6, /* see usage in code */
|
---|
43 | DhcpRediscover, /* see usage in code */
|
---|
44 | };
|
---|
45 | };
|
---|
46 |
|
---|
47 | class SVCHlpClient
|
---|
48 | {
|
---|
49 | public:
|
---|
50 |
|
---|
51 | SVCHlpClient();
|
---|
52 | virtual ~SVCHlpClient();
|
---|
53 |
|
---|
54 | int create (const char *aName);
|
---|
55 | int connect();
|
---|
56 | int open (const char *aName);
|
---|
57 | int close();
|
---|
58 |
|
---|
59 | bool isOpen() const { return mIsOpen; }
|
---|
60 | bool isServer() const { return mIsServer; }
|
---|
61 | const com::Utf8Str &name() const { return mName; }
|
---|
62 |
|
---|
63 | int write (const void *aVal, size_t aLen);
|
---|
64 | template <typename Scalar>
|
---|
65 | int write (Scalar aVal) { return write (&aVal, sizeof (aVal)); }
|
---|
66 | int write (const com::Utf8Str &aVal);
|
---|
67 | int write (const com::Guid &aGuid);
|
---|
68 |
|
---|
69 | int read (void *aVal, size_t aLen);
|
---|
70 | template <typename Scalar>
|
---|
71 | int read (Scalar &aVal) { return read (&aVal, sizeof (aVal)); }
|
---|
72 | int read (com::Utf8Str &aVal);
|
---|
73 | int read (com::Guid &aGuid);
|
---|
74 |
|
---|
75 | private:
|
---|
76 |
|
---|
77 | bool mIsOpen : 1;
|
---|
78 | bool mIsServer : 1;
|
---|
79 |
|
---|
80 | HANDLE mReadEnd;
|
---|
81 | HANDLE mWriteEnd;
|
---|
82 | com::Utf8Str mName;
|
---|
83 | };
|
---|
84 |
|
---|
85 | class SVCHlpServer : public SVCHlpClient
|
---|
86 | {
|
---|
87 | public:
|
---|
88 |
|
---|
89 | SVCHlpServer();
|
---|
90 |
|
---|
91 | int run();
|
---|
92 | };
|
---|
93 |
|
---|
94 | #endif /* __VBox_svchlp_h__ */
|
---|
95 |
|
---|