sock/posix: Add get/set_opts methods to posix socket implementation
Signed-off-by: Evgeniy Kochetov <evgeniik@mellanox.com> Change-Id: Ibfd731dd6e84f9fd4074ff88d1159ffe8c913970 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/609 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
parent
e9e8735628
commit
bc157de238
@ -1,8 +1,8 @@
|
|||||||
/*-
|
/*-
|
||||||
* BSD LICENSE
|
* BSD LICENSE
|
||||||
*
|
*
|
||||||
* Copyright (c) Intel Corporation.
|
* Copyright (c) Intel Corporation. All rights reserved.
|
||||||
* All rights reserved.
|
* Copyright (c) 2020 Mellanox Technologies LTD. All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@ -1290,6 +1290,40 @@ posix_sock_group_impl_close(struct spdk_sock_group_impl *_group)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
posix_sock_impl_get_opts(struct spdk_sock_impl_opts *opts, size_t *len)
|
||||||
|
{
|
||||||
|
if (!opts || !len) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FIELD_OK(field) \
|
||||||
|
offsetof(struct spdk_sock_impl_opts, field) + sizeof(opts->field) <= *len
|
||||||
|
|
||||||
|
#undef FIELD_OK
|
||||||
|
|
||||||
|
*len = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
posix_sock_impl_set_opts(const struct spdk_sock_impl_opts *opts, size_t len)
|
||||||
|
{
|
||||||
|
if (!opts) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define FIELD_OK(field) \
|
||||||
|
offsetof(struct spdk_sock_impl_opts, field) + sizeof(opts->field) <= len
|
||||||
|
|
||||||
|
#undef FIELD_OK
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct spdk_net_impl g_posix_net_impl = {
|
static struct spdk_net_impl g_posix_net_impl = {
|
||||||
.name = "posix",
|
.name = "posix",
|
||||||
.getaddr = posix_sock_getaddr,
|
.getaddr = posix_sock_getaddr,
|
||||||
@ -1314,6 +1348,8 @@ static struct spdk_net_impl g_posix_net_impl = {
|
|||||||
.group_impl_remove_sock = posix_sock_group_impl_remove_sock,
|
.group_impl_remove_sock = posix_sock_group_impl_remove_sock,
|
||||||
.group_impl_poll = posix_sock_group_impl_poll,
|
.group_impl_poll = posix_sock_group_impl_poll,
|
||||||
.group_impl_close = posix_sock_group_impl_close,
|
.group_impl_close = posix_sock_group_impl_close,
|
||||||
|
.get_opts = posix_sock_impl_get_opts,
|
||||||
|
.set_opts = posix_sock_impl_set_opts,
|
||||||
};
|
};
|
||||||
|
|
||||||
SPDK_NET_IMPL_REGISTER(posix, &g_posix_net_impl, DEFAULT_SOCK_PRIORITY);
|
SPDK_NET_IMPL_REGISTER(posix, &g_posix_net_impl, DEFAULT_SOCK_PRIORITY);
|
||||||
|
Loading…
Reference in New Issue
Block a user