You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/10/01 19:20:29 UTC

[GitHub] [incubator-nuttx-apps] antmerlino commented on a change in pull request #415: Network Monitor: Runtime selection of DHCP/Static IP with fall back set by fsutil/ipcfg and a polled mode for HW lacking a PHY interrupt

antmerlino commented on a change in pull request #415:
URL: https://github.com/apache/incubator-nuttx-apps/pull/415#discussion_r498463703



##########
File path: netutils/netinit/netinit.c
##########
@@ -720,6 +867,80 @@ static int netinit_monitor(void)
             {
               /* The link is still up.  Take a long, well-deserved rest */
 
+#ifdef CONFIG_NETINIT_DHCPC
+              /* Get Current time */
+
+              DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &abstime));
+
+              /* Did we ever get a lease */
+#ifdef CONFIG_FSUTILS_IPCFG
+              if (g_ds.lease_time == 0 && (g_netconf.proto & BOOTPROTO_DHCP))
+#else
+              if (g_ds.lease_time == 0)
+#endif
+                {
+                  /* No so, let's try to bring up the network */
+
+                  netinit_net_bringup();
+
+                  /* Did we get a lease */
+
+                  if (g_ds.lease_time != 0)
+                    {
+                      /* Yes, set next renewal time */
+
+                      DEBUGVERIFY(clock_gettime(CLOCK_REALTIME, &dhcprenew));
+                      dhcprenew.tv_sec  += g_ds.lease_time / 2;
+                    }
+#if defined(USE_FALLBACK)
+                  else
+                    {
+                      if ((g_netconf.proto & BOOTPROTO_FALLBACK) ==
+                          BOOTPROTO_FALLBACK &&
+                          ++dhcp_fail_count > CONFIG_NETINIT_FALLBACK)
+                        {
+                          struct in_addr addr;
+                          g_netconf.proto &= ~BOOTPROTO_DHCP;

Review comment:
       @davids5 Will this create the desired behavior? I would think that if the cable gets unplugged, and then replugged in where DHCP may not fail, we'd want to use DHCP again. Right?  Perhaps I am seeing it wrong, but with the current logic, once you fallback to static once, that's it.  Is that the desired behavior?




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org