open-vm-tools 12.1.5
gdp.h
Go to the documentation of this file.
1/*********************************************************
2 * Copyright (C) 2020-2021 VMware, Inc. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation version 2.1 and no later version.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11 * License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 *********************************************************/
18
19#ifndef _VMWARE_TOOLS_GDP_H_
20#define _VMWARE_TOOLS_GDP_H_
21
28#include <glib-object.h>
29#include "vmware/tools/plugin.h"
30
31/*
32 * Size in bytes:
33 * 17 * 4096 - Maximum VMCI datagram size
34 * 24 - VMCI datagram header size
35 */
36#define GDP_MAX_PACKET_LEN (17 * 4096 - 24)
37
38/*
39 * Limit GDP packet JSON base64 key value size to (16 * 4096) bytes, then
40 * the rest JSON content will have (4096 - 24) bytes available.
41 *
42 * Base64 (16 * 4096) bytes are (12 * 4096) bytes before encoding.
43 */
44#define GDP_USER_DATA_LEN (12 * 4096)
45
46/*
47 * Property name of the gdp plugin service in the tools
48 * applicatin context service object.
49 */
50#define TOOLS_PLUGIN_SVC_PROP_GDP "tps_prop_gdp"
51
52/*
53 * GdpError definitions.
54 */
55#define GDP_ERR_LIST \
56 GDP_ERR_ITEM(GDP_ERROR_SUCCESS = 0, \
57 "No error") \
58 GDP_ERR_ITEM(GDP_ERROR_INVALID_DATA, \
59 "Invalid data") \
60 GDP_ERR_ITEM(GDP_ERROR_DATA_SIZE, \
61 "Data size too large") \
62 GDP_ERR_ITEM(GDP_ERROR_GENERAL, \
63 "General error") \
64 GDP_ERR_ITEM(GDP_ERROR_STOP, \
65 "Stopped for vmtoolsd shutdown") \
66 GDP_ERR_ITEM(GDP_ERROR_UNREACH, \
67 "Host daemon unreachable") \
68 GDP_ERR_ITEM(GDP_ERROR_TIMEOUT, \
69 "Operation timed out")
70
71/*
72 * GdpError codes.
73 */
74#define GDP_ERR_ITEM(a, b) a,
75typedef enum GdpError {
76 GDP_ERR_LIST
77 GDP_ERR_MAX
78} GdpError;
79#undef GDP_ERR_ITEM
80
87typedef struct ToolsPluginSvcGdp {
88 GdpError (*publish)(gint64 createTime,
89 const gchar *topic,
90 const gchar *token,
91 const gchar *category,
92 const gchar *data,
93 guint32 dataLen,
94 gboolean cacheData);
96
97
98/*
99 ******************************************************************************
100 * ToolsPluginSvcGdp_Publish -- */
125static inline GdpError
126ToolsPluginSvcGdp_Publish(ToolsAppCtx *ctx, // IN
127 gint64 createTime, // IN
128 const gchar *topic, // IN
129 const gchar *token, // IN, OPTIONAL
130 const gchar *category, // IN, OPTIONAL
131 const gchar *data, // IN
132 guint32 dataLen, // IN
133 gboolean cacheData) // IN
134{
135 ToolsPluginSvcGdp *svcGdp = NULL;
136 g_object_get(ctx->serviceObj, TOOLS_PLUGIN_SVC_PROP_GDP, &svcGdp, NULL);
137 if (svcGdp != NULL && svcGdp->publish != NULL) {
138 return svcGdp->publish(createTime, topic, token,
139 category, data, dataLen, cacheData);
140 }
141 return GDP_ERROR_GENERAL;
142}
143
144#endif /* _VMWARE_TOOLS_GDP_H_ */
struct ToolsPluginSvcGdp ToolsPluginSvcGdp
Type of the public interface of the gdp plugin service.
Definition: plugin.h:282
gpointer serviceObj
Definition: plugin.h:314
Type of the public interface of the gdp plugin service.
Definition: gdp.h:87