finetune the RA parsing procedure
@@ -369,30 +369,48 @@ 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)
+ {
+ case ICMPv6_OPT_SRCLLADDR:
{
+ FAR struct icmpv6_srclladdr_s *sllopt =
+ (FAR struct icmpv6_srclladdr_s *)opt;
neighbor_add(dev, ipv6->srcipaddr, sllopt->srclladdr);
}
+ break;
- FAR struct icmpv6_prefixinfo_s *opt =
- (FAR struct icmpv6_prefixinfo_s *)&options[ndx];
+ case ICMPv6_OPT_PREFIX:
+ {
+ FAR struct icmpv6_prefixinfo_s *prefixopt =
+ (FAR struct icmpv6_prefixinfo_s *)opt;
- /* Is this the sought for prefix? Is it the correct size? Is
- * the "A" flag set?
- */
+ /* Is the "A" flag set? */
- if (opt->opttype == ICMPv6_OPT_PREFIX &&
- (opt->flags & ICMPv6_PRFX_FLAG_A) != 0)
+ if ((prefixopt->flags & ICMPv6_PRFX_FLAG_A) != 0)
{
- /* Yes.. Notify any waiting threads */
+ /* Notify any waiting threads */
icmpv6_rnotify(dev, ipv6->srcipaddr,
- opt->prefix, opt->preflen);
+ 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) */
