ISC DHCP 4.4.3-P1
A reference DHCPv4 and DHCPv6 implementation
 
Loading...
Searching...
No Matches
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-2022 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 * PO Box 360
23 * Newmarket, NH 03857 USA
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/* Uncomment this to enable protocol level debug logs */
64/* #define DEBUG_PROTOCOL 1 */
65
66#include <omapip/convert.h>
67#include <omapip/hash.h>
68#include <omapip/omapip.h>
69#include <omapip/trace.h>
70
71/* DST_API control flags */
72/* These are used in functions dst_sign_data and dst_verify_data */
73#define SIG_MODE_INIT 1 /* initalize digest */
74#define SIG_MODE_UPDATE 2 /* add data to digest */
75#define SIG_MODE_FINAL 4 /* generate/verify signature */
76#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
77
78/* OMAPI protocol header, version 1.00 */
79typedef struct {
80 u_int32_t authlen; /* Length of authenticator. */
81 u_int32_t authid; /* Authenticator object ID. */
82 u_int32_t op; /* Opcode. */
83 omapi_handle_t handle; /* Handle of object being operated on,
84 or zero. */
85 u_int32_t id; /* Transaction ID. */
86 u_int32_t rid; /* ID of transaction to which this is a response. */
88
89#define OMAPI_PROTOCOL_VERSION 100
90
91#define OMAPI_OP_OPEN 1
92#define OMAPI_OP_REFRESH 2
93#define OMAPI_OP_UPDATE 3
94#define OMAPI_OP_NOTIFY 4
95#define OMAPI_OP_STATUS 5
96#define OMAPI_OP_DELETE 6
97
105
115
131
137
140 u_int32_t header_size;
142 u_int32_t next_xid;
143
144 omapi_protocol_state_t state; /* Input state. */
145 int reading_message_values; /* True if reading message-specific
146 values. */
147 omapi_message_object_t *message; /* Incoming message. */
148 omapi_data_string_t *name; /* Incoming name. */
149 omapi_typed_data_t *value; /* Incoming value. */
150 isc_result_t verify_result;
151 omapi_remote_auth_t *default_auth; /* Default authinfo to use. */
152 omapi_remote_auth_t *remote_auth_list; /* Authenticators active on
153 this connection. */
154
155 isc_boolean_t insecure; /* Set to allow unauthenticated
156 messages. */
157
160
161typedef struct {
163
164 isc_boolean_t insecure; /* Set to allow unauthenticated
165 messages. */
166
169
170#include <omapip/buffer.h>
171
174 int socket; /* Connection socket. */
175 int index;
176 struct sockaddr_in address;
179
182 int socket; /* Connection socket. */
183 int32_t index;
185 struct sockaddr_in remote_addr;
186 struct sockaddr_in local_addr;
187 omapi_addr_list_t *connect_list; /* List of addresses to which
188 to connect. */
189 int cptr; /* Current element we are connecting to. */
190 u_int32_t bytes_needed; /* Bytes of input needed before wakeup. */
191 u_int32_t in_bytes; /* Bytes of input already buffered. */
193 u_int32_t out_bytes; /* Bytes of output in buffers. */
195 omapi_listener_object_t *listener; /* Listener that accepted this
196 connection, if any. */
197 dst_key_t *in_key; /* Authenticator signing incoming
198 data. */
199 void *in_context; /* Input hash context. */
200 dst_key_t *out_key; /* Authenticator signing outgoing
201 data. */
202 void *out_context; /* Output hash context. */
204
205typedef struct __omapi_io_object {
210 isc_result_t (*reader) (omapi_object_t *);
211 isc_result_t (*writer) (omapi_object_t *);
212 isc_result_t (*reaper) (omapi_object_t *);
213 isc_socket_t *fd;
214 isc_boolean_t closed; /* ISC_TRUE = closed, do not use */
216
223
230
231#define OMAPI_HANDLE_TABLE_SIZE 120
232
242
243#include <omapip/alloc.h>
244
247OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
250OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
252OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
256OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
260OMAPI_OBJECT_ALLOC_DECL (omapi_message,
262
263isc_result_t omapi_connection_sign_data (int mode,
264 dst_key_t *key,
265 void **context,
266 const unsigned char *data,
267 const unsigned len,
268 omapi_typed_data_t **result);
270 omapi_listener_object_t *listener,
271 int socket,
272 struct sockaddr_in *remote_addr);
277 const char *, int);
280
282
283extern int log_perror;
284extern void (*log_cleanup) (void);
285
286void log_fatal (const char *, ...)
287 __attribute__((__format__(__printf__,1,2))) ISC_DHCP_NORETURN;
288int log_error (const char *, ...)
289 __attribute__((__format__(__printf__,1,2)));
290int log_info (const char *, ...)
291 __attribute__((__format__(__printf__,1,2)));
292int log_debug (const char *, ...)
293 __attribute__((__format__(__printf__,1,2)));
294
295void do_percentm (char *obuf, size_t obufsize, const char *ibuf);
296
297isc_result_t uerr2isc (int);
298isc_result_t ns_rcode_to_isc (int);
299
301
302#endif /* __OMAPIP_OMAPIP_P_H__ */
struct _omapi_buffer omapi_buffer_t
#define __attribute__(x)
Definition cdefs.h:39
#define ISC_DHCP_NORETURN
Definition config.h:132
isc_boolean_t
Definition data.h:150
omapi_object_type_t * omapi_type_io_object
Definition support.c:35
const char int
Definition omapip.h:442
struct __omapi_object omapi_object_t
Definition omapip.h:39
omapi_object_type_t * omapi_type_waiter
Definition support.c:40
#define OMAPI_OBJECT_ALLOC_DECL(name, stype, type)
Definition omapip.h:179
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
#define OMAPI_ARRAY_TYPE_DECL(name, stype)
Definition omapip.h:232
struct auth_key omapi_auth_key_t
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:261
isc_result_t ns_rcode_to_isc(int)
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
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:808
void omapi_buffer_trace_setup(void)
void omapi_connection_trace_setup(void)
#define OMAPI_HANDLE_TABLE_SIZE
Definition omapip_p.h:231
omapi_protocol_state_t
Definition omapip_p.h:106
@ omapi_protocol_value_wait
Definition omapip_p.h:112
@ omapi_protocol_signature_wait
Definition omapip_p.h:109
@ omapi_protocol_value_length_wait
Definition omapip_p.h:113
@ omapi_protocol_intro_wait
Definition omapip_p.h:107
@ omapi_protocol_name_wait
Definition omapip_p.h:110
@ omapi_protocol_header_wait
Definition omapip_p.h:108
@ omapi_protocol_name_length_wait
Definition omapip_p.h:111
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:253
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:257
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:98
@ omapi_connection_unconnected
Definition omapip_p.h:99
@ omapi_connection_connected
Definition omapip_p.h:101
@ omapi_connection_disconnecting
Definition omapip_p.h:102
@ omapi_connection_closed
Definition omapip_p.h:103
@ omapi_connection_connecting
Definition omapip_p.h:100
omapi_connection_state_t state
Definition omapip_p.h:184
omapi_listener_object_t * listener
Definition omapip_p.h:195
omapi_buffer_t * outbufs
Definition omapip_p.h:194
omapi_addr_list_t * connect_list
Definition omapip_p.h:187
struct sockaddr_in remote_addr
Definition omapip_p.h:185
omapi_buffer_t * inbufs
Definition omapip_p.h:192
struct sockaddr_in local_addr
Definition omapip_p.h:186
omapi_value_t ** values
Definition omapip_p.h:219
omapi_handle_t first
Definition omapip_p.h:234
omapi_handle_t limit
Definition omapip_p.h:234
struct __omapi_handle_table * table
Definition omapip_p.h:239
omapi_handle_t next
Definition omapip_p.h:235
union __omapi_handle_table::@164211330172214370145263323303307162114331216117 children[OMAPI_HANDLE_TABLE_SIZE]
omapi_object_t * object
Definition omapip_p.h:238
isc_result_t(* reaper)(omapi_object_t *)
Definition omapip_p.h:212
struct __omapi_io_object * next
Definition omapip_p.h:207
isc_socket_t * fd
Definition omapip_p.h:213
isc_result_t(* writer)(omapi_object_t *)
Definition omapip_p.h:211
isc_result_t(* reader)(omapi_object_t *)
Definition omapip_p.h:210
int(* readfd)(omapi_object_t *)
Definition omapip_p.h:208
int(* writefd)(omapi_object_t *)
Definition omapip_p.h:209
isc_boolean_t closed
Definition omapip_p.h:214
isc_result_t(* verify_addr)(omapi_object_t *, omapi_addr_t *)
Definition omapip_p.h:177
struct sockaddr_in address
Definition omapip_p.h:176
omapi_object_t * id_object
Definition omapip_p.h:125
omapi_object_t * object
Definition omapip_p.h:119
omapi_typed_data_t * authenticator
Definition omapip_p.h:123
struct __omapi_protocol_object * protocol_object
Definition omapip_p.h:121
struct __omapi_message_object * next
Definition omapip_p.h:118
omapi_object_t * notify_object
Definition omapip_p.h:120
struct __omapi_message_object * prev
Definition omapip_p.h:118
omapi_remote_auth_t * remote_auth_list
Definition omapip_p.h:152
isc_result_t verify_result
Definition omapip_p.h:150
omapi_data_string_t * name
Definition omapip_p.h:148
isc_boolean_t insecure
Definition omapip_p.h:155
omapi_typed_data_t * value
Definition omapip_p.h:149
omapi_protocol_state_t state
Definition omapip_p.h:144
omapi_message_object_t * message
Definition omapip_p.h:147
u_int32_t protocol_version
Definition omapip_p.h:141
omapi_remote_auth_t * default_auth
Definition omapip_p.h:151
isc_result_t(* verify_auth)(omapi_object_t *, omapi_auth_key_t *)
Definition omapip_p.h:158
struct __omapi_remote_auth * next
Definition omapip_p.h:133
omapi_object_t * a
Definition omapip_p.h:135
omapi_handle_t remote_handle
Definition omapip_p.h:134
struct __omapi_waiter_object * next
Definition omapip_p.h:228
isc_result_t waitstatus
Definition omapip_p.h:227
omapi_handle_t handle
Definition omapip_p.h:83
isc_result_t(* verify_auth)(omapi_object_t *, omapi_auth_key_t *)
Definition omapip_p.h:167