* 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. */
| 838 | * Note: linux2freebsd_msghdr and freebsd2linux_msghdr must be called in sequence and in pairs. |
| 839 | */ |
| 840 | static int |
| 841 | freebsd2linux_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 | |
| 868 | static int |
| 869 | linux2freebsd_msghdr(const struct linux_msghdr *linux_msg, struct msghdr *freebsd_msg, int send_flag) |
no test coverage detected