* getpeername1() - Get name of peer for connected socket. */
| 1435 | * getpeername1() - Get name of peer for connected socket. |
| 1436 | */ |
| 1437 | static int |
| 1438 | getpeername1(struct thread *td, struct getpeername_args *uap, int compat) |
| 1439 | { |
| 1440 | struct sockaddr *sa; |
| 1441 | socklen_t len; |
| 1442 | int error; |
| 1443 | |
| 1444 | error = copyin(uap->alen, &len, sizeof (len)); |
| 1445 | if (error != 0) |
| 1446 | return (error); |
| 1447 | |
| 1448 | error = kern_getpeername(td, uap->fdes, &sa, &len); |
| 1449 | if (error != 0) |
| 1450 | return (error); |
| 1451 | |
| 1452 | if (len != 0) { |
| 1453 | #ifdef COMPAT_OLDSOCK |
| 1454 | if (compat && SV_PROC_FLAG(td->td_proc, SV_AOUT)) |
| 1455 | ((struct osockaddr *)sa)->sa_family = sa->sa_family; |
| 1456 | #endif |
| 1457 | error = copyout(sa, uap->asa, (u_int)len); |
| 1458 | } |
| 1459 | free(sa, M_SONAME); |
| 1460 | if (error == 0) |
| 1461 | error = copyout(&len, uap->alen, sizeof(len)); |
| 1462 | return (error); |
| 1463 | } |
| 1464 | |
| 1465 | int |
| 1466 | kern_getpeername(struct thread *td, int fd, struct sockaddr **sa, |
no test coverage detected