Path: blob/main/crypto/krb5/src/include/kdb_log.h
104991 views
/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */1/*2* Copyright 2004 Sun Microsystems, Inc. All rights reserved.3* Use is subject to license terms.4*/56#ifndef _KDB_LOG_H7#define _KDB_LOG_H89/* #pragma ident "@(#)kdb_log.h 1.3 04/02/23 SMI" */1011#include <iprop_hdr.h>12#include <iprop.h>13#include <limits.h>14#include "kdb.h"1516#ifdef __cplusplus17extern "C" {18#endif1920/*21* Current DB version #22*/23#define KDB_VERSION 12425/*26* DB log states27*/28#define KDB_STABLE 129#define KDB_UNSTABLE 230#define KDB_CORRUPT 33132/*33* DB log constants34*/35#define KDB_ULOG_MAGIC 0x666121236#define KDB_ULOG_HDR_MAGIC 0x66623233738/*39* Default ulog file attributes40*/41#define DEF_ULOGENTRIES 100042#define ULOG_IDLE_TIME 10 /* in seconds */43/*44* Max size of update entry + update header45* We make this large since resizing can be costly.46*/47#define ULOG_BLOCK 2048 /* Default size of principal record */4849#define MAXLOGLEN 0x10000000 /* 256 MB log file */5051/*52* Prototype declarations53*/54krb5_error_code ulog_map(krb5_context context, const char *logname,55uint32_t entries);56krb5_error_code ulog_init_header(krb5_context context);57krb5_error_code ulog_add_update(krb5_context context, kdb_incr_update_t *upd);58krb5_error_code ulog_get_entries(krb5_context context, const kdb_last_t *last,59kdb_incr_result_t *ulog_handle);60krb5_error_code ulog_replay(krb5_context context, kdb_incr_result_t *incr_ret,61char **db_args);62krb5_error_code ulog_conv_2logentry(krb5_context context, krb5_db_entry *entry,63kdb_incr_update_t *update);64krb5_error_code ulog_conv_2dbentry(krb5_context context, krb5_db_entry **entry,65kdb_incr_update_t *update);66void ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates);67krb5_error_code ulog_set_role(krb5_context ctx, iprop_role role);68update_status_t ulog_get_sno_status(krb5_context context,69const kdb_last_t *last);70krb5_error_code ulog_get_last(krb5_context context, kdb_last_t *last_out);71krb5_error_code ulog_set_last(krb5_context context, const kdb_last_t *last);72void ulog_fini(krb5_context context);7374typedef struct kdb_hlog {75uint32_t kdb_hmagic; /* Log header magic # */76uint16_t db_version_num; /* Kerberos database version no. */77uint32_t kdb_num; /* # of updates in log */78kdbe_time_t kdb_first_time; /* Timestamp of first update */79kdbe_time_t kdb_last_time; /* Timestamp of last update */80kdb_sno_t kdb_first_sno; /* First serial # in the update log */81kdb_sno_t kdb_last_sno; /* Last serial # in the update log */82uint16_t kdb_state; /* State of update log */83uint16_t kdb_block; /* Block size of each element */84} kdb_hlog_t;8586typedef struct kdb_ent_header {87uint32_t kdb_umagic; /* Update entry magic # */88kdb_sno_t kdb_entry_sno; /* Serial # of entry */89kdbe_time_t kdb_time; /* Timestamp of update */90bool_t kdb_commit; /* Is the entry committed or not */91uint32_t kdb_entry_size; /* Size of update entry */92uint8_t entry_data[4]; /* Address of kdb_incr_update_t */93} kdb_ent_header_t;9495typedef struct _kdb_log_context {96iprop_role iproprole;97kdb_hlog_t *ulog;98uint32_t ulogentries;99int ulogfd;100} kdb_log_context;101102/* Return the address of the i'th record in ulog for the given block size. */103static inline uint8_t *104ulog_record_ptr(kdb_hlog_t *ulog, size_t i, size_t bsize)105{106return (uint8_t *)ulog + sizeof(*ulog) + i * bsize;107}108109/* Return the i'th update entry header for ulog. */110static inline kdb_ent_header_t *111ulog_index(kdb_hlog_t *ulog, size_t i)112{113return (void *)ulog_record_ptr(ulog, i, ulog->kdb_block);114}115116#ifdef __cplusplus117}118#endif119120#endif /* !_KDB_LOG_H */121122123