From 9bc62b9bb27fe5db4f16581780b3309aba8cf32e Mon Sep 17 00:00:00 2001 From: Ted Lemon Date: Wed, 27 Jun 2001 00:12:02 +0000 Subject: Add these to the mainline. --- includes/isc-dhcp/boolean.h | 32 ++++++++++ includes/isc-dhcp/dst.h | 142 ++++++++++++++++++++++++++++++++++++++++++++ includes/isc-dhcp/int.h | 36 +++++++++++ includes/isc-dhcp/lang.h | 29 +++++++++ includes/isc-dhcp/list.h | 116 ++++++++++++++++++++++++++++++++++++ includes/isc-dhcp/result.h | 113 +++++++++++++++++++++++++++++++++++ includes/isc-dhcp/types.h | 40 +++++++++++++ 7 files changed, 508 insertions(+) create mode 100644 includes/isc-dhcp/boolean.h create mode 100644 includes/isc-dhcp/dst.h create mode 100644 includes/isc-dhcp/int.h create mode 100644 includes/isc-dhcp/lang.h create mode 100644 includes/isc-dhcp/list.h create mode 100644 includes/isc-dhcp/result.h create mode 100644 includes/isc-dhcp/types.h diff --git a/includes/isc-dhcp/boolean.h b/includes/isc-dhcp/boolean.h new file mode 100644 index 00000000..08d8c245 --- /dev/null +++ b/includes/isc-dhcp/boolean.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 1998, 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_BOOLEAN_H +#define ISC_BOOLEAN_H 1 + +#include + +ISC_LANG_BEGINDECLS + +typedef enum { isc_boolean_false = 0, isc_boolean_true = 1 } isc_boolean_t; + +#define ISC_FALSE isc_boolean_false +#define ISC_TRUE isc_boolean_true + +ISC_LANG_ENDDECLS + +#endif /* ISC_BOOLEAN_H */ diff --git a/includes/isc-dhcp/dst.h b/includes/isc-dhcp/dst.h new file mode 100644 index 00000000..65c54d24 --- /dev/null +++ b/includes/isc-dhcp/dst.h @@ -0,0 +1,142 @@ +#ifndef DST_H +#define DST_H + +#ifndef HAS_DST_KEY +typedef struct dst_key { + char *dk_key_name; /* name of the key */ + int dk_key_size; /* this is the size of the key in bits */ + int dk_proto; /* what protocols this key can be used for */ + int dk_alg; /* algorithm number from key record */ + unsigned dk_flags; /* and the flags of the public key */ + unsigned dk_id; /* identifier of the key */ +} DST_KEY; +#endif /* HAS_DST_KEY */ + +/* + * DST Crypto API defintions + */ +void dst_init(void); +int dst_check_algorithm(const int); + +int dst_sign_data(const int mode, /* specifies INIT/UPDATE/FINAL/ALL */ + DST_KEY *in_key, /* the key to use */ + void **context, /* pointer to state structure */ + const u_char *data, /* data to be signed */ + const unsigned len, /* length of input data */ + u_char *signature, /* buffer to write signature to */ + const unsigned sig_len); /* size of output buffer */ + +int dst_verify_data(const int mode, /* specifies INIT/UPDATE/FINAL/ALL */ + DST_KEY *in_key, /* the key to use */ + void **context, /* pointer to state structure */ + const u_char *data, /* data to be verified */ + const unsigned len, /* length of input data */ + const u_char *signature,/* buffer containing signature */ + const unsigned sig_len); /* length of signature */ + + +DST_KEY *dst_read_key(const char *in_name, /* name of key */ + const unsigned in_id, /* key tag identifier */ + const int in_alg, /* key algorithm */ + const int key_type); /* Private/PublicKey wanted*/ + +int dst_write_key(const DST_KEY *key, /* key to write out */ + const int key_type); /* Public/Private */ + +DST_KEY *dst_dnskey_to_key(const char *in_name, /* KEY record name */ + const u_char *key, /* KEY RDATA */ + const unsigned len); /* size of input buffer*/ + + +int dst_key_to_dnskey(const DST_KEY *key, /* key to translate */ + u_char *out_storage, /* output buffer */ + const unsigned out_len); /* size of out_storage*/ + + +DST_KEY *dst_buffer_to_key(const char *key_name, /* name of the key */ + const int alg, /* algorithm */ + const unsigned flags, /* dns flags */ + const int protocol, /* dns protocol */ + const u_char *key_buf, /* key in dns wire fmt */ + const unsigned key_len); /* size of key */ + + +int dst_key_to_buffer(DST_KEY *key, u_char *out_buff, unsigned buf_len); + +DST_KEY *dst_generate_key(const char *name, /* name of new key */ + const int bits, /* size of new key */ + const int exp, /* alg dependent parameter*/ + const unsigned flags, /* key DNS flags */ + const int protocol, /* key DNS protocol */ + const int alg); /* key algorithm to generate */ + +DST_KEY *dst_free_key(DST_KEY *f_key); +int dst_compare_keys(const DST_KEY *key1, const DST_KEY *key2); + +int dst_sig_size(DST_KEY *key); + +int dst_random(const int mode, unsigned wanted, u_char *outran); + + +/* support for dns key tags/ids */ +u_int16_t dst_s_dns_key_id(const u_char *dns_key_rdata, + const unsigned rdata_len); +u_int16_t dst_s_id_calc(const u_char *key_data, const unsigned key_len); + +/* Used by callers as well as by the library. */ +#define RAW_KEY_SIZE 8192 /* large enough to store any key */ + +/* DST_API control flags */ +/* These are used used in functions dst_sign_data and dst_verify_data */ +#define SIG_MODE_INIT 1 /* initalize digest */ +#define SIG_MODE_UPDATE 2 /* add data to digest */ +#define SIG_MODE_FINAL 4 /* generate/verify signature */ +#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL) + +/* Flags for dst_read_private_key() */ +#define DST_FORCE_READ 0x1000000 +#define DST_CAN_SIGN 0x010F +#define DST_NO_AUTHEN 0x8000 +#define DST_EXTEND_FLAG 0x1000 +#define DST_STANDARD 0 +#define DST_PRIVATE 0x2000000 +#define DST_PUBLIC 0x4000000 +#define DST_RAND_SEMI 1 +#define DST_RAND_STD 2 +#define DST_RAND_KEY 3 +#define DST_RAND_DSS 4 + + +/* DST algorithm codes */ +#define KEY_RSA 1 +#define KEY_DH 2 +#define KEY_DSA 3 +#define KEY_PRIVATE 254 +#define KEY_EXPAND 255 +#define KEY_HMAC_MD5 157 +#define KEY_HMAC_SHA1 158 +#define UNKNOWN_KEYALG 0 +#define DST_MAX_ALGS KEY_HMAC_SHA1 + +/* DST constants to locations in KEY record changes in new KEY record */ +#define DST_FLAGS_SIZE 2 +#define DST_KEY_PROT 2 +#define DST_KEY_ALG 3 +#define DST_EXT_FLAG 4 +#define DST_KEY_START 4 + +#ifndef SIGN_F_NOKEY +#define SIGN_F_NOKEY 0xC000 +#endif + +/* error codes from dst routines */ +#define SIGN_INIT_FAILURE (-23) +#define SIGN_UPDATE_FAILURE (-24) +#define SIGN_FINAL_FAILURE (-25) +#define VERIFY_INIT_FAILURE (-26) +#define VERIFY_UPDATE_FAILURE (-27) +#define VERIFY_FINAL_FAILURE (-28) +#define MISSING_KEY_OR_SIGNATURE (-30) +#define UNSUPPORTED_KEYALG (-31) + +#endif /* DST_H */ diff --git a/includes/isc-dhcp/int.h b/includes/isc-dhcp/int.h new file mode 100644 index 00000000..98159f53 --- /dev/null +++ b/includes/isc-dhcp/int.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_INT_H +#define ISC_INT_H 1 + +#include + +ISC_LANG_BEGINDECLS + +typedef char isc_int8_t; +typedef unsigned char isc_uint8_t; +typedef short isc_int16_t; +typedef unsigned short isc_uint16_t; +typedef int isc_int32_t; +typedef unsigned int isc_uint32_t; +typedef long long isc_int64_t; +typedef unsigned long long isc_uint64_t; + +ISC_LANG_ENDDECLS + +#endif /* ISC_INT_H */ diff --git a/includes/isc-dhcp/lang.h b/includes/isc-dhcp/lang.h new file mode 100644 index 00000000..3edeb72d --- /dev/null +++ b/includes/isc-dhcp/lang.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_LANG_H +#define ISC_LANG_H 1 + +#ifdef __cplusplus +#define ISC_LANG_BEGINDECLS extern "C" { +#define ISC_LANG_ENDDECLS } +#else +#define ISC_LANG_BEGINDECLS +#define ISC_LANG_ENDDECLS +#endif + +#endif /* ISC_LANG_H */ diff --git a/includes/isc-dhcp/list.h b/includes/isc-dhcp/list.h new file mode 100644 index 00000000..d9660088 --- /dev/null +++ b/includes/isc-dhcp/list.h @@ -0,0 +1,116 @@ +/* + * Copyright (C) 1997, 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_LIST_H +#define ISC_LIST_H 1 + +#define ISC_LIST(type) struct { type *head, *tail; } +#define ISC_LIST_INIT(list) \ + do { (list).head = NULL; (list).tail = NULL; } while (0) + +#define ISC_LINK(type) struct { type *prev, *next; } +#define ISC_LINK_INIT(elt, link) \ + do { \ + (elt)->link.prev = (void *)(-1); \ + (elt)->link.next = (void *)(-1); \ + } while (0) +#define ISC_LINK_LINKED(elt, link) ((elt)->link.prev != (void *)(-1)) + +#define ISC_LIST_HEAD(list) ((list).head) +#define ISC_LIST_TAIL(list) ((list).tail) +#define ISC_LIST_EMPTY(list) ((list).head == NULL) + +#define ISC_LIST_PREPEND(list, elt, link) \ + do { \ + if ((list).head != NULL) \ + (list).head->link.prev = (elt); \ + else \ + (list).tail = (elt); \ + (elt)->link.prev = NULL; \ + (elt)->link.next = (list).head; \ + (list).head = (elt); \ + } while (0) + +#define ISC_LIST_APPEND(list, elt, link) \ + do { \ + if ((list).tail != NULL) \ + (list).tail->link.next = (elt); \ + else \ + (list).head = (elt); \ + (elt)->link.prev = (list).tail; \ + (elt)->link.next = NULL; \ + (list).tail = (elt); \ + } while (0) + +#define ISC_LIST_UNLINK(list, elt, link) \ + do { \ + if ((elt)->link.next != NULL) \ + (elt)->link.next->link.prev = (elt)->link.prev; \ + else \ + (list).tail = (elt)->link.prev; \ + if ((elt)->link.prev != NULL) \ + (elt)->link.prev->link.next = (elt)->link.next; \ + else \ + (list).head = (elt)->link.next; \ + (elt)->link.prev = (void *)(-1); \ + (elt)->link.next = (void *)(-1); \ + } while (0) + +#define ISC_LIST_PREV(elt, link) ((elt)->link.prev) +#define ISC_LIST_NEXT(elt, link) ((elt)->link.next) + +#define ISC_LIST_INSERTBEFORE(list, before, elt, link) \ + do { \ + if ((before)->link.prev == NULL) \ + ISC_LIST_PREPEND(list, elt, link); \ + else { \ + (elt)->link.prev = (before)->link.prev; \ + (before)->link.prev = (elt); \ + (elt)->link.prev->link.next = (elt); \ + (elt)->link.next = (before); \ + } \ + } while (0) + +#define ISC_LIST_INSERTAFTER(list, after, elt, link) \ + do { \ + if ((after)->link.next == NULL) \ + ISC_LIST_APPEND(list, elt, link); \ + else { \ + (elt)->link.next = (after)->link.next; \ + (after)->link.next = (elt); \ + (elt)->link.next->link.prev = (elt); \ + (elt)->link.prev = (after); \ + } \ + } while (0) + +#define ISC_LIST_APPENDLIST(list1, list2, link) \ + do { \ + if (ISC_LIST_EMPTY(list1)) \ + (list1) = (list2); \ + else if (!ISC_LIST_EMPTY(list2)) { \ + (list1).tail->link.next = (list2).head; \ + (list2).head->link.prev = (list1).tail; \ + (list1).tail = (list2).tail; \ + (list2).head = NULL; \ + (list2).tail = NULL; \ + } \ + } while (0) + +#define ISC_LIST_ENQUEUE(list, elt, link) ISC_LIST_APPEND(list, elt, link) +#define ISC_LIST_DEQUEUE(list, elt, link) ISC_LIST_UNLINK(list, elt, link) + +#endif /* ISC_LIST_H */ diff --git a/includes/isc-dhcp/result.h b/includes/isc-dhcp/result.h new file mode 100644 index 00000000..a2de1fcd --- /dev/null +++ b/includes/isc-dhcp/result.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 1998, 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_RESULT_H +#define ISC_RESULT_H 1 + +#include +#include +#include +#include + +ISC_LANG_BEGINDECLS + +typedef enum { + ISC_R_SUCCESS = 0, + ISC_R_NOMEMORY = 1, + ISC_R_TIMEDOUT = 2, + ISC_R_NOTHREADS = 3, + ISC_R_ADDRNOTAVAIL = 4, + ISC_R_ADDRINUSE = 5, + ISC_R_NOPERM = 6, + ISC_R_NOCONN = 7, + ISC_R_NETUNREACH = 8, + ISC_R_HOSTUNREACH = 9, + ISC_R_NETDOWN = 10, + ISC_R_HOSTDOWN = 11, + ISC_R_CONNREFUSED = 12, + ISC_R_NORESOURCES = 13, + ISC_R_EOF = 14, + ISC_R_BOUND = 15, + ISC_R_TASKDONE = 16, + ISC_R_LOCKBUSY = 17, + ISC_R_EXISTS = 18, + ISC_R_NOSPACE = 19, + ISC_R_CANCELED = 20, + ISC_R_TASKNOSEND = 21, + ISC_R_SHUTTINGDOWN = 22, + ISC_R_NOTFOUND = 23, + ISC_R_UNEXPECTEDEND = 24, + ISC_R_FAILURE = 25, + ISC_R_IOERROR = 26, + ISC_R_NOTIMPLEMENTED = 27, + ISC_R_UNBALANCED = 28, + ISC_R_NOMORE = 29, + ISC_R_INVALIDFILE = 30, + ISC_R_BADBASE64 = 31, + ISC_R_UNEXPECTEDTOKEN = 32, + ISC_R_QUOTA = 33, + ISC_R_UNEXPECTED = 34, + ISC_R_ALREADYRUNNING = 35, + ISC_R_HOSTUNKNOWN = 36, + ISC_R_VERSIONMISMATCH = 37, + ISC_R_PROTOCOLERROR = 38, + ISC_R_INVALIDARG = 39, + ISC_R_NOTCONNECTED = 40, + ISC_R_NOTYET = 41, + ISC_R_UNCHANGED = 42, + ISC_R_MULTIPLE = 43, + ISC_R_KEYCONFLICT = 44, + ISC_R_BADPARSE = 45, + ISC_R_NOKEYS = 46, + ISC_R_KEY_UNKNOWN = 47, + ISC_R_INVALIDKEY = 48, + ISC_R_INCOMPLETE = 49, + ISC_R_FORMERR = 50, + ISC_R_SERVFAIL = 51, + ISC_R_NXDOMAIN = 52, + ISC_R_NOTIMPL = 53, + ISC_R_REFUSED = 54, + ISC_R_YXDOMAIN = 55, + ISC_R_YXRRSET = 56, + ISC_R_NXRRSET = 57, + ISC_R_NOTAUTH = 58, + ISC_R_NOTZONE = 59, + ISC_R_BADSIG = 60, + ISC_R_BADKEY = 61, + ISC_R_BADTIME = 62, + ISC_R_NOROOTZONE = 63, + ISC_R_DESTADDRREQ = 64, + ISC_R_CROSSZONE = 65, + ISC_R_NO_TSIG = 66, + ISC_R_NOT_EQUAL = 67, + ISC_R_CONNRESET = 68, + ISC_R_UNKNOWNATTRIBUTE = 69 +} isc_result_t; + + +#define ISC_R_NRESULTS 70 /* Number of results */ + +const char * isc_result_totext(isc_result_t); +isc_result_t isc_result_register(unsigned int base, + unsigned int nresults, + char **text, + isc_msgcat_t *msgcat, + int set); + +ISC_LANG_ENDDECLS + +#endif /* ISC_RESULT_H */ diff --git a/includes/isc-dhcp/types.h b/includes/isc-dhcp/types.h new file mode 100644 index 00000000..862bd376 --- /dev/null +++ b/includes/isc-dhcp/types.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 1999 Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +#ifndef ISC_TYPES_H +#define ISC_TYPES_H 1 + +#include +#include +#include + +/*** + *** Core Types. + ***/ + +typedef struct isc_mem isc_mem_t; +typedef struct isc_mempool isc_mempool_t; +typedef struct isc_msgcat isc_msgcat_t; +typedef unsigned int isc_eventtype_t; +typedef struct isc_event isc_event_t; +typedef struct isc_task isc_task_t; +typedef struct isc_taskmgr isc_taskmgr_t; +typedef struct isc_rwlock isc_rwlock_t; + +typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *); + +#endif /* ISC_TYPES_H */ -- cgit v1.2.1