ISC DHCP 4.4.2b1
A reference DHCPv4 and DHCPv6 implementation
omapip_p.h
Go to the documentation of this file.
1/* omapip_p.h
2
3 Private master include file for the OMAPI library. */
4
5/*
6 * Copyright (c) 2004-2019 by Internet Systems Consortium, Inc. ("ISC")
7 * Copyright (c) 1996-2003 by Internet Software Consortium
8 *
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/.
12 *
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.
20 *
21 * Internet Systems Consortium, Inc.
22 * 950 Charter Street
23 * Redwood City, CA 94063
24 * <info@isc.org>
25 * https://www.isc.org/
26 *
27 */
28
29#ifndef __OMAPIP_OMAPIP_P_H__
30#define __OMAPIP_OMAPIP_P_H__
31
32#ifndef __CYGWIN32__
33#include <sys/types.h>
34#include <netinet/in.h>
35#include <sys/socket.h>
36#include <sys/un.h>
37#include <arpa/inet.h>
38
39#include <netdb.h>
40#else
41#define fd_set cygwin_fd_set
42#include <sys/types.h>
43#endif
44#include <fcntl.h>
45#include <stdio.h>
46#include <unistd.h>
47#include <string.h>
48#include <memory.h>
49#include <stdlib.h>
50#include <sys/stat.h>
51#include <ctype.h>
52#include <time.h>
53
54/*
55 * XXX: I'm not sure why these were here.
56#include "cdefs.h"
57#include "osdep.h"
58 */
59
60#include <dst/dst.h>
61#include "result.h"
62
63#include <omapip/convert.h>
64#include <omapip/hash.h>
65#include <omapip/omapip.h>
66#include <omapip/trace.h>
67
68/* DST_API control flags */
69/* These are used in functions dst_sign_data and dst_verify_data */
70#define SIG_MODE_INIT 1 /* initalize digest */
71#define SIG_MODE_UPDATE 2 /* add data to digest */
72#define SIG_MODE_FINAL 4 /* generate/verify signature */
73#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
74
75/* OMAPI protocol header, version 1.00 */
76typedef 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. */
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
95typedef enum {
102
103typedef enum {
112
119 u_int32_t authlen;
121 u_int32_t authid;
123 u_int32_t op;
124 u_int32_t h;
125 u_int32_t id;
126 u_int32_t rid;
128
129typedef struct __omapi_remote_auth {
134
137 u_int32_t header_size;
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
157
158typedef struct {
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 *);
166
167#include <omapip/buffer.h>
168
171 int socket; /* Connection socket. */
172 int index;
173 struct sockaddr_in address;
176
179 int socket; /* Connection socket. */
180 int32_t index;
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. */
190 u_int32_t out_bytes; /* Bytes of output in buffers. */
192 omapi_listener_object_t *listener; /* Listener that accepted this
193 connection, if any. */
194 dst_key_t *in_key; /* Authenticator signing incoming
195 data. */
196 void *in_context; /* Input hash context. */
197 dst_key_t *out_key; /* Authenticator signing outgoing
198 data. */
199 void *out_context; /* Output hash context. */
201
202typedef struct __omapi_io_object {
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 isc_socket_t *fd;
211 isc_boolean_t closed; /* ISC_TRUE = closed, do not use */
213
217 u_int8_t *changed;
220
221typedef struct __omapi_waiter_object {
223 int ready;
224 isc_result_t waitstatus;
227
228#define OMAPI_HANDLE_TABLE_SIZE 120
229
230typedef struct __omapi_handle_table {
233 int leafp;
234 union {
239
240#include <omapip/alloc.h>
241
244OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
247OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
249OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
253OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
257OMAPI_OBJECT_ALLOC_DECL (omapi_message,
259
260isc_result_t omapi_connection_sign_data (int mode,
261 dst_key_t *key,
262 void **context,
263 const unsigned char *data,
264 const unsigned len,
265 omapi_typed_data_t **result);
267 omapi_listener_object_t *listener,
268 int socket,
269 struct sockaddr_in *remote_addr);
274 const char *, int);
277
279
280extern int log_perror;
281extern void (*log_cleanup) (void);
282
283void log_fatal (const char *, ...)
284 __attribute__((__format__(__printf__,1,2))) ISC_DHCP_NORETURN;
285int log_error (const char *, ...)
286 __attribute__((__format__(__printf__,1,2)));
287int log_info (const char *, ...)
288 __attribute__((__format__(__printf__,1,2)));
289int log_debug (const char *, ...)
290 __attribute__((__format__(__printf__,1,2)));
291
292void do_percentm (char *obuf, size_t obufsize, const char *ibuf);
293
294isc_result_t uerr2isc (int);
295isc_result_t ns_rcode_to_isc (int);
296
298
299#endif /* __OMAPIP_OMAPIP_P_H__ */
isc_boolean_t
Definition: data.h:150
void __attribute__((noreturn))
omapi_object_type_t * omapi_type_io_object
Definition: support.c:35
const char int
Definition: omapip.h:442
omapi_object_type_t * omapi_type_waiter
Definition: support.c:40
omapi_object_type_t * omapi_type_generic
Definition: support.c:37
omapi_object_type_t * omapi_type_protocol
Definition: support.c:38
unsigned int omapi_handle_t
Definition: omapip.h:36
omapi_object_type_t * omapi_type_connection
Definition: support.c:33
omapi_object_type_t * omapi_type_listener
Definition: support.c:34
omapi_object_type_t * omapi_type_protocol_listener
Definition: support.c:39
omapi_object_type_t * omapi_type_message
Definition: support.c:42
isc_result_t uerr2isc(int)
Definition: toisc.c:37
void(* log_cleanup)(void)
Definition: errwarn.c:45
struct __omapi_message_object omapi_message_object_t
Definition: omapip_p.h:258
isc_result_t ns_rcode_to_isc(int)
void ISC_DHCP_NORETURN
Definition: omapip_p.h:284
isc_result_t omapi_listener_connect(omapi_connection_object_t **obj, omapi_listener_object_t *listener, int socket, struct sockaddr_in *remote_addr)
Definition: listener.c:278
int log_error(const char *,...) __attribute__((__format__(__printf__
int int int log_debug(const char *,...) __attribute__((__format__(__printf__
struct __omapi_generic_object omapi_generic_object_t
OMAPI_OBJECT_ALLOC_DECL(omapi_protocol, omapi_protocol_object_t, omapi_type_protocol) OMAPI_OBJECT_ALLOC_DECL(omapi_protocol_listener
struct __omapi_connection_object omapi_connection_object_t
omapi_type_protocol_listener omapi_type_listener omapi_type_waiter omapi_type_message isc_result_t omapi_connection_sign_data(int mode, dst_key_t *key, void **context, const unsigned char *data, const unsigned len, omapi_typed_data_t **result)
Definition: connection.c:828
omapi_protocol_listener_object_t
Definition: omapip_p.h:245
void omapi_buffer_trace_setup(void)
void omapi_connection_trace_setup(void)
#define OMAPI_HANDLE_TABLE_SIZE
Definition: omapip_p.h:228
OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t)
omapi_protocol_state_t
Definition: omapip_p.h:103
@ omapi_protocol_value_wait
Definition: omapip_p.h:109
@ omapi_protocol_signature_wait
Definition: omapip_p.h:106
@ omapi_protocol_value_length_wait
Definition: omapip_p.h:110
@ omapi_protocol_intro_wait
Definition: omapip_p.h:104
@ omapi_protocol_name_wait
Definition: omapip_p.h:107
@ omapi_protocol_header_wait
Definition: omapip_p.h:105
@ omapi_protocol_name_length_wait
Definition: omapip_p.h:108
int log_perror
Definition: errwarn.c:43
void omapi_listener_trace_setup(void)
struct __omapi_listener_object omapi_listener_object_t
Definition: omapip_p.h:250
struct __omapi_handle_table omapi_handle_table_t
int int int void do_percentm(char *obuf, size_t obufsize, const char *ibuf)
Definition: errwarn.c:210
void log_fatal(const char *,...) __attribute__((__format__(__printf__
struct __omapi_remote_auth omapi_remote_auth_t
omapi_message_object_t * omapi_registered_messages
struct __omapi_io_object omapi_io_object_t
struct __omapi_protocol_object omapi_protocol_object_t
isc_result_t omapi_handle_clear(omapi_handle_t)
Definition: handle.c:298
struct __omapi_waiter_object omapi_waiter_object_t
Definition: omapip_p.h:254
void omapi_connection_register(omapi_connection_object_t *, const char *, int)
int int log_info(const char *,...) __attribute__((__format__(__printf__
omapi_connection_state_t
Definition: omapip_p.h:95
@ omapi_connection_unconnected
Definition: omapip_p.h:96
@ omapi_connection_connected
Definition: omapip_p.h:98
@ omapi_connection_disconnecting
Definition: omapip_p.h:99
@ omapi_connection_closed
Definition: omapip_p.h:100
@ omapi_connection_connecting
Definition: omapip_p.h:97
omapi_connection_state_t state
Definition: omapip_p.h:181
omapi_listener_object_t * listener
Definition: omapip_p.h:192
omapi_buffer_t * outbufs
Definition: omapip_p.h:191
omapi_addr_list_t * connect_list
Definition: omapip_p.h:184
struct sockaddr_in remote_addr
Definition: omapip_p.h:182
omapi_buffer_t * inbufs
Definition: omapip_p.h:189
struct sockaddr_in local_addr
Definition: omapip_p.h:183
omapi_value_t ** values
Definition: omapip_p.h:216
u_int8_t * changed
Definition: omapip_p.h:217
omapi_handle_t first
Definition: omapip_p.h:231
omapi_handle_t limit
Definition: omapip_p.h:231
struct __omapi_handle_table * table
Definition: omapip_p.h:236
omapi_handle_t next
Definition: omapip_p.h:232
union __omapi_handle_table::@6 children[OMAPI_HANDLE_TABLE_SIZE]
omapi_object_t * object
Definition: omapip_p.h:235
isc_result_t(* reaper)(omapi_object_t *)
Definition: omapip_p.h:209
struct __omapi_io_object * next
Definition: omapip_p.h:204
isc_socket_t * fd
Definition: omapip_p.h:210
isc_result_t(* writer)(omapi_object_t *)
Definition: omapip_p.h:208
isc_result_t(* reader)(omapi_object_t *)
Definition: omapip_p.h:207
int(* readfd)(omapi_object_t *)
Definition: omapip_p.h:205
int(* writefd)(omapi_object_t *)
Definition: omapip_p.h:206
isc_boolean_t closed
Definition: omapip_p.h:211
isc_result_t(* verify_addr)(omapi_object_t *, omapi_addr_t *)
Definition: omapip_p.h:174
struct sockaddr_in address
Definition: omapip_p.h:173
omapi_object_t * id_object
Definition: omapip_p.h:122
omapi_object_t * object
Definition: omapip_p.h:116
omapi_typed_data_t * authenticator
Definition: omapip_p.h:120
struct __omapi_protocol_object * protocol_object
Definition: omapip_p.h:118
struct __omapi_message_object * next
Definition: omapip_p.h:115
omapi_object_t * notify_object
Definition: omapip_p.h:117
struct __omapi_message_object * prev
Definition: omapip_p.h:115
omapi_remote_auth_t * remote_auth_list
Definition: omapip_p.h:149
isc_result_t verify_result
Definition: omapip_p.h:147
omapi_data_string_t * name
Definition: omapip_p.h:145
isc_boolean_t insecure
Definition: omapip_p.h:152
omapi_typed_data_t * value
Definition: omapip_p.h:146
omapi_protocol_state_t state
Definition: omapip_p.h:141
omapi_message_object_t * message
Definition: omapip_p.h:144
u_int32_t protocol_version
Definition: omapip_p.h:138
omapi_remote_auth_t * default_auth
Definition: omapip_p.h:148
isc_result_t(* verify_auth)(omapi_object_t *, omapi_auth_key_t *)
Definition: omapip_p.h:155
struct __omapi_remote_auth * next
Definition: omapip_p.h:130
omapi_object_t * a
Definition: omapip_p.h:132
omapi_handle_t remote_handle
Definition: omapip_p.h:131
struct __omapi_waiter_object * next
Definition: omapip_p.h:225
isc_result_t waitstatus
Definition: omapip_p.h:224
omapi_handle_t handle
Definition: omapip_p.h:80