You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/08/26 08:00:28 UTC

[incubator-nuttx] 01/04: finetune the RA parsing procedure

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

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

commit 7c2986bb34f8334d5906a1bdefa02de7b00f3df0
Author: luojun1 <lu...@xiaomi.com>
AuthorDate: Thu Jul 28 21:53:58 2022 +0800

    finetune the RA parsing procedure
    
    Signed-off-by: luojun1 <lu...@xiaomi.com>
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 net/icmpv6/icmpv6_input.c | 60 ++++++++++++++++++++++++++++++-----------------
 1 file changed, 39 insertions(+), 21 deletions(-)

diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c
index 08272fe922..4684eb0f49 100644
--- a/net/icmpv6/icmpv6_input.c
+++ b/net/icmpv6/icmpv6_input.c
@@ -369,29 +369,47 @@ void icmpv6_input(FAR struct net_driver_s *dev, unsigned int iplen)
 
         for (ndx = 0; ndx + sizeof(struct icmpv6_prefixinfo_s) <= optlen; )
           {
-            FAR struct icmpv6_srclladdr_s *sllopt =
-              (FAR struct icmpv6_srclladdr_s *)&options[ndx];
+           FAR struct icmpv6_generic_s *opt =
+                                (FAR struct icmpv6_generic_s *)&options[ndx];
 
-            if (sllopt->opttype == ICMPv6_OPT_SRCLLADDR)
+            switch (opt->opttype)
               {
-                neighbor_add(dev, ipv6->srcipaddr, sllopt->srclladdr);
-              }
-
-            FAR struct icmpv6_prefixinfo_s *opt =
-              (FAR struct icmpv6_prefixinfo_s *)&options[ndx];
-
-            /* Is this the sought for prefix? Is it the correct size? Is
-             * the "A" flag set?
-             */
-
-            if (opt->opttype == ICMPv6_OPT_PREFIX &&
-               (opt->flags & ICMPv6_PRFX_FLAG_A) != 0)
-              {
-                /* Yes.. Notify any waiting threads */
-
-                icmpv6_rnotify(dev, ipv6->srcipaddr,
-                               opt->prefix, opt->preflen);
-                prefix = true;
+                case ICMPv6_OPT_SRCLLADDR:
+                  {
+                    FAR struct icmpv6_srclladdr_s *sllopt =
+                                      (FAR struct icmpv6_srclladdr_s *)opt;
+                    neighbor_add(dev, ipv6->srcipaddr, sllopt->srclladdr);
+                  }
+                  break;
+
+                case ICMPv6_OPT_PREFIX:
+                  {
+                    FAR struct icmpv6_prefixinfo_s *prefixopt =
+                                      (FAR struct icmpv6_prefixinfo_s *)opt;
+
+                    /* Is the "A" flag set? */
+
+                    if ((prefixopt->flags & ICMPv6_PRFX_FLAG_A) != 0)
+                      {
+                        /* Notify any waiting threads */
+
+                        icmpv6_rnotify(dev, ipv6->srcipaddr,
+                                    prefixopt->prefix, prefixopt->preflen);
+                        prefix = true;
+                      }
+                  }
+                  break;
+
+                case ICMPv6_OPT_MTU:
+                  {
+                    FAR struct icmpv6_mtu_s *mtuopt =
+                                        (FAR struct icmpv6_mtu_s *)opt;
+                    dev->d_pktsize = mtuopt->mtu;
+                  }
+                  break;
+
+                default:
+                  break;
               }
 
             /* Skip to the next option (units of octets) */