1 /* 2 * Copyright (c) 2024 Google Inc. All rights reserved 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files 6 * (the "Software"), to deal in the Software without restriction, 7 * including without limitation the rights to use, copy, modify, merge, 8 * publish, distribute, sublicense, and/or sell copies of the Software, 9 * and to permit persons to whom the Software is furnished to do so, 10 * subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice shall be 13 * included in all copies or substantial portions of the Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 */ 23 24 use core::ptr::null_mut; 25 26 pub use crate::sys::ipc_get_msg; 27 pub use crate::sys::ipc_port_connect_async; 28 pub use crate::sys::ipc_put_msg; 29 pub use crate::sys::ipc_read_msg; 30 pub use crate::sys::ipc_send_msg; 31 32 pub use crate::sys::iovec_kern; 33 pub use crate::sys::ipc_msg_info; 34 pub use crate::sys::ipc_msg_kern; 35 36 pub use crate::sys::zero_uuid; 37 pub use crate::sys::IPC_CONNECT_WAIT_FOR_PORT; 38 pub use crate::sys::IPC_PORT_PATH_MAX; 39 40 impl Default for ipc_msg_kern { default() -> Self41 fn default() -> Self { 42 Self { iov: null_mut(), num_iov: 0, handles: null_mut(), num_handles: 0 } 43 } 44 } 45 46 impl ipc_msg_kern { new(iov: &mut iovec_kern) -> Self47 pub fn new(iov: &mut iovec_kern) -> Self { 48 Self { iov, num_iov: 1, ..ipc_msg_kern::default() } 49 } 50 } 51 52 impl From<&mut [u8]> for iovec_kern { from(value: &mut [u8]) -> Self53 fn from(value: &mut [u8]) -> Self { 54 Self { iov_base: value.as_mut_ptr() as _, iov_len: value.len() } 55 } 56 } 57