304152494433b2bc25cea641436332e4a738f85e
[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 TRANSARC_AFS_ADMIN_INTERNAL_H
11 #define TRANSARC_AFS_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     int end_magic;
54 } afs_cell_handle_t, *afs_cell_handle_p;
55
56 #define CACHED_ITEMS 5
57
58 typedef int (*validate_specific_data_func)(
59   void *rpc_specific,
60   afs_status_p st
61 );
62  
63 typedef int (*destroy_specific_data_func)(
64   void *rpc_specific,
65   afs_status_p st
66 );
67  
68 typedef int (*get_cached_data_func)(
69   void *rpc_specific,
70   int slot,
71   void *dest,
72   afs_status_p st
73 );
74  
75 typedef int (*make_rpc_func)(
76   void *rpc_specific,
77   int slot,
78   int *last_item,
79   int *last_item_contains_data,
80   afs_status_p st
81 );
82  
83
84 /*
85  * the afs_admin_iterator_t structure contains one mutex (named
86  * mutex) that should be held while manipulating any of the other
87  * elements in the structure.  The only exception to this rule is
88  * that it is legale to make rpc's without the mutex being held.
89  */
90
91 typedef struct afs_admin_iterator {
92     int begin_magic;
93     int is_valid;
94     pthread_mutex_t mutex; /* hold to manipulate this structure */
95     pthread_cond_t add_item; /* wait for data to be added to the cache */
96     pthread_cond_t remove_item; /* wait for data to be removed from the cache */
97     pthread_t bg_worker; /* thread id of background worker */
98     int cache_slots_used; /* number of items in the cache */
99     int done_iterating; /* finished iterating over the database */
100     int request_terminated; /* Done has been called on this iterator */
101     afs_status_t st; /* the status of the last rpc */
102     int cache_queue_head; /* index into principal that's the head of the q */
103     int cache_queue_tail; /* index into principal that's the tail of the q */
104     void *rpc_specific;
105     make_rpc_func make_rpc;
106     get_cached_data_func get_cached_data;
107     validate_specific_data_func validate_specific;
108     destroy_specific_data_func destroy_specific;
109     int end_magic;
110 } afs_admin_iterator_t, *afs_admin_iterator_p;
111
112 int IteratorNext(
113   afs_admin_iterator_p iter,
114   void *dest,
115   afs_status_p st
116 );
117
118 int IteratorDone(
119   afs_admin_iterator_p iter,
120   afs_status_p st
121 );
122
123 int IteratorInit(
124   afs_admin_iterator_p iter,
125   void *rpc_specific,
126   make_rpc_func make_rpc,
127   get_cached_data_func get_cached_data,
128   validate_specific_data_func validate_specific_data,
129   destroy_specific_data_func destroy_specific_data,
130   afs_status_p st
131 );
132 #endif /* TRANSARC_AFS_ADMIN_INTERNAL_H */