yp.h 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. /*
  2. * Copyright (c) 2010, Oracle America, Inc.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are
  6. * met:
  7. *
  8. * * Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * * Redistributions in binary form must reproduce the above
  11. * copyright notice, this list of conditions and the following
  12. * disclaimer in the documentation and/or other materials
  13. * provided with the distribution.
  14. * * Neither the name of the "Oracle America, Inc." nor the names of its
  15. * contributors may be used to endorse or promote products derived
  16. * from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  21. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  22. * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  23. * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  24. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  25. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  26. * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  27. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  29. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. */
  31. #ifndef __RPCSVC_YP_H__
  32. #define __RPCSVC_YP_H__
  33. #include <features.h>
  34. #include <rpc/rpc.h>
  35. #define YPMAXRECORD 1024
  36. #define YPMAXDOMAIN 64
  37. #define YPMAXMAP 64
  38. #define YPMAXPEER 64
  39. enum ypstat {
  40. YP_TRUE = 1,
  41. YP_NOMORE = 2,
  42. YP_FALSE = 0,
  43. YP_NOMAP = -1,
  44. YP_NODOM = -2,
  45. YP_NOKEY = -3,
  46. YP_BADOP = -4,
  47. YP_BADDB = -5,
  48. YP_YPERR = -6,
  49. YP_BADARGS = -7,
  50. YP_VERS = -8,
  51. };
  52. typedef enum ypstat ypstat;
  53. enum ypxfrstat {
  54. YPXFR_SUCC = 1,
  55. YPXFR_AGE = 2,
  56. YPXFR_NOMAP = -1,
  57. YPXFR_NODOM = -2,
  58. YPXFR_RSRC = -3,
  59. YPXFR_RPC = -4,
  60. YPXFR_MADDR = -5,
  61. YPXFR_YPERR = -6,
  62. YPXFR_BADARGS = -7,
  63. YPXFR_DBM = -8,
  64. YPXFR_FILE = -9,
  65. YPXFR_SKEW = -10,
  66. YPXFR_CLEAR = -11,
  67. YPXFR_FORCE = -12,
  68. YPXFR_XFRERR = -13,
  69. YPXFR_REFUSED = -14,
  70. };
  71. typedef enum ypxfrstat ypxfrstat;
  72. typedef char *domainname;
  73. typedef char *mapname;
  74. typedef char *peername;
  75. typedef struct {
  76. u_int keydat_len;
  77. char *keydat_val;
  78. } keydat;
  79. typedef struct {
  80. u_int valdat_len;
  81. char *valdat_val;
  82. } valdat;
  83. struct ypmap_parms {
  84. domainname domain;
  85. mapname map;
  86. u_int ordernum;
  87. peername peer;
  88. };
  89. typedef struct ypmap_parms ypmap_parms;
  90. struct ypreq_key {
  91. domainname domain;
  92. mapname map;
  93. keydat key;
  94. };
  95. typedef struct ypreq_key ypreq_key;
  96. struct ypreq_nokey {
  97. domainname domain;
  98. mapname map;
  99. };
  100. typedef struct ypreq_nokey ypreq_nokey;
  101. struct ypreq_xfr {
  102. ypmap_parms map_parms;
  103. u_int transid;
  104. u_int prog;
  105. u_int port;
  106. };
  107. typedef struct ypreq_xfr ypreq_xfr;
  108. struct ypresp_val {
  109. ypstat stat;
  110. valdat val;
  111. };
  112. typedef struct ypresp_val ypresp_val;
  113. struct ypresp_key_val {
  114. ypstat stat;
  115. #ifdef STUPID_SUN_BUG
  116. /* This is the form as distributed by Sun. But even the Sun NIS
  117. servers expect the values in the other order. So their
  118. implementation somehow must change the order internally. We
  119. don't want to follow this bad example since the user should be
  120. able to use rpcgen on this file. */
  121. keydat key;
  122. valdat val;
  123. #else
  124. valdat val;
  125. keydat key;
  126. #endif
  127. };
  128. typedef struct ypresp_key_val ypresp_key_val;
  129. struct ypresp_master {
  130. ypstat stat;
  131. peername peer;
  132. };
  133. typedef struct ypresp_master ypresp_master;
  134. struct ypresp_order {
  135. ypstat stat;
  136. u_int ordernum;
  137. };
  138. typedef struct ypresp_order ypresp_order;
  139. struct ypresp_all {
  140. bool_t more;
  141. union {
  142. ypresp_key_val val;
  143. } ypresp_all_u;
  144. };
  145. typedef struct ypresp_all ypresp_all;
  146. struct ypresp_xfr {
  147. u_int transid;
  148. ypxfrstat xfrstat;
  149. };
  150. typedef struct ypresp_xfr ypresp_xfr;
  151. struct ypmaplist {
  152. mapname map;
  153. struct ypmaplist *next;
  154. };
  155. typedef struct ypmaplist ypmaplist;
  156. struct ypresp_maplist {
  157. ypstat stat;
  158. ypmaplist *maps;
  159. };
  160. typedef struct ypresp_maplist ypresp_maplist;
  161. enum yppush_status {
  162. YPPUSH_SUCC = 1,
  163. YPPUSH_AGE = 2,
  164. YPPUSH_NOMAP = -1,
  165. YPPUSH_NODOM = -2,
  166. YPPUSH_RSRC = -3,
  167. YPPUSH_RPC = -4,
  168. YPPUSH_MADDR = -5,
  169. YPPUSH_YPERR = -6,
  170. YPPUSH_BADARGS = -7,
  171. YPPUSH_DBM = -8,
  172. YPPUSH_FILE = -9,
  173. YPPUSH_SKEW = -10,
  174. YPPUSH_CLEAR = -11,
  175. YPPUSH_FORCE = -12,
  176. YPPUSH_XFRERR = -13,
  177. YPPUSH_REFUSED = -14,
  178. };
  179. typedef enum yppush_status yppush_status;
  180. struct yppushresp_xfr {
  181. u_int transid;
  182. yppush_status status;
  183. };
  184. typedef struct yppushresp_xfr yppushresp_xfr;
  185. enum ypbind_resptype {
  186. YPBIND_SUCC_VAL = 1,
  187. YPBIND_FAIL_VAL = 2,
  188. };
  189. typedef enum ypbind_resptype ypbind_resptype;
  190. struct ypbind_binding {
  191. char ypbind_binding_addr[4];
  192. char ypbind_binding_port[2];
  193. };
  194. typedef struct ypbind_binding ypbind_binding;
  195. struct ypbind_resp {
  196. ypbind_resptype ypbind_status;
  197. union {
  198. u_int ypbind_error;
  199. ypbind_binding ypbind_bindinfo;
  200. } ypbind_resp_u;
  201. };
  202. typedef struct ypbind_resp ypbind_resp;
  203. #define YPBIND_ERR_ERR 1
  204. #define YPBIND_ERR_NOSERV 2
  205. #define YPBIND_ERR_RESC 3
  206. struct ypbind_setdom {
  207. domainname ypsetdom_domain;
  208. ypbind_binding ypsetdom_binding;
  209. u_int ypsetdom_vers;
  210. };
  211. typedef struct ypbind_setdom ypbind_setdom;
  212. __BEGIN_DECLS
  213. #define YPPROG 100004
  214. #define YPVERS 2
  215. #define YPPROC_NULL 0
  216. extern void *ypproc_null_2 (void *, CLIENT *);
  217. extern void *ypproc_null_2_svc (void *, struct svc_req *);
  218. #define YPPROC_DOMAIN 1
  219. extern bool_t *ypproc_domain_2 (domainname *, CLIENT *);
  220. extern bool_t *ypproc_domain_2_svc (domainname *, struct svc_req *);
  221. #define YPPROC_DOMAIN_NONACK 2
  222. extern bool_t *ypproc_domain_nonack_2 (domainname *, CLIENT *);
  223. extern bool_t *ypproc_domain_nonack_2_svc (domainname *, struct svc_req *);
  224. #define YPPROC_MATCH 3
  225. extern ypresp_val *ypproc_match_2 (ypreq_key *, CLIENT *);
  226. extern ypresp_val *ypproc_match_2_svc (ypreq_key *, struct svc_req *);
  227. #define YPPROC_FIRST 4
  228. extern ypresp_key_val *ypproc_first_2 (ypreq_key *, CLIENT *);
  229. extern ypresp_key_val *ypproc_first_2_svc (ypreq_key *, struct svc_req *);
  230. #define YPPROC_NEXT 5
  231. extern ypresp_key_val *ypproc_next_2 (ypreq_key *, CLIENT *);
  232. extern ypresp_key_val *ypproc_next_2_svc (ypreq_key *, struct svc_req *);
  233. #define YPPROC_XFR 6
  234. extern ypresp_xfr *ypproc_xfr_2 (ypreq_xfr *, CLIENT *);
  235. extern ypresp_xfr *ypproc_xfr_2_svc (ypreq_xfr *, struct svc_req *);
  236. #define YPPROC_CLEAR 7
  237. extern void *ypproc_clear_2 (void *, CLIENT *);
  238. extern void *ypproc_clear_2_svc (void *, struct svc_req *);
  239. #define YPPROC_ALL 8
  240. extern ypresp_all *ypproc_all_2 (ypreq_nokey *, CLIENT *);
  241. extern ypresp_all *ypproc_all_2_svc (ypreq_nokey *, struct svc_req *);
  242. #define YPPROC_MASTER 9
  243. extern ypresp_master *ypproc_master_2 (ypreq_nokey *, CLIENT *);
  244. extern ypresp_master *ypproc_master_2_svc (ypreq_nokey *, struct svc_req *);
  245. #define YPPROC_ORDER 10
  246. extern ypresp_order *ypproc_order_2 (ypreq_nokey *, CLIENT *);
  247. extern ypresp_order *ypproc_order_2_svc (ypreq_nokey *, struct svc_req *);
  248. #define YPPROC_MAPLIST 11
  249. extern ypresp_maplist *ypproc_maplist_2 (domainname *, CLIENT *);
  250. extern ypresp_maplist *ypproc_maplist_2_svc (domainname *, struct svc_req *);
  251. extern int ypprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
  252. #define YPPUSH_XFRRESPPROG (0x40000000)
  253. #define YPPUSH_XFRRESPVERS 1
  254. #define YPPUSHPROC_NULL 0
  255. extern void *yppushproc_null_1 (void *, CLIENT *);
  256. extern void *yppushproc_null_1_svc (void *, struct svc_req *);
  257. #define YPPUSHPROC_XFRRESP 1
  258. extern void *yppushproc_xfrresp_1 (yppushresp_xfr *, CLIENT *);
  259. extern void *yppushproc_xfrresp_1_svc (yppushresp_xfr *, struct svc_req *);
  260. extern int yppush_xfrrespprog_1_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
  261. #define YPBINDPROG 100007
  262. #define YPBINDVERS 2
  263. #define YPBINDPROC_NULL 0
  264. extern void *ypbindproc_null_2 (void *, CLIENT *);
  265. extern void *ypbindproc_null_2_svc (void *, struct svc_req *);
  266. #define YPBINDPROC_DOMAIN 1
  267. extern ypbind_resp *ypbindproc_domain_2 (domainname *, CLIENT *);
  268. extern ypbind_resp *ypbindproc_domain_2_svc (domainname *, struct svc_req *);
  269. #define YPBINDPROC_SETDOM 2
  270. extern void *ypbindproc_setdom_2 (ypbind_setdom *, CLIENT *);
  271. extern void *ypbindproc_setdom_2_svc (ypbind_setdom *, struct svc_req *);
  272. extern int ypbindprog_2_freeresult (SVCXPRT *, xdrproc_t, caddr_t);
  273. extern bool_t xdr_ypstat (XDR *, ypstat*);
  274. extern bool_t xdr_ypxfrstat (XDR *, ypxfrstat*);
  275. extern bool_t xdr_domainname (XDR *, domainname*);
  276. extern bool_t xdr_mapname (XDR *, mapname*);
  277. extern bool_t xdr_peername (XDR *, peername*);
  278. extern bool_t xdr_keydat (XDR *, keydat*);
  279. extern bool_t xdr_valdat (XDR *, valdat*);
  280. extern bool_t xdr_ypmap_parms (XDR *, ypmap_parms*);
  281. extern bool_t xdr_ypreq_key (XDR *, ypreq_key*);
  282. extern bool_t xdr_ypreq_nokey (XDR *, ypreq_nokey*);
  283. extern bool_t xdr_ypreq_xfr (XDR *, ypreq_xfr*);
  284. extern bool_t xdr_ypresp_val (XDR *, ypresp_val*);
  285. extern bool_t xdr_ypresp_key_val (XDR *, ypresp_key_val*);
  286. extern bool_t xdr_ypresp_master (XDR *, ypresp_master*);
  287. extern bool_t xdr_ypresp_order (XDR *, ypresp_order*);
  288. extern bool_t xdr_ypresp_all (XDR *, ypresp_all*);
  289. extern bool_t xdr_ypresp_xfr (XDR *, ypresp_xfr*);
  290. extern bool_t xdr_ypmaplist (XDR *, ypmaplist*);
  291. extern bool_t xdr_ypresp_maplist (XDR *, ypresp_maplist*);
  292. extern bool_t xdr_yppush_status (XDR *, yppush_status*);
  293. extern bool_t xdr_yppushresp_xfr (XDR *, yppushresp_xfr*);
  294. extern bool_t xdr_ypbind_resptype (XDR *, ypbind_resptype*);
  295. extern bool_t xdr_ypbind_binding (XDR *, ypbind_binding*);
  296. extern bool_t xdr_ypbind_resp (XDR *, ypbind_resp*);
  297. extern bool_t xdr_ypbind_setdom (XDR *, ypbind_setdom*);
  298. __END_DECLS
  299. #endif /* !__RPCSVC_YP_H__ */