xref: /plan9/sys/src/cmd/srvold9p/9p1.h (revision 9a747e4fd48b9f4522c70c07e8f882a15030f964)
1 #include <authsrv.h>
2 
3 #define	DIRREC		116		/* size of a directory ascii record */
4 #define	ERRREC		64		/* size of a error record */
5 #define	NAMEREC	28
6 
7 typedef	struct	Fcall9p1	Fcall9p1;
8 typedef	struct	Qid9p1	Qid9p1;
9 
10 struct	Qid9p1
11 {
12 	long	path;
13 	long	version;
14 };
15 
16 struct	Fcall9p1
17 {
18 	char	type;
19 	ushort	fid;
20 	short	err;
21 	short	tag;
22 	union
23 	{
24 		struct
25 		{
26 			short	uid;		/* T-Userstr */
27 			short	oldtag;		/* T-nFlush */
28 			Qid9p1	qid;		/* R-Attach, R-Clwalk, R-Walk,
29 						 * R-Open, R-Create */
30 			char	rauth[AUTHENTLEN];	/* R-attach */
31 		};
32 		struct
33 		{
34 			char	uname[NAMEREC];	/* T-nAttach */
35 			char	aname[NAMEREC];	/* T-nAttach */
36 			char	ticket[TICKETLEN];	/* T-attach */
37 			char	auth[AUTHENTLEN];	/* T-attach */
38 		};
39 		struct
40 		{
41 			char	ename[ERRREC];	/* R-nError */
42 			char	chal[CHALLEN];	/* T-session, R-session */
43 			char	authid[NAMEREC];	/* R-session */
44 			char	authdom[DOMLEN];	/* R-session */
45 		};
46 		struct
47 		{
48 			char	name[NAMEREC];	/* T-Walk, T-Clwalk, T-Create, T-Remove */
49 			long	perm;		/* T-Create */
50 			ushort	newfid;		/* T-Clone, T-Clwalk */
51 			char	mode;		/* T-Create, T-Open */
52 		};
53 		struct
54 		{
55 			long	offset;		/* T-Read, T-Write */
56 			long	count;		/* T-Read, T-Write, R-Read */
57 			char*	data;		/* T-Write, R-Read */
58 		};
59 		struct
60 		{
61 			char	stat[DIRREC];	/* T-Wstat, R-Stat */
62 		};
63 	};
64 };
65 
66 /*
67  * P9 protocol message types
68  */
69 enum
70 {
71 	Tnop9p1 =		50,
72 	Rnop9p1,
73 	Tosession9p1 =	52,
74 	Rosession9p1,
75 	Terror9p1 =	54,	/* illegal */
76 	Rerror9p1,
77 	Tflush9p1 =	56,
78 	Rflush9p1,
79 	Toattach9p1 =	58,
80 	Roattach9p1,
81 	Tclone9p1 =	60,
82 	Rclone9p1,
83 	Twalk9p1 =		62,
84 	Rwalk9p1,
85 	Topen9p1 =		64,
86 	Ropen9p1,
87 	Tcreate9p1 =	66,
88 	Rcreate9p1,
89 	Tread9p1 =		68,
90 	Rread9p1,
91 	Twrite9p1 =	70,
92 	Rwrite9p1,
93 	Tclunk9p1 =	72,
94 	Rclunk9p1,
95 	Tremove9p1 =	74,
96 	Rremove9p1,
97 	Tstat9p1 =		76,
98 	Rstat9p1,
99 	Twstat9p1 =	78,
100 	Rwstat9p1,
101 	Tclwalk9p1 =	80,
102 	Rclwalk9p1,
103 	Tauth9p1 =		82,	/* illegal */
104 	Rauth9p1,			/* illegal */
105 	Tsession9p1 =	84,
106 	Rsession9p1,
107 	Tattach9p1 =	86,
108 	Rattach9p1,
109 
110 	MAXSYSCALL
111 };
112 
113 int	convA2M9p1(Authenticator*, char*, char*);
114 void	convM2A9p1(char*, Authenticator*, char*);
115 void	convM2T9p1(char*, Ticket*, char*);
116 int	convD2M9p1(Dir*, char*);
117 int	convM2D9p1(char*, Dir*);
118 int	convM2S9p1(char*, Fcall9p1*, int);
119 int	convS2M9p1(Fcall9p1*, char*);
120 int	fcallfmt9p1(Fmt*);
121 int	fcall(int);
122 
123 #pragma	varargck	type	"F"	Fcall*
124 #pragma	varargck	type	"G"	Fcall9p1*
125 #pragma	varargck	type	"D"	Dir*
126 
127 void	fatal(char*, ...);
128