CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

DHCP and Webserver implementation - help!

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
thefloyd



Joined: 02 Sep 2009
Posts: 46

View user's profile Send private message

DHCP and Webserver implementation - help!
PostPosted: Wed Nov 14, 2012 10:27 am     Reply with quote

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..
temtronic



Joined: 01 Jul 2010
Posts: 9162
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Wed Nov 14, 2012 12:34 pm     Reply with quote

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
thefloyd



Joined: 02 Sep 2009
Posts: 46

View user's profile Send private message

PostPosted: Wed Nov 14, 2012 12:38 pm     Reply with quote

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
bkamen



Joined: 07 Jan 2004
Posts: 1611
Location: Central Illinois, USA

View user's profile Send private message

PostPosted: Thu Nov 15, 2012 3:01 am     Reply with quote

If you want the "standard" in DHCP, you should go to http://www.isc.org/software/dhcp.

Additionally, you should download RFC 2131 http://www.ietf.org/rfc/rfc2131.txt (and possible 2132).

As for HTTP, you can look to the RFC here as well, http://tools.ietf.org/html/rfc2616 and for the de facto standard, www.apache.org.

For PIC implementations, you can also download the free microchip library that already implements BOTH... (although it won't compile in CCS)
http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&nodeId=2680&dDocName=en537041

But at least you have example PIC C code.

Cheers,

-Ben
_________________
Dazed and confused? I don't think so. Just "plain lost" will do. :D
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group