<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:10pt"><DIV></DIV>
<DIV>Thank you very much for your help.</DIV>
<DIV>I havent payed attention to the figure "State-transition diagram for DHCP clients" in rfc 2131 so that i didnt understand that. Your answer helped me much in reading the code. There are still some things that i haven't understood in the code. I'll try myself. If i will not be able, i'll ask for your helps.</DIV>
<DIV> </DIV>
<DIV>Best regards.</DIV>
<DIV>Cam Thach.</DIV>
<DIV><BR> </DIV>
<DIV><STRONG>DO Phan Cam Thach</STRONG></DIV>
<DIV>email: <A href="mailto:dophancamthach@yahoo.co.uk" target=_blank rel=nofollow>dophancamthach@yahoo.co.uk</A></DIV>
<DIV><BR></DIV>
<DIV style="FONT-SIZE: 10pt; FONT-FAMILY: times new roman, new york, times, serif"><BR>
<DIV style="FONT-SIZE: 13px; FONT-FAMILY: arial, helvetica, sans-serif">----- Original Message ----<BR>From: Ted Lemon <Ted.Lemon@nominum.com><BR>To: "dhcp-users@isc.org" <dhcp-users@isc.org><BR>Sent: Tuesday, 8 July, 2008 12:48:42 AM<BR>Subject: RE: Dont understand the main in the code of dhclient.c<BR><BR>> I have read the file dhclient.c, but i haven't found out where<BR>> and how the main calls the majors functions for making, sending<BR>> the messages DHCP like make_discover, send_discover,... or for<BR>> treating the messages received from server like dhcpoffer,..<BR><BR>The thing you need to understand is that the code is not linear - it's event-driven.  So the DHCP client sets up all the state that's required to run, and then it sets up a timer that sends the first DHCPDISCOVER or DHCPREQUEST.  When the timer expires, typically in about a second, the timer expiry function calls the appropriate state_* function to
 send off a request.  When a packet comes in, the appropriate packet handling function is called.  If no packet comes in, another timer expires and triggers a retransmission, or else triggers a call to a different state_* function.<BR><BR>So you have to read the code with that idea in mind, not with the idea that you're following a single thread step by step from start to end.<BR><BR>One way to see how this happens is to run gdb on the DHCP client and watch what happens.  You will find that after all the main functions run, you wind up in select().  When select() returns, that means an event has happened.  If you continue to trace with gdb, you will see which event happened, and how it was processed.<BR><BR><BR></DIV></DIV></div><br>



      <hr size=1> 
Not happy with your email address?
<br> <a href="http://uk.docs.yahoo.com/ymail/new.html"> Get the one you 

really want</a> - millions of new email addresses available now at <a 

href="http://uk.docs.yahoo.com/ymail/new.html"> Yahoo!</a></body></html>