/*1* Details of the "wire" protocol between Xen Store Daemon and client2* library or guest kernel.3*4* Permission is hereby granted, free of charge, to any person obtaining a copy5* of this software and associated documentation files (the "Software"), to6* deal in the Software without restriction, including without limitation the7* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or8* sell copies of the Software, and to permit persons to whom the Software is9* furnished to do so, subject to the following conditions:10*11* The above copyright notice and this permission notice shall be included in12* all copies or substantial portions of the Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20* DEALINGS IN THE SOFTWARE.21*22* Copyright (C) 2005 Rusty Russell IBM Corporation23*/2425#ifndef _XS_WIRE_H26#define _XS_WIRE_H2728enum xsd_sockmsg_type29{30XS_CONTROL,31#define XS_DEBUG XS_CONTROL32XS_DIRECTORY,33XS_READ,34XS_GET_PERMS,35XS_WATCH,36XS_UNWATCH,37XS_TRANSACTION_START,38XS_TRANSACTION_END,39XS_INTRODUCE,40XS_RELEASE,41XS_GET_DOMAIN_PATH,42XS_WRITE,43XS_MKDIR,44XS_RM,45XS_SET_PERMS,46XS_WATCH_EVENT,47XS_ERROR,48XS_IS_DOMAIN_INTRODUCED,49XS_RESUME,50XS_SET_TARGET,51/* XS_RESTRICT has been removed */52XS_RESET_WATCHES = XS_SET_TARGET + 2,53XS_DIRECTORY_PART,5455XS_TYPE_COUNT, /* Number of valid types. */5657XS_INVALID = 0xffff /* Guaranteed to remain an invalid type */58};5960#define XS_WRITE_NONE "NONE"61#define XS_WRITE_CREATE "CREATE"62#define XS_WRITE_CREATE_EXCL "CREATE|EXCL"6364/* We hand errors as strings, for portability. */65struct xsd_errors66{67int errnum;68const char *errstring;69};70#ifdef EINVAL71#define XSD_ERROR(x) { x, #x }72/* LINTED: static unused */73static struct xsd_errors xsd_errors[]74#if defined(__GNUC__)75__attribute__((unused))76#endif77= {78XSD_ERROR(EINVAL),79XSD_ERROR(EACCES),80XSD_ERROR(EEXIST),81XSD_ERROR(EISDIR),82XSD_ERROR(ENOENT),83XSD_ERROR(ENOMEM),84XSD_ERROR(ENOSPC),85XSD_ERROR(EIO),86XSD_ERROR(ENOTEMPTY),87XSD_ERROR(ENOSYS),88XSD_ERROR(EROFS),89XSD_ERROR(EBUSY),90XSD_ERROR(EAGAIN),91XSD_ERROR(EISCONN),92XSD_ERROR(E2BIG)93};94#endif9596struct xsd_sockmsg97{98uint32_t type; /* XS_??? */99uint32_t req_id;/* Request identifier, echoed in daemon's response. */100uint32_t tx_id; /* Transaction id (0 if not related to a transaction). */101uint32_t len; /* Length of data following this. */102103/* Generally followed by nul-terminated string(s). */104};105106enum xs_watch_type107{108XS_WATCH_PATH = 0,109XS_WATCH_TOKEN110};111112/*113* `incontents 150 xenstore_struct XenStore wire protocol.114*115* Inter-domain shared memory communications. */116#define XENSTORE_RING_SIZE 1024117typedef uint32_t XENSTORE_RING_IDX;118#define MASK_XENSTORE_IDX(idx) ((idx) & (XENSTORE_RING_SIZE-1))119struct xenstore_domain_interface {120char req[XENSTORE_RING_SIZE]; /* Requests to xenstore daemon. */121char rsp[XENSTORE_RING_SIZE]; /* Replies and async watch events. */122XENSTORE_RING_IDX req_cons, req_prod;123XENSTORE_RING_IDX rsp_cons, rsp_prod;124uint32_t server_features; /* Bitmap of features supported by the server */125uint32_t connection;126};127128/* Violating this is very bad. See docs/misc/xenstore.txt. */129#define XENSTORE_PAYLOAD_MAX 4096130131/* Violating these just gets you an error back */132#define XENSTORE_ABS_PATH_MAX 3072133#define XENSTORE_REL_PATH_MAX 2048134135/* The ability to reconnect a ring */136#define XENSTORE_SERVER_FEATURE_RECONNECTION 1137138/* Valid values for the connection field */139#define XENSTORE_CONNECTED 0 /* the steady-state */140#define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */141142#endif /* _XS_WIRE_H */143144/*145* Local variables:146* mode: C147* c-file-style: "BSD"148* c-basic-offset: 4149* tab-width: 4150* indent-tabs-mode: nil151* End:152*/153154155