Simple DHCP server

stemora wrote on Thursday, July 26, 2018:

Hi all,
I’m trying to write a simple DHCP server, starting from the client one, for an ARM micro.
I’ve directly connected the board with a PC that acts as client.
I’m listening on DHCP server port and after a while a receive the DISCOVERY packet.
So i build the OFFER packet and I sent it.
The problem is that if I sent the packet to broadcast I see the packet on Wireshark but the client doesn’t reply with REQUEST packet.
If I sent it to the (new) IP address, I don’t see the packet on Wireshark … why ??

In the meantime maybe i undestand why the client did not reply: on the OFFER packet I see on the ‘Ethernet II Dst’ field the broacast value for the MAC address instead of the client MAC address…
How can I force the client MAC address ??
The FREERTOS_sendto() is sending a payload from a buffer …
(I’m using a copy of the functions for the DHCP client).

Thanks!

heinbali01 wrote on Friday, July 27, 2018:

Maybe you can tell your IP-stack to bind between a MAC-address with the target IP-address:

    void vARPRefreshCacheEntry( const MACAddress_t * pxMACAddress, const uint32_t ulIPAddress );

Remember that the IP-address must be provided in the network order, which is MSB first.

I think that after this, it will be possible to send the OFFER reply using sendto().