[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] [patch #8361] Add support for NTP option in DHCP
From: |
Claudius Zingerli |
Subject: |
[lwip-devel] [patch #8361] Add support for NTP option in DHCP |
Date: |
Wed, 26 Feb 2014 13:28:22 +0000 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Firefox/24.0 |
URL:
<http://savannah.nongnu.org/patch/?8361>
Summary: Add support for NTP option in DHCP
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: zeuz
Submitted on: Wed 26 Feb 2014 01:28:20 PM GMT
Category: DHCP
Priority: 5 - Normal
Status: None
Privacy: Public
Assigned to: None
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Planned Release: None
_______________________________________________________
Details:
I added support for the NTP Server option in the DHCP request.
It is enabled if USE_DHCP_NTP is set to 1 in the config file. It requests up
to NTP_MAX_SERVERS (default: 2) IP addresses for NTP servers. It does not
support host names yet.
(Below is a diff of the original source tree () and my version. I have changed
more than just NTP support and removed the other changes from the diff file as
far as possible (Not so in opt.h, to not change line numbers))
diff -rwd v1.4.1/src/core/dhcp.c v1.4.1orig/src/core/dhcp.c
124,125c124
< #define DHCP_OPTION_IDX_NTP_SERVER 8
< #define DHCP_OPTION_IDX_DNS_SERVER 9
---
> #define DHCP_OPTION_IDX_DNS_SERVER 8
306,308d304
< #if LWIP_DHCP_NTP
< dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 5/*num
options*/);
< #else
310d305
< #endif
315,317d309
< #if LWIP_DHCP_NTP
< dhcp_option_byte(dhcp, DHCP_OPTION_NTP);
< #endif
519c511
< #if LWIP_DNS || LWIP_DHCP_NTP
---
> #if LWIP_DNS
526,531d517
< #if LWIP_DHCP_NTP
< for (n=0;n<NTP_MAX_SERVERS;++n)
< {
< ip_addr_set_zero(&dhcp->ntp_ip_addr[n]);
< }
< #endif
582,589d567
< #if LWIP_DHCP_NTP
< n = 0;
< while(dhcp_option_given(dhcp, DHCP_OPTION_IDX_NTP_SERVER + n) && (n <
NTP_MAX_SERVERS)) {
< ip4_addr_set_u32(&(dhcp->ntp_ip_addr[n]),
htonl(dhcp_get_option_value(dhcp, DHCP_OPTION_IDX_NTP_SERVER + n)));
< n++;
< }
< #endif
<
910,912d887
< #if LWIP_DHCP_NTP
< dhcp_option(dhcp, DHCP_OPTION_PARAMETER_REQUEST_LIST, 5/*num
options*/);
< #else
914d888
< #endif
919,921c893
< #if LWIP_DHCP_NTP
< dhcp_option_byte(dhcp, DHCP_OPTION_NTP);
< #endif
---
>
1450,1455d1421
< break;
< case(DHCP_OPTION_NTP):
< LWIP_ERROR("len == 4", len % 4 == 0, return ERR_VAL;);
< decode_len = LWIP_MIN(len, 4 * DNS_MAX_SERVERS);
< LWIP_ERROR("len >= decode_len", len >= decode_len, return
ERR_VAL;);
< decode_idx = DHCP_OPTION_IDX_NTP_SERVER;
diff -rwd v1.4.1/src/include/lwip/dhcp.h v1.4.1orig/src/include/lwip/dhcp.h
56,58d55
< #if LWIP_DHCP_NTP
< ip_addr_t ntp_ip_addr[NTP_MAX_SERVERS];
< #endif
210d206
< #define DHCP_OPTION_NTP 42
diff -rwd v1.4.1/src/include/lwip/opt.h v1.4.1orig/src/include/lwip/opt.h
48,51d47
< //Use hardware based random number generator.
< #ifndef LWIP_USE_HW_RAND
< #define LWIP_USE_HW_RAND 0
< #endif
696,712d691
< #ifndef LWIP_DHCP_NTP
< #define LWIP_DHCP_NTP 0
< #endif
<
< /* The maximum of NTP servers parsed from DHCP response*/
< #ifndef NTP_MAX_SERVERS
< #define NTP_MAX_SERVERS 2
< #endif
<
< /**
< * NTP_DEBUG: Enable debugging in NTP_Task.c.
< */
< #ifndef NTP_DEBUG
< #define NTP_DEBUG LWIP_DBG_OFF
< #endif
<
<
_______________________________________________________
Reply to this item at:
<http://savannah.nongnu.org/patch/?8361>
_______________________________________________
Message sent via/by Savannah
http://savannah.nongnu.org/
- [lwip-devel] [patch #8361] Add support for NTP option in DHCP,
Claudius Zingerli <=