| 1214 | } |
| 1215 | |
| 1216 | ssize_t |
| 1217 | ff_sendmsg(int s, const struct msghdr *msg, int flags) |
| 1218 | { |
| 1219 | int rc, ret; |
| 1220 | struct sockaddr_storage freebsd_sa; |
| 1221 | struct msghdr freebsd_msg; |
| 1222 | struct cmsghdr *freebsd_cmsg = NULL; |
| 1223 | |
| 1224 | freebsd_msg.msg_name = &freebsd_sa; |
| 1225 | if ((__DECONST(struct linux_msghdr *, msg))->msg_control) { |
| 1226 | freebsd_cmsg = malloc((__DECONST(struct linux_msghdr *, msg))->msg_controllen, NULL, 0); |
| 1227 | if (freebsd_cmsg == NULL) { |
| 1228 | rc = ENOMEM; |
| 1229 | goto kern_fail; |
| 1230 | } |
| 1231 | } |
| 1232 | freebsd_msg.msg_control = freebsd_cmsg; |
| 1233 | |
| 1234 | ret = linux2freebsd_msghdr((const struct linux_msghdr *)msg, &freebsd_msg, 1); |
| 1235 | if (ret < 0) { |
| 1236 | rc = EINVAL; |
| 1237 | goto kern_fail; |
| 1238 | } |
| 1239 | |
| 1240 | rc = sendit(curthread, s, &freebsd_msg, flags); |
| 1241 | if (rc) |
| 1242 | goto kern_fail; |
| 1243 | |
| 1244 | rc = curthread->td_retval[0]; |
| 1245 | |
| 1246 | freebsd2linux_msghdr(__DECONST(struct linux_msghdr *, msg), &freebsd_msg, 1); |
| 1247 | |
| 1248 | if (freebsd_cmsg) { |
| 1249 | free(freebsd_cmsg, NULL); |
| 1250 | } |
| 1251 | |
| 1252 | return (rc); |
| 1253 | kern_fail: |
| 1254 | ff_os_errno(rc); |
| 1255 | return (-1); |
| 1256 | } |
| 1257 | |
| 1258 | |
| 1259 | ssize_t |
no test coverage detected