1 /* $NetBSD: test.c,v 1.1.1.2 2014/07/12 11:58:00 spz Exp $ */
4 Test code for omapip... */
7 * Copyright (c) 2009-2010,2013-2014 by Internet Systems Consortium, Inc. ("ISC")
8 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
9 * Copyright (c) 1999-2003 by Internet Software Consortium
11 * Permission to use, copy, modify, and distribute this software for any
12 * purpose with or without fee is hereby granted, provided that the above
13 * copyright notice and this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
16 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
18 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Internet Systems Consortium, Inc.
25 * Redwood City, CA 94063
27 * https://www.isc.org/
31 #include <sys/cdefs.h>
32 __RCSID("$NetBSD: test.c,v 1.1.1.2 2014/07/12 11:58:00 spz Exp $");
41 #include <omapip/result.h>
43 #include <omapip/omapip.h>
44 #include <omapip/isclib.h>
46 int main (int argc
, char **argv
)
48 omapi_object_t
*listener
= (omapi_object_t
*)0;
49 omapi_object_t
*connection
= (omapi_object_t
*)0;
52 status
= dhcp_context_create(DHCP_CONTEXT_PRE_DB
| DHCP_CONTEXT_POST_DB
,
54 if (status
!= ISC_R_SUCCESS
) {
55 fprintf(stderr
, "Can't initialize context: %s\n",
56 isc_result_totext(status
));
62 if (argc
> 1 && !strcmp (argv
[1], "listen")) {
64 fprintf (stderr
, "Usage: test listen port\n");
67 status
= omapi_generic_new (&listener
, MDL
);
68 if (status
!= ISC_R_SUCCESS
) {
69 fprintf (stderr
, "omapi_generic_new: %s\n",
70 isc_result_totext (status
));
73 status
= omapi_protocol_listen (listener
,
74 (unsigned)atoi (argv
[2]), 1);
75 if (status
!= ISC_R_SUCCESS
) {
76 fprintf (stderr
, "omapi_listen: %s\n",
77 isc_result_totext (status
));
81 } else if (argc
> 1 && !strcmp (argv
[1], "connect")) {
83 fprintf (stderr
, "Usage: test listen address port\n");
86 status
= omapi_generic_new (&connection
, MDL
);
87 if (status
!= ISC_R_SUCCESS
) {
88 fprintf (stderr
, "omapi_generic_new: %s\n",
89 isc_result_totext (status
));
92 status
= omapi_protocol_connect (connection
,
94 (unsigned)atoi (argv
[3]), 0);
95 fprintf (stderr
, "connect: %s\n", isc_result_totext (status
));
96 if (status
!= ISC_R_SUCCESS
)
98 status
= omapi_wait_for_completion (connection
, 0);
99 fprintf (stderr
, "completion: %s\n",
100 isc_result_totext (status
));
101 if (status
!= ISC_R_SUCCESS
)
105 fprintf (stderr
, "Usage: test [listen | connect] ...\n");