use super::*;
use crate::syscalls::*;
#[instrument(level = "trace", skip_all, fields(%sock, addr = field::Empty), ret)]
pub fn sock_addr_peer<M: MemorySize>(
mut ctx: FunctionEnvMut<'_, WasiEnv>,
sock: WasiFd,
ro_addr: WasmPtr<__wasi_addr_port_t, M>,
) -> Errno {
let addr = wasi_try!(__sock_actor(
&mut ctx,
sock,
Rights::empty(),
|socket, _| socket.addr_peer()
));
Span::current().record("addr", format!("{:?}", addr));
let env = ctx.data();
let memory = unsafe { env.memory_view(&ctx) };
wasi_try!(crate::net::write_ip_port(
&memory,
ro_addr,
addr.ip(),
addr.port()
));
Errno::Success
}