problem with omapi
Glenn Satchell
Glenn.Satchell at uniq.com.au
Mon Jan 4 03:13:44 UTC 2010
Hi Bob
We're all volunteers here, so maybe no-one knows the answer?
The only thing I can think of is to try swapping the order of the
bytes. Refer to the byteorder(5) man page. Maybe need to wrap a call
to ntohl() around the value obtained from omapi in the printf?
ctime( ntohl (&thetime))
I tried this on a Sun sparc (big endian,same byte order as network) and
it worked correctly. ntohl() is a no-op on this platform.
regards,
-glenn
>Date: Mon, 4 Jan 2010 09:25:44 +0800 (CST)
>From: syhshanda <syhshanda at 126.com>
>To: "Users of ISC DHCP" <dhcp-users at lists.isc.org>
>Subject: Re:Re:Re: problem with omapi
>
> Hi,
> I tried this question several times, but nobody there seems interested.
> The question was get the wrong time!The detail info was showed as following.
> Thanks for your time!
> Regards,
> Bob
>
>
> ÔÚ2009-12-30 09:52:08£¬syhshanda <syhshanda at 126.com> дµÀ£º
>
> Greetings to the community!
> Recently, I came cross the same problem, can anyone give some advice to me?
> I'd really appreciate your help. Thanks for your time!!
> Best Regards,
> Bob
>
>
> ÔÚ2009-12-22 14:58:22£¬"¾¢²Ý " <brilliant_er at yahoo.cn> дµÀ£º
>
> Hi,
> My version of dhcpd is 4.0.2b3.The OS is fedora-10 and environment of
programming is
> NetBeans-6.5.1. I use the following code to link dhcpd:
>
> ?#include <stdarg.h>
> #include <sys/time.h>
> #include <sys/socket.h>
> #include <stdio.h>
> #include <netinet/in.h>
>
> #include <isc-dhcp/result.h>
> #include <dhcpctl/dhcpctl.h>
>
> int main (int argc, char **argv) {
> dhcpctl_data_string ipaddrstring = NULL;
> dhcpctl_data_string value = NULL;
> dhcpctl_handle connection = NULL;
> dhcpctl_handle lease = NULL;
> isc_result_t waitstatus;
> struct in_addr convaddr;
> time_t thetime;
>
> dhcpctl_initialize ();
>
> /* get connection with server */
> dhcpctl_connect (&connection,
> "211.87.239.28",7911, 0);
>
> /* create a lease object */
> dhcpctl_new_object (&lease, connection,"lease");
>
> memset (&ipaddrstring, 0, sizeof ipaddrstring);
>
> inet_pton(AF_INET, "211.87.239.238",&convaddr);
>
> /* allocates a new dhcpctl_data_string object*/
> omapi_data_string_new (&ipaddrstring,4, MDL);
>
> memcpy(ipaddrstring->value, &convaddr.s_addr, 4);
>
> dhcpctl_set_value (lease, ipaddrstring,"ip-address");
>
> dhcpctl_open_object (lease, connection, 0);
>
> /* wait for response from server */
> dhcpctl_wait_for_completion (lease,&waitstatus);
>
> if (waitstatus != ISC_R_SUCCESS) {
> /* server not authoritative */
> printf ( "Not successful ! \n");
> //exit (0);
> }
>
> // deallocates a data string created by omapi_data_string_new()
> dhcpctl_data_string_dereference(&ipaddrstring,MDL);
>
> // extracts a value of an attribute from the handle
> dhcpctl_get_value (&value, lease, "ends");
>
> memcpy(&thetime, value->value, value->len);
>
> dhcpctl_data_string_dereference(&value, MDL);
>
> fprintf (stdout, "ending time is %s",ctime(&thetime));
> }
>
> In the dhcpd.leases file,the IP 211.87.239.238 detail info is following:
> lease 211.87.239.238 {
> starts 2 2009/12/08 07:23:44;
> ends 3 2009/12/09 07:23:44;
> tstp 3 2009/12/09 07:23:44;
> cltt 2 2009/12/08 07:23:44;
> binding state free;
> hardware ethernet 00:01:6c:cb:93:e6;
> }
>
> Finally, when I run the code,but I get the error end time of lease:
> ?ending time is Wed Feb 12 23:26:35 1902
>
> Thanks for you help!
> Best Regards,
> John
>
>
More information about the dhcp-users
mailing list