Skip to content

Commit 298ab2c

Browse files
jukkarcarlescufi
authored andcommitted
net: socket: Add support for SO_DOMAIN option
The getsockopt() will return the address domain of the given socket like AF_INET or AF_INET6. Signed-off-by: Jukka Rissanen <[email protected]>
1 parent fe9e306 commit 298ab2c

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

include/zephyr/net/socket.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,7 @@ struct ifreq {
11661166
/** Protocol used with the socket */
11671167
#define SO_PROTOCOL 38
11681168

1169-
/** Domain used with SOCKET (ignored, for compatibility) */
1169+
/** Domain used with SOCKET */
11701170
#define SO_DOMAIN 39
11711171

11721172
/** Enable SOCKS5 for Socket */

subsys/net/lib/sockets/sockets.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2447,6 +2447,18 @@ int zsock_getsockopt_ctx(struct net_context *ctx, int level, int optname,
24472447

24482448
return 0;
24492449
}
2450+
2451+
case SO_DOMAIN: {
2452+
if (*optlen != sizeof(int)) {
2453+
errno = EINVAL;
2454+
return -1;
2455+
}
2456+
2457+
*(int *)optval = net_context_get_family(ctx);
2458+
2459+
return 0;
2460+
}
2461+
24502462
break;
24512463

24522464
case SO_RCVBUF:

0 commit comments

Comments
 (0)