yp_prot.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*
  2. * This file contains symbols and structures defining the rpc protocol
  3. * between the NIS clients and the NIS servers. The servers
  4. * are the NIS database servers, and the NIS binders.
  5. */
  6. #ifndef _RPCSVC_YP_PROT_H
  7. #define _RPCSVC_YP_PROT_H
  8. #include <features.h>
  9. #include <rpc/rpc.h>
  10. #include <rpcsvc/ypclnt.h>
  11. __BEGIN_DECLS
  12. /*
  13. * The following procedures are supported by the protocol:
  14. *
  15. * YPPROC_NULL() returns () takes nothing, returns nothing. This indicates
  16. * that the NIS server is alive.
  17. *
  18. * YPPROC_DOMAIN (char *) returns (bool_t) TRUE. Indicates that the
  19. * responding NIS server does serve the named domain; FALSE indicates no
  20. * support.
  21. *
  22. * YPPROC_DOMAIN_NONACK (char *) returns (TRUE) if the NIS server does serve
  23. * the named domain, otherwise does not return. Used in the broadcast case.
  24. *
  25. * YPPROC_MATCH (struct ypreq_key) returns (struct ypresp_val). Returns the
  26. * right-hand value for a passed left-hand key, within a named map and
  27. * domain.
  28. *
  29. * YPPROC_FIRST (struct ypreq_nokey) returns (struct ypresp_key_val).
  30. * Returns the first key-value pair from a named domain and map.
  31. *
  32. * YPPROC_NEXT (struct ypreq_key) returns (struct ypresp_key_val). Returns
  33. * the key-value pair following a passed key-value pair within a named
  34. * domain and map.
  35. *
  36. * YPPROC_XFR (struct ypreq_xfr) returns nothing. Indicates to a server that
  37. * a map should be updated.
  38. *
  39. * YPPROC_CLEAR takes nothing, returns nothing. Instructs a NIS server to
  40. * close the current map, so that old versions of the disk file don't get
  41. * held open.
  42. *
  43. * YPPROC_ALL (struct ypreq_nokey), returns
  44. * union switch (bool_t more) {
  45. * TRUE: (struct ypresp_key_val);
  46. * FALSE: (struct) {};
  47. * }
  48. *
  49. * YPPROC_MASTER (struct ypreq_nokey), returns (ypresp_master)
  50. *
  51. * YPPROC_ORDER (struct ypreq_nokey), returns (ypresp_order)
  52. *
  53. * YPPROC_MAPLIST (char *), returns (struct ypmaplist *)
  54. */
  55. /* Program and version symbols, magic numbers */
  56. #define YPPROG 100004
  57. #define YPVERS 2
  58. #define YPVERS_ORIG 1
  59. #define YPMAXRECORD 1024
  60. #define YPMAXDOMAIN 64 /* XXX orig. yp_prot.h defines 256 */
  61. #define YPMAXMAP 64
  62. #define YPMAXPEER 64 /* XXX orig. yp_prot.h defines 256 */
  63. /* byte size of a large NIS packet */
  64. #define YPMSGSZ 1600
  65. typedef struct {
  66. u_int keydat_len;
  67. char *keydat_val;
  68. } keydat_t;
  69. typedef struct {
  70. u_int valdat_len;
  71. char *valdat_val;
  72. } valdat_t;
  73. struct ypmap_parms {
  74. char *domain; /* Null string means not available */
  75. char *map; /* Null string means not available */
  76. unsigned int ordernum; /* 0 means not available */
  77. char *owner; /* Null string means not available */
  78. };
  79. /*
  80. * Request parameter structures
  81. */
  82. struct ypreq_key {
  83. const char *domain;
  84. const char *map;
  85. keydat_t keydat;
  86. };
  87. struct ypreq_nokey {
  88. char *domain;
  89. char *map;
  90. };
  91. struct ypreq_xfr {
  92. struct ypmap_parms map_parms;
  93. u_int transid;
  94. u_int proto;
  95. u_int port;
  96. };
  97. #define ypxfr_domain map_parms.domain
  98. #define ypxfr_map map_parms.map
  99. #define ypxfr_ordernum map_parms.ordernum
  100. #define ypxfr_owner map_parms.owner
  101. /* Return status values */
  102. enum ypstat {
  103. YP_TRUE = 1, /* General purpose success code */
  104. #define YP_TRUE YP_TRUE
  105. YP_NOMORE = 2, /* No more entries in map */
  106. #define YP_NOMORE YP_NOMORE
  107. YP_FALSE = 0, /* General purpose failure code */
  108. #define YP_FALSE YP_FALSE
  109. YP_NOMAP = -1, /* No such map in domain */
  110. #define YP_NOMAP YP_NOMAP
  111. YP_NODOM = -2, /* Domain not supported */
  112. #define YP_NODOM YP_NODOM
  113. YP_NOKEY = -3, /* No such key in map */
  114. #define YP_NOKEY YP_NOKEY
  115. YP_BADOP = -4, /* Invalid operation */
  116. #define YP_BADOP YP_BADOP
  117. YP_BADDB = -5, /* Server data base is bad */
  118. #define YP_BADDB YP_BADDB
  119. YP_YPERR = -6, /* NIS server error */
  120. #define YP_YPERR YP_YPERR
  121. YP_BADARGS = -7, /* Request arguments bad */
  122. #define YP_BADARGS YP_BADARGS
  123. YP_VERS = -8, /* NIS server version mismatch - server can't supply
  124. requested service. */
  125. #define YP_VERS YP_VERS
  126. };
  127. /*
  128. * Response parameter structures
  129. */
  130. typedef enum ypstat ypstat;
  131. struct ypresp_val {
  132. ypstat status;
  133. valdat_t valdat;
  134. };
  135. struct ypresp_key_val {
  136. ypstat status;
  137. #ifdef STUPID_SUN_BUG
  138. /* This is the form as distributed by Sun. But even the Sun NIS
  139. servers expect the values in the other order. So their
  140. implementation somehow must change the order internally. We
  141. don't want to follow this bad example since the user should be
  142. able to use rpcgen on this file. */
  143. keydat_t keydat;
  144. valdat_t valdat;
  145. #else
  146. valdat_t valdat;
  147. keydat_t keydat;
  148. #endif
  149. };
  150. struct ypresp_master {
  151. ypstat status;
  152. char *master;
  153. };
  154. struct ypresp_order {
  155. ypstat status;
  156. u_int ordernum;
  157. };
  158. struct ypmaplist {
  159. char *map;
  160. #define ypml_name map
  161. struct ypmaplist *next;
  162. #define ypml_next next
  163. };
  164. struct ypresp_maplist {
  165. ypstat status;
  166. struct ypmaplist *list;
  167. };
  168. /*
  169. * Procedure symbols. YPPROC_NULL, YPPROC_DOMAIN, and YPPROC_DOMAIN_NONACK
  170. * must keep the same values (0, 1, and 2) that they had in the first version
  171. * of the protocol.
  172. */
  173. #define YPPROC_NULL 0
  174. #define YPPROC_DOMAIN 1
  175. #define YPPROC_DOMAIN_NONACK 2
  176. #define YPPROC_MATCH 3
  177. #define YPPROC_FIRST 4
  178. #define YPPROC_NEXT 5
  179. #define YPPROC_XFR 6
  180. #define YPPROC_CLEAR 7
  181. #define YPPROC_ALL 8
  182. #define YPPROC_MASTER 9
  183. #define YPPROC_ORDER 10
  184. #define YPPROC_MAPLIST 11
  185. #define YPPROC_NEWXFR 12
  186. /*
  187. * Protocol between clients and NIS binder servers
  188. */
  189. /*
  190. * The following procedures are supported by the protocol:
  191. *
  192. * YPBINDPROC_NULL() returns ()
  193. * takes nothing, returns nothing
  194. *
  195. * YPBINDPROC_DOMAIN takes (char *) returns (struct ypbind_resp)
  196. *
  197. * YPBINDPROC_SETDOM takes (struct ypbind_setdom) returns nothing
  198. */
  199. /* Program and version symbols, magic numbers */
  200. #define YPBINDPROG 100007
  201. #define YPBINDVERS 2
  202. #define YPBINDVERS_ORIG 1
  203. /* Procedure symbols */
  204. #define YPBINDPROC_NULL 0
  205. #define YPBINDPROC_DOMAIN 1
  206. #define YPBINDPROC_SETDOM 2
  207. /*
  208. * Response structure and overall result status codes. Success and failure
  209. * represent two separate response message types.
  210. */
  211. enum ypbind_resptype {YPBIND_SUCC_VAL = 1, YPBIND_FAIL_VAL = 2};
  212. struct ypbind_binding {
  213. struct in_addr ypbind_binding_addr; /* In network order */
  214. unsigned short int ypbind_binding_port; /* In network order */
  215. };
  216. struct ypbind_resp {
  217. enum ypbind_resptype ypbind_status;
  218. union {
  219. u_int ypbind_error;
  220. struct ypbind_binding ypbind_bindinfo;
  221. } ypbind_respbody;
  222. };
  223. /* Detailed failure reason codes for response field ypbind_error*/
  224. #define YPBIND_ERR_ERR 1 /* Internal error */
  225. #define YPBIND_ERR_NOSERV 2 /* No bound server for passed domain */
  226. #define YPBIND_ERR_RESC 3 /* System resource allocation failure */
  227. /*
  228. * Request data structure for ypbind "Set domain" procedure.
  229. */
  230. struct ypbind_setdom {
  231. char *ypsetdom_domain;
  232. struct ypbind_binding ypsetdom_binding;
  233. u_int ypsetdom_vers;
  234. };
  235. #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
  236. #define ypsetdom_port ypsetdom_binding.ypbind_binding_port
  237. /*
  238. * Protocol between clients (ypxfr, only) and yppush
  239. * yppush speaks a protocol in the transient range, which
  240. * is supplied to ypxfr as a command-line parameter when it
  241. * is activated by ypserv.
  242. */
  243. #define YPPUSHVERS 1
  244. #define YPPUSHVERS_ORIG 1
  245. /* Procedure symbols */
  246. #define YPPUSHPROC_NULL 0
  247. #define YPPUSHPROC_XFRRESP 1
  248. /* Status values for yppushresp_xfr.status */
  249. enum yppush_status {
  250. YPPUSH_SUCC = 1, /* Success */
  251. #define YPPUSH_SUCC YPPUSH_SUCC
  252. YPPUSH_AGE = 2, /* Master's version not newer */
  253. #define YPPUSH_AGE YPPUSH_AGE
  254. YPPUSH_NOMAP = -1, /* Can't find server for map */
  255. #define YPPUSH_NOMAP YPPUSH_NOMAP
  256. YPPUSH_NODOM = -2, /* Domain not supported */
  257. #define YPPUSH_NODOM YPPUSH_NODOM
  258. YPPUSH_RSRC = -3, /* Local resouce alloc failure */
  259. #define YPPUSH_RSRC YPPUSH_RSRC
  260. YPPUSH_RPC = -4, /* RPC failure talking to server */
  261. #define YPPUSH_RPC YPPUSH_RPC
  262. YPPUSH_MADDR = -5, /* Can't get master address */
  263. #define YPPUSH_MADDR YPPUSH_MADDR
  264. YPPUSH_YPERR = -6, /* NIS server/map db error */
  265. #define YPPUSH_YPERR YPPUSH_YPERR
  266. YPPUSH_BADARGS = -7, /* Request arguments bad */
  267. #define YPPUSH_BADARGS YPPUSH_BADARGS
  268. YPPUSH_DBM = -8, /* Local dbm operation failed */
  269. #define YPPUSH_DBM YPPUSH_DBM
  270. YPPUSH_FILE = -9, /* Local file I/O operation failed */
  271. #define YPPUSH_FILE YPPUSH_FILE
  272. YPPUSH_SKEW = -10, /* Map version skew during transfer */
  273. #define YPPUSH_SKEW YPPUSH_SKEW
  274. YPPUSH_CLEAR = -11, /* Can't send "Clear" req to local ypserv */
  275. #define YPPUSH_CLEAR YPPUSH_CLEAR
  276. YPPUSH_FORCE = -12, /* No local order number in map - use -f flag*/
  277. #define YPPUSH_FORCE YPPUSH_FORCE
  278. YPPUSH_XFRERR = -13, /* ypxfr error */
  279. #define YPPUSH_XFRERR YPPUSH_XFRERR
  280. YPPUSH_REFUSED = -14, /* Transfer request refused by ypserv */
  281. #define YPPUSH_REFUSED YPPUSH_REFUSED
  282. YPPUSH_NOALIAS = -15 /* Alias not found for map or domain */
  283. #define YPPUSH_NOALIAS YPPUSH_NOALIAS
  284. };
  285. typedef enum yppush_status yppush_status;
  286. struct yppushresp_xfr {
  287. u_int transid;
  288. yppush_status status;
  289. };
  290. struct ypresp_all {
  291. bool_t more;
  292. union {
  293. struct ypresp_key_val val;
  294. } ypresp_all_u;
  295. };
  296. extern bool_t xdr_ypreq_key (XDR *__xdrs, struct ypreq_key * __objp);
  297. extern bool_t xdr_ypreq_nokey (XDR *__xdrs, struct ypreq_nokey * __objp);
  298. extern bool_t xdr_ypreq_xfr (XDR *__xdrs, struct ypreq_xfr * __objp);
  299. extern bool_t xdr_ypresp_val (XDR *__xdrs, struct ypresp_val * __objp);
  300. extern bool_t xdr_ypresp_key_val (XDR *__xdrs, struct ypresp_key_val * __objp);
  301. extern bool_t xdr_ypbind_resp (XDR *__xdrs, struct ypbind_resp * __objp);
  302. extern bool_t xdr_ypbind_setdom (XDR *__xdrs, struct ypbind_setdom * __objp);
  303. extern bool_t xdr_ypmap_parms (XDR *__xdrs, struct ypmap_parms * __objp);
  304. extern bool_t xdr_yppushresp_xfr (XDR *__xdrs, struct yppushresp_xfr * __objp);
  305. extern bool_t xdr_ypresp_order (XDR *__xdrs, struct ypresp_order * __objp);
  306. extern bool_t xdr_ypresp_master (XDR *__xdrs, struct ypresp_master * __objp);
  307. extern bool_t xdr_ypall (XDR *__xdrs, struct ypall_callback * __objp);
  308. extern bool_t xdr_ypresp_maplist (XDR *__xdrs, struct ypresp_maplist * __objp);
  309. extern bool_t xdr_ypbind_binding (XDR *__xdrs, struct ypbind_binding * __objp);
  310. extern bool_t xdr_ypbind_resptype (XDR *__xdrs, enum ypbind_resptype * __objp);
  311. extern bool_t xdr_ypstat (XDR *__xdrs, enum ypbind_resptype * __objp);
  312. extern bool_t xdr_ypresp_all (XDR *__xdrs, struct ypresp_all * __objp);
  313. extern bool_t xdr_domainname (XDR *__xdrs, char ** __objp);
  314. __END_DECLS
  315. #endif /* _RPCSVC_YP_PROT_H */