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

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: 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
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..f9eb4467a2110de2cc4277afb727fb88240929f5
--- /dev/null
+++ b/mojo/public/c/bindings/message.h
@@ -0,0 +1,36 @@
+// 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 <stdint.h>
+
+#include "mojo/public/c/bindings/struct.h"
+
+#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(mojo_struct_header_t* header, uint32_t size);
viettrungluu 2016/02/02 00:48:47 const mojo_struct_header_t*? |size_t| for size?
jamesr 2016/02/02 00:55:04 Sure (although it's meaningless here)
+
viettrungluu 2016/02/02 00:48:47 Probably you want suitable pack pragmas, no?
jamesr 2016/02/02 00:55:04 I'm relying on the static assertions to tell me if
+typedef struct mojo_message_header {
+ mojo_struct_header_t struct_header;
+ uint32_t name;
+ uint32_t flags;
+} mojo_message_header_t;
viettrungluu 2016/02/02 00:48:47 Note that POSIX sez that _t names are reserved for
jamesr 2016/02/02 00:55:04 That's super annoying. Is there another naming co
+
+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_

Powered by Google App Engine
This is Rietveld 408576698