sysdeps/linux: Implement sys_sockname and sys_peername
@@ -541,6 +541,24 @@ int sys_setsockopt(int fd, int layer, int number, const void *buffer, socklen_t
return 0;
}
+int sys_sockname(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length,
+ socklen_t *actual_length) {
+ auto ret = do_syscall(SYS_getsockname, fd, addr_ptr, &max_addr_length);
+ if (int e = sc_error(ret); e)
+ return e;
+ *actual_length = max_addr_length;
+ return 0;
+}
+
+int sys_peername(int fd, struct sockaddr *addr_ptr, socklen_t max_addr_length,
+ socklen_t *actual_length) {
+ auto ret = do_syscall(SYS_getpeername, fd, addr_ptr, &max_addr_length);
+ if (int e = sc_error(ret); e)
+ return e;
+ *actual_length = max_addr_length;
+ return 0;
+}
+
int sys_listen(int fd, int backlog) {
auto ret = do_syscall(SYS_listen, fd, backlog, 0, 0, 0, 0);
if (int e = sc_error(ret); e)
