3 Definitions for the object management API protocol buffering... */
6 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
9 * Permission to use, copy, modify, and distribute this software for any
10 * purpose with or without fee is hereby granted, provided that the above
11 * copyright notice and this permission notice appear in all copies.
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 * Redwood City, CA 94063
27 * This software has been written for Internet Systems Consortium
28 * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
29 * To learn more about Internet Systems Consortium, see
30 * ``http://www.isc.org/''. To learn more about Vixie Enterprises,
31 * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
32 * ``http://www.nominum.com''.
35 /* OMAPI buffers are ring buffers, which means that the beginning of the
36 buffer and the end of the buffer chase each other around. As long as
37 the tail never catches up to the head, there's room in the buffer for
40 - If the tail and the head are equal, the buffer is empty.
42 - If the tail is less than the head, the contents of the buffer
43 are the bytes from the head to the end of buffer, and in addition,
44 the bytes between the beginning of the buffer and the tail, not
45 including the byte addressed by the tail.
47 - If the tail is greater than the head, then the buffer contains
48 valid bytes starting with the byte addressed by the head, and
49 ending with the byte before the byte addressed by the tail.
51 There will always be at least one byte of waste, because the tail can't
52 increase so that it's equal to the head (that would represent an empty
54 #define OMAPI_BUF_SIZE 4048
55 typedef struct _omapi_buffer
{
56 struct _omapi_buffer
*next
; /* Buffers can be chained. */
57 u_int32_t refcnt
; /* Buffers are reference counted. */
58 u_int16_t head
, tail
; /* Buffers are organized in a ring. */
59 char buf
[OMAPI_BUF_SIZE
]; /* The actual buffer is included in
60 the buffer data structure. */
63 #define BUFFER_BYTES_FREE(x) \
64 ((x) -> tail > (x) -> head \
65 ? sizeof ((x) -> buf) - ((x) -> tail - (x) -> head) \
66 : (x) -> head - (x) -> tail)
68 #define BYTES_IN_BUFFER(x) \
69 ((x) -> tail > (x) -> head \
70 ? (x) -> tail - (x) -> head - 1 \
71 : sizeof ((x) -> buf) - ((x) -> head - (x) -> tail) - 1)
73 isc_result_t
omapi_connection_require (omapi_object_t
*, unsigned);
74 isc_result_t
omapi_connection_copyout (unsigned char *,
75 omapi_object_t
*, unsigned);
76 isc_result_t
omapi_connection_copyin (omapi_object_t
*,
77 const unsigned char *, unsigned);
78 isc_result_t
omapi_connection_flush (omapi_object_t
*);
79 isc_result_t
omapi_connection_get_uint32 (omapi_object_t
*, u_int32_t
*);
80 isc_result_t
omapi_connection_put_uint32 (omapi_object_t
*, u_int32_t
);
81 isc_result_t
omapi_connection_get_uint16 (omapi_object_t
*, u_int16_t
*);
82 isc_result_t
omapi_connection_put_uint16 (omapi_object_t
*, u_int32_t
);