(fd: i32, msg: UserConstPtr<msghdr>, flags: u32)
| 57 | } |
| 58 | |
| 59 | pub fn sys_sendmsg(fd: i32, msg: UserConstPtr<msghdr>, flags: u32) -> AxResult<isize> { |
| 60 | let msg = msg.get_as_ref()?; |
| 61 | let mut cmsg = Vec::new(); |
| 62 | if !msg.msg_control.is_null() { |
| 63 | let mut ptr = msg.msg_control as usize; |
| 64 | let ptr_end = ptr + msg.msg_controllen; |
| 65 | while ptr + size_of::<cmsghdr>() <= ptr_end { |
| 66 | let hdr = UserConstPtr::<cmsghdr>::from(ptr).get_as_ref()?; |
| 67 | if ptr_end - ptr < hdr.cmsg_len { |
| 68 | return Err(AxError::InvalidInput); |
| 69 | } |
| 70 | cmsg.push(Box::new(CMsg::parse(hdr)?) as CMsgData); |
| 71 | ptr += hdr.cmsg_len; |
| 72 | } |
| 73 | } |
| 74 | send_impl( |
| 75 | fd, |
| 76 | IoVectorBuf::new(msg.msg_iov as *const IoVec, msg.msg_iovlen)?.into_io(), |
| 77 | flags, |
| 78 | UserConstPtr::from(msg.msg_name as usize), |
| 79 | msg.msg_namelen as socklen_t, |
| 80 | cmsg, |
| 81 | ) |
| 82 | } |
| 83 | |
| 84 | fn recv_impl( |
| 85 | fd: i32, |
no test coverage detected