You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by bt...@apache.org on 2020/12/05 18:45:03 UTC

[incubator-nuttx] branch master updated (bce576c -> e37001f)

This is an automated email from the ASF dual-hosted git repository.

btashton pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from bce576c  sched/sched/sched_waitid.c: Discard the child entry
     new 4af687b  net/igmp: add MULTICAST_TTL support
     new 5ad2c93  net/inet: fix nxstyle warnings
     new e37001f  net/setsockopt/IP_MULTICAST_TTL: add handles of different prototypes

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 net/inet/ipv4_setsockopt.c | 50 +++++++++++++++++++++++++++++++++++++---------
 1 file changed, 41 insertions(+), 9 deletions(-)


[incubator-nuttx] 01/03: net/igmp: add MULTICAST_TTL support

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 4af687b8c23b6775eaf9660076d2054055219a1e
Author: chao.an <an...@xiaomi.com>
AuthorDate: Thu Dec 3 13:53:50 2020 +0800

    net/igmp: add MULTICAST_TTL support
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 net/inet/ipv4_setsockopt.c | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/net/inet/ipv4_setsockopt.c b/net/inet/ipv4_setsockopt.c
index e1e21eb..b5bb7bc 100644
--- a/net/inet/ipv4_setsockopt.c
+++ b/net/inet/ipv4_setsockopt.c
@@ -51,6 +51,7 @@
 #include "netdev/netdev.h"
 #include "igmp/igmp.h"
 #include "inet/inet.h"
+#include "udp/udp.h"
 
 #ifdef CONFIG_NET_IPv4
 
@@ -184,12 +185,37 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
         }
         break;
 
+      case IP_MULTICAST_TTL:          /* Set/read the time-to-live value of
+                                       * outgoing multicast packets */
+        {
+          if (psock->s_type != SOCK_DGRAM ||
+              value_len != sizeof(int))
+            {
+              ret = -EINVAL;
+            }
+          else
+            {
+              FAR struct udp_conn_s *conn;
+              int ttl = *(FAR int *)value;
+
+              if (ttl <= 0 || ttl > 255)
+                {
+                  ret = -EINVAL;
+                }
+              else
+                {
+                  conn = (FAR struct udp_conn_s *)psock->s_conn;
+                  conn->ttl = ttl;
+                  ret = OK;
+                }
+            }
+        }
+        break;
+
       /* The following IPv4 socket options are defined, but not implemented */
 
       case IP_MULTICAST_IF:           /* Set local device for a multicast
                                        * socket */
-      case IP_MULTICAST_TTL:          /* Set/read the time-to-live value of
-                                       * outgoing multicast packets */
       case IP_MULTICAST_LOOP:         /* Set/read boolean that determines
                                        * whether sent multicast packets
                                        * should be looped back to local


[incubator-nuttx] 03/03: net/setsockopt/IP_MULTICAST_TTL: add handles of different prototypes

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit e37001f2694072dc6be5d7e406f22498148ea203
Author: chao.an <an...@xiaomi.com>
AuthorDate: Sat Dec 5 18:21:18 2020 +0800

    net/setsockopt/IP_MULTICAST_TTL: add handles of different prototypes
    
    Reference here:
    https://github.com/torvalds/linux/blob/b3298500b23f0b53a8d81e0d5ad98a29db71f4f0/net/ipv4/ip_sockglue.c#L923-L932
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 net/inet/ipv4_setsockopt.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)

diff --git a/net/inet/ipv4_setsockopt.c b/net/inet/ipv4_setsockopt.c
index 6c1ca94..7d08910 100644
--- a/net/inet/ipv4_setsockopt.c
+++ b/net/inet/ipv4_setsockopt.c
@@ -192,26 +192,28 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
       case IP_MULTICAST_TTL:          /* Set/read the time-to-live value of
                                        * outgoing multicast packets */
         {
+          FAR struct udp_conn_s *conn;
+          int ttl;
+
           if (psock->s_type != SOCK_DGRAM ||
-              value_len != sizeof(int))
+              value == NULL || value_len == 0)
+            {
+              ret = -EINVAL;
+              break;
+            }
+
+          ttl = (value_len >= sizeof(int)) ?
+            *(FAR int *)value : (int)*(FAR unsigned char *)value;
+
+          if (ttl <= 0 || ttl > 255)
             {
               ret = -EINVAL;
             }
           else
             {
-              FAR struct udp_conn_s *conn;
-              int ttl = *(FAR int *)value;
-
-              if (ttl <= 0 || ttl > 255)
-                {
-                  ret = -EINVAL;
-                }
-              else
-                {
-                  conn = (FAR struct udp_conn_s *)psock->s_conn;
-                  conn->ttl = ttl;
-                  ret = OK;
-                }
+              conn = (FAR struct udp_conn_s *)psock->s_conn;
+              conn->ttl = ttl;
+              ret = OK;
             }
         }
         break;


[incubator-nuttx] 02/03: net/inet: fix nxstyle warnings

Posted by bt...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

btashton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5ad2c931a3b4665591031bed6353dfbbf8904ac7
Author: chao.an <an...@xiaomi.com>
AuthorDate: Fri Nov 27 11:19:33 2020 +0800

    net/inet: fix nxstyle warnings
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 net/inet/ipv4_setsockopt.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/net/inet/ipv4_setsockopt.c b/net/inet/ipv4_setsockopt.c
index b5bb7bc..6c1ca94 100644
--- a/net/inet/ipv4_setsockopt.c
+++ b/net/inet/ipv4_setsockopt.c
@@ -91,9 +91,9 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
 
   ninfo("option: %d\n", option);
 
-  /* With IPv4, the multicast-related socket options are simply an alternative
-   * way to access IGMP.  That IGMP functionality can also be accessed via
-   * IOCTL commands (see netdev/netdev_ioctl.c)
+  /* With IPv4, the multicast-related socket options are simply an
+   * alternative way to access IGMP.  That IGMP functionality can also be
+   * accessed via IOCTL commands (see netdev/netdev_ioctl.c)
    *
    * REVISIT:  Clone the logic from netdev_ioctl.c here.
    */
@@ -120,7 +120,7 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
               dev = netdev_findby_lipv4addr(imsf->imsf_interface.s_addr);
               if (dev == NULL)
                 {
-                  nwarn("WARNING: Could not find device for imsf_interface\n");
+                  nwarn("WARNING: Could not find device\n");
                   ret = -ENODEV;
                 }
               else if (imsf->imsf_fmode == MCAST_INCLUDE)
@@ -155,7 +155,9 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
             }
           else
             {
-              /* Use the default network device is imr_interface is INADDRY_ANY. */
+              /* Use the default network device is imr_interface is
+               * INADDRY_ANY.
+               */
 
               if (mrec->imr_interface.s_addr == INADDR_ANY)
                 {
@@ -163,14 +165,16 @@ int ipv4_setsockopt(FAR struct socket *psock, int option,
                 }
               else
                 {
-                  /* Get the device associated with the local interface address */
+                  /* Get the device associated with the local interface
+                   * address
+                   */
 
                   dev = netdev_findby_lipv4addr(mrec->imr_interface.s_addr);
                 }
 
               if (dev == NULL)
                 {
-                  nwarn("WARNING: Could not find device for imr_interface\n");
+                  nwarn("WARNING: Could not find device\n");
                   ret = -ENODEV;
                 }
               else if (option == IP_ADD_MEMBERSHIP)