Annotation of embedaddon/dhcp/includes/omapip/omapip_p.h, revision 1.1.1.1
1.1 misho 1: /* omapip_p.h
2:
3: Private master include file for the OMAPI library. */
4:
5: /*
6: * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
7: * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
8: * Copyright (c) 1996-2003 by Internet Software Consortium
9: *
10: * Permission to use, copy, modify, and distribute this software for any
11: * purpose with or without fee is hereby granted, provided that the above
12: * copyright notice and this permission notice appear in all copies.
13: *
14: * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
15: * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16: * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
17: * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18: * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19: * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
20: * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21: *
22: * Internet Systems Consortium, Inc.
23: * 950 Charter Street
24: * Redwood City, CA 94063
25: * <info@isc.org>
26: * https://www.isc.org/
27: *
28: * This software has been written for Internet Systems Consortium
29: * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
30: * To learn more about Internet Systems Consortium, see
31: * ``https://www.isc.org/''. To learn more about Vixie Enterprises,
32: * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
33: * ``http://www.nominum.com''.
34: */
35:
36: #ifndef __OMAPIP_OMAPIP_P_H__
37: #define __OMAPIP_OMAPIP_P_H__
38:
39: #ifndef __CYGWIN32__
40: #include <sys/types.h>
41: #include <netinet/in.h>
42: #include <sys/socket.h>
43: #include <sys/un.h>
44: #include <arpa/inet.h>
45:
46: #include <netdb.h>
47: #else
48: #define fd_set cygwin_fd_set
49: #include <sys/types.h>
50: #endif
51: #include <fcntl.h>
52: #include <stdio.h>
53: #include <unistd.h>
54: #include <string.h>
55: #include <memory.h>
56: #include <stdlib.h>
57: #include <sys/stat.h>
58: #include <ctype.h>
59: #include <time.h>
60:
61: /*
62: * XXX: I'm not sure why these were here.
63: #include "cdefs.h"
64: #include "osdep.h"
65: */
66:
67: #include <isc-dhcp/dst.h>
68: #include <isc-dhcp/result.h>
69:
70: #include <omapip/convert.h>
71: #include <omapip/hash.h>
72: #include <omapip/omapip.h>
73: #include <omapip/trace.h>
74:
75: /* OMAPI protocol header, version 1.00 */
76: typedef struct {
77: u_int32_t authlen; /* Length of authenticator. */
78: u_int32_t authid; /* Authenticator object ID. */
79: u_int32_t op; /* Opcode. */
80: omapi_handle_t handle; /* Handle of object being operated on,
81: or zero. */
82: u_int32_t id; /* Transaction ID. */
83: u_int32_t rid; /* ID of transaction to which this is a response. */
84: } omapi_protocol_header_t;
85:
86: #define OMAPI_PROTOCOL_VERSION 100
87:
88: #define OMAPI_OP_OPEN 1
89: #define OMAPI_OP_REFRESH 2
90: #define OMAPI_OP_UPDATE 3
91: #define OMAPI_OP_NOTIFY 4
92: #define OMAPI_OP_STATUS 5
93: #define OMAPI_OP_DELETE 6
94:
95: typedef enum {
96: omapi_connection_unconnected,
97: omapi_connection_connecting,
98: omapi_connection_connected,
99: omapi_connection_disconnecting,
100: omapi_connection_closed
101: } omapi_connection_state_t;
102:
103: typedef enum {
104: omapi_protocol_intro_wait,
105: omapi_protocol_header_wait,
106: omapi_protocol_signature_wait,
107: omapi_protocol_name_wait,
108: omapi_protocol_name_length_wait,
109: omapi_protocol_value_wait,
110: omapi_protocol_value_length_wait
111: } omapi_protocol_state_t;
112:
113: typedef struct __omapi_message_object {
114: OMAPI_OBJECT_PREAMBLE;
115: struct __omapi_message_object *next, *prev;
116: omapi_object_t *object;
117: omapi_object_t *notify_object;
118: struct __omapi_protocol_object *protocol_object;
119: u_int32_t authlen;
120: omapi_typed_data_t *authenticator;
121: u_int32_t authid;
122: omapi_object_t *id_object;
123: u_int32_t op;
124: u_int32_t h;
125: u_int32_t id;
126: u_int32_t rid;
127: } omapi_message_object_t;
128:
129: typedef struct __omapi_remote_auth {
130: struct __omapi_remote_auth *next;
131: omapi_handle_t remote_handle;
132: omapi_object_t *a;
133: } omapi_remote_auth_t;
134:
135: typedef struct __omapi_protocol_object {
136: OMAPI_OBJECT_PREAMBLE;
137: u_int32_t header_size;
138: u_int32_t protocol_version;
139: u_int32_t next_xid;
140:
141: omapi_protocol_state_t state; /* Input state. */
142: int reading_message_values; /* True if reading message-specific
143: values. */
144: omapi_message_object_t *message; /* Incoming message. */
145: omapi_data_string_t *name; /* Incoming name. */
146: omapi_typed_data_t *value; /* Incoming value. */
147: isc_result_t verify_result;
148: omapi_remote_auth_t *default_auth; /* Default authinfo to use. */
149: omapi_remote_auth_t *remote_auth_list; /* Authenticators active on
150: this connection. */
151:
152: isc_boolean_t insecure; /* Set to allow unauthenticated
153: messages. */
154:
155: isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
156: } omapi_protocol_object_t;
157:
158: typedef struct {
159: OMAPI_OBJECT_PREAMBLE;
160:
161: isc_boolean_t insecure; /* Set to allow unauthenticated
162: messages. */
163:
164: isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
165: } omapi_protocol_listener_object_t;
166:
167: #include <omapip/buffer.h>
168:
169: typedef struct __omapi_listener_object {
170: OMAPI_OBJECT_PREAMBLE;
171: int socket; /* Connection socket. */
172: int index;
173: struct sockaddr_in address;
174: isc_result_t (*verify_addr) (omapi_object_t *, omapi_addr_t *);
175: } omapi_listener_object_t;
176:
177: typedef struct __omapi_connection_object {
178: OMAPI_OBJECT_PREAMBLE;
179: int socket; /* Connection socket. */
180: int32_t index;
181: omapi_connection_state_t state;
182: struct sockaddr_in remote_addr;
183: struct sockaddr_in local_addr;
184: omapi_addr_list_t *connect_list; /* List of addresses to which
185: to connect. */
186: int cptr; /* Current element we are connecting to. */
187: u_int32_t bytes_needed; /* Bytes of input needed before wakeup. */
188: u_int32_t in_bytes; /* Bytes of input already buffered. */
189: omapi_buffer_t *inbufs;
190: u_int32_t out_bytes; /* Bytes of output in buffers. */
191: omapi_buffer_t *outbufs;
192: omapi_listener_object_t *listener; /* Listener that accepted this
193: connection, if any. */
194: DST_KEY *in_key; /* Authenticator signing incoming
195: data. */
196: void *in_context; /* Input hash context. */
197: DST_KEY *out_key; /* Authenticator signing outgoing
198: data. */
199: void *out_context; /* Output hash context. */
200: } omapi_connection_object_t;
201:
202: typedef struct __omapi_io_object {
203: OMAPI_OBJECT_PREAMBLE;
204: struct __omapi_io_object *next;
205: int (*readfd) (omapi_object_t *);
206: int (*writefd) (omapi_object_t *);
207: isc_result_t (*reader) (omapi_object_t *);
208: isc_result_t (*writer) (omapi_object_t *);
209: isc_result_t (*reaper) (omapi_object_t *);
210: } omapi_io_object_t;
211:
212: typedef struct __omapi_generic_object {
213: OMAPI_OBJECT_PREAMBLE;
214: omapi_value_t **values;
215: u_int8_t *changed;
216: int nvalues, va_max;
217: } omapi_generic_object_t;
218:
219: typedef struct __omapi_waiter_object {
220: OMAPI_OBJECT_PREAMBLE;
221: int ready;
222: isc_result_t waitstatus;
223: struct __omapi_waiter_object *next;
224: } omapi_waiter_object_t;
225:
226: #define OMAPI_HANDLE_TABLE_SIZE 120
227:
228: typedef struct __omapi_handle_table {
229: omapi_handle_t first, limit;
230: omapi_handle_t next;
231: int leafp;
232: union {
233: omapi_object_t *object;
234: struct __omapi_handle_table *table;
235: } children [OMAPI_HANDLE_TABLE_SIZE];
236: } omapi_handle_table_t;
237:
238: #include <omapip/alloc.h>
239:
240: OMAPI_OBJECT_ALLOC_DECL (omapi_protocol, omapi_protocol_object_t,
241: omapi_type_protocol)
242: OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
243: omapi_protocol_listener_object_t,
244: omapi_type_protocol_listener)
245: OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
246: omapi_connection_object_t, omapi_type_connection)
247: OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
248: omapi_listener_object_t, omapi_type_listener)
249: OMAPI_OBJECT_ALLOC_DECL (omapi_io,
250: omapi_io_object_t, omapi_type_io_object)
251: OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
252: omapi_waiter_object_t, omapi_type_waiter)
253: OMAPI_OBJECT_ALLOC_DECL (omapi_generic,
254: omapi_generic_object_t, omapi_type_generic)
255: OMAPI_OBJECT_ALLOC_DECL (omapi_message,
256: omapi_message_object_t, omapi_type_message)
257:
258: isc_result_t omapi_connection_sign_data (int mode,
259: DST_KEY *key,
260: void **context,
261: const unsigned char *data,
262: const unsigned len,
263: omapi_typed_data_t **result);
264: isc_result_t omapi_listener_connect (omapi_connection_object_t **obj,
265: omapi_listener_object_t *listener,
266: int socket,
267: struct sockaddr_in *remote_addr);
268: void omapi_listener_trace_setup (void);
269: void omapi_connection_trace_setup (void);
270: void omapi_buffer_trace_setup (void);
271: void omapi_connection_register (omapi_connection_object_t *,
272: const char *, int);
273: void trace_mr_init (void);
274:
275: OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t);
276: OMAPI_ARRAY_TYPE_DECL(omapi_connection, omapi_connection_object_t);
277:
278: isc_result_t omapi_handle_clear(omapi_handle_t);
279:
280: extern int log_priority;
281: extern int log_perror;
282: extern void (*log_cleanup) (void);
283:
284: void log_fatal (const char *, ...)
1.1.1.1 ! misho 285: __attribute__((__format__(__printf__,1,2))) ISC_DHCP_NORETURN;
1.1 misho 286: int log_error (const char *, ...)
287: __attribute__((__format__(__printf__,1,2)));
288: int log_info (const char *, ...)
289: __attribute__((__format__(__printf__,1,2)));
290: int log_debug (const char *, ...)
291: __attribute__((__format__(__printf__,1,2)));
292: void do_percentm (char *obuf, const char *ibuf);
293:
294: isc_result_t uerr2isc (int);
295: isc_result_t ns_rcode_to_isc (int);
296:
297: extern omapi_message_object_t *omapi_registered_messages;
298:
299: #endif /* __OMAPIP_OMAPIP_P_H__ */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>