e0d86b1adc515f676b29fa892ed2d386456ebae3
[openafs.git] / src / auth / cellconfig.p.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 /*
11 cellconfig.h:
12
13     Interface to the routines used by the FileServer to manipulate the cell/server database
14     for the Cellular Andrew system, along with an operation to determine the name of the
15     local cell.  Included are a string variable used to hold the local cell name, definitions for
16     the database file format and routines for:
17         1) Acquiring the local cell name.
18         2) Reading in the cell/server database from disk.
19         3) Reporting the set of servers associated with a given cell name.
20         4) Printing out the contents of the cell/server database.
21         5) Reclaiming the space used by an in-memory database.
22
23 Creation date:
24     17 August 1987
25
26 --------------------------------------------------------------------------------------------------------------*/
27
28 #ifndef __CELLCONFIG_AFS_INCL_
29 #define __CELLCONFIG_AFS_INCL_  1
30
31 #ifndef IPPROTO_MAX
32         /* get sockaddr_in */
33 #ifdef AFS_NT40_ENV
34 #include <winsock2.h>
35 #else
36 #include <sys/types.h>
37 #include <netinet/in.h>
38 #endif
39 #endif
40
41 #define MAXCELLCHARS    64
42 #define MAXHOSTCHARS    64
43 #define MAXHOSTSPERCELL  8
44
45 /*
46  * Return codes.
47  */
48 #define AFSCONF_SUCCESS   0     /* worked */
49 #if 0
50 #define AFSCONF_FAILURE   1     /* mysterious failure */
51 #define AFSCONF_NOTFOUND  2     /* could not find entry */
52 #define AFSCONF_UNKNOWN   3     /* do not know that information */
53 #define AFSCONF_NOCELL    4     /* line appears before a cell has been defined */
54 #define AFSCONF_SYNTAX    5     /* syntax error */
55 #define AFSCONF_NODB      6     /* a database file is missing */
56 #define AFSCONF_FULL      7     /* no more entries */
57 #endif
58
59 /*
60  * Complete server info for one cell.
61  */
62 struct afsconf_cell {
63     char name[MAXCELLCHARS];    /*Cell name */
64     short numServers;           /*Num active servers for the cell */
65     short flags;                /* useful flags */
66     struct sockaddr_in hostAddr[MAXHOSTSPERCELL];       /*IP addresses for cell's servers */
67     char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];       /*Names for cell's servers */
68     char *linkedCell;           /* Linked cell name, if any */
69     int timeout;                /* Data timeout, if non-zero */
70 };
71
72 #define AFSCONF_CELL_FLAG_DNS_QUERIED   1
73
74 struct afsconf_cellalias {
75     char aliasName[MAXCELLCHARS];
76     char realName[MAXCELLCHARS];
77 };
78
79 struct afsconf_entry {
80     struct afsconf_entry *next; /* next guy in afsconf_dir */
81     struct afsconf_cell cellInfo;       /* info for this cell */
82 };
83
84 struct afsconf_aliasentry {
85     struct afsconf_aliasentry *next;
86     struct afsconf_cellalias aliasInfo;
87 };
88
89 struct afsconf_dir {
90     char *name;                 /* pointer to dir prefix */
91     char *cellName;             /* cell name, if any, we're in */
92     struct afsconf_entry *entries;      /* list of cell entries */
93     struct afsconf_keys *keystr;        /* structure containing keys */
94     afs_int32 timeRead;         /* time stamp of file last read */
95     struct afsconf_aliasentry *alias_entries;   /* cell aliases */
96 };
97
98 extern afs_int32 afsconf_FindService(const char *aname);
99 extern const char *afsconf_FindIANAName(const char *aname);
100 extern struct afsconf_dir *afsconf_Open(register const char *adir);
101 extern int afsconf_CellApply(struct afsconf_dir *adir,
102                              int (*aproc) (struct afsconf_cell * cell,
103                                            void *arock,
104                                            struct afsconf_dir * dir),
105                              void *arock);
106 extern int afsconf_CellAliasApply(struct afsconf_dir *adir,
107                                   int (*aproc) (struct afsconf_cellalias *
108                                                 alias, void *arock,
109                                                 struct afsconf_dir * dir),
110                                   void *arock);
111 extern int afsconf_GetExtendedCellInfo(struct afsconf_dir *adir,
112                                        char *acellName, char *aservice,
113                                        struct afsconf_cell *acellInfo,
114                                        char clones[]);
115 extern int afsconf_GetAfsdbInfo(char *acellName, char *aservice,
116                                 struct afsconf_cell *acellInfo);
117 extern int afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName,
118                                char *aservice,
119                                struct afsconf_cell *acellInfo);
120 extern int afsconf_GetLocalCell(register struct afsconf_dir *adir,
121                                 char *aname, afs_int32 alen);
122 extern int afsconf_Close(struct afsconf_dir *adir);
123 extern int afsconf_IntGetKeys(struct afsconf_dir *adir);
124 extern int afsconf_GetKeys(struct afsconf_dir *adir,
125                            struct afsconf_keys *astr);
126 struct ktc_encryptionKey;
127 extern afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir,
128                                       afs_int32 * avno, 
129                                       struct ktc_encryptionKey *akey);
130 extern int afsconf_GetKey(void *rock, int avno,
131                           struct ktc_encryptionKey *akey);
132 extern int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno,
133                           char akey[8], afs_int32 overwrite);
134 extern int afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno);
135
136 /* authcon.c */
137 struct rx_securityClass;
138 extern afs_int32 afsconf_ServerAuth(void *arock, 
139                                     struct rx_securityClass **,
140                                     afs_int32 *);
141 extern afs_int32 afsconf_ClientAuth(void *arock,
142                                     struct rx_securityClass **astr,
143                                     afs_int32 * aindex);
144 extern afs_int32 afsconf_ClientAuthSecure(void *arock,
145                                           struct rx_securityClass **astr,
146                                           afs_int32 * aindex);
147
148 /* Flags for this function */
149 #define AFSCONF_SEC_OBJS_RXKAD_CRYPT 1
150 extern void afsconf_BuildServerSecurityObjects(struct afsconf_dir *,
151                                                afs_uint32,
152                                                struct rx_securityClass ***,
153                                                afs_int32 *);
154
155 /* writeconfig.c */
156 int afsconf_SetExtendedCellInfo(struct afsconf_dir *adir, const char *apath, 
157                                 struct afsconf_cell *acellInfo, char clones[]);
158 int afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath, 
159                         struct afsconf_cell *acellInfo);
160
161
162 /* userok.c */
163
164 struct rx_call;
165 extern int afsconf_CheckAuth(void *arock, struct rx_call *acall);
166 extern int afsconf_GetNoAuthFlag(struct afsconf_dir *adir);
167 extern void afsconf_SetNoAuthFlag(struct afsconf_dir *adir, int aflag);
168 extern int afsconf_DeleteUser(struct afsconf_dir *adir, register char *auser);
169 extern int afsconf_GetNthUser(struct afsconf_dir *adir, afs_int32 an, 
170                               char *abuffer, afs_int32 abufferLen);
171 extern int afsconf_AddUser(struct afsconf_dir *adir, char *aname);
172 extern int afsconf_SuperUser(struct afsconf_dir *adir, struct rx_call *acall,
173                              char *namep);
174
175 /* some well-known ports and their names; new additions to table in cellconfig.c, too */
176 #define AFSCONF_FILESERVICE             "afs"
177 #define AFSCONF_FILEPORT                7000
178 #define AFSCONF_CALLBACKSERVICE         "afscb"
179 #define AFSCONF_CALLBACKPORT            7001
180 #define AFSCONF_PROTSERVICE             "afsprot"
181 #define AFSCONF_PROTPORT                7002
182 #define AFSCONF_VLDBSERVICE             "afsvldb"
183 #define AFSCONF_VLDBPORT                7003
184 #define AFSCONF_KAUTHSERVICE            "afskauth"
185 #define AFSCONF_KAUTHPORT               7004
186 #define AFSCONF_VOLUMESERVICE           "afsvol"
187 #define AFSCONF_VOLUMEPORT              7005
188 #define AFSCONF_ERRORSERVICE            "afserror"
189 #define AFSCONF_ERRORPORT               7006
190 #define AFSCONF_NANNYSERVICE            "afsnanny"
191 #define AFSCONF_NANNYPORT               7007
192 #define AFSCONF_UPDATESERVICE           "afsupdate"
193 #define AFSCONF_UPDATEPORT              7008
194 #define AFSCONF_RMTSYSSERVICE           "afsrmtsys"
195 #define AFSCONF_RMTSYSPORT              7009
196 #define AFSCONF_RSDBSERVICE             "afsres"
197 #define AFSCONF_RESPORT                 7010
198 #define AFSCONF_REMIODBSERVICE          "afsremio"
199 #define AFSCONF_REMIOPORT               7011
200
201 #endif /* __CELLCONFIG_AFS_INCL_ */