Automate RST HTML generation with doxygen info
[krb5.git] / src / include / kdb_log.h
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(ulogaddr, i) ((unsigned long) ulogaddr + sizeof (kdb_hlog_t) + \
25                             (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  * DB Flags
47  */
48 #define FKADMIND        1
49 #define FKPROPLOG       2
50 #define FKPROPD         3
51 #define FKCOMMAND       4       /* Includes kadmin.local and kdb5_util */
52
53 /*
54  * Default ulog file attributes
55  */
56 #define MAX_ULOGENTRIES 2500
57 #define DEF_ULOGENTRIES 1000
58 #define ULOG_IDLE_TIME  10              /* in seconds */
59 /*
60  * Max size of update entry + update header
61  * We make this large since resizing can be costly.
62  */
63 #define ULOG_BLOCK      2048            /* Default size of principal record */
64
65 #define MAXLOGLEN       0x10000000      /* 256 MB log file */
66
67 /*
68  * Prototype declarations
69  */
70 extern krb5_error_code ulog_map(krb5_context context,
71                                 const char *logname, uint32_t entries,
72                                 int caller,
73                                 char **db_args);
74 extern krb5_error_code ulog_add_update(krb5_context context,
75                                        kdb_incr_update_t *upd);
76 extern krb5_error_code ulog_delete_update(krb5_context context,
77                                           kdb_incr_update_t *upd);
78 extern krb5_error_code ulog_finish_update(krb5_context context,
79                                           kdb_incr_update_t *upd);
80 extern krb5_error_code ulog_get_entries(krb5_context context, kdb_last_t last,
81                                         kdb_incr_result_t *ulog_handle);
82
83 extern krb5_error_code
84 ulog_replay(krb5_context context, kdb_incr_result_t *incr_ret, char **db_args);
85
86 extern krb5_error_code
87 ulog_conv_2logentry(krb5_context context, krb5_db_entry *entry,
88                     kdb_incr_update_t *update);
89
90 extern krb5_error_code
91 ulog_conv_2dbentry(krb5_context context, krb5_db_entry **entry,
92                    kdb_incr_update_t *update);
93
94 extern void ulog_free_entries(kdb_incr_update_t *updates, int no_of_updates);
95 extern krb5_error_code ulog_set_role(krb5_context ctx, iprop_role role);
96
97 extern krb5_error_code ulog_lock(krb5_context ctx, int mode);
98
99 typedef struct kdb_hlog {
100     uint32_t        kdb_hmagic;     /* Log header magic # */
101     uint16_t        db_version_num; /* Kerberos database version no. */
102     uint32_t        kdb_num;        /* # of updates in log */
103     kdbe_time_t     kdb_first_time; /* Timestamp of first update */
104     kdbe_time_t     kdb_last_time;  /* Timestamp of last update */
105     kdb_sno_t       kdb_first_sno;  /* First serial # in the update log */
106     kdb_sno_t       kdb_last_sno;   /* Last serial # in the update log */
107     uint16_t        kdb_state;      /* State of update log */
108     uint16_t        kdb_block;      /* Block size of each element */
109 } kdb_hlog_t;
110
111 typedef struct kdb_ent_header {
112     uint32_t        kdb_umagic;     /* Update entry magic # */
113     kdb_sno_t       kdb_entry_sno;  /* Serial # of entry */
114     kdbe_time_t     kdb_time;       /* Timestamp of update */
115     bool_t          kdb_commit;     /* Is the entry committed or not */
116     uint32_t        kdb_entry_size; /* Size of update entry */
117     uint8_t         entry_data[4];  /* Address of kdb_incr_update_t */
118 } kdb_ent_header_t;
119
120 typedef struct _kdb_log_context {
121     iprop_role      iproprole;
122     kdb_hlog_t      *ulog;
123     uint32_t        ulogentries;
124     int             ulogfd;
125 } kdb_log_context;
126
127 #ifdef  __cplusplus
128 }
129 #endif
130
131 #endif  /* !_KDB_LOG_H */