From 42fd827009f84e22c08d33128e9ea7764b5039d1 Mon Sep 17 00:00:00 2001 From: Michael Tuexen Date: Wed, 7 Aug 2019 12:53:40 +0200 Subject: [PATCH] Add support for getsockopt with SO_ERROR. This is cherry picked from #339, since it is not related. --- usrsctplib/user_socket.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/usrsctplib/user_socket.c b/usrsctplib/user_socket.c index 6ac0af7ea..bec022638 100755 --- a/usrsctplib/user_socket.c +++ b/usrsctplib/user_socket.c @@ -2406,6 +2406,20 @@ usrsctp_getsockopt(struct socket *so, int level, int option_name, *option_len = (socklen_t)sizeof(struct linger); return (0); } + break; + case SO_ERROR: + if (*option_len < (socklen_t)sizeof(int)) { + errno = EINVAL; + return (-1); + } else { + int *intval; + + intval = (int *)option_value; + *intval = so->so_error; + *option_len = (socklen_t)sizeof(int); + return (0); + } + break; default: errno = EINVAL; return (-1);