iPXE
xs_wire.h
Go to the documentation of this file.
00001 /*
00002  * Details of the "wire" protocol between Xen Store Daemon and client
00003  * library or guest kernel.
00004  *
00005  * Permission is hereby granted, free of charge, to any person obtaining a copy
00006  * of this software and associated documentation files (the "Software"), to
00007  * deal in the Software without restriction, including without limitation the
00008  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00009  * sell copies of the Software, and to permit persons to whom the Software is
00010  * furnished to do so, subject to the following conditions:
00011  *
00012  * The above copyright notice and this permission notice shall be included in
00013  * all copies or substantial portions of the Software.
00014  *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00018  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00020  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00021  * DEALINGS IN THE SOFTWARE.
00022  *
00023  * Copyright (C) 2005 Rusty Russell IBM Corporation
00024  */
00025 
00026 #ifndef _XS_WIRE_H
00027 #define _XS_WIRE_H
00028 
00029 FILE_LICENCE ( MIT );
00030 
00031 enum xsd_sockmsg_type
00032 {
00033     XS_DEBUG,
00034     XS_DIRECTORY,
00035     XS_READ,
00036     XS_GET_PERMS,
00037     XS_WATCH,
00038     XS_UNWATCH,
00039     XS_TRANSACTION_START,
00040     XS_TRANSACTION_END,
00041     XS_INTRODUCE,
00042     XS_RELEASE,
00043     XS_GET_DOMAIN_PATH,
00044     XS_WRITE,
00045     XS_MKDIR,
00046     XS_RM,
00047     XS_SET_PERMS,
00048     XS_WATCH_EVENT,
00049     XS_ERROR,
00050     XS_IS_DOMAIN_INTRODUCED,
00051     XS_RESUME,
00052     XS_SET_TARGET,
00053     XS_RESTRICT,
00054     XS_RESET_WATCHES
00055 };
00056 
00057 #define XS_WRITE_NONE "NONE"
00058 #define XS_WRITE_CREATE "CREATE"
00059 #define XS_WRITE_CREATE_EXCL "CREATE|EXCL"
00060 
00061 /* We hand errors as strings, for portability. */
00062 struct xsd_errors
00063 {
00064     int errnum;
00065     const char *errstring;
00066 };
00067 #ifdef EINVAL
00068 #define XSD_ERROR(x) { x, #x }
00069 /* LINTED: static unused */
00070 static struct xsd_errors xsd_errors[]
00071 #if defined(__GNUC__)
00072 __attribute__((unused))
00073 #endif
00074     = {
00075     XSD_ERROR(EINVAL),
00076     XSD_ERROR(EACCES),
00077     XSD_ERROR(EEXIST),
00078     XSD_ERROR(EISDIR),
00079     XSD_ERROR(ENOENT),
00080     XSD_ERROR(ENOMEM),
00081     XSD_ERROR(ENOSPC),
00082     XSD_ERROR(EIO),
00083     XSD_ERROR(ENOTEMPTY),
00084     XSD_ERROR(ENOSYS),
00085     XSD_ERROR(EROFS),
00086     XSD_ERROR(EBUSY),
00087     XSD_ERROR(EAGAIN),
00088     XSD_ERROR(EISCONN),
00089     XSD_ERROR(E2BIG)
00090 };
00091 #endif
00092 
00093 struct xsd_sockmsg
00094 {
00095     uint32_t type;  /* XS_??? */
00096     uint32_t req_id;/* Request identifier, echoed in daemon's response.  */
00097     uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */
00098     uint32_t len;   /* Length of data following this. */
00099 
00100     /* Generally followed by nul-terminated string(s). */
00101 };
00102 
00103 enum xs_watch_type
00104 {
00105     XS_WATCH_PATH = 0,
00106     XS_WATCH_TOKEN
00107 };
00108 
00109 /*
00110  * `incontents 150 xenstore_struct XenStore wire protocol.
00111  *
00112  * Inter-domain shared memory communications. */
00113 #define XENSTORE_RING_SIZE 1024
00114 typedef uint32_t XENSTORE_RING_IDX;
00115 #define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))
00116 struct xenstore_domain_interface {
00117     char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */
00118     char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */
00119     XENSTORE_RING_IDX req_cons, req_prod;
00120     XENSTORE_RING_IDX rsp_cons, rsp_prod;
00121 };
00122 
00123 /* Violating this is very bad.  See docs/misc/xenstore.txt. */
00124 #define XENSTORE_PAYLOAD_MAX 4096
00125 
00126 /* Violating these just gets you an error back */
00127 #define XENSTORE_ABS_PATH_MAX 3072
00128 #define XENSTORE_REL_PATH_MAX 2048
00129 
00130 #endif /* _XS_WIRE_H */
00131 
00132 /*
00133  * Local variables:
00134  * mode: C
00135  * c-file-style: "BSD"
00136  * c-basic-offset: 4
00137  * tab-width: 4
00138  * indent-tabs-mode: nil
00139  * End:
00140  */