mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Refactor sock option implementations
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
782cd05ade
commit
f8eca84a99
@ -1,13 +1,11 @@
|
||||
use crate::fs::file_table::FileDescripter;
|
||||
use crate::get_socket_without_holding_filetable_lock;
|
||||
use crate::log_syscall_entry;
|
||||
use crate::net::socket::SendRecvFlags;
|
||||
use crate::prelude::*;
|
||||
use crate::util::net::read_socket_addr_from_user;
|
||||
use crate::util::net::{get_socket_from_fd, read_socket_addr_from_user};
|
||||
use crate::util::read_bytes_from_user;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use super::SYS_SENDTO;
|
||||
use super::{SyscallReturn, SYS_SENDTO};
|
||||
|
||||
pub fn sys_sendto(
|
||||
sockfd: FileDescripter,
|
||||
@ -28,8 +26,10 @@ pub fn sys_sendto(
|
||||
debug!("sockfd = {sockfd}, buf = 0x{buf:x}, len = 0x{len:x}, flags = {flags:?}, socket_addr = {socket_addr:?}");
|
||||
let mut buffer = vec![0u8; len];
|
||||
read_bytes_from_user(buf, &mut buffer)?;
|
||||
let current = current!();
|
||||
get_socket_without_holding_filetable_lock!(socket, current, sockfd);
|
||||
|
||||
let socket = get_socket_from_fd(sockfd)?;
|
||||
|
||||
let send_size = socket.sendto(&buffer, socket_addr, flags)?;
|
||||
|
||||
Ok(SyscallReturn::Return(send_size as _))
|
||||
}
|
||||
|
Reference in New Issue
Block a user