* @brief Sets the value of a socket option. * * This system call sets a socket option for the specified socket. Socket options control various aspects * of socket behavior, such as timeouts, buffer sizes, or connection parameters. The option value is * provided in the `optval` buffer, and its length is specified by the `optlen` parameter. * * @param[in] socket The socket descriptor for w
| 5456 | * sized buffer could result in undefined behavior or errors. |
| 5457 | */ |
| 5458 | sysret_t sys_setsockopt(int socket, int level, int optname, const void *optval, socklen_t optlen) |
| 5459 | { |
| 5460 | int ret; |
| 5461 | void *koptval = RT_NULL; |
| 5462 | |
| 5463 | if (!lwp_user_accessable((void *)optval, optlen)) |
| 5464 | return -EFAULT; |
| 5465 | |
| 5466 | koptval = kmem_get(optlen); |
| 5467 | if (koptval == RT_NULL) |
| 5468 | { |
| 5469 | return -ENOMEM; |
| 5470 | } |
| 5471 | |
| 5472 | if (lwp_get_from_user(koptval, (void *)optval, optlen) != optlen) |
| 5473 | { |
| 5474 | kmem_put(koptval); |
| 5475 | return -EINVAL; |
| 5476 | } |
| 5477 | |
| 5478 | convert_sockopt(&level, &optname); |
| 5479 | ret = setsockopt(socket, level, optname, koptval, optlen); |
| 5480 | |
| 5481 | kmem_put(koptval); |
| 5482 | |
| 5483 | return (ret < 0 ? GET_ERRNO() : ret); |
| 5484 | } |
| 5485 | |
| 5486 | /** |
| 5487 | * @brief Establishes a connection to a remote socket. |
nothing calls this directly
no test coverage detected