Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: mojo/public/c/bindings/message.h

Issue 1654373002: C types and utilities to validate and access struct and message headers (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: review feedback, for trybots Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/c/bindings/lib/struct.c ('k') | mojo/public/c/bindings/struct.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/c/bindings/message.h
diff --git a/mojo/public/c/bindings/message.h b/mojo/public/c/bindings/message.h
new file mode 100644
index 0000000000000000000000000000000000000000..45734b08aa3bd7be4e9290d84266e25bbac0f497
--- /dev/null
+++ b/mojo/public/c/bindings/message.h
@@ -0,0 +1,42 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_PUBLIC_C_BINDINGS_MESSAGE_H_
+#define MOJO_PUBLIC_C_BINDINGS_MESSAGE_H_
+
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include "mojo/public/c/bindings/struct.h"
+
+// These bits may be set in the |flags| field of a Mojo message header.
+#define MOJO_MESSAGE_HEADER_FLAGS_EXPECTS_RESPONSE (1 << 0u)
+#define MOJO_MESSAGE_HEADER_FLAGS_IS_RESPONSE (1 << 1u)
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+// Validates that the buffer started at a (validated) mojo_struct_header with a
+// given size contains a valid mojo message header.
+bool mojo_validate_message_header(const mojo_struct_header_t* header,
+ size_t size);
+
+typedef struct mojo_message_header {
+ mojo_struct_header_t struct_header;
+ uint32_t name;
+ uint32_t flags;
+} mojo_message_header_t;
+
+typedef struct mojo_message_header_with_request_id {
+ mojo_message_header_t message_header;
+ uint64_t request_id;
+} mojo_message_header_with_request_id_t;
+
+#ifdef __cplusplus
+} // extern "C"
+#endif
+
+#endif // MOJO_PUBLIC_C_BINDINGS_MESSAGE_H_
« no previous file with comments | « mojo/public/c/bindings/lib/struct.c ('k') | mojo/public/c/bindings/struct.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698