1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 2 /* 3 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 4 * Use is subject to license terms. 5 */ 6 7 #ifndef _KDB_LOG_H 8 #define _KDB_LOG_H 9 10 /* #pragma ident "@(#)kdb_log.h 1.3 04/02/23 SMI" */ 11 12 #include <iprop_hdr.h> 13 #include <iprop.h> 14 #include <limits.h> 15 #include "kdb.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /* 22 * DB macros 23 */ 24 #define INDEX(ulog, i) (kdb_ent_header_t *)(void *) \ 25 ((char *)(ulog) + sizeof(kdb_hlog_t) + (i) * ulog->kdb_block) 26 27 /* 28 * Current DB version # 29 */ 30 #define KDB_VERSION 1 31 32 /* 33 * DB log states 34 */ 35 #define KDB_STABLE 1 36 #define KDB_UNSTABLE 2 37 #define KDB_CORRUPT 3 38 39 /* 40 * DB log constants 41 */ 42 #define KDB_ULOG_MAGIC 0x6661212 43 #define KDB_ULOG_HDR_MAGIC 0x6662323 44 45 /* 46 * Default ulog file attributes 47 */ 48 #define DEF_ULOGENTRIES 1000 49 #define ULOG_IDLE_TIME 10 /* in seconds */ 50 /* 51 * Max size of update entry + update header 52 * We make this large since resizing can be costly. 53 */ 54 #define ULOG_BLOCK 2048 /* Default size of principal record */ 55 56 #define MAXLOGLEN 0x10000000 /* 256 MB log file */ 57 58 /* 59 * Prototype declarations 60 */ 61 krb5_error_code ulog_map(krb5_context context, const char *logname, 62 uint32_t entries); 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, 68 char **db_args); 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); 80 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 */ 91 } kdb_hlog_t; 92 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 */ 100 } kdb_ent_header_t; 101 102 typedef struct _kdb_log_context { 103 iprop_role iproprole; 104 kdb_hlog_t *ulog; 105 uint32_t ulogentries; 106 int ulogfd; 107 } kdb_log_context; 108 109 #ifdef __cplusplus 110 } 111 #endif 112 113 #endif /* !_KDB_LOG_H */ 114