* Helper routine for getsockopt. */
| 3192 | * Helper routine for getsockopt. |
| 3193 | */ |
| 3194 | int |
| 3195 | sooptcopyout(struct sockopt *sopt, const void *buf, size_t len) |
| 3196 | { |
| 3197 | int error; |
| 3198 | size_t valsize; |
| 3199 | |
| 3200 | error = 0; |
| 3201 | |
| 3202 | /* |
| 3203 | * Documented get behavior is that we always return a value, possibly |
| 3204 | * truncated to fit in the user's buffer. Traditional behavior is |
| 3205 | * that we always tell the user precisely how much we copied, rather |
| 3206 | * than something useful like the total amount we had available for |
| 3207 | * her. Note that this interface is not idempotent; the entire |
| 3208 | * answer must be generated ahead of time. |
| 3209 | */ |
| 3210 | valsize = min(len, sopt->sopt_valsize); |
| 3211 | sopt->sopt_valsize = valsize; |
| 3212 | if (sopt->sopt_val != NULL) { |
| 3213 | if (sopt->sopt_td != NULL) |
| 3214 | error = copyout(buf, sopt->sopt_val, valsize); |
| 3215 | else |
| 3216 | bcopy(buf, sopt->sopt_val, valsize); |
| 3217 | } |
| 3218 | return (error); |
| 3219 | } |
| 3220 | |
| 3221 | int |
| 3222 | sogetopt(struct socket *so, struct sockopt *sopt) |
no test coverage detected