PageRenderTime 64ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/external/bsd/dhcp/dist/includes/omapip/omapip_p.h

https://gitlab.com/storedmirrors/minix
C Header | 301 lines | 217 code | 39 blank | 45 comment | 0 complexity | 7f3b93efb196389d82482ac199260d12 MD5 | raw file
  1. /* $NetBSD: omapip_p.h,v 1.1.1.4 2014/07/12 11:57:57 spz Exp $ */
  2. /* omapip_p.h
  3. Private master include file for the OMAPI library. */
  4. /*
  5. * Copyright (c) 2009-2010,2014 by Internet Systems Consortium, Inc. ("ISC")
  6. * Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
  7. * Copyright (c) 1996-2003 by Internet Software Consortium
  8. *
  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.
  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. #ifndef __OMAPIP_OMAPIP_P_H__
  29. #define __OMAPIP_OMAPIP_P_H__
  30. #ifndef __CYGWIN32__
  31. #include <sys/types.h>
  32. #include <netinet/in.h>
  33. #include <sys/socket.h>
  34. #include <sys/un.h>
  35. #include <arpa/inet.h>
  36. #include <netdb.h>
  37. #else
  38. #define fd_set cygwin_fd_set
  39. #include <sys/types.h>
  40. #endif
  41. #include <fcntl.h>
  42. #include <stdio.h>
  43. #include <unistd.h>
  44. #include <string.h>
  45. #include <memory.h>
  46. #include <stdlib.h>
  47. #include <sys/stat.h>
  48. #include <ctype.h>
  49. #include <time.h>
  50. /*
  51. * XXX: I'm not sure why these were here.
  52. #include "cdefs.h"
  53. #include "osdep.h"
  54. */
  55. #include <dst/dst.h>
  56. #include "result.h"
  57. #include <omapip/convert.h>
  58. #include <omapip/hash.h>
  59. #include <omapip/omapip.h>
  60. #include <omapip/trace.h>
  61. /* DST_API control flags */
  62. /* These are used in functions dst_sign_data and dst_verify_data */
  63. #define SIG_MODE_INIT 1 /* initalize digest */
  64. #define SIG_MODE_UPDATE 2 /* add data to digest */
  65. #define SIG_MODE_FINAL 4 /* generate/verify signature */
  66. #define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL)
  67. /* OMAPI protocol header, version 1.00 */
  68. typedef struct {
  69. u_int32_t authlen; /* Length of authenticator. */
  70. u_int32_t authid; /* Authenticator object ID. */
  71. u_int32_t op; /* Opcode. */
  72. omapi_handle_t handle; /* Handle of object being operated on,
  73. or zero. */
  74. u_int32_t id; /* Transaction ID. */
  75. u_int32_t rid; /* ID of transaction to which this is a response. */
  76. } omapi_protocol_header_t;
  77. #define OMAPI_PROTOCOL_VERSION 100
  78. #define OMAPI_OP_OPEN 1
  79. #define OMAPI_OP_REFRESH 2
  80. #define OMAPI_OP_UPDATE 3
  81. #define OMAPI_OP_NOTIFY 4
  82. #define OMAPI_OP_STATUS 5
  83. #define OMAPI_OP_DELETE 6
  84. typedef enum {
  85. omapi_connection_unconnected,
  86. omapi_connection_connecting,
  87. omapi_connection_connected,
  88. omapi_connection_disconnecting,
  89. omapi_connection_closed
  90. } omapi_connection_state_t;
  91. typedef enum {
  92. omapi_protocol_intro_wait,
  93. omapi_protocol_header_wait,
  94. omapi_protocol_signature_wait,
  95. omapi_protocol_name_wait,
  96. omapi_protocol_name_length_wait,
  97. omapi_protocol_value_wait,
  98. omapi_protocol_value_length_wait
  99. } omapi_protocol_state_t;
  100. typedef struct __omapi_message_object {
  101. OMAPI_OBJECT_PREAMBLE;
  102. struct __omapi_message_object *next, *prev;
  103. omapi_object_t *object;
  104. omapi_object_t *notify_object;
  105. struct __omapi_protocol_object *protocol_object;
  106. u_int32_t authlen;
  107. omapi_typed_data_t *authenticator;
  108. u_int32_t authid;
  109. omapi_object_t *id_object;
  110. u_int32_t op;
  111. u_int32_t h;
  112. u_int32_t id;
  113. u_int32_t rid;
  114. } omapi_message_object_t;
  115. typedef struct __omapi_remote_auth {
  116. struct __omapi_remote_auth *next;
  117. omapi_handle_t remote_handle;
  118. omapi_object_t *a;
  119. } omapi_remote_auth_t;
  120. typedef struct __omapi_protocol_object {
  121. OMAPI_OBJECT_PREAMBLE;
  122. u_int32_t header_size;
  123. u_int32_t protocol_version;
  124. u_int32_t next_xid;
  125. omapi_protocol_state_t state; /* Input state. */
  126. int reading_message_values; /* True if reading message-specific
  127. values. */
  128. omapi_message_object_t *message; /* Incoming message. */
  129. omapi_data_string_t *name; /* Incoming name. */
  130. omapi_typed_data_t *value; /* Incoming value. */
  131. isc_result_t verify_result;
  132. omapi_remote_auth_t *default_auth; /* Default authinfo to use. */
  133. omapi_remote_auth_t *remote_auth_list; /* Authenticators active on
  134. this connection. */
  135. isc_boolean_t insecure; /* Set to allow unauthenticated
  136. messages. */
  137. isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
  138. } omapi_protocol_object_t;
  139. typedef struct {
  140. OMAPI_OBJECT_PREAMBLE;
  141. isc_boolean_t insecure; /* Set to allow unauthenticated
  142. messages. */
  143. isc_result_t (*verify_auth) (omapi_object_t *, omapi_auth_key_t *);
  144. } omapi_protocol_listener_object_t;
  145. #include <omapip/buffer.h>
  146. typedef struct __omapi_listener_object {
  147. OMAPI_OBJECT_PREAMBLE;
  148. int socket; /* Connection socket. */
  149. int index;
  150. struct sockaddr_in address;
  151. isc_result_t (*verify_addr) (omapi_object_t *, omapi_addr_t *);
  152. } omapi_listener_object_t;
  153. typedef struct __omapi_connection_object {
  154. OMAPI_OBJECT_PREAMBLE;
  155. int socket; /* Connection socket. */
  156. int32_t index;
  157. omapi_connection_state_t state;
  158. struct sockaddr_in remote_addr;
  159. struct sockaddr_in local_addr;
  160. omapi_addr_list_t *connect_list; /* List of addresses to which
  161. to connect. */
  162. int cptr; /* Current element we are connecting to. */
  163. u_int32_t bytes_needed; /* Bytes of input needed before wakeup. */
  164. u_int32_t in_bytes; /* Bytes of input already buffered. */
  165. omapi_buffer_t *inbufs;
  166. u_int32_t out_bytes; /* Bytes of output in buffers. */
  167. omapi_buffer_t *outbufs;
  168. omapi_listener_object_t *listener; /* Listener that accepted this
  169. connection, if any. */
  170. dst_key_t *in_key; /* Authenticator signing incoming
  171. data. */
  172. void *in_context; /* Input hash context. */
  173. dst_key_t *out_key; /* Authenticator signing outgoing
  174. data. */
  175. void *out_context; /* Output hash context. */
  176. } omapi_connection_object_t;
  177. typedef struct __omapi_io_object {
  178. OMAPI_OBJECT_PREAMBLE;
  179. struct __omapi_io_object *next;
  180. int (*readfd) (omapi_object_t *);
  181. int (*writefd) (omapi_object_t *);
  182. isc_result_t (*reader) (omapi_object_t *);
  183. isc_result_t (*writer) (omapi_object_t *);
  184. isc_result_t (*reaper) (omapi_object_t *);
  185. isc_socket_t *fd;
  186. isc_boolean_t closed; /* ISC_TRUE = closed, do not use */
  187. } omapi_io_object_t;
  188. typedef struct __omapi_generic_object {
  189. OMAPI_OBJECT_PREAMBLE;
  190. omapi_value_t **values;
  191. u_int8_t *changed;
  192. int nvalues, va_max;
  193. } omapi_generic_object_t;
  194. typedef struct __omapi_waiter_object {
  195. OMAPI_OBJECT_PREAMBLE;
  196. int ready;
  197. isc_result_t waitstatus;
  198. struct __omapi_waiter_object *next;
  199. } omapi_waiter_object_t;
  200. #define OMAPI_HANDLE_TABLE_SIZE 120
  201. typedef struct __omapi_handle_table {
  202. omapi_handle_t first, limit;
  203. omapi_handle_t next;
  204. int leafp;
  205. union {
  206. omapi_object_t *object;
  207. struct __omapi_handle_table *table;
  208. } children [OMAPI_HANDLE_TABLE_SIZE];
  209. } omapi_handle_table_t;
  210. #include <omapip/alloc.h>
  211. OMAPI_OBJECT_ALLOC_DECL (omapi_protocol, omapi_protocol_object_t,
  212. omapi_type_protocol)
  213. OMAPI_OBJECT_ALLOC_DECL (omapi_protocol_listener,
  214. omapi_protocol_listener_object_t,
  215. omapi_type_protocol_listener)
  216. OMAPI_OBJECT_ALLOC_DECL (omapi_connection,
  217. omapi_connection_object_t, omapi_type_connection)
  218. OMAPI_OBJECT_ALLOC_DECL (omapi_listener,
  219. omapi_listener_object_t, omapi_type_listener)
  220. OMAPI_OBJECT_ALLOC_DECL (omapi_io,
  221. omapi_io_object_t, omapi_type_io_object)
  222. OMAPI_OBJECT_ALLOC_DECL (omapi_waiter,
  223. omapi_waiter_object_t, omapi_type_waiter)
  224. OMAPI_OBJECT_ALLOC_DECL (omapi_generic,
  225. omapi_generic_object_t, omapi_type_generic)
  226. OMAPI_OBJECT_ALLOC_DECL (omapi_message,
  227. omapi_message_object_t, omapi_type_message)
  228. isc_result_t omapi_connection_sign_data (int mode,
  229. dst_key_t *key,
  230. void **context,
  231. const unsigned char *data,
  232. const unsigned len,
  233. omapi_typed_data_t **result);
  234. isc_result_t omapi_listener_connect (omapi_connection_object_t **obj,
  235. omapi_listener_object_t *listener,
  236. int socket,
  237. struct sockaddr_in *remote_addr);
  238. void omapi_listener_trace_setup (void);
  239. void omapi_connection_trace_setup (void);
  240. void omapi_buffer_trace_setup (void);
  241. void omapi_connection_register (omapi_connection_object_t *,
  242. const char *, int);
  243. OMAPI_ARRAY_TYPE_DECL(omapi_listener, omapi_listener_object_t);
  244. OMAPI_ARRAY_TYPE_DECL(omapi_connection, omapi_connection_object_t);
  245. isc_result_t omapi_handle_clear(omapi_handle_t);
  246. extern int log_priority;
  247. extern int log_perror;
  248. extern void (*log_cleanup) (void);
  249. void log_fatal (const char *, ...)
  250. __attribute__((__format__(__printf__,1,2))) ISC_DHCP_NORETURN;
  251. int log_error (const char *, ...)
  252. __attribute__((__format__(__printf__,1,2)));
  253. int log_info (const char *, ...)
  254. __attribute__((__format__(__printf__,1,2)));
  255. int log_debug (const char *, ...)
  256. __attribute__((__format__(__printf__,1,2)));
  257. void do_percentm (char *obuf, const char *ibuf);
  258. isc_result_t uerr2isc (int);
  259. isc_result_t ns_rcode_to_isc (int);
  260. extern omapi_message_object_t *omapi_registered_messages;
  261. #endif /* __OMAPIP_OMAPIP_P_H__ */