/*
 * Copyright (c) 2024, Andrew Kaster <akaster@serenityos.org>
 * Copyright (c) 2024, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/Platform.h>
#include <AK/Types.h>

#if !defined(AK_OS_MACH)
#    error "This file is only available on Mach platforms"
#endif

#include <mach/mach.h>

namespace IPC {

struct MessageBodyWithSelfTaskPort {
    mach_msg_body_t body;
    mach_msg_port_descriptor_t port_descriptor;
    mach_msg_audit_trailer_t trailer;
};

struct MessageWithSelfTaskPort {
    mach_msg_header_t header;
    mach_msg_body_t body;
    mach_msg_port_descriptor_t port_descriptor;
};

struct ReceivedMachMessage {
    mach_msg_header_t header;
    MessageBodyWithSelfTaskPort body;
};

struct MessageWithIPCChannelPorts {
    mach_msg_header_t header;
    mach_msg_body_t body;
    mach_msg_port_descriptor_t receive_port;
    mach_msg_port_descriptor_t send_port;
};

struct ReceivedIPCChannelPortsMessage {
    mach_msg_header_t header;
    mach_msg_body_t body;
    mach_msg_port_descriptor_t receive_port;
    mach_msg_port_descriptor_t send_port;
    mach_msg_trailer_t trailer;
};

static constexpr mach_msg_id_t SELF_TASK_PORT_MESSAGE_ID = 0x1234CAFE;
static constexpr mach_msg_id_t IPC_CHANNEL_PORTS_MESSAGE_ID = 0x4950C002;

}
