blob: 4cdd2e6e16b9eeacf5ae27e84ca0c368e24ac9db [file] [log] [blame]
// Copyright 2019 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <zircon/fidl.h>
// These functions are declared `static inline` to make it available in source
// form to specific functions in early bootstrapping libraries (such as libc)
// which cannot be compiled with sanitizers.
// TODO( Make these regular C functions after the linked bug
// about libc improvements.
// Initialize a transaction header according to
static inline void fidl_init_txn_header(fidl_message_header_t* out_hdr, zx_txid_t txid,
uint64_t ordinal, uint8_t dynamic_flags) {
*out_hdr = (fidl_message_header_t){
.txid = txid,
.at_rest_flags =
.dynamic_flags = dynamic_flags,
.magic_number = kFidlWireFormatMagicNumberInitial,
.ordinal = ordinal,
// Validate that a transaction header contains a supported magic number.
static inline zx_status_t fidl_validate_txn_header(const fidl_message_header_t* hdr) {
return hdr->magic_number == kFidlWireFormatMagicNumberInitial ? ZX_OK