Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dhcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& tr

while (_dhcpUdpSocket.available() > 0)
{
switch (_dhcpUdpSocket.read())
//PAH save the byte for later
unsigned char sread = _dhcpUdpSocket.read();
switch (sread)
{
case endOption :
break;
Expand Down Expand Up @@ -370,6 +372,8 @@ uint8_t DhcpClass::parseDHCPResponse(unsigned long responseTimeout, uint32_t& tr
}
break;
}
//PAH break from the loop if endOption was read
if(sread == endOption)break;
}
}

Expand Down
13 changes: 7 additions & 6 deletions Dhcp.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,13 @@ class DhcpClass {
private:
uint32_t _dhcpInitialTransactionId;
uint32_t _dhcpTransactionId;
uint8_t _dhcpMacAddr[6];
uint8_t _dhcpLocalIp[4];
uint8_t _dhcpSubnetMask[4];
uint8_t _dhcpGatewayIp[4];
uint8_t _dhcpDhcpServerIp[4];
uint8_t _dhcpDnsServerIp[4];
//PAH force alignment to 4 bytes for 32-bit processors
uint8_t _dhcpMacAddr[6] __attribute__ ((aligned (4)));
uint8_t _dhcpLocalIp[4] __attribute__ ((aligned (4)));
uint8_t _dhcpSubnetMask[4] __attribute__ ((aligned (4)));
uint8_t _dhcpGatewayIp[4] __attribute__ ((aligned (4)));
uint8_t _dhcpDhcpServerIp[4] __attribute__ ((aligned (4)));
uint8_t _dhcpDnsServerIp[4] __attribute__ ((aligned (4)));
uint32_t _dhcpLeaseTime;
uint32_t _dhcpT1, _dhcpT2;
signed long _renewInSec;
Expand Down
3 changes: 2 additions & 1 deletion utility/util.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef UTIL_H
#define UTIL_H

#define htons(x) ( ((x)<<8) | (((x)>>8)&0xFF) )
//PAH - Add & 0xff00 so that it works on 32-bit processors
#define htons(x) ( (((x)<<8) & 0xff00) | (((x)>>8)&0xFF) )
#define ntohs(x) htons(x)

#define htonl(x) ( ((x)<<24 & 0xFF000000UL) | \
Expand Down