From 912ece4c3dd486bcd62f0d0dfee760b9f01caac6 Mon Sep 17 00:00:00 2001 From: Philippe Reynes Date: Fri, 18 Sep 2020 14:13:02 +0200 Subject: sntp: use udp framework This commits update the support of sntp to use the framework udp. This change allows to remove all the reference to sntp in the main network file net/net.c. Signed-off-by: Philippe Reynes Reviewed-by: Simon Glass --- net/sntp.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'net/sntp.c') diff --git a/net/sntp.c b/net/sntp.c index 39d7664a224..d5d56719331 100644 --- a/net/sntp.c +++ b/net/sntp.c @@ -12,12 +12,17 @@ #include #include -#include "sntp.h" +#include #define SNTP_TIMEOUT 10000UL static int sntp_our_port; +/* NTP server IP address */ +struct in_addr net_ntp_server; +/* offset time from UTC */ +int net_ntp_time_offset; + static void sntp_send(void) { struct sntp_pkt_t pkt; @@ -93,7 +98,25 @@ static void sntp_handler(uchar *pkt, unsigned dest, struct in_addr sip, net_set_state(NETLOOP_SUCCESS); } -void sntp_start(void) +/* + * SNTP: + * + * Prerequisites: - own ethernet address + * - own IP address + * We want: - network time + * Next step: none + */ +int sntp_prereq(void *data) +{ + if (net_ntp_server.s_addr == 0) { + puts("*** ERROR: NTP server address not given\n"); + return 1; + } + + return 0; +} + +int sntp_start(void *data) { debug("%s\n", __func__); @@ -102,4 +125,6 @@ void sntp_start(void) memset(net_server_ethaddr, 0, sizeof(net_server_ethaddr)); sntp_send(); + + return 0; } -- cgit