pub struct CanAddr(/* private fields */);
Expand description
CAN socket address.
This is the address for use with CAN sockets. It is simply an addres to the SocketCAN host interface. It can be created by looking up the name of the interface, like “can0”, “vcan0”, etc, or an interface index can be specified directly, if known. An index of zero can be used to read frames from all interfaces.
This is based on, and compatible with, the sockaddr_can
struct from
libc.
ref
Implementations§
Source§impl CanAddr
impl CanAddr
Sourcepub fn new(ifindex: u32) -> Self
pub fn new(ifindex: u32) -> Self
Creates a new CAN socket address for the specified interface by index. An index of zero can be used to read from all interfaces.
Sourcepub fn from_iface(ifname: &str) -> Result<Self>
pub fn from_iface(ifname: &str) -> Result<Self>
Try to create an address from an interface name.
Sourcepub fn as_ptr(&self) -> *const sockaddr_can
pub fn as_ptr(&self) -> *const sockaddr_can
Gets the address of the structure as a sockaddr_can
pointer.
Sourcepub fn as_sockaddr_ptr(&self) -> *const sockaddr
pub fn as_sockaddr_ptr(&self) -> *const sockaddr
Gets the address of the structure as a sockaddr
pointer.
Sourcepub fn into_storage(self) -> (sockaddr_storage, socklen_t)
pub fn into_storage(self) -> (sockaddr_storage, socklen_t)
Converts the CAN address into a sockaddr_storage
type.
This is a generic socket address container with enough space to hold
any address type in the system.