pub struct Ipcon { /* private fields */ }Expand description
IPCON peer.
Implementations§
Source§impl Ipcon
impl Ipcon
pub fn to_handler(u: usize) -> *mut c_void
Sourcepub fn new(
peer_name: Option<&str>,
flag: Option<IpconFlag>,
) -> Result<Ipcon, IpconError>
pub fn new( peer_name: Option<&str>, flag: Option<IpconFlag>, ) -> Result<Ipcon, IpconError>
Create an IPCON peer. If the name is omitted, an anonymous will be created. Following flags can be specified with bitwise OR (|).
- IPF_DISABLE_KEVENT_FILTER
By default, IPCON kernel module will only delivery the add/remove notification of peers and groups which are considered to be interested by the peer. If this flag is enabled, all notification will be delivered by IPCON kernel module. - IPF_SND_IF
Use message sending interface. - IPF_RCV_IF
Use message receiving interface. - IPF_DEFAULT
This is same to IPF_RCV_IF | IPF_SND_IF.
Sourcepub fn get_read_fd(&self) -> Result<i32, IpconError>
pub fn get_read_fd(&self) -> Result<i32, IpconError>
Retrieve netlink socket file descriptor of message receiving interface.
Sourcepub fn get_write_fd(&self) -> Result<i32, IpconError>
pub fn get_write_fd(&self) -> Result<i32, IpconError>
Retrieve netlink socket file descriptor of message sending interface.
Sourcepub fn get_ctrl_fd(&self) -> Result<i32, IpconError>
pub fn get_ctrl_fd(&self) -> Result<i32, IpconError>
Retrieve netlink socket file descriptor of control interface.
Sourcepub fn is_peer_present(&self, peer: &str) -> bool
pub fn is_peer_present(&self, peer: &str) -> bool
Inquiry whether a peer is present.
Sourcepub fn is_group_present(&self, peer: &str, group: &str) -> bool
pub fn is_group_present(&self, peer: &str, group: &str) -> bool
Inquiry whether the group of a peer is present.
Sourcepub fn receive_msg(&self) -> Result<IpconMsg, IpconError>
pub fn receive_msg(&self) -> Result<IpconMsg, IpconError>
Receive IPCON message. This function will fail if the peer doesn’t enable IPF_RCV_IF.
Sourcepub fn send_unicast_msg(&self, peer: &str, buf: &[u8]) -> Result<(), IpconError>
pub fn send_unicast_msg(&self, peer: &str, buf: &[u8]) -> Result<(), IpconError>
Send an unicast IPCON message to a specific peer. This function will fail if the peer doesn’t enable IPF_SND_IF.
Sourcepub fn send_unicast_msg_by_ref(
&self,
peer: &str,
buf: &[u8],
) -> Result<(), IpconError>
pub fn send_unicast_msg_by_ref( &self, peer: &str, buf: &[u8], ) -> Result<(), IpconError>
Send an unicast IPCON message to a specific peer. This function will fail if the peer doesn’t enable IPF_SND_IF.
Sourcepub fn register_group(&self, group: &str) -> Result<(), IpconError>
pub fn register_group(&self, group: &str) -> Result<(), IpconError>
Register a multicast group.
Sourcepub fn unregister_group(&self, group: &str) -> Result<(), IpconError>
pub fn unregister_group(&self, group: &str) -> Result<(), IpconError>
Unregister a multicast group.
Sourcepub fn join_group(&self, peer: &str, group: &str) -> Result<(), IpconError>
pub fn join_group(&self, peer: &str, group: &str) -> Result<(), IpconError>
Subscribe a multicast group of a peer.
Sourcepub fn leave_group(&self, peer: &str, group: &str) -> Result<(), IpconError>
pub fn leave_group(&self, peer: &str, group: &str) -> Result<(), IpconError>
Unsubscribe a multicast group of a peer.
Sourcepub fn send_multicast(
&self,
group: &str,
buf: &[u8],
sync: bool,
) -> Result<(), IpconError>
pub fn send_multicast( &self, group: &str, buf: &[u8], sync: bool, ) -> Result<(), IpconError>
Send multicast messages to an owned group.
Sourcepub fn send_multicast_by_ref(
&self,
group: &str,
buf: &[u8],
sync: bool,
) -> Result<(), IpconError>
pub fn send_multicast_by_ref( &self, group: &str, buf: &[u8], sync: bool, ) -> Result<(), IpconError>
Send multicast messages to an owned group.
Sourcepub fn receive_msg_timeout(
&self,
tv_sec: u32,
tv_usec: u32,
) -> Result<IpconMsg, IpconError>
pub fn receive_msg_timeout( &self, tv_sec: u32, tv_usec: u32, ) -> Result<IpconMsg, IpconError>
Receiving message with timeout. receive_msg() will block until a message come. receive_msg_timeout() adds a timeout to it.The timeout is specified with seconds and microseconds.
Sourcepub fn receive_msg_nonblock(&self) -> Result<IpconMsg, IpconError>
pub fn receive_msg_nonblock(&self) -> Result<IpconMsg, IpconError>
Receiving message without block. This is same to receive_msg_timeout(0, 0);