[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 10/11] Signed-off-by: Karim Taha <address@hidden>
From: |
Karim Taha |
Subject: |
[PATCH v3 10/11] Signed-off-by: Karim Taha <address@hidden> |
Date: |
Fri, 21 Apr 2023 18:41:59 +0200 |
From: Stacey Son <sson@FreeBSD.org>
getpeername(2) syscall.
Add the getpeername(2) syscall to bsd-user/bsd-socket.h.
Signed-off-by: Karim Taha <kariem.taha2.7@gmail.com>
---
bsd-user/bsd-socket.h | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/bsd-user/bsd-socket.h b/bsd-user/bsd-socket.h
index f748266730..16fae3752a 100644
--- a/bsd-user/bsd-socket.h
+++ b/bsd-user/bsd-socket.h
@@ -112,4 +112,32 @@ static inline abi_long do_bsd_accept(int fd, abi_ulong
target_addr,
return ret;
}
+/* getpeername(2) */
+static inline abi_long do_bsd_getpeername(int fd, abi_ulong target_addr,
+ abi_ulong target_addrlen_addr)
+{
+ socklen_t addrlen;
+ void *addr;
+ abi_long ret;
+
+ if (get_user_u32(addrlen, target_addrlen_addr)) {
+ return -TARGET_EFAULT;
+ }
+ if ((int)addrlen < 0) {
+ return -TARGET_EINVAL;
+ }
+ if (!access_ok(VERIFY_WRITE, target_addr, addrlen)) {
+ return -TARGET_EFAULT;
+ }
+ addr = alloca(addrlen);
+ ret = get_errno(getpeername(fd, addr, &addrlen));
+ if (!is_error(ret)) {
+ host_to_target_sockaddr(target_addr, addr, addrlen);
+ if (put_user_u32(addrlen, target_addrlen_addr)) {
+ ret = -TARGET_EFAULT;
+ }
+ }
+ return ret;
+}
+
#endif /* BSD_SOCKET_H */
--
2.40.0
- [PATCH v3 00/11] Contribution task implementations, for the 'FreeBSD user emulation improvements' project., Karim Taha, 2023/04/21
- [PATCH v3 01/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 02/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 03/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 04/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 05/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 06/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 07/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 09/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 10/11] Signed-off-by: Karim Taha <address@hidden>,
Karim Taha <=
- [PATCH v3 08/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21
- [PATCH v3 11/11] Signed-off-by: Karim Taha <address@hidden>, Karim Taha, 2023/04/21