You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ar...@apache.org on 2026/10/20 12:39:19 UTC
(nuttx) 01/04: net: adjust the option sort of level SOL_SOCKET
This is an automated email from the ASF dual-hosted git repository.
anchao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 09f0300894fc06eccce1fcd299a47985efd58383
Author: dongjiuzhu1 <do...@xiaomi.com>
AuthorDate: Wed Dec 3 17:54:39 2025 +0800
net: adjust the option sort of level SOL_SOCKET
Adjust the order of all options where the level is SOL_SOCKET. If an
option occupies a bit in socket_conn_s:s_options, place it at the front.
This is to save bits for options of other levels and prevent the 32-bit
overflow of socket_conn_s:s_options.
The definition of many options for other levels uses _SO_PROTOCOL as the
base value. If _SO_PROTOCOL is relatively small, more bits will be left
for options of other levels. Before adjustment, there were 16 bits
available; after adjustment, this number has increased to 23 bits.
Signed-off-by: dongjiuzhu1 <do...@xiaomi.com>
---
include/sys/socket.h | 73 ++++++++++++++++++++++++++++------------------------
1 file changed, 40 insertions(+), 33 deletions(-)
diff --git a/include/sys/socket.h b/include/sys/socket.h
index 6471fdc2f0a..fd3ddfee8cc 100644
--- a/include/sys/socket.h
+++ b/include/sys/socket.h
@@ -146,8 +146,7 @@
/* Socket-level options */
-#define SO_ACCEPTCONN 0 /* Reports whether socket listening is enabled
- * (get only).
+#define SO_REUSEADDR 0 /* Allow reuse of local addresses (get/set)
* arg: pointer to integer containing a boolean
* value
*/
@@ -165,8 +164,8 @@
* arg: pointer to integer containing a boolean
* value
*/
-#define SO_ERROR 4 /* Reports and clears error status (get only).
- * arg: returns an integer value
+#define SO_TIMESTAMP 4 /* Generates a timestamp in us for each incoming packet
+ * arg: integer value
*/
#define SO_KEEPALIVE 5 /* Keeps connections active by enabling the periodic
* transmission of messages (get/set).
@@ -181,54 +180,69 @@
* (get/set) arg: pointer to integer containing a
* boolean value
*/
-#define SO_RCVBUF 8 /* Sets receive buffer size.
+#define SO_TIMESTAMPNS 8 /* Generates a timestamp in ns for each incoming packet
+ * arg: integer value
+ */
+#define SO_TIMESTAMPING 9 /* Generates timestamp for each output packet
+ */
+
+#define __SO_PROTOCOL 9 /* Protocol-level socket options may begin with this
+ * value. The current value is determined by the option
+ * in SOL_SOCKET that uses the highest bit, which
+ * is SO_TIMESTAMPNS
+ */
+
+/* Start from 64 to avoid redefinition with other protocol options. */
+
+#define SO_RCVBUF 64 /* Sets receive buffer size.
* arg: integer value (get/set).
*/
-#define SO_RCVLOWAT 9 /* Sets the minimum number of bytes to process for
+#define SO_RCVLOWAT 65 /* Sets the minimum number of bytes to process for
* socket input (get/set).
* arg: integer value
*/
-#define SO_RCVTIMEO 10 /* Sets the timeout value that specifies the maximum
+#define SO_RCVTIMEO 66 /* Sets the timeout value that specifies the maximum
* amount of time an input function waits until it
* completes (get/set).
* arg: struct timeval
*/
-#define SO_REUSEADDR 11 /* Allow reuse of local addresses (get/set)
- * arg: pointer to integer containing a boolean
- * value
- */
-#define SO_SNDBUF 12 /* Sets send buffer size (get/set).
+#define SO_SNDBUF 67 /* Sets send buffer size (get/set).
* arg: integer value
*/
-#define SO_SNDLOWAT 13 /* Sets the minimum number of bytes to process for
+#define SO_SNDLOWAT 68 /* Sets the minimum number of bytes to process for
* socket output (get/set).
* arg: integer value
*/
-#define SO_SNDTIMEO 14 /* Sets the timeout value specifying the amount of
+#define SO_SNDTIMEO 69 /* Sets the timeout value specifying the amount of
* time that an output function blocks because flow
* control prevents data from being sent(get/set).
* arg: struct timeval
*/
-#define SO_TYPE 15 /* Reports the socket type (get only).
+#define SO_TYPE 70 /* Reports the socket type (get only).
* return: int
*/
-#define SO_TIMESTAMP 16 /* Generates a timestamp in us for each incoming packet
- * arg: integer value
+#define SO_ERROR 71 /* Reports and clears error status (get only).
+ * arg: returns an integer value
*/
-#define SO_BINDTODEVICE 17 /* Bind this socket to a specific network device.
+#define SO_BINDTODEVICE 72 /* Bind this socket to a specific network device.
*/
-#define SO_PEERCRED 18 /* Return the credentials of the peer process
+#define SO_PEERCRED 73 /* Return the credentials of the peer process
* connected to this socket.
*/
-#define SO_TIMESTAMPNS 20 /* Generates a timestamp in ns for each incoming packet
- * arg: integer value
+#define SO_PRIORITY 74 /* Set the priority for all packets to be sent on this
+ * socket. Nuttx uses this value to order the
+ * networking queues: packets with a higher priority
+ * may be processed first depending on the selected
+ * device queueing discipline.
*/
-#define SO_TIMESTAMPING 21 /* Generates timestamp for each output packet
+#define SO_ACCEPTCONN 75 /* Reports whether socket listening is enabled
+ * (get only).
+ * arg: pointer to integer containing a boolean
+ * value
*/
-
-/* Protocol-level socket options may begin with this value */
-
-#define __SO_PROTOCOL 16
+#define SO_SNDBUFFORCE 76
+#define SO_RCVBUFFORCE 77
+#define SO_RXQ_OVFL 78
/* SO_TIMESTAMPING flags, with the same values as Linux so that they can
* also describe the capabilities of an interface (ETHTOOL_GET_TS_INFO).
@@ -249,13 +263,6 @@
#define SOF_TIMESTAMPING_SYS_HARDWARE (1 << 5)
#define SOF_TIMESTAMPING_RAW_HARDWARE (1 << 6)
-/* The options are unsupported but included for compatibility
- * and portability
- */
-#define SO_SNDBUFFORCE 32
-#define SO_RCVBUFFORCE 33
-#define SO_RXQ_OVFL 40
-
/* Protocol-level socket operations. */
#define SOL_IP IPPROTO_IP /* See options in include/netinet/in.h */