dat.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. enum
  10. {
  11. FHSIZE = 32
  12. };
  13. typedef struct Accept Accept;
  14. typedef struct Auth Auth;
  15. typedef struct Authunix Authunix;
  16. typedef struct Chalstuff Chalstuff;
  17. typedef uchar Fhandle[FHSIZE];
  18. typedef struct Fid Fid;
  19. typedef struct Procmap Procmap;
  20. typedef struct Progmap Progmap;
  21. typedef struct Reject Reject;
  22. typedef struct Rpccall Rpccall;
  23. typedef struct Rpccache Rpccache;
  24. typedef struct Sattr Sattr;
  25. typedef struct Session Session;
  26. typedef struct String String;
  27. typedef struct Strnode Strnode;
  28. typedef struct Unixid Unixid;
  29. typedef struct Unixidmap Unixidmap;
  30. typedef struct Unixmap Unixmap;
  31. typedef struct Unixscmap Unixscmap;
  32. typedef struct Xfid Xfid;
  33. typedef struct Xfile Xfile;
  34. struct String
  35. {
  36. uint32_t n;
  37. char * s;
  38. };
  39. struct Progmap
  40. {
  41. int progno;
  42. int vers;
  43. void (*init)(int, char**);
  44. Procmap *pmap;
  45. };
  46. struct Procmap
  47. {
  48. int procno;
  49. int (*procp)(int, Rpccall*, Rpccall*);
  50. };
  51. struct Auth
  52. {
  53. uint32_t flavor;
  54. uint32_t count;
  55. void * data;
  56. };
  57. struct Authunix
  58. {
  59. uint32_t stamp;
  60. String mach;
  61. uint32_t uid;
  62. uint32_t gid;
  63. int gidlen;
  64. uint32_t gids[10];
  65. };
  66. struct Accept
  67. {
  68. Auth averf;
  69. uint32_t astat;
  70. union{
  71. void * results; /* SUCCESS */
  72. struct{ /* PROG_MISMATCH */
  73. uint32_t plow; /* acceptable version numbers */
  74. uint32_t phigh;
  75. };
  76. };
  77. };
  78. struct Reject
  79. {
  80. uint32_t rstat;
  81. union{
  82. struct{ /* RPC_MISMATCH */
  83. uint32_t rlow; /* acceptable rpc version numbers */
  84. uint32_t rhigh;
  85. };
  86. uint32_t authstat; /* AUTH_ERROR */
  87. };
  88. };
  89. struct Rpccall
  90. {
  91. /* corresponds to Udphdr */
  92. uchar prefix0[12];
  93. uint32_t host; /* ipv4 subset: prefixed to RPC message */
  94. uchar prefix1[12];
  95. uint32_t lhost; /* ipv4 subset: prefixed to RPC message */
  96. /* ignore ifcaddr */
  97. uint32_t port; /* prefixed to RPC message */
  98. uint32_t lport; /* prefixed to RPC message */
  99. uint32_t xid; /* transaction id */
  100. uint32_t mtype; /* CALL or REPLY */
  101. union{
  102. struct{ /* CALL */
  103. uint32_t rpcvers; /* must be equal to two (2) */
  104. uint32_t prog; /* program number */
  105. uint32_t vers; /* program version */
  106. uint32_t proc; /* procedure number */
  107. Auth cred; /* authentication credentials */
  108. Auth verf; /* authentication verifier */
  109. Unixidmap *up;
  110. char * user;
  111. void * args; /* procedure-specific */
  112. };
  113. struct{ /* REPLY */
  114. uint32_t stat; /* MSG_ACCEPTED or MSG_DENIED */
  115. union{
  116. Accept;
  117. Reject;
  118. };
  119. };
  120. };
  121. };
  122. struct Rpccache
  123. {
  124. Rpccache *prev;
  125. Rpccache *next;
  126. uint32_t host;
  127. uint32_t port;
  128. uint32_t xid;
  129. int n;
  130. uchar data[4];
  131. };
  132. struct Sattr
  133. {
  134. uint32_t mode;
  135. uint32_t uid;
  136. uint32_t gid;
  137. uint32_t size;
  138. uint32_t atime; /* sec's */
  139. uint32_t ausec; /* microsec's */
  140. uint32_t mtime;
  141. uint32_t musec;
  142. };
  143. struct Strnode
  144. {
  145. Strnode *next; /* in hash bucket */
  146. char str[4];
  147. };
  148. struct Unixid
  149. {
  150. Unixid *next;
  151. char * name;
  152. int id;
  153. };
  154. struct Unixmap
  155. {
  156. char * file;
  157. int style;
  158. long timestamp;
  159. Unixid *ids;
  160. };
  161. struct Unixidmap
  162. {
  163. Unixidmap *next;
  164. int flag;
  165. char * server;
  166. char * client;
  167. Reprog *sexp;
  168. Reprog *cexp;
  169. Unixmap u;
  170. Unixmap g;
  171. };
  172. struct Unixscmap
  173. {
  174. Unixscmap *next;
  175. char * server;
  176. uint32_t clientip;
  177. Unixidmap *map;
  178. };
  179. struct Xfile
  180. {
  181. Xfile * next; /* hash chain */
  182. Session *s;
  183. Qid qid; /* from stat */
  184. Xfile * parent;
  185. Xfile * child; /* if directory */
  186. Xfile * sib; /* siblings */
  187. char * name; /* path element */
  188. Xfid * users;
  189. };
  190. enum
  191. {
  192. Oread = 1,
  193. Owrite = 2,
  194. Open = 3,
  195. Trunc = 4
  196. };
  197. struct Xfid
  198. {
  199. Xfid * next; /* Xfile's user list */
  200. Xfile * xp;
  201. char * uid;
  202. Fid * urfid;
  203. Fid * opfid;
  204. uint32_t mode; /* open mode, if opfid is non-zero */
  205. uint32_t offset;
  206. };
  207. struct Fid
  208. {
  209. Fid ** owner; /* null for root fids */
  210. Fid * prev;
  211. Fid * next;
  212. long tstale; /* auto-clunk */
  213. };
  214. enum
  215. {
  216. Maxfdata = 8192,
  217. Maxstatdata = 2048,
  218. };
  219. struct Session
  220. {
  221. Session *next;
  222. char * service; /* for dial */
  223. int fd;
  224. #define CHALLEN 1
  225. char cchal[CHALLEN]; /* client challenge */
  226. char schal[CHALLEN]; /* server challenge */
  227. char authid[ANAMELEN]; /* server encryption uid */
  228. char authdom[DOMLEN]; /* server encryption domain */
  229. char * spec; /* for attach */
  230. Xfile * root; /* to answer mount rpc */
  231. ushort tag;
  232. Fcall f;
  233. uchar data[IOHDRSZ+Maxfdata];
  234. uchar statbuf[Maxstatdata];
  235. Fid * free; /* available */
  236. Fid list; /* active, most-recently-used order */
  237. Fid fids[1000];
  238. int noauth;
  239. };
  240. struct Chalstuff
  241. {
  242. Chalstuff *next;
  243. Xfid * xf;
  244. long tstale;
  245. Chalstate;
  246. };
  247. extern int rpcdebug;
  248. extern int p9debug;
  249. extern int chatty;
  250. extern void (*rpcalarm)(void);
  251. extern long starttime;
  252. extern long nfstime;
  253. extern char * config;
  254. extern int staletime;
  255. extern int messagesize;
  256. extern char * commonopts;