Blob


1 enum
2 {
3 MaxRpc = 2048, /* max size of any protocol message */
5 /* keep in sync with rpc.c:/rpcname */
6 RpcUnknown = 0, /* Rpc.op */
7 RpcAuthinfo,
8 RpcAttr,
9 RpcRead,
10 RpcStart,
11 RpcWrite,
12 RpcReadHex,
13 RpcWriteHex,
15 /* thread stack size - big buffers for printing */
16 STACK = 65536
17 };
19 typedef struct Conv Conv;
20 typedef struct Key Key;
21 typedef struct Logbuf Logbuf;
22 typedef struct Proto Proto;
23 typedef struct Ring Ring;
24 typedef struct Role Role;
25 typedef struct Rpc Rpc;
27 struct Rpc
28 {
29 int op;
30 void *data;
31 int count;
32 int hex; /* should result of read be turned into hex? */
33 };
35 struct Conv
36 {
37 int ref; /* ref count */
38 int hangup; /* flag: please hang up */
39 int active; /* flag: there is an active thread */
40 int done; /* flag: conversation finished successfully */
41 ulong tag; /* identifying tag */
42 Conv *next; /* in linked list */
43 char *sysuser; /* system name for user speaking to us */
44 char *state; /* for debugging */
45 char statebuf[128]; /* for formatted states */
46 char err[ERRMAX]; /* last error */
48 Attr *attr; /* current attributes */
49 Proto *proto; /* protocol */
51 Channel *rpcwait; /* wait here for an rpc */
52 Rpc rpc; /* current rpc. op==RpcUnknown means none */
53 char rpcbuf[MaxRpc]; /* buffer for rpc */
54 char reply[MaxRpc]; /* buffer for response */
55 int nreply; /* count of response */
56 void (*kickreply)(Conv*); /* call to send response */
57 Req *req; /* 9P call to read response */
59 Channel *keywait; /* wait here for key confirmation */
61 };
63 struct Key
64 {
65 int ref; /* ref count */
66 ulong tag; /* identifying tag: sequence number */
67 Attr *attr; /* public attributes */
68 Attr *privattr; /* private attributes, like !password */
69 Proto *proto; /* protocol owner of key */
70 void *priv; /* protocol-specific storage */
71 };
73 struct Logbuf
74 {
75 Req *wait;
76 Req **waitlast;
77 int rp;
78 int wp;
79 char *msg[128];
80 };
82 struct Ring
83 {
84 Key **key;
85 int nkey;
86 };
88 struct Proto
89 {
90 char *name; /* name of protocol */
91 Role *roles; /* list of roles and service functions */
92 char *keyprompt; /* required attributes for key proto=name */
93 int (*checkkey)(Key*); /* initialize k->priv or reject key */
94 void (*closekey)(Key*); /* free k->priv */
95 };
97 struct Role
98 {
99 char *name; /* name of role */
100 int (*fn)(Conv*); /* service function */
101 };
103 extern char *authaddr; /* plan9.c */
104 extern int *confirminuse; /* fs.c */
105 extern Conv* conv; /* conv.c */
106 extern int debug; /* main.c */
107 extern char *factname; /* main.c */
108 extern Srv fs; /* fs.c */
109 extern int *needkeyinuse; /* fs.c */
110 extern char *owner; /* main.c */
111 extern Proto *prototab[]; /* main.c */
112 extern Ring ring; /* key.c */
113 extern char *rpcname[]; /* rpc.c */
115 extern char Easproto[]; /* err.c */
117 void fsinit0(void);
119 /* provided by lib9p */
120 #define emalloc emalloc9p
121 #define erealloc erealloc9p
122 #define estrdup estrdup9p
124 /* hidden in libauth */
125 #define attrfmt _attrfmt
126 #define copyattr _copyattr
127 #define delattr _delattr
128 #define findattr _findattr
129 #define freeattr _freeattr
130 #define mkattr _mkattr
131 #define parseattr _parseattr
132 #define strfindattr _strfindattr
134 extern Attr* addattr(Attr*, char*, ...);
135 /* #pragma varargck argpos addattr 2 */
136 extern Attr* addattrs(Attr*, Attr*);
137 extern Attr* sortattr(Attr*);
138 extern int attrnamefmt(Fmt*);
139 /* #pragma varargck type "N" Attr* */
140 extern int matchattr(Attr*, Attr*, Attr*);
141 extern Attr* parseattrfmt(char*, ...);
142 /* #pragma varargck argpos parseattrfmt 1 */
143 extern Attr* parseattrfmtv(char*, va_list);
145 extern void confirmflush(Req*);
146 extern void confirmread(Req*);
147 extern int confirmwrite(char*);
148 extern int needkey(Conv*, Attr*);
149 extern int badkey(Conv*, Key*, char*, Attr*);
150 extern int confirmkey(Conv*, Key*);
152 extern Conv* convalloc(char*);
153 extern void convclose(Conv*);
154 extern void convhangup(Conv*);
155 extern int convneedkey(Conv*, Attr*);
156 extern int convbadkey(Conv*, Key*, char*, Attr*);
157 extern int convread(Conv*, void*, int);
158 extern int convreadm(Conv*, char**);
159 extern int convprint(Conv*, char*, ...);
160 /* #pragma varargck argpos convprint 2 */
161 extern int convreadfn(Conv*, int(*)(void*, int), char**);
162 extern void convreset(Conv*);
163 extern int convwrite(Conv*, void*, int);
165 extern int ctlwrite(char*);
167 extern char* estrappend(char*, char*, ...);
168 /* #pragma varargck argpos estrappend 2 */
169 extern int hexparse(char*, uchar*, int);
171 extern void keyadd(Key*);
172 extern Key* keylookup(char*, ...);
173 extern Key* keyiterate(int, char*, ...);
174 /* #pragma varargck argpos keylookup 1 */
175 extern Key* keyfetch(Conv*, char*, ...);
176 /* #pragma varargck argpos keyfetch 2 */
177 extern void keyclose(Key*);
178 extern void keyevict(Conv*, Key*, char*, ...);
179 /* #pragma varargck argpos keyevict 3 */
180 extern Key* keyreplace(Conv*, Key*, char*, ...);
181 /* #pragma varargck argpos keyreplace 3 */
183 extern void lbkick(Logbuf*);
184 extern void lbappend(Logbuf*, char*, ...);
185 extern void lbvappend(Logbuf*, char*, va_list);
186 /* #pragma varargck argpos lbappend 2 */
187 extern void lbread(Logbuf*, Req*);
188 extern void lbflush(Logbuf*, Req*);
189 extern void flog(char*, ...);
190 /* #pragma varargck argpos flog 1 */
192 extern void logflush(Req*);
193 extern void logread(Req*);
194 extern void logwrite(Req*);
196 extern void needkeyread(Req*);
197 extern void needkeyflush(Req*);
198 extern int needkeywrite(char*);
199 extern int needkeyqueue(void);
201 extern Attr* addcap(Attr*, char*, Ticket*);
202 extern Key* plan9authkey(Attr*);
203 extern int _authdial(char*, char*);
205 extern int memrandom(void*, int);
207 extern Proto* protolookup(char*);
209 extern int rpcwrite(Conv*, void*, int);
210 extern void rpcrespond(Conv*, char*, ...);
211 /* #pragma varargck argpos rpcrespond 2 */
212 extern void rpcrespondn(Conv*, char*, void*, int);
213 extern void rpcexec(Conv*);
215 extern int xioauthdial(char*, char*);
216 extern void xioclose(int);
217 extern int xiodial(char*, char*, char*, int*);
218 extern int xiowrite(int, void*, int);
219 extern int xioasrdresp(int, void*, int);
220 extern int xioasgetticket(int, char*, char*);
222 /* pkcs1.c - maybe should be in libsec */
223 typedef DigestState *DigestAlg(uchar*, ulong, uchar*, DigestState*);
224 int rsasign(RSApriv*, DigestAlg*, uchar*, uint, uchar*, uint);
225 int rsaverify(RSApub*, DigestAlg*, uchar*, uint, uchar*, uint);
226 void mptoberjust(mpint*, uchar*, uint);
229 extern int extrafactotumdir;
231 int havesecstore(void);
232 int secstorefetch(void);