This now a complete working DHCP server and Web server here
, but I don't want to leave it there permanently - it's my music website!Just a small update
- I'd left in some duplicate code. It wasn't doing any harm - but wasn't doing any good either, so it's removed and a bit of memory gained. Link above goes to the new code.
The DVCP server is derived from Nebster's code and the web server from the example in the ethernet library.
This might just squeeze into an atmega168. It will comfortably fit into a 328 and beyond. There are a lot of debugging messages available if you uncomment 'debug', but then it probably won't fit in a 128.
Most of what you might need should be there, but there is more than could be added. Please try this out being called from clients on different OSs as I found a few curiosities connected with auto-connect systems
I've re-arranged memory handling to correct some errors and reduce the requirements as much as I can, but I'm not a memory guru so there may be things that are technically 'wrong' and/or could be improved.
I've also done things like moving the magic cookie out of the OPT part of the structure. It's still in the same place in the data, but makes stepping through the options easier and less error prone.
I've removed the memory check routine completely. It wasn't giving the correct results (something to do with how flash memory is accessed?) and actually caused some obscure crashes.
Lease time has been set very short (10 minutes) this was just to check that it will re-apply. I don't really know how to test this fully.
Dynamic IP is still not implemented, but I think it shouldn't be too difficult to do a basic version. I think the only info you actually must
store over successive calls is the clients mac address and any previous IP you've given it.
There are also a couple of input buttons, that can be used to make the arduino switch things off and on etc. The way I've done this is a bit of a cheat and doesn't use POST the way your supposed to, but I think it's reasonably error-trapped and sort of legal
I've tried it with several different browsers and only Konqueror had a problem - it could send data but wouldn't display the data fetches for some reason.
Almost all the webpage data is held in PROGMEM. Just a few computed values are in 'real' memory. This makes a dramatic difference to how much you can do
Well it isn't there yet but I think the icing on the cake would be to add a basic DNS server so you can just plug in your lappy and call the arduino by name. Anyone want to help with that?