1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
3 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
4 * Use is subject to license terms.
10 /* #pragma ident "@(#)kdb_log.h 1.3 04/02/23 SMI" */
12 #include <iprop_hdr.h>
24 #define INDEX(ulog, i) (kdb_ent_header_t *)(void *) \
25 ((char *)(ulog) + sizeof(kdb_hlog_t) + (i) * ulog->kdb_block)
28 * Current DB version #
36 #define KDB_UNSTABLE 2
42 #define KDB_ULOG_MAGIC 0x6661212
43 #define KDB_ULOG_HDR_MAGIC 0x6662323
46 * Default ulog file attributes
48 #define DEF_ULOGENTRIES 1000
49 #define ULOG_IDLE_TIME 10 /* in seconds */
51 * Max size of update entry + update header
52 * We make this large since resizing can be costly.
54 #define ULOG_BLOCK 2048 /* Default size of principal record */
56 #define MAXLOGLEN 0x10000000 /* 256 MB log file */
59 * Prototype declarations
61 krb5_error_code ulog_map(krb5_context context, const char *logname,
63 krb5_error_code ulog_init_header(krb5_context context);
64 krb5_error_code ulog_add_update(krb5_context context, kdb_incr_update_t *upd);
65 krb5_error_code ulog_get_entries(krb5_context context, const kdb_last_t *last,
66 kdb_incr_result_t *ulog_handle);
67 krb5_error_code ulog_replay(krb5_context context, kdb_incr_result_t *incr_ret,
69 krb5_error_code ulog_conv_2logentry(krb5_context context, krb5_db_entry *entry,
70 kdb_incr_update_t *update);
71 krb5_error_code ulog_conv_2dbentry(krb5_context context, krb5_db_entry **entry,
72 kdb_incr_update_t *update);
73 void ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates);
74 krb5_error_code ulog_set_role(krb5_context ctx, iprop_role role);
75 update_status_t ulog_get_sno_status(krb5_context context,
76 const kdb_last_t *last);
77 krb5_error_code ulog_get_last(krb5_context context, kdb_last_t *last_out);
78 krb5_error_code ulog_set_last(krb5_context context, const kdb_last_t *last);
79 void ulog_fini(krb5_context context);
81 typedef struct kdb_hlog {
82 uint32_t kdb_hmagic; /* Log header magic # */
83 uint16_t db_version_num; /* Kerberos database version no. */
84 uint32_t kdb_num; /* # of updates in log */
85 kdbe_time_t kdb_first_time; /* Timestamp of first update */
86 kdbe_time_t kdb_last_time; /* Timestamp of last update */
87 kdb_sno_t kdb_first_sno; /* First serial # in the update log */
88 kdb_sno_t kdb_last_sno; /* Last serial # in the update log */
89 uint16_t kdb_state; /* State of update log */
90 uint16_t kdb_block; /* Block size of each element */
93 typedef struct kdb_ent_header {
94 uint32_t kdb_umagic; /* Update entry magic # */
95 kdb_sno_t kdb_entry_sno; /* Serial # of entry */
96 kdbe_time_t kdb_time; /* Timestamp of update */
97 bool_t kdb_commit; /* Is the entry committed or not */
98 uint32_t kdb_entry_size; /* Size of update entry */
99 uint8_t entry_data[4]; /* Address of kdb_incr_update_t */
102 typedef struct _kdb_log_context {
103 iprop_role iproprole;
105 uint32_t ulogentries;
113 #endif /* !_KDB_LOG_H */