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/06/15 18:20:44 UTC
[incubator-nuttx] 01/03: net/can/can.h: Add can_setsockopt and
can_getsockopt prototypes.
This is an automated email from the ASF dual-hosted git repository.
gnutt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 155903fc54f4a04181f2d57075618646d3a4f885
Author: Ouss4 <ab...@gmail.com>
AuthorDate: Mon Jun 15 18:57:13 2020 +0100
net/can/can.h: Add can_setsockopt and can_getsockopt prototypes.
---
net/can/can.h | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
net/socket/getsockopt.c | 1 +
net/socket/setsockopt.c | 1 +
3 files changed, 65 insertions(+)
diff --git a/net/can/can.h b/net/can/can.h
index cae3eb4..2d8bcdd 100644
--- a/net/can/can.h
+++ b/net/can/can.h
@@ -376,6 +376,69 @@ ssize_t psock_can_sendmsg(FAR struct socket *psock, FAR struct msghdr *msg);
void can_readahead_signal(FAR struct can_conn_s *conn);
#endif
+/****************************************************************************
+ * Name: can_setsockopt
+ *
+ * Description:
+ * can_setsockopt() sets the CAN-protocol option specified by the
+ * 'option' argument to the value pointed to by the 'value' argument for
+ * the socket specified by the 'psock' argument.
+ *
+ * See <netinet/can.h> for the a complete list of values of CAN protocol
+ * options.
+ *
+ * Input Parameters:
+ * psock Socket structure of socket to operate on
+ * option identifies the option to set
+ * value Points to the argument value
+ * value_len The length of the argument value
+ *
+ * Returned Value:
+ * Returns zero (OK) on success. On failure, it returns a negated errno
+ * value to indicate the nature of the error. See psock_setcockopt() for
+ * the list of possible error values.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_CANPROTO_OPTIONS
+int can_setsockopt(FAR struct socket *psock, int option,
+ FAR const void *value, socklen_t value_len);
+#endif
+
+/****************************************************************************
+ * Name: can_getsockopt
+ *
+ * Description:
+ * can_getsockopt() retrieves the value for the option specified by the
+ * 'option' argument for the socket specified by the 'psock' argument. If
+ * the size of the option value is greater than 'value_len', the value
+ * stored in the object pointed to by the 'value' argument will be silently
+ * truncated. Otherwise, the length pointed to by the 'value_len' argument
+ * will be modified to indicate the actual length of the 'value'.
+ *
+ * See <sys/socket.h> a complete list of values for the socket-level
+ * 'option' argument. Protocol-specific options are are protocol specific
+ * header files (such as netpacket/can.h for the case of the CAN protocol).
+ *
+ * Input Parameters:
+ * psock Socket structure of the socket to query
+ * level Protocol level to set the option
+ * option identifies the option to get
+ * value Points to the argument value
+ * value_len The length of the argument value
+ *
+ * Returned Value:
+ * Returns zero (OK) on success. On failure, it returns a negated errno
+ * value to indicate the nature of the error. See psock_getsockopt() for
+ * the complete list of appropriate return error codes.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_NET_CANPROTO_OPTIONS
+int can_getsockopt(FAR struct socket *psock, int option,
+ FAR void *value, FAR socklen_t *value_len);
+#endif
+
#undef EXTERN
#ifdef __cplusplus
}
diff --git a/net/socket/getsockopt.c b/net/socket/getsockopt.c
index fb5f7c9..7f0d598 100644
--- a/net/socket/getsockopt.c
+++ b/net/socket/getsockopt.c
@@ -52,6 +52,7 @@
#include "tcp/tcp.h"
#include "usrsock/usrsock.h"
#include "utils/utils.h"
+#include "can/can.h"
/****************************************************************************
* Private Functions
diff --git a/net/socket/setsockopt.c b/net/socket/setsockopt.c
index da4b923..a5ab719 100644
--- a/net/socket/setsockopt.c
+++ b/net/socket/setsockopt.c
@@ -57,6 +57,7 @@
#include "udp/udp.h"
#include "usrsock/usrsock.h"
#include "utils/utils.h"
+#include "can/can.h"
/****************************************************************************
* Public Functions