You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by gn...@apache.org on 2020/01/01 19:58:24 UTC
[incubator-nuttx] 02/02: Add files missed in last commit
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch netlink_crypto
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 176eb028482381fdd4f0895b99c4426aa14b36c0
Author: Gregory Nutt <gn...@nuttx.org>
AuthorDate: Fri Nov 29 15:03:55 2019 -0600
Add files missed in last commit
---
crypto/crypto_netlink.c | 202 ++++++++++++++++++++++++++++++++++
crypto/crypto_netlink.h | 146 ++++++++++++++++++++++++
include/nuttx/crypto/crypto_netlink.h | 81 ++++++++++++++
net/netlink/netlink_crypto.c | 193 ++++++++++++++++++++++++++++++++
4 files changed, 622 insertions(+)
diff --git a/crypto/crypto_netlink.c b/crypto/crypto_netlink.c
new file mode 100644
index 0000000..ffdbcc9
--- /dev/null
+++ b/crypto/crypto_netlink.c
@@ -0,0 +1,202 @@
+/****************************************************************************
+ * crypto/crypto_netlink.c
+ * Provides the Netlink interface between the socket layer and the crypto
+ * subsystem.
+ *
+ * Copyright (C) 2019 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdbool.h>
+#include <string.h>
+#include <poll.h>
+#include <assert.h>
+#include <debug.h>
+#include <errno.h>
+
+#include <netpacket/netlink.h>
+#include <nuttx/net/netlink.h>
+#include <nuttx/crypto/crypto_netlink.h>
+
+#include "crypto_netlink.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: crypto_request_handler
+ *
+ * Description:
+ * This function receives the raw NETLINK_CRYPTO request and provides that
+ * request to the appropriate handler.
+ *
+ * Input Parameters:
+ * handle - A handle for use in subsequent calls to netlink_add_response()
+ * when the response to the request is available.
+ * req - A reference to the common header of the Netlink messages.
+ * This may be cast to the specific message type associated with
+ * the decoded Netlink messages.
+ * reqlen - The full length of the request 'req'
+ * to - The destination address for bound sockets.
+ *
+ * Returned Value
+ * Zero is returned on success meaning that the response was successfully
+ * processed. In this case, a response has been or will be generated. In
+ * the event of an error, a negated errno value will be returned.
+ *
+ ****************************************************************************/
+
+int crypto_request_handler(NETLINK_HANDLE handle,
+ FAR const struct nlmsghdr *req, size_t reqlen,
+ FAR const struct sockaddr_alg *to)
+{
+ int ret;
+
+ DEBUGASSERT(handle != NULL && req != NULL);
+
+ /* Dispatch the NETLINK_CRYPTO request according to its nlmsg_type */
+
+ switch (req->nlmsg_type)
+ {
+ case CRYPTO_MSG_NEWALG:
+ {
+ FAR const struct crypto_msg_newalg_request_s *newalg =
+ (FAR const struct crypto_msg_newalg_request_s *)req;
+
+ if (reqlen < sizeof(struct crypto_msg_newalg_request_s))
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = crypto_newalg_request(handle, newalg, reqlen, to);
+ }
+ }
+ break;
+
+ case CRYPTO_MSG_DELALG:
+ {
+ FAR const struct crypto_msg_delalg_request_s *delalg =
+ (FAR const struct crypto_msg_delalg_request_s *)req;
+
+ if (reqlen < sizeof(struct crypto_msg_delalg_request_s))
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = crypto_delalg_request(handle, delalg, reqlen, to);
+ }
+ }
+ break;
+
+ case CRYPTO_MSG_UPDATEALG:
+ {
+ FAR const struct crypto_msg_updatealg_request_s *updatealg =
+ (FAR const struct crypto_msg_updatealg_request_s *)req;
+
+ if (reqlen < sizeof(struct crypto_msg_updatealg_request_s))
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = crypto_updatealg_request(handle, updatealg, reqlen, to);
+ }
+ }
+ break;
+
+ case CRYPTO_MSG_GETALG:
+ {
+ FAR const struct crypto_msg_getalg_request_s *getalg =
+ (FAR const struct crypto_msg_getalg_request_s *)req;
+
+ if (reqlen < sizeof(struct crypto_msg_getalg_request_s))
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = crypto_getalg_request(handle, getalg, reqlen, to);
+ }
+ }
+ break;
+
+ case CRYPTO_MSG_DELRNG:
+ {
+ FAR const struct crypto_msg_delrng_request_s *delrng =
+ (FAR const struct crypto_msg_delrng_request_s *)req;
+
+ if (reqlen < sizeof(struct crypto_msg_delrng_request_s))
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = crypto_delrng_request(handle, delrng, reqlen, to);
+ }
+ }
+ break;
+
+ case CRYPTO_MSG_GETSTAT:
+ {
+ FAR const struct crypto_msg_getstat_request_s *getstat =
+ (FAR const struct crypto_msg_getstat_request_s *)req;
+
+ if (reqlen < sizeof(struct crypto_msg_getstat_request_s))
+ {
+ ret = -EINVAL;
+ }
+ else
+ {
+ ret = crypto_getstat_request(handle, getstat, reqlen, to);
+ }
+ }
+ break;
+
+ default:
+ {
+ nerr("ERROR: Invalid nlmsg_type: %u\n", req->nlmsg_type);
+ ret = -EINVAL;
+ }
+ break;
+ }
+
+ return ret;
+}
diff --git a/crypto/crypto_netlink.h b/crypto/crypto_netlink.h
new file mode 100644
index 0000000..c9b5d51
--- /dev/null
+++ b/crypto/crypto_netlink.h
@@ -0,0 +1,146 @@
+/****************************************************************************
+ * crypto/crypto_netlink.h
+ * Describes NETLINK_CRYPTO messaging
+ *
+ * Copyright (C) 2019 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __CRYPTO_CRYPTO_NETLINK_H
+#define __CRYPTO_CRYPTO_NETLINK_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <netpacket/netlink.h>
+#include <nuttx/net/netlink.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/* Request Message Structures */
+
+struct crypto_msg_newalg_request_s
+{
+ struct nlmsghdr hdr; /* nlmsg_type = CRYPTO_MSG_NEWALG */
+ struct crypto_user_alg alg;
+};
+
+struct crypto_msg_delalg_request_s
+{
+ struct nlmsghdr hdr; /* nlmsg_type = CRYPTO_MSG_DELALG */
+ struct crypto_user_alg alg;
+};
+
+struct crypto_msg_updatealg_request_s
+{
+ struct nlmsghdr hdr; /* nlmsg_type = CRYPTO_MSG_UPDATEALG */
+ struct crypto_user_alg alg;
+};
+
+struct crypto_msg_getalg_request_s
+{
+ struct nlmsghdr hdr; /* nlmsg_type = CRYPTO_MSG_GETALG */
+ struct crypto_user_alg alg;
+};
+
+struct crypto_msg_delrng_request_s
+{
+ struct nlmsghdr hdr; /* nlmsg_type = CRYPTO_MSG_DELRNG */
+};
+
+struct crypto_msg_getstat_request_s
+{
+ struct nlmsghdr hdr; /* nlmsg_type = CRYPTO_MSG_GETSTAT */
+ struct crypto_user_alg alg;
+};
+
+/* Response message structures */
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: crypto_*alg_request
+ *
+ * Description:
+ * The is a set of messages handlers that are required to provide the
+ * response to each NETLINK_CRYPTO request message.
+ *
+ * If successfully, each function will create the appropriate response
+ * message and queue that message via a call to netlink_add_response().
+ * That call may be synchronous with the call to the response handler
+ * or may occur sometime later asynchronously.
+ *
+ * Input Parameters:
+ * handle - A handle for use in subsequent calls to netlink_add_response()
+ * when the response to the request is available.
+ * req - A reference received request.
+ * reqlen - The size of the received request. This size is guaranteed by
+ * the message dispatcher to be at least as large as the type
+ * refereed to by the 'req' parameter.
+ *
+ * Returned Value
+ * Zero is returned on success meaning that the response was successfully
+ * processed. In this case, a response has been or will be generated. In
+ * the event of an error, a negated errno value will be returned.
+ *
+ ****************************************************************************/
+
+int crypto_newalg_request(NETLINK_HANDLE handle,
+ FAR const struct crypto_msg_newalg_request_s *req,
+ size_t reqlen, FAR const struct sockaddr_alg *to);
+int crypto_delalg_request(NETLINK_HANDLE handle,
+ FAR const struct crypto_msg_delalg_request_s *req,
+ size_t reqlen, FAR const struct sockaddr_alg *to);
+int crypto_updatealg_request(NETLINK_HANDLE handle,
+ FAR const struct crypto_msg_updatealg_request_s *req,
+ size_t reqlen, FAR const struct sockaddr_alg *to);
+int crypto_getalg_request(NETLINK_HANDLE handle,
+ FAR const struct crypto_msg_getalg_request_s *req,
+ size_t reqlen, FAR const struct sockaddr_alg *to);
+int crypto_delrng_request(NETLINK_HANDLE handle,
+ FAR const struct crypto_msg_delrng_request_s *req,
+ size_t reqlen, FAR const struct sockaddr_alg *to);
+int crypto_getstat_request(NETLINK_HANDLE handle,
+ FAR const struct crypto_msg_getstat_request_s *req,
+ size_t reqlen, FAR const struct sockaddr_alg *to);
+
+#endif /* __CRYPTO_CRYPTO_NETLINK_H */
diff --git a/include/nuttx/crypto/crypto_netlink.h b/include/nuttx/crypto/crypto_netlink.h
new file mode 100644
index 0000000..10b5ada
--- /dev/null
+++ b/include/nuttx/crypto/crypto_netlink.h
@@ -0,0 +1,81 @@
+/****************************************************************************
+ * include/nuttx/crypto/crypto_netlink.h
+ * Describes Netlink interface between the socket layer and the crypto
+ * subsystem.
+ *
+ * Copyright (C) 2019 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __INCLUDE_NUTTX_CRYPTO_CRYPTO_NETLINK_H
+#define __INCLUDE_NUTTX_CRYPTO_CRYPTO_NETLINK_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <netpacket/netlink.h>
+#include <nuttx/net/netlink.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: crypto_request_handler
+ *
+ * Description:
+ * This function receives the raw NETLINK_CRYPTO request and provides that
+ * request to the appropriate handler.
+ *
+ * Input Parameters:
+ * handle - A handle for use in subsequent calls to netlink_add_response()
+ * when the response to the request is available.
+ * req - A reference to the common header of the Netlink messages.
+ * This may be cast to the specific message type associated with
+ * the decoded Netlink messages.
+ * reqlen - The full length of the request 'req'
+ * to - The destination address for bound sockets.
+ *
+ * Returned Value
+ * Zero is returned on success meaning that the response was successfully
+ * processed. In this case, a response has been or will be generated. In
+ * the event of an error, a negated errno value will be returned.
+ *
+ ****************************************************************************/
+
+int crypto_request_handler(NETLINK_HANDLE handle,
+ FAR const struct nlmsghdr *req, size_t reqlen,
+ FAR const struct sockaddr_alg *to);
+
+#endif /* __INCLUDE_NUTTX_CRYPTO_CRYPTO_NETLINK_H */
diff --git a/net/netlink/netlink_crypto.c b/net/netlink/netlink_crypto.c
new file mode 100644
index 0000000..45b6551
--- /dev/null
+++ b/net/netlink/netlink_crypto.c
@@ -0,0 +1,193 @@
+/****************************************************************************
+ * net/netlink/netlink_crypto.c
+ *
+ * Copyright (C) 2019 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <gn...@nuttx.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <string.h>
+#include <assert.h>
+#include <errno.h>
+
+#include <nuttx/kmalloc.h>
+#include <nuttx/crypto/crypto_netlink.h>
+
+#include "netlink/netlink.h"
+
+#ifdef CONFIG_NETLINK_CRYPTO
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+/* Helpers ******************************************************************/
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: netlink_crypto_sendto()
+ *
+ * Description:
+ * Perform the sendto() operation for the NETLINK_CRYPTO protocol.
+ *
+ ****************************************************************************/
+
+ssize_t netlink_crypto_sendto(FAR struct socket *psock,
+ FAR const struct nlmsghdr *nlmsg,
+ size_t len, int flags,
+ FAR const struct sockaddr_alg *to,
+ socklen_t tolen)
+{
+ int ret;
+
+ DEBUGASSERT(psock != NULL && nlmsg != NULL &&
+ nlmsg->nlmsg_len >= sizeof(struct nlmsghdr) &&
+ len >= sizeof(struct nlmsghdr) &&
+ len >= nlmsg->nlmsg_len && to != NULL &&
+ tolen >= sizeof(struct sockaddr_alg));
+
+ /* Message parsing is handled by the crypto subsystem.
+ */
+
+ ret = crypto_request_handler((NETLINK_HANDLE)psock, nlmsg, len, to);
+
+ /* On success, return the size of the request that was processed */
+
+ if (ret >= 0)
+ {
+ ret = len;
+ }
+
+ return ret;
+}
+
+/****************************************************************************
+ * Name: netlink_crypto_recvfrom()
+ *
+ * Description:
+ * Perform the recvfrom() operation for the NETLINK_CRYPTO protocol.
+ *
+ ****************************************************************************/
+
+ssize_t netlink_crypto_recvfrom(FAR struct socket *psock,
+ FAR struct nlmsghdr *nlmsg,
+ size_t len, int flags,
+ FAR struct sockaddr_alg *from)
+{
+ FAR struct netlink_response_s *entry;
+ ssize_t ret;
+
+ DEBUGASSERT(psock != NULL && nlmsg != NULL &&
+ len >= sizeof(struct nlmsghdr));
+
+ /* Find the response to this message. The return value */
+
+ entry = (FAR struct netlink_response_s *)netlink_tryget_response(psock);
+ if (entry == NULL)
+ {
+ /* No response is variable, but presumably, one is expected. Check
+ * if the socket has been configured for non-blocking operation.
+ * REVISIT: I think there needs to be some higher level logic to
+ * select Netlink non-blocking sockets.
+ */
+
+ if (_SS_ISNONBLOCK(psock->s_flags))
+ {
+ return -EAGAIN;
+ }
+
+ /* Wait for the response. This should always succeed. */
+
+ entry = (FAR struct netlink_response_s *)netlink_get_response(psock);
+ DEBUGASSERT(entry != NULL);
+ if (entry == NULL)
+ {
+ return -EPIPE;
+ }
+ }
+
+ if (len < entry->msg.nlmsg_len)
+ {
+ kmm_free(entry);
+ return -EMSGSIZE;
+ }
+
+ /* Handle the response according to the message type */
+
+ switch (entry->msg.nlmsg_type)
+ {
+#warning Missing logic
+ case ???:
+ {
+ /* Return address. REVISIT... this is just a guess. */
+
+ if (from != NULL)
+ {
+#warning Missing logic
+ }
+
+ /* The return value is the payload size, i.e., the */
+
+ ret = entry->msg.nlmsg_len;
+ }
+ break;
+
+ default:
+ nerr("ERROR: Unrecognized message type: %u\n",
+ entry->msg.nlmsg_type);
+ ret = -EIO;
+ break;
+ }
+
+ kmm_free(entry);
+ return ret;
+}
+
+#endif /* CONFIG_NETLINK_CRYPTO */