MCPcopy Index your code
hub / github.com/F-Stack/f-stack / freebsd2linux_msghdr

Function freebsd2linux_msghdr

lib/ff_syscall_wrapper.c:840–866  ·  view source on GitHub ↗

* While sendmsg, need convert msg_name and msg_control from Linux to FreeBSD. * While recvmsg, need convert msg_name and msg_control from FreeBSD to Linux. * Note: linux2freebsd_msghdr and freebsd2linux_msghdr must be called in sequence and in pairs. */

Source from the content-addressed store, hash-verified

838 * Note: linux2freebsd_msghdr and freebsd2linux_msghdr must be called in sequence and in pairs.
839 */
840static int
841freebsd2linux_msghdr(struct linux_msghdr *linux_msg, struct msghdr *freebsd_msg, int send_flag)
842{
843 if (linux_msg == NULL || freebsd_msg == NULL) {
844 return -1;
845 }
846
847 if (linux_msg->msg_name && freebsd_msg->msg_name && !send_flag) {
848 linux_msg->msg_name = freebsd_msg->msg_name;
849 freebsd2linux_sockaddr(linux_msg->msg_name, freebsd_msg->msg_name);
850 linux_msg->msg_namelen = freebsd_msg->msg_namelen;
851 }
852
853 linux_msg->msg_iov = freebsd_msg->msg_iov;
854 linux_msg->msg_iovlen = freebsd_msg->msg_iovlen;
855 /* Restore the old iov pointer, compatible with the Linux interface */
856 memcpy(linux_msg->msg_iov, msg_iov_tmp, msg_iovlen_tmp * sizeof(struct iovec));
857
858 if(freebsd_msg->msg_control && linux_msg->msg_control && !send_flag) {
859 freebsd2linux_cmsghdr(linux_msg, freebsd_msg);
860 linux_msg->msg_controllen = freebsd_msg->msg_controllen;
861 }
862
863 linux_msg->msg_flags = freebsd_msg->msg_flags;
864
865 return 0;
866}
867
868static int
869linux2freebsd_msghdr(const struct linux_msghdr *linux_msg, struct msghdr *freebsd_msg, int send_flag)

Callers 1

ff_recvmsgFunction · 0.85

Calls 3

freebsd2linux_sockaddrFunction · 0.85
freebsd2linux_cmsghdrFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected