Commit f6263c81 authored by Hubert Miś's avatar Hubert Miś Committed by Jukka Rissanen
Browse files

net: socket: getsockopt SO_TYPE implementation



This patch adds implementation of socket option used to get
type of given socket (e.g. SOCK_STREAM).

Signed-off-by: default avatarHubert Miś <hubert.mis@nordicsemi.no>
parent b49e3952
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -793,6 +793,8 @@ static inline char *inet_ntop(sa_family_t family, const void *src, char *dst,
/* Socket options for SOL_SOCKET level */
/** sockopt: Enable server address reuse (ignored, for compatibility) */
#define SO_REUSEADDR 2
/** sockopt: Type of the socket */
#define SO_TYPE 3
/** sockopt: Async error (ignored, for compatibility) */
#define SO_ERROR 4

+13 −0
Original line number Diff line number Diff line
@@ -1497,6 +1497,19 @@ int zsock_getsockopt_ctx(struct net_context *ctx, int level, int optname,
	switch (level) {
	case SOL_SOCKET:
		switch (optname) {
		case SO_TYPE: {
			int type = (int)net_context_get_type(ctx);

			if (*optlen != sizeof(type)) {
				errno = EINVAL;
				return -1;
			}

			*(int *)optval = type;

			return 0;
		}

		case SO_TXTIME:
			if (IS_ENABLED(CONFIG_NET_CONTEXT_TXTIME)) {
				ret = net_context_get_option(ctx,