Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / libadmin / adminutil / afs_AdminInternal.h
1 /*
2 * Copyright 2000, International Business Machines Corporation and others.
3 * All Rights Reserved.
4 *
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
8 */
9
10 #ifndef OPENAFS_ADMIN_INTERNAL_H
11 #define OPENAFS_ADMIN_INTERNAL_H
12
13 #include <afs/param.h>
14 #include <afs/stds.h>
15 #include <afs/cellconfig.h>
16 #include <afs/auth.h>
17 #include <ubik.h>
18 #include <pthread.h>
19
20 #define BEGIN_MAGIC 0xb0b0b0b0
21 #define END_MAGIC 0xc0c0c0c0
22
23 typedef struct afs_token_handle {
24 int begin_magic;
25 int is_valid;
26 int from_kernel;
27 int afs_token_set;
28 int kas_token_set;
29 int sc_index;
30 char cell[MAXCELLCHARS];
31 struct ktc_token afs_token;
32 struct ktc_token kas_token;
33 struct rx_securityClass *afs_sc[3];
34 struct rx_securityClass *afs_encrypt_sc[3];
35 struct rx_securityClass *kas_sc[3];
36 struct ktc_principal client;
37 int end_magic;
38 } afs_token_handle_t, *afs_token_handle_p;
39
40 typedef struct afs_cell_handle {
41 int begin_magic;
42 int is_valid;
43 int is_null;
44 afs_token_handle_p tokens;
45 char working_cell[MAXCELLCHARS];
46 struct ubik_client *kas;
47 struct ubik_client *pts;
48 struct ubik_client *vos;
49 int kas_valid;
50 int pts_valid;
51 int vos_valid;
52 int vos_new;
53 /* need to add server lists with TTL
54 * so we don't pound the dns servers constantly
55 * when generating the iterators
56 */
57 void *server_list;
58 time_t server_ttl; /* expiration time */
59 int end_magic;
60 } afs_cell_handle_t, *afs_cell_handle_p;
61
62 #define CACHED_ITEMS 5
63
64 typedef int (*validate_specific_data_func) (void *rpc_specific,
65 afs_status_p st);
66
67 typedef int (*destroy_specific_data_func) (void *rpc_specific,
68 afs_status_p st);
69
70 typedef int (*get_cached_data_func) (void *rpc_specific, int slot, void *dest,
71 afs_status_p st);
72
73 typedef int (*make_rpc_func) (void *rpc_specific, int slot, int *last_item,
74 int *last_item_contains_data, afs_status_p st);
75
76
77 /*
78 * the afs_admin_iterator_t structure contains one mutex (named
79 * mutex) that should be held while manipulating any of the other
80 * elements in the structure. The only exception to this rule is
81 * that it is legale to make rpc's without the mutex being held.
82 */
83
84 typedef struct afs_admin_iterator {
85 int begin_magic;
86 int is_valid;
87 pthread_mutex_t mutex; /* hold to manipulate this structure */
88 pthread_cond_t add_item; /* wait for data to be added to the cache */
89 pthread_cond_t remove_item; /* wait for data to be removed from the cache */
90 pthread_t bg_worker; /* thread id of background worker */
91 int cache_slots_used; /* number of items in the cache */
92 int done_iterating; /* finished iterating over the database */
93 int request_terminated; /* Done has been called on this iterator */
94 afs_status_t st; /* the status of the last rpc */
95 int cache_queue_head; /* index into principal that's the head of the q */
96 int cache_queue_tail; /* index into principal that's the tail of the q */
97 void *rpc_specific;
98 make_rpc_func make_rpc;
99 get_cached_data_func get_cached_data;
100 validate_specific_data_func validate_specific;
101 destroy_specific_data_func destroy_specific;
102 int end_magic;
103 } afs_admin_iterator_t, *afs_admin_iterator_p;
104
105 int IteratorNext(afs_admin_iterator_p iter, void *dest, afs_status_p st);
106
107 int IteratorDone(afs_admin_iterator_p iter, afs_status_p st);
108
109 int IteratorInit(afs_admin_iterator_p iter, void *rpc_specific,
110 make_rpc_func make_rpc, get_cached_data_func get_cached_data,
111 validate_specific_data_func validate_specific_data,
112 destroy_specific_data_func destroy_specific_data,
113 afs_status_p st);
114 #endif /* OPENAFS_ADMIN_INTERNAL_H */