|
| 1 | +// SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) |
| 2 | +/* Do not edit directly, auto-generated from: */ |
| 3 | +/* Documentation/netlink/specs/binder.yaml */ |
| 4 | +/* YNL-GEN rust source */ |
| 5 | +/* To regenerate run: tools/net/ynl/ynl-regen.sh */ |
| 6 | + |
| 7 | +#![allow(unreachable_pub, clippy::wrong_self_convention)] |
| 8 | +use kernel::netlink::{Family, MulticastGroup}; |
| 9 | +use kernel::prelude::*; |
| 10 | + |
| 11 | +pub static BINDER_NL_FAMILY: Family = Family::const_new( |
| 12 | + &crate::THIS_MODULE, |
| 13 | + kernel::uapi::BINDER_FAMILY_NAME, |
| 14 | + kernel::uapi::BINDER_FAMILY_VERSION, |
| 15 | + &BINDER_NL_FAMILY_MCGRPS, |
| 16 | +); |
| 17 | + |
| 18 | +static BINDER_NL_FAMILY_MCGRPS: [MulticastGroup; 1] = [MulticastGroup::const_new(c"report")]; |
| 19 | + |
| 20 | +/// A multicast event sent to userspace subscribers to notify them about |
| 21 | +/// binder transaction failures. The generated report provides the full |
| 22 | +/// details of the specific transaction that failed. The intention is for |
| 23 | +/// programs to monitor these events and react to the failures as needed. |
| 24 | +pub struct Report { |
| 25 | + skb: kernel::netlink::GenlMsg, |
| 26 | +} |
| 27 | + |
| 28 | +impl Report { |
| 29 | + /// Create a new multicast message. |
| 30 | + pub fn new( |
| 31 | + size: usize, |
| 32 | + portid: u32, |
| 33 | + seq: u32, |
| 34 | + flags: kernel::alloc::Flags, |
| 35 | + ) -> Result<Self, kernel::alloc::AllocError> { |
| 36 | + const BINDER_CMD_REPORT: u8 = kernel::uapi::BINDER_CMD_REPORT as u8; |
| 37 | + let skb = kernel::netlink::NetlinkSkBuff::new(size, flags)?; |
| 38 | + let skb = skb.genlmsg_put(portid, seq, &BINDER_NL_FAMILY, BINDER_CMD_REPORT)?; |
| 39 | + Ok(Self { skb }) |
| 40 | + } |
| 41 | + |
| 42 | + /// Broadcast this message. |
| 43 | + pub fn multicast(self, portid: u32, flags: kernel::alloc::Flags) -> Result { |
| 44 | + self.skb.multicast(&BINDER_NL_FAMILY, portid, 0, flags) |
| 45 | + } |
| 46 | + |
| 47 | + /// Check if this message type has listeners. |
| 48 | + pub fn has_listeners() -> bool { |
| 49 | + BINDER_NL_FAMILY.has_listeners(0) |
| 50 | + } |
| 51 | + |
| 52 | + /// The enum binder_driver_return_protocol returned to the sender. |
| 53 | + pub fn error(&mut self, val: u32) -> Result { |
| 54 | + const BINDER_A_REPORT_ERROR: c_int = kernel::uapi::BINDER_A_REPORT_ERROR as c_int; |
| 55 | + self.skb.put_u32(BINDER_A_REPORT_ERROR, val) |
| 56 | + } |
| 57 | + |
| 58 | + /// The binder context where the transaction occurred. |
| 59 | + pub fn context(&mut self, val: &CStr) -> Result { |
| 60 | + const BINDER_A_REPORT_CONTEXT: c_int = kernel::uapi::BINDER_A_REPORT_CONTEXT as c_int; |
| 61 | + self.skb.put_string(BINDER_A_REPORT_CONTEXT, val) |
| 62 | + } |
| 63 | + |
| 64 | + /// The PID of the sender process. |
| 65 | + pub fn from_pid(&mut self, val: u32) -> Result { |
| 66 | + const BINDER_A_REPORT_FROM_PID: c_int = kernel::uapi::BINDER_A_REPORT_FROM_PID as c_int; |
| 67 | + self.skb.put_u32(BINDER_A_REPORT_FROM_PID, val) |
| 68 | + } |
| 69 | + |
| 70 | + /// The TID of the sender thread. |
| 71 | + pub fn from_tid(&mut self, val: u32) -> Result { |
| 72 | + const BINDER_A_REPORT_FROM_TID: c_int = kernel::uapi::BINDER_A_REPORT_FROM_TID as c_int; |
| 73 | + self.skb.put_u32(BINDER_A_REPORT_FROM_TID, val) |
| 74 | + } |
| 75 | + |
| 76 | + /// The PID of the recipient process. This attribute may not be present |
| 77 | + /// if the target could not be determined. |
| 78 | + pub fn to_pid(&mut self, val: u32) -> Result { |
| 79 | + const BINDER_A_REPORT_TO_PID: c_int = kernel::uapi::BINDER_A_REPORT_TO_PID as c_int; |
| 80 | + self.skb.put_u32(BINDER_A_REPORT_TO_PID, val) |
| 81 | + } |
| 82 | + |
| 83 | + /// The TID of the recipient thread. This attribute may not be present |
| 84 | + /// if the target could not be determined. |
| 85 | + pub fn to_tid(&mut self, val: u32) -> Result { |
| 86 | + const BINDER_A_REPORT_TO_TID: c_int = kernel::uapi::BINDER_A_REPORT_TO_TID as c_int; |
| 87 | + self.skb.put_u32(BINDER_A_REPORT_TO_TID, val) |
| 88 | + } |
| 89 | + |
| 90 | + /// When present, indicates the failed transaction is a reply. |
| 91 | + pub fn is_reply(&mut self) -> Result { |
| 92 | + const BINDER_A_REPORT_IS_REPLY: c_int = kernel::uapi::BINDER_A_REPORT_IS_REPLY as c_int; |
| 93 | + self.skb.put_flag(BINDER_A_REPORT_IS_REPLY) |
| 94 | + } |
| 95 | + |
| 96 | + /// The bitmask of enum transaction_flags from the transaction. |
| 97 | + pub fn flags(&mut self, val: u32) -> Result { |
| 98 | + const BINDER_A_REPORT_FLAGS: c_int = kernel::uapi::BINDER_A_REPORT_FLAGS as c_int; |
| 99 | + self.skb.put_u32(BINDER_A_REPORT_FLAGS, val) |
| 100 | + } |
| 101 | + |
| 102 | + /// The application-defined code from the transaction. |
| 103 | + pub fn code(&mut self, val: u32) -> Result { |
| 104 | + const BINDER_A_REPORT_CODE: c_int = kernel::uapi::BINDER_A_REPORT_CODE as c_int; |
| 105 | + self.skb.put_u32(BINDER_A_REPORT_CODE, val) |
| 106 | + } |
| 107 | + |
| 108 | + /// The transaction payload size in bytes. |
| 109 | + pub fn data_size(&mut self, val: u32) -> Result { |
| 110 | + const BINDER_A_REPORT_DATA_SIZE: c_int = kernel::uapi::BINDER_A_REPORT_DATA_SIZE as c_int; |
| 111 | + self.skb.put_u32(BINDER_A_REPORT_DATA_SIZE, val) |
| 112 | + } |
| 113 | +} |
0 commit comments