1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// SPDX-License-Identifier: MIT
use crate::*;
/// Trait containing the rest of [`struct@FwResp`] methods.
///
/// # Implementors
///
/// [`FwResp`][struct@crate::FwResp]
pub trait FwRespExtManual {
/// Emitted when any node transfers request subaction to local nodes within the address
/// range reserved in Linux system.
///
/// The handler is expected to call [`FwRespExt::set_resp_frame()`][crate::prelude::FwRespExt::set_resp_frame()] with frame and return
/// [`FwRcode`][crate::FwRcode] for response subaction.
///
/// The value of @tstamp is unsigned 16 bit integer including higher 3 bits for three low
/// order bits of second field and the rest 13 bits for cycle field in the format of IEEE
/// 1394 CYCLE_TIMER register.
///
/// If the version of kernel ABI for Linux FireWire subsystem is less than 6, the value of
/// tstamp argument has invalid value (=G_MAXUINT). Furthermore, if the version is less than
/// 4, the src, dst, card, generation arguments have invalid value (=G_MAXUINT).
/// ## `tcode`
/// One of [`FwTcode`][crate::FwTcode] enumerations
/// ## `offset`
/// The address offset at which the transaction arrives.
/// ## `src_node_id`
/// The node ID of source for the transaction.
/// ## `dst_node_id`
/// The node ID of destination for the transaction.
/// ## `card_id`
/// The index of card specific to the 1394 OHCI hardware at which the request
/// subaction arrived.
/// ## `generation`
/// The generation of bus when the transaction is transferred.
/// ## `tstamp`
/// The isochronous cycle at which the request arrived.
/// ## `frame`
/// The array with elements for byte
/// data.
///
/// # Returns
///
/// One of [`FwRcode`][crate::FwRcode] enumerations corresponding to rcodes defined in IEEE 1394
/// specification.
#[doc(alias = "requested")]
fn connect_requested<F>(&self, f: F) -> SignalHandlerId
where
F: Fn(&Self, FwTcode, u64, u32, u32, u32, u32, u32, &[u8]) -> FwRcode + 'static;
}
impl<O: IsA<FwResp>> FwRespExtManual for O {
fn connect_requested<F>(&self, f: F) -> SignalHandlerId
where
F: Fn(&Self, FwTcode, u64, u32, u32, u32, u32, u32, &[u8]) -> FwRcode + 'static,
{
unsafe extern "C" fn requested_trampoline<P, F>(
this: *mut ffi::HinawaFwResp,
tcode: ffi::HinawaFwTcode,
offset: u64,
src: std::ffi::c_uint,
dst: std::ffi::c_uint,
card: std::ffi::c_uint,
generation: std::ffi::c_uint,
tstamp: std::ffi::c_uint,
frame: *const u8,
length: std::ffi::c_uint,
f: glib::ffi::gpointer,
) -> ffi::HinawaFwRcode
where
P: IsA<FwResp>,
F: Fn(&P, FwTcode, u64, u32, u32, u32, u32, u32, &[u8]) -> FwRcode + 'static,
{
let f: &F = &*(f as *const F);
f(
&FwResp::from_glib_borrow(this).unsafe_cast_ref(),
from_glib(tcode),
offset,
src,
dst,
card,
generation,
tstamp,
std::slice::from_raw_parts(frame, length as usize),
)
.into_glib()
}
unsafe {
let f: std::boxed::Box<F> = std::boxed::Box::new(f);
connect_raw(
self.as_ptr() as *mut _,
c"requested".as_ptr() as *const _,
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
requested_trampoline::<Self, F> as *const (),
)),
std::boxed::Box::into_raw(f),
)
}
}
}