Setting NTP server address according to some conditions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting NTP server address according to some conditions

SciMan

Hi!

 

I’m using LWIP 2.0.3. In my code I have a static  NTP server address. But this address can be invalid or valid (depending what the user will write in it). If DHCP is enabled I want to reach the following behavior:

  • If the NTP server address is delivered via the DHCP, it will be set and used (it doesn’t matter what is the static address).
  • If the NTP server address is not delivered via the DHCP and the static NTP server address is invalid, the NTP will not be initialized.
  • If the NTP server address is not delivered, but the static NTP server address is valid, the NTP will be initialized and will use the static address.

To reach this, I need to decide what to do in the call of the function dhcp_set_ntp_address(). But there is no callback, so I cannot call my own code. How can I reach this behavior without modifying the original code of the stack (file sntp.c)?

 

Best regards!

SciMan


_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users
Reply | Threaded
Open this post in threaded view
|

Re: Setting NTP server address according to some conditions

goldsimon@gmx.de
Am 19.04.2019 um 09:33 schrieb [hidden email]:

> Hi!
>
> I’m using LWIP 2.0.3. In my code I have a static  NTP server address.
> But this address can be invalid or valid (depending what the user will
> write in it). If DHCP is enabled I want to reach the following behavior:
>
>   * If the NTP server address is delivered via the DHCP, it will be set
>     and used (it doesn’t matter what is the static address).
>   * If the NTP server address is not delivered via the DHCP and the
>     static NTP server address is invalid, the NTP will not be initialized.
>   * If the NTP server address is not delivered, but the static NTP
>     server address is valid, the NTP will be initialized and will use
>     the static address.
>
> To reach this, I need to decide what to do in the call of the function
> dhcp_set_ntp_address(). But there is no callback, so I cannot call my
> own code. How can I reach this behavior without modifying the original
> code of the stack (file sntp.c)?

This is open source development: post a patch that does what you want in
a portable way and we'll see if it can be added.

Regards,
Simon

_______________________________________________
lwip-users mailing list
[hidden email]
https://lists.nongnu.org/mailman/listinfo/lwip-users