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: Hubert Miś <hubert.mis@nordicsemi.no>
This commit is contained in:
parent
b49e395277
commit
f6263c8143
@ -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
|
||||
|
||||
|
||||
@ -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,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user