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 <philippe.reynes@softathome.com> Reviewed-by: Simon Glass <sjg@chromium.org>
This commit is contained in:

committed by
Tom Rini

parent
6b981a224e
commit
912ece4c3d
29
net/sntp.c
29
net/sntp.c
@@ -12,12 +12,17 @@
|
||||
#include <net.h>
|
||||
#include <rtc.h>
|
||||
|
||||
#include "sntp.h"
|
||||
#include <net/sntp.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user