Mark, we've run into a problem using DHCP with a relay agent. The DHCP server is located on another subnet, so the broadcast request must go through a relay agent. When using this setup, our customer said all the parameters would get set except the IP. He gave us a Wireshark log of the problem, and we were able to fix it by commenting out the check (uMemcmp(ucDHCP_SERVER_IP, ucIP, IPV4_LENGTH)) in fnDHCPListner() . Being the incoming IP from the relay agent will be different than the DHCP server IP. it would fail.
John
// The UDP listner function for DHCP port
//
static int fnDHCPListner(USOCKET SocketNr, unsigned char ucEvent, unsigned char *ucIP, unsigned short usPortNr, unsigned char *data, unsigned short usLength)
{
|
|
/* check magic cookie */
if (uMemcmp(data, ucMagicCookie_and_message, MAGIC_COOKIE_LENGTH)) return BAD_MAGIC_COOKIE; // magic cookie is bad - quit
data += MAGIC_COOKIE_LENGTH;
FIX if (ucDHCP_state == DHCP_STATE_REQUESTING) { // we do this check here simply to avoid having to pass parameters
---->>>> if ( /*** (uMemcmp(ucDHCP_SERVER_IP, ucIP, IPV4_LENGTH)) || ***/ (uMemcmp(usOfferedIP, ucDHCP_IP, IPV4_LENGTH))) {
return FOREIGN_DHCP_PACKET; // server or requested IP not same
}
}
// the initial checks were successful - now we do state specific stuff
return (fnDoRxDHCP(data, usOfferedIP, (unsigned short)(usLength + UDP_HLEN - (3 + 8 + XID_LENGTH + IPV4_LENGTH + 216))));
}
return 0;
}