/include/rpcsvc/yp_prot.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 329 lines · 177 code · 34 blank · 118 comment · 0 complexity · f80ddcef1502a56e05a9b4daff1b59e8 MD5 · raw file

  1. /*
  2. * Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. The name of the author may not be used to endorse or promote
  14. * products derived from this software without specific prior written
  15. * permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
  18. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  19. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  21. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27. * SUCH DAMAGE.
  28. *
  29. * $FreeBSD$
  30. */
  31. #ifndef _RPCSVC_YP_PROT_H_
  32. #define _RPCSVC_YP_PROT_H_
  33. /*
  34. * YPSERV PROTOCOL:
  35. *
  36. * ypserv supports the following procedures:
  37. *
  38. * YPPROC_NULL takes (void), returns (void).
  39. * called to check if server is alive.
  40. * YPPROC_DOMAIN takes (char *), returns (bool_t).
  41. * true if ypserv serves the named domain.
  42. * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t).
  43. * true if ypserv serves the named domain.
  44. * used for broadcasts, does not ack if ypserv
  45. * doesn't handle named domain.
  46. * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val)
  47. * does a lookup.
  48. * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val).
  49. * gets the first key/datum from the map.
  50. * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val).
  51. * gets the next key/datum from the map.
  52. * YPPROC_XFR takes (struct ypreq_xfr), returns (void).
  53. * tells ypserv to check if there is a new version of
  54. * the map.
  55. * YPPROC_CLEAR takes (void), returns (void).
  56. * tells ypserv to flush it's file cache, so that
  57. * newly transferred files will get read.
  58. * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and
  59. * struct ypresp_key_val).
  60. * returns an array of data, with the bool_t being
  61. * false on the last datum. read the source, it's
  62. * convoluted.
  63. * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master).
  64. * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order).
  65. * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *).
  66. */
  67. #ifndef BOOL_DEFINED
  68. typedef u_int bool;
  69. #define BOOL_DEFINED
  70. #endif
  71. /* Program and version symbols, magic numbers */
  72. #define YPPROG ((u_long)100004)
  73. #define YPVERS ((u_long)2)
  74. #define YPVERS_ORIG ((u_long)1)
  75. #define YPMAXRECORD ((u_long)1024)
  76. #define YPMAXDOMAIN ((u_long)64)
  77. #define YPMAXMAP ((u_long)64)
  78. #define YPMAXPEER ((u_long)256)
  79. /*
  80. * I don't know if anything of sun's depends on this, or if they
  81. * simply defined it so that their own code wouldn't try to send
  82. * packets over the ethernet MTU. This YP code doesn't use it.
  83. */
  84. #define YPMSGSZ 1600
  85. #ifndef DATUM
  86. typedef struct {
  87. char *dptr;
  88. int dsize;
  89. } datum;
  90. #define DATUM
  91. #endif
  92. struct ypmap_parms {
  93. char *domain;
  94. char *map;
  95. u_int ordernum;
  96. char *owner;
  97. };
  98. struct ypreq_key {
  99. char *domain;
  100. char *map;
  101. datum keydat;
  102. };
  103. struct ypreq_nokey {
  104. char *domain;
  105. char *map;
  106. };
  107. struct ypreq_xfr {
  108. struct ypmap_parms map_parms;
  109. u_int transid;
  110. u_int proto;
  111. u_int port;
  112. };
  113. #define ypxfr_domain map_parms.domain
  114. #define ypxfr_map map_parms.map
  115. #define ypxfr_ordernum map_parms.ordernum
  116. #define ypxfr_owner map_parms.owner
  117. struct ypresp_val {
  118. u_int status;
  119. datum valdat;
  120. };
  121. struct ypresp_key_val {
  122. u_int status;
  123. datum keydat;
  124. datum valdat;
  125. };
  126. struct ypresp_master {
  127. u_int status;
  128. char *master;
  129. };
  130. struct ypresp_order {
  131. u_int status;
  132. u_int ordernum;
  133. };
  134. struct ypmaplist {
  135. char *ypml_name;
  136. struct ypmaplist *ypml_next;
  137. };
  138. struct ypresp_maplist {
  139. u_int status;
  140. struct ypmaplist *list;
  141. };
  142. /* ypserv procedure numbers */
  143. #define YPPROC_NULL ((u_long)0)
  144. #define YPPROC_DOMAIN ((u_long)1)
  145. #define YPPROC_DOMAIN_NONACK ((u_long)2)
  146. #define YPPROC_MATCH ((u_long)3)
  147. #define YPPROC_FIRST ((u_long)4)
  148. #define YPPROC_NEXT ((u_long)5)
  149. #define YPPROC_XFR ((u_long)6)
  150. #define YPPROC_CLEAR ((u_long)7)
  151. #define YPPROC_ALL ((u_long)8)
  152. #define YPPROC_MASTER ((u_long)9)
  153. #define YPPROC_ORDER ((u_long)10)
  154. #define YPPROC_MAPLIST ((u_long)11)
  155. /* ypserv procedure return status values */
  156. #define YP_TRUE ((long)1) /* general purpose success code */
  157. #define YP_NOMORE ((long)2) /* no more entries in map */
  158. #define YP_FALSE ((long)0) /* general purpose failure code */
  159. #define YP_NOMAP ((long)-1) /* no such map in domain */
  160. #define YP_NODOM ((long)-2) /* domain not supported */
  161. #define YP_NOKEY ((long)-3) /* no such key in map */
  162. #define YP_BADOP ((long)-4) /* invalid operation */
  163. #define YP_BADDB ((long)-5) /* server data base is bad */
  164. #define YP_YPERR ((long)-6) /* YP server error */
  165. #define YP_BADARGS ((long)-7) /* request arguments bad */
  166. #define YP_VERS ((long)-8) /* YP server version mismatch */
  167. /*
  168. * Sun's header file says:
  169. * "Domain binding data structure, used by ypclnt package and ypserv modules.
  170. * Users of the ypclnt package (or of this protocol) don't HAVE to know about
  171. * it, but it must be available to users because _yp_dobind is a public
  172. * interface."
  173. *
  174. * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is
  175. * a public interface, and I don't know any reason anyone would want to call
  176. * it. But, just in case anyone does actually expect it to be available..
  177. * we provide this.. exactly as Sun wants it.
  178. */
  179. struct dom_binding {
  180. struct dom_binding *dom_pnext;
  181. char dom_domain[YPMAXDOMAIN + 1];
  182. struct sockaddr_in dom_server_addr;
  183. u_short dom_server_port;
  184. int dom_socket;
  185. CLIENT *dom_client;
  186. u_short dom_local_port;
  187. long dom_vers;
  188. };
  189. /*
  190. * YPBIND PROTOCOL:
  191. *
  192. * ypbind supports the following procedures:
  193. *
  194. * YPBINDPROC_NULL takes (void), returns (void).
  195. * to check if ypbind is running.
  196. * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp).
  197. * requests that ypbind start to serve the
  198. * named domain (if it doesn't already)
  199. * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void).
  200. * used by ypset.
  201. */
  202. #define YPBINDPROG ((u_long)100007)
  203. #define YPBINDVERS ((u_long)2)
  204. #define YPBINDVERS_ORIG ((u_long)1)
  205. /* ypbind procedure numbers */
  206. #define YPBINDPROC_NULL ((u_long)0)
  207. #define YPBINDPROC_DOMAIN ((u_long)1)
  208. #define YPBINDPROC_SETDOM ((u_long)2)
  209. /* error code in ypbind_resp.ypbind_status */
  210. enum ypbind_resptype {
  211. YPBIND_SUCC_VAL = 1,
  212. YPBIND_FAIL_VAL = 2
  213. };
  214. /* network order, of course */
  215. struct ypbind_binding {
  216. struct in_addr ypbind_binding_addr;
  217. u_short ypbind_binding_port;
  218. };
  219. struct ypbind_resp {
  220. enum ypbind_resptype ypbind_status;
  221. union {
  222. u_int ypbind_error;
  223. struct ypbind_binding ypbind_bindinfo;
  224. } ypbind_respbody;
  225. };
  226. /* error code in ypbind_resp.ypbind_respbody.ypbind_error */
  227. #define YPBIND_ERR_ERR 1 /* internal error */
  228. #define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */
  229. #define YPBIND_ERR_RESC 3 /* system resource allocation failure */
  230. /*
  231. * Request data structure for ypbind "Set domain" procedure.
  232. */
  233. struct ypbind_setdom {
  234. char ypsetdom_domain[YPMAXDOMAIN + 1];
  235. struct ypbind_binding ypsetdom_binding;
  236. u_int ypsetdom_vers;
  237. };
  238. #define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr
  239. #define ypsetdom_port ypsetdom_binding.ypbind_binding_port
  240. /*
  241. * YPPUSH PROTOCOL:
  242. *
  243. * Sun says:
  244. * "Protocol between clients (ypxfr, only) and yppush
  245. * yppush speaks a protocol in the transient range, which
  246. * is supplied to ypxfr as a command-line parameter when it
  247. * is activated by ypserv."
  248. *
  249. * This protocol is not implemented, naturally, because this YP
  250. * implementation only does the client side.
  251. */
  252. #define YPPUSHVERS ((u_long)1)
  253. #define YPPUSHVERS_ORIG ((u_long)1)
  254. /* yppush procedure numbers */
  255. #define YPPUSHPROC_NULL ((u_long)0)
  256. #define YPPUSHPROC_XFRRESP ((u_long)1)
  257. struct yppushresp_xfr {
  258. u_int transid;
  259. u_int status;
  260. };
  261. /* yppush status value in yppushresp_xfr.status */
  262. #define YPPUSH_SUCC ((long)1) /* Success */
  263. #define YPPUSH_AGE ((long)2) /* Master's version not newer */
  264. #define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */
  265. #define YPPUSH_NODOM ((long)-2) /* Domain not supported */
  266. #define YPPUSH_RSRC ((long)-3) /* Local resource alloc failure */
  267. #define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */
  268. #define YPPUSH_MADDR ((long)-5) /* Can't get master address */
  269. #define YPPUSH_YPERR ((long)-6) /* YP server/map db error */
  270. #define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */
  271. #define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */
  272. #define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */
  273. #define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */
  274. #define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */
  275. #define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */
  276. #define YPPUSH_XFRERR ((long)-13) /* ypxfr error */
  277. #define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */
  278. struct inaddr;
  279. __BEGIN_DECLS
  280. bool_t xdr_datum(XDR *, datum *);
  281. bool_t xdr_ypreq_key(XDR *, struct ypreq_key *);
  282. bool_t xdr_ypreq_nokey(XDR *, struct ypreq_nokey *);
  283. bool_t xdr_ypreq_xfr(XDR *, struct ypreq_xfr *);
  284. bool_t xdr_ypresp_val(XDR *, struct ypresp_val *);
  285. bool_t xdr_ypresp_key_val(XDR *, struct ypresp_key_val *);
  286. bool_t xdr_ypbind_resp(XDR *, struct ypbind_resp *);
  287. bool_t xdr_ypbind_setdom(XDR *, struct ypbind_setdom *);
  288. bool_t xdr_yp_inaddr(XDR *, struct inaddr *);
  289. bool_t xdr_ypmap_parms(XDR *, struct ypmap_parms *);
  290. bool_t xdr_yppushresp_xfr(XDR *, struct yppushresp_xfr *);
  291. bool_t xdr_ypresp_order(XDR *, struct ypresp_order *);
  292. bool_t xdr_ypresp_master(XDR *, struct ypresp_master *);
  293. bool_t xdr_ypresp_maplist(XDR *, struct ypresp_maplist *);
  294. __END_DECLS
  295. #endif /* _RPCSVC_YP_PROT_H_ */