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