<div>Hi,<br> <span class="postbody">I tried this question several times, but nobody there seems interested.
</span><br> The question was get the wrong time!The detail info was showed as following.<br> Thanks for your time!<br> Regards,<br> Bob<br></div><div></div><br>在2009-12-30 09:52:08,syhshanda <syhshanda@126.com> 写道:<br> <blockquote id="isReplyContent" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;"><div>Greetings to the community!<br>Recently, I came cross the same problem, can anyone give some advice to me?<br>I'd really appreciate your help. Thanks for your time!!<br>Best Regards,<br>Bob<br></div><div></div><br>在2009-12-22 14:58:22,"劲草 " <<a href="mailto:brilliant_er@yahoo.cn">brilliant_er@yahoo.cn</a>> 写道:<br> <blockquote id="isReplyContent" style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;"><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td style="font-family: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-size: inherit; line-height: inherit; font-size-adjust: inherit; font-stretch: inherit;" valign="top"><div id="yiv1976730246"><pre>Hi,<br>My version of dhcpd is 4.0.2b3.The OS is fedora-10 and environment of programming is <br>NetBeans-6.5.1. I use the following code to link dhcpd:<br><br> #include <stdarg.h><br> #include <sys/time.h><br> #include <sys/socket.h><br> #include <stdio.h><br> #include <netinet/in.h><br><br> #include <isc-dhcp/result.h><br> #include <dhcpctl/dhcpctl.h><br><br>int main (int argc, char **argv) { <br> dhcpctl_data_string ipaddrstring = NULL;<br> dhcpctl_data_string value = NULL;<br> dhcpctl_handle connection = NULL;<br> dhcpctl_handle lease = NULL;<br> isc_result_t waitstatus;<br> struct in_addr convaddr;<br> time_t thetime; <br> <br> dhcpctl_initialize (); <br><br> /* get connection with server */<br> dhcpctl_connect (&connection,
"211.87.239.28",7911, 0);<br> <br> /* create a lease object */<br> dhcpctl_new_object (&lease, connection,"lease");<br> <br> memset (&ipaddrstring, 0, sizeof ipaddrstring);<br> <br> inet_pton(AF_INET, "211.87.239.238",&convaddr);<br><br> /* allocates a new dhcpctl_data_string object*/<br> omapi_data_string_new (&ipaddrstring,4, MDL);<br><br> memcpy(ipaddrstring->value, &convaddr.s_addr, 4);<br><br> dhcpctl_set_value (lease, ipaddrstring,"ip-address");<br> <br> dhcpctl_open_object (lease, connection, 0);<br> <br> /* wait for response from server */<br> dhcpctl_wait_for_completion (lease,&waitstatus);<br> <br> if (waitstatus != ISC_R_SUCCESS) {<br> /* server not authoritative */ <br> printf ( "Not successful ! \n"); <br> //exit (0);<br> }<br><br> // deallocates a data string created by omapi_data_string_new()<br> dhcpctl_data_string_dereference(&ipaddrstring,MDL);<br><br> // extracts a value of an attribute from the handle<br> dhcpctl_get_value (&value, lease, "ends");<br> <br> memcpy(&thetime, value->value, value->len);<br><br> dhcpctl_data_string_dereference(&value, MDL);<br><br> fprintf (stdout, "ending time is %s",ctime(&thetime));<br>}<br><br>In the dhcpd.leases file,the IP 211.87.239.238 detail info is following:<br>lease 211.87.239.238 {<br> starts 2 2009/12/08 07:23:44;<br> ends 3 2009/12/09 07:23:44;<br> tstp 3 2009/12/09 07:23:44;<br> cltt 2 2009/12/08 07:23:44;<br> binding state free;<br> hardware ethernet 00:01:6c:cb:93:e6;<br>}<br><br>Finally, when I run the code,but I get the error end time of lease:<br> ending time is Wed Feb 12 23:26:35 1902<br><br>Thanks for you help!<br>Best Regards,<br>John<br><br><br><br></pre></div></td></tr></tbody></table><br>
<hr size="1"><a href="http://cn.rd.yahoo.com/mail_cn/tagline/card/*http://card.mail.cn.yahoo.com/"> 好玩贺卡等你发,邮箱贺卡全新上线!</a></blockquote><br><br><span title="neteasefooter"></span></blockquote><br><br><span title="neteasefooter"/></span>