Trait to extend [`SocketAddr`] and its variants with methods for reading from and writing to user space.
| 18 | /// Trait to extend [`SocketAddr`] and its variants with methods for reading |
| 19 | /// from and writing to user space. |
| 20 | pub trait SocketAddrExt: Sized { |
| 21 | /// This method attempts to interpret the data pointed to by `addr` with the |
| 22 | /// given `addrlen` as a valid socket address of the implementing type. |
| 23 | fn read_from_user(addr: UserConstPtr<sockaddr>, addrlen: socklen_t) -> AxResult<Self>; |
| 24 | |
| 25 | /// This method serializes the current socket address instance into the |
| 26 | /// [`sockaddr`] structure pointed to by `addr` in user space. |
| 27 | fn write_to_user(&self, addr: UserPtr<sockaddr>, addrlen: &mut socklen_t) -> AxResult<()>; |
| 28 | |
| 29 | /// Gets the address family of the socket address. |
| 30 | fn family(&self) -> u16; |
| 31 | } |
| 32 | |
| 33 | fn read_family(addr: UserConstPtr<sockaddr>, addrlen: socklen_t) -> AxResult<u16> { |
| 34 | if size_of::<__kernel_sa_family_t>() > addrlen as usize { |
nothing calls this directly
no outgoing calls
no test coverage detected