casaroli commented on code in PR #21881:
URL: https://github.com/apache/nuttx/pull/21881#discussion_r4665497524


##########
include/sys/socket.h:
##########
@@ -180,69 +181,63 @@
                             * (get/set) arg: pointer to integer containing a
                             * boolean value
                             */
-#define SO_TIMESTAMPNS   8 /* Generates a timestamp in ns for each incoming 
packet
-                            * arg: integer value
+#define SO_RCVBUF        8 /* Sets receive buffer size.
+                            * arg: integer value (get/set).
                             */
-#define SO_TIMESTAMPING  9 /* Generates timestamp for each output packet
+#define SO_RCVLOWAT      9 /* 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
                             * amount of time an input function waits until it
                             * completes (get/set).
                             * arg: struct timeval
                             */
-#define SO_SNDTIMEO     11 /* 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_PROTOCOL   11 /* 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     65 /* Sets the minimum number of bytes to process for
-                            * socket input (get/set).
-                            * arg: integer value
+#define SO_REUSEADDR    11 /* Allow reuse of local addresses (get/set)
+                            * arg: pointer to integer containing a boolean
+                            * value
                             */
-#define SO_SNDBUF       66 /* Sets send buffer size (get/set).
+#define SO_SNDBUF       12 /* Sets send buffer size (get/set).
                             * arg: integer value
                             */
-#define SO_SNDLOWAT     67 /* Sets the minimum number of bytes to process for
+#define SO_SNDLOWAT     13 /* Sets the minimum number of bytes to process for
                             * socket output (get/set).
                             * arg: integer value
                             */
-#define SO_TYPE         68 /* Reports the socket type (get only).
+#define SO_SNDTIMEO     14 /* 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).
                             * return: int
                             */
-#define SO_ERROR        69 /* Reports and clears error status (get only).
-                            * arg: returns an integer value
+#define SO_TIMESTAMP    16 /* Generates a timestamp in us for each incoming 
packet
+                            * arg: integer value
                             */
-#define SO_BINDTODEVICE 70 /* Bind this socket to a specific network device.
+#define SO_BINDTODEVICE 17 /* Bind this socket to a specific network device.
                             */
-#define SO_PEERCRED     71 /* Return the credentials of the peer process
+#define SO_PEERCRED     18 /* Return the credentials of the peer process
                             * connected to this socket.
                             */
-#define SO_PRIORITY     72 /* 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_PRIORITY     19 /* Set priority for packets */
+#define SO_TIMESTAMPNS  20 /* Generates a timestamp in ns for each incoming 
packet
+                            * arg: integer value
                             */
-#define SO_ACCEPTCONN   73 /* Reports whether socket listening is enabled
-                            * (get only).
-                            * arg: pointer to integer containing a boolean
-                            * value
+#define SO_TIMESTAMPING 21 /* Generates timestamp for each output packet
                             */
-#define SO_SNDBUFFORCE  74
-#define SO_RCVBUFFORCE  75
-#define SO_RXQ_OVFL     76
+
+/* Protocol-level socket options may begin with this value */
+
+#define __SO_PROTOCOL   22

Review Comment:
   `__SO_PROTOCOL` is 22 here. It was 16 before #20713 (nuttx-13.1.0), and the 
Rust libc crate also uses 16. So the options based on it change again: 
`TCP_NODELAY` is 22 (Rust passes 16), `IP_TTL` is 36 (Rust passes 30), and the 
Rust `IPV6_V6ONLY` (23) is now `IPV6_JOIN_GROUP`. The PR body says 
`__SO_PROTOCOL = 16` and that `TCP_NODELAY` (16) and `IP_TTL` (30) match Rust, 
but the commit message says 22.
   
   Fix: keep `__SO_PROTOCOL` at 16, as in 13.1.0, and put the `s_options` bits 
of the protocol-level options where they do not overlap `SO_TIMESTAMP`, 
`SO_TIMESTAMPNS` and `SO_TIMESTAMPING` (bits 16, 20, 21). Or, if 22 is what you 
want, say in the body and the commit message that all protocol-level values 
change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to