DHCP uses LWIP_RAND() for xid's (bug #30302)

This commit is contained in:
Simon Goldschmidt 2011-09-03 22:27:06 +02:00
parent a0bf8d5740
commit e27d34d118
2 changed files with 19 additions and 1 deletions

View File

@ -6,6 +6,9 @@ HISTORY
++ New features:
2011-09-03: Simon Goldschmidt
* dhcp.c: DHCP uses LWIP_RAND() for xid's (bug #30302)
2011-08-24: Simon Goldschmidt
* opt.h, netif.h/.c: added netif remove callback (bug #32397)

View File

@ -83,6 +83,13 @@
#include <string.h>
/** DHCP_CREATE_RAND_XID: if this is set to 1, the xid is created using
* LWIP_RAND() (this overrides DHCP_GLOBAL_XID)
*/
#ifndef DHCP_CREATE_RAND_XID
#define DHCP_CREATE_RAND_XID 1
#endif
/** Default for DHCP_GLOBAL_XID is 0xABCD0000
* This can be changed by defining DHCP_GLOBAL_XID and DHCP_GLOBAL_XID_HEADER, e.g.
* #define DHCP_GLOBAL_XID_HEADER "stdlib.h"
@ -1623,7 +1630,11 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type)
* with a packet analyser). We simply increment for each new request.
* Predefine DHCP_GLOBAL_XID to a better value or a function call to generate one
* at runtime, any supporting function prototypes can be defined in DHCP_GLOBAL_XID_HEADER */
#if DHCP_CREATE_RAND_XID && defined(LWIP_RAND)
static u32_t xid;
#else /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */
static u32_t xid = 0xABCD0000;
#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */
#else
if (!xid_initialised) {
xid = DHCP_GLOBAL_XID;
@ -1645,7 +1656,11 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type)
/* reuse transaction identifier in retransmissions */
if (dhcp->tries == 0) {
#if DHCP_CREATE_RAND_XID && defined(LWIP_RAND)
xid = LWIP_RAND();
#else /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */
xid++;
#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_RAND) */
}
dhcp->xid = xid;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE,