]>
git.ipfire.org Git - thirdparty/dhcp.git/blob - omapip/test.c
3 Test code for omapip... */
6 * Copyright (C) 2004-2022 Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1999-2003 by Internet Software Consortium
9 * This Source Code Form is subject to the terms of the Mozilla Public
10 * License, v. 2.0. If a copy of the MPL was not distributed with this
11 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
13 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
14 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
16 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
19 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 * Internet Systems Consortium, Inc.
23 * Newmarket, NH 03857 USA
25 * https://www.isc.org/
36 #include <omapip/result.h>
38 #include <omapip/omapip.h>
39 #include <omapip/isclib.h>
41 int main (int argc
, char **argv
)
43 omapi_object_t
*listener
= (omapi_object_t
*)0;
44 omapi_object_t
*connection
= (omapi_object_t
*)0;
47 status
= dhcp_context_create(DHCP_CONTEXT_PRE_DB
| DHCP_CONTEXT_POST_DB
,
49 if (status
!= ISC_R_SUCCESS
) {
50 fprintf(stderr
, "Can't initialize context: %s\n",
51 isc_result_totext(status
));
55 status
= omapi_init ();
56 if (status
!= ISC_R_SUCCESS
) {
57 fprintf(stderr
, "omapi_init failed: %s\n",
58 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");