View previous topic :: View next topic |
Author |
Message |
thefloyd
Joined: 02 Sep 2009 Posts: 46
|
DHCP and Webserver implementation - help! |
Posted: Wed Nov 14, 2012 10:27 am |
|
|
I'm hoping someone has some advice or examples to steer me in the right direction.
I've managed to code up reliable TCP & UDP communications using the Wiznet W5100 and Wiznet W5200 ICs (moreso the W5200, still tracking down some reliability issues with the W5100). It's taken me a while to get here, mostly because coding in C isn't my day job and I'm learning as I go along..
My next step is that I need to implement a web server and a DHCP client. I've got a very basic web server that grabs the request and stuffs it in a long character variable and serves a generic page up to the client, but I need to be able to do far more. I've taken a peek at the CCS port of the Microchip code stack for inspiration and ideas, but it seems very tied to the mchip hardware and stack and quite honestly it's all a bit confusing.
First thing is I need to do is take the received data and parse it. GET and POST requests need to be broken out and the key=value pairs need to be assigned to variables. Also need to serve up response pages with variables or options substituted within, based on some of that data I've parsed above. Manipulating strings in C is a bit confusing to me still, mostly from lack of experience.
Second is writing a DHCP implementation. I know this is a tall order, but I feel like it's not as tall as I make it out to be. I've got a UDP socket ready and waiting, so it's just writing the code to negotiate the lease and renew the lease when necessary. I feel like this is a mountain I can climb with some help.
Really, some concise and well commented code that I could follow and truly understand what it's doing would probably get me there. The problem is that none of the examples I've seen are well commented or easy to follow.. |
|
![](templates/subSilver/images/spacer.gif) |
temtronic
Joined: 01 Jul 2010 Posts: 9172 Location: Greensville,Ontario
|
|
Posted: Wed Nov 14, 2012 12:34 pm |
|
|
I just googled 'pic dhcp c code' and got a few hits and the first ,from codeforge, looked 'promising.Though written for microchip c it could be 'ported over' to ccs c and would be a great adition to the code library here.
hth
jay |
|
![](templates/subSilver/images/spacer.gif) |
thefloyd
Joined: 02 Sep 2009 Posts: 46
|
|
Posted: Wed Nov 14, 2012 12:38 pm |
|
|
thanks Jay. My google skills must be getting worse these days because I was struggling to find good code. I'll take a look tonight when I get home.
As soon as I clean up some of my w5x00 code I'll add it to the code library. Ditto if I can get the DHCP code ported over. Some of my code is downright ugly "let me see if putting this printf here tells me something useful" type of code so it's not ready for consumption just yet.. and I'm sure you seasoned pros can show me all of the mistakes I've made and optimizations I've missed ![Smile](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
bkamen
Joined: 07 Jan 2004 Posts: 1611 Location: Central Illinois, USA
|
|
![](templates/subSilver/images/spacer.gif) |
|