1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _REPCACHE_PROTOCOL_H 28*7c478bd9Sstevel@tonic-gate #define _REPCACHE_PROTOCOL_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * The Repository Cache Protocol 34*7c478bd9Sstevel@tonic-gate * ----------------------------- 35*7c478bd9Sstevel@tonic-gate * 36*7c478bd9Sstevel@tonic-gate * 1. Introduction 37*7c478bd9Sstevel@tonic-gate * --------------- 38*7c478bd9Sstevel@tonic-gate * This header file defines the private protocols between libscf(3lib) and 39*7c478bd9Sstevel@tonic-gate * svc.configd(1m). There are two separate protocols: 40*7c478bd9Sstevel@tonic-gate * 41*7c478bd9Sstevel@tonic-gate * 1. The 'global' protocol, accessible via an fattach(3C)ed door located 42*7c478bd9Sstevel@tonic-gate * at REPOSITORY_DOOR_NAME. 43*7c478bd9Sstevel@tonic-gate * 44*7c478bd9Sstevel@tonic-gate * 2. The 'client' protocol, accessible through a door created using the 45*7c478bd9Sstevel@tonic-gate * global protocol, which allows access to the repository. 46*7c478bd9Sstevel@tonic-gate * 47*7c478bd9Sstevel@tonic-gate * 1.1 Design restrictions 48*7c478bd9Sstevel@tonic-gate * ----------------------- 49*7c478bd9Sstevel@tonic-gate * A basic constraint of the door IPC mechanism is that there is no reliable 50*7c478bd9Sstevel@tonic-gate * delivery. In particular: 51*7c478bd9Sstevel@tonic-gate * 52*7c478bd9Sstevel@tonic-gate * 1. If libscf(3lib) recieves an EINTR from door_call(), it doesn't know 53*7c478bd9Sstevel@tonic-gate * whether or not the server recieved (and is processing) its request. 54*7c478bd9Sstevel@tonic-gate * 55*7c478bd9Sstevel@tonic-gate * 2. When svc.configd(1M) calls door_return(), the client may have already 56*7c478bd9Sstevel@tonic-gate * received an EINTR, aborting its door_call(). In this case, the 57*7c478bd9Sstevel@tonic-gate * returned values are dropped on the floor. 58*7c478bd9Sstevel@tonic-gate * 59*7c478bd9Sstevel@tonic-gate * The practical upshot of all of this is simple: 60*7c478bd9Sstevel@tonic-gate * 61*7c478bd9Sstevel@tonic-gate * Every individual protocol action must be idempotent. 62*7c478bd9Sstevel@tonic-gate * 63*7c478bd9Sstevel@tonic-gate * That is, a client must be able to retry any single request multiple times, 64*7c478bd9Sstevel@tonic-gate * and get the correct results. 65*7c478bd9Sstevel@tonic-gate * 66*7c478bd9Sstevel@tonic-gate * 1.2. Protocol shorthand 67*7c478bd9Sstevel@tonic-gate * ----------------------- 68*7c478bd9Sstevel@tonic-gate * We represent by "REQUEST(arg1, arg2) -> result, res1, [desc]" a request code 69*7c478bd9Sstevel@tonic-gate * of REP_PROTOCOL_REQUEST (or REPOSITORY_DOOR_REQUEST), which takes two 70*7c478bd9Sstevel@tonic-gate * additional arguments, arg1 and arg2, and returns a result code, res1, and 71*7c478bd9Sstevel@tonic-gate * a file descriptor desc. 72*7c478bd9Sstevel@tonic-gate * 73*7c478bd9Sstevel@tonic-gate * If an error occurs, the server will usually only send the result code. (a 74*7c478bd9Sstevel@tonic-gate * short return) 75*7c478bd9Sstevel@tonic-gate * 76*7c478bd9Sstevel@tonic-gate * Inside the protocol destription, <foo> indicates the type foo indicates. 77*7c478bd9Sstevel@tonic-gate * 78*7c478bd9Sstevel@tonic-gate * 2. The Global protocol 79*7c478bd9Sstevel@tonic-gate * ---------------------- 80*7c478bd9Sstevel@tonic-gate * Everything starting with "REPOSITORY_DOOR" or "repository_door" belongs 81*7c478bd9Sstevel@tonic-gate * to the global protocol. 82*7c478bd9Sstevel@tonic-gate * 83*7c478bd9Sstevel@tonic-gate * 2.1. Global requests 84*7c478bd9Sstevel@tonic-gate * -------------------- 85*7c478bd9Sstevel@tonic-gate * 86*7c478bd9Sstevel@tonic-gate * REQUEST_CONNECT(rdr_flags, ...) -> result, [new_door] 87*7c478bd9Sstevel@tonic-gate * Request a new Client door. rdr_flags determines attributes of the 88*7c478bd9Sstevel@tonic-gate * connection: 89*7c478bd9Sstevel@tonic-gate * 90*7c478bd9Sstevel@tonic-gate * FLAG_DEBUG 91*7c478bd9Sstevel@tonic-gate * Sets connection debugging flags to those in rdr_debug. 92*7c478bd9Sstevel@tonic-gate * 93*7c478bd9Sstevel@tonic-gate * The new door is returned with DOOR_RELEASE set, so if the client does 94*7c478bd9Sstevel@tonic-gate * not recieve the response, the new door will recieve an unref 95*7c478bd9Sstevel@tonic-gate * notification. This makes this request idempotent. 96*7c478bd9Sstevel@tonic-gate * 97*7c478bd9Sstevel@tonic-gate * 2.2. Global reponse codes 98*7c478bd9Sstevel@tonic-gate * ------------------------- 99*7c478bd9Sstevel@tonic-gate * GLXXX: This needs to be thought through. 100*7c478bd9Sstevel@tonic-gate * 101*7c478bd9Sstevel@tonic-gate * SUCCESS 102*7c478bd9Sstevel@tonic-gate * FAIL_BAD_REQUEST 103*7c478bd9Sstevel@tonic-gate * FAIL_VERSION_MISMATCH 104*7c478bd9Sstevel@tonic-gate * FAIL_BAD_FLAG 105*7c478bd9Sstevel@tonic-gate * FAIL_BAD_USER 106*7c478bd9Sstevel@tonic-gate * FAIL_NO_RESOURCES 107*7c478bd9Sstevel@tonic-gate * 108*7c478bd9Sstevel@tonic-gate * 3. The Client protocol 109*7c478bd9Sstevel@tonic-gate * ---------------------- 110*7c478bd9Sstevel@tonic-gate * Everything starting with "REP_PROTOCOL" or "rep_protocol" belongs to the 111*7c478bd9Sstevel@tonic-gate * client protocol. 112*7c478bd9Sstevel@tonic-gate * 113*7c478bd9Sstevel@tonic-gate * 3.1. Techniques used 114*7c478bd9Sstevel@tonic-gate * -------------------- 115*7c478bd9Sstevel@tonic-gate * 3.1.1. Client-controlled identifiers 116*7c478bd9Sstevel@tonic-gate * 117*7c478bd9Sstevel@tonic-gate * An idiom the protocol uses to lower the number of round trips is 118*7c478bd9Sstevel@tonic-gate * client-controlled identifiers. The basic idea is this: whenever a 119*7c478bd9Sstevel@tonic-gate * client wants to set up and use a piece of server state, he picks an 120*7c478bd9Sstevel@tonic-gate * integer *which he knows is not in use* to identify it. The server then 121*7c478bd9Sstevel@tonic-gate * maintains per-client, per-resource id->resource maps. This has a number 122*7c478bd9Sstevel@tonic-gate * of advantages: 123*7c478bd9Sstevel@tonic-gate * 124*7c478bd9Sstevel@tonic-gate * 1. Since the client allocates the identifiers, we don't need to do 125*7c478bd9Sstevel@tonic-gate * a round-trip just to allocate a number. 126*7c478bd9Sstevel@tonic-gate * 127*7c478bd9Sstevel@tonic-gate * 2. Since it is the client's job to make sure identifiers don't collide, 128*7c478bd9Sstevel@tonic-gate * idempotency for setup (destroy) are simple: If the identifier 129*7c478bd9Sstevel@tonic-gate * already exists (does not exist), we just return success. 130*7c478bd9Sstevel@tonic-gate * 131*7c478bd9Sstevel@tonic-gate * 3. Since the identifiers are per-client, the design automatically 132*7c478bd9Sstevel@tonic-gate * precludes clients being able to manipulate other client's state. 133*7c478bd9Sstevel@tonic-gate * 134*7c478bd9Sstevel@tonic-gate * 3.1.2 Sequence numbers 135*7c478bd9Sstevel@tonic-gate * 136*7c478bd9Sstevel@tonic-gate * A standard way of gaining idempotency is introducing sequence numbers. 137*7c478bd9Sstevel@tonic-gate * These are simply integers which get incremented at points in the protocol, 138*7c478bd9Sstevel@tonic-gate * and make sure the client and server are in sync. 139*7c478bd9Sstevel@tonic-gate * 140*7c478bd9Sstevel@tonic-gate * In this protocol, we use sequence numbers for requests (like ITER_READ) 141*7c478bd9Sstevel@tonic-gate * which are repeated, returning different data each time. Since requests 142*7c478bd9Sstevel@tonic-gate * can also be repeated due to unreliable dispatch, the client increments 143*7c478bd9Sstevel@tonic-gate * the sequence number after every successful request. This allows the server 144*7c478bd9Sstevel@tonic-gate * to differentiate the two cases. (note that this means that failing 145*7c478bd9Sstevel@tonic-gate * requests have no side effects and are repeatable) 146*7c478bd9Sstevel@tonic-gate * 147*7c478bd9Sstevel@tonic-gate * 3.2. Client abstractions 148*7c478bd9Sstevel@tonic-gate * ------------------------ 149*7c478bd9Sstevel@tonic-gate * 3.2.1 Entities 150*7c478bd9Sstevel@tonic-gate * 151*7c478bd9Sstevel@tonic-gate * An "entity" is a typed register which the client can manipulate. 152*7c478bd9Sstevel@tonic-gate * Entities are named in the protocol by client-controlled identifiers. 153*7c478bd9Sstevel@tonic-gate * They have a fixed type for their entire lifetime, and may be in one 154*7c478bd9Sstevel@tonic-gate * of two states: 155*7c478bd9Sstevel@tonic-gate * 156*7c478bd9Sstevel@tonic-gate * valid 157*7c478bd9Sstevel@tonic-gate * The entity has a valid value, and may be read from. This state 158*7c478bd9Sstevel@tonic-gate * is reached by a successful write to the entity by some protocol 159*7c478bd9Sstevel@tonic-gate * step. 160*7c478bd9Sstevel@tonic-gate * 161*7c478bd9Sstevel@tonic-gate * invalid 162*7c478bd9Sstevel@tonic-gate * The entity does not contain a valid value. There are a number 163*7c478bd9Sstevel@tonic-gate * of ways to reach this state: 164*7c478bd9Sstevel@tonic-gate * 165*7c478bd9Sstevel@tonic-gate * 1. The entity was just created. 166*7c478bd9Sstevel@tonic-gate * 2. The underlying object that this entity refers to was destroyed. 167*7c478bd9Sstevel@tonic-gate * 3. A protocol request which would have modified this entity 168*7c478bd9Sstevel@tonic-gate * failed. 169*7c478bd9Sstevel@tonic-gate * 170*7c478bd9Sstevel@tonic-gate * An entity is an element in the tree of repository data. Every entity 171*7c478bd9Sstevel@tonic-gate * (except for the most distant SCOPE) has exactly one parent. Entities 172*7c478bd9Sstevel@tonic-gate * can have multiple children of different types, restricted by its base 173*7c478bd9Sstevel@tonic-gate * type. 174*7c478bd9Sstevel@tonic-gate * 175*7c478bd9Sstevel@tonic-gate * The ENTITY_GET call is used to get the root of the tree (the most local 176*7c478bd9Sstevel@tonic-gate * scope) 177*7c478bd9Sstevel@tonic-gate * 178*7c478bd9Sstevel@tonic-gate * 3.2.2. The entity tree 179*7c478bd9Sstevel@tonic-gate * ---------------------- 180*7c478bd9Sstevel@tonic-gate * The structure of a scope is as follows: 181*7c478bd9Sstevel@tonic-gate * 182*7c478bd9Sstevel@tonic-gate * _______ 183*7c478bd9Sstevel@tonic-gate * | SCOPE | 184*7c478bd9Sstevel@tonic-gate * |_______| 185*7c478bd9Sstevel@tonic-gate * \ . 186*7c478bd9Sstevel@tonic-gate * \ . 187*7c478bd9Sstevel@tonic-gate * \_________ 188*7c478bd9Sstevel@tonic-gate * | SERVICE | 189*7c478bd9Sstevel@tonic-gate * |_________| 190*7c478bd9Sstevel@tonic-gate * /. \ . 191*7c478bd9Sstevel@tonic-gate * /. \ . 192*7c478bd9Sstevel@tonic-gate * ____/ \__________ 193*7c478bd9Sstevel@tonic-gate * | PG | | INSTANCE | 194*7c478bd9Sstevel@tonic-gate * |____| |__________| 195*7c478bd9Sstevel@tonic-gate * /. \ . 196*7c478bd9Sstevel@tonic-gate * /. \ . 197*7c478bd9Sstevel@tonic-gate * ____/ \__________ 198*7c478bd9Sstevel@tonic-gate * | PG | | SNAPSHOT | 199*7c478bd9Sstevel@tonic-gate * |____| |__________| 200*7c478bd9Sstevel@tonic-gate * \ . 201*7c478bd9Sstevel@tonic-gate * \ . 202*7c478bd9Sstevel@tonic-gate * \___________ 203*7c478bd9Sstevel@tonic-gate * | SNAPLEVEL | 204*7c478bd9Sstevel@tonic-gate * |___________| 205*7c478bd9Sstevel@tonic-gate * /. 206*7c478bd9Sstevel@tonic-gate * /. 207*7c478bd9Sstevel@tonic-gate * ____/ 208*7c478bd9Sstevel@tonic-gate * | PG | 209*7c478bd9Sstevel@tonic-gate * |____| 210*7c478bd9Sstevel@tonic-gate * 211*7c478bd9Sstevel@tonic-gate * Where the dots indicate an arbitrary number (including 0) of children. 212*7c478bd9Sstevel@tonic-gate * 213*7c478bd9Sstevel@tonic-gate * For a given scope, the next scope (in the sense of distance) is its 214*7c478bd9Sstevel@tonic-gate * TYPE_SCOPE parent. The furthest out scope has no parent. 215*7c478bd9Sstevel@tonic-gate * 216*7c478bd9Sstevel@tonic-gate * 3.2.2 Iterators 217*7c478bd9Sstevel@tonic-gate * 218*7c478bd9Sstevel@tonic-gate * GLXXX 219*7c478bd9Sstevel@tonic-gate * 220*7c478bd9Sstevel@tonic-gate * 3.3. Client requests 221*7c478bd9Sstevel@tonic-gate * -------------------- 222*7c478bd9Sstevel@tonic-gate * 223*7c478bd9Sstevel@tonic-gate * CLOSE() -> result 224*7c478bd9Sstevel@tonic-gate * Closes the connection, revoking the door. After this call completes, 225*7c478bd9Sstevel@tonic-gate * no further calls will succeed. 226*7c478bd9Sstevel@tonic-gate * 227*7c478bd9Sstevel@tonic-gate * ENTITY_SETUP(entity_id, type) -> result 228*7c478bd9Sstevel@tonic-gate * Sets up an entity, identified by entity_id, to identify a single 229*7c478bd9Sstevel@tonic-gate * <type>. <type> may not be TYPE_NONE. 230*7c478bd9Sstevel@tonic-gate * 231*7c478bd9Sstevel@tonic-gate * ENTITY_NAME(entity_id, name_type) -> result, name 232*7c478bd9Sstevel@tonic-gate * Returns the name of entity_id. name_type determines which type of 233*7c478bd9Sstevel@tonic-gate * name to get. 234*7c478bd9Sstevel@tonic-gate * 235*7c478bd9Sstevel@tonic-gate * ENTITY_PARENT_TYPE(entity_id) -> result, parent_type 236*7c478bd9Sstevel@tonic-gate * Retrieves the type of entity_id's parent 237*7c478bd9Sstevel@tonic-gate * 238*7c478bd9Sstevel@tonic-gate * ENTITY_GET_CHILD(entity_id, child_id, name) -> result 239*7c478bd9Sstevel@tonic-gate * Puts entity_id's child (of child_id's type) named 'name' into child_id. 240*7c478bd9Sstevel@tonic-gate * 241*7c478bd9Sstevel@tonic-gate * ENTITY_GET_PARENT(entity_id, out_id) -> result 242*7c478bd9Sstevel@tonic-gate * Puts entity_id's parent into out_id. 243*7c478bd9Sstevel@tonic-gate * 244*7c478bd9Sstevel@tonic-gate * ENTITY_GET(entity_id, number) -> result 245*7c478bd9Sstevel@tonic-gate * Makes entity_id point to a particular object. If any error 246*7c478bd9Sstevel@tonic-gate * occurs, dest_id will be invalid. 247*7c478bd9Sstevel@tonic-gate * 248*7c478bd9Sstevel@tonic-gate * ENTITY_UPDATE(entity_id, changeid) -> result 249*7c478bd9Sstevel@tonic-gate * Updates the entity to pick up any new changes. 250*7c478bd9Sstevel@tonic-gate * 251*7c478bd9Sstevel@tonic-gate * ENTITY_CREATE_CHILD(entity_id, type, name, child_id, changeid) -> result 252*7c478bd9Sstevel@tonic-gate * Attaches the object of type /type/ in child_id as the child of 253*7c478bd9Sstevel@tonic-gate * entity_id named 'name'. 254*7c478bd9Sstevel@tonic-gate * 255*7c478bd9Sstevel@tonic-gate * ENTITY_CREATE_PG(entity_id, name, type, flags, child_id, changeid) -> result 256*7c478bd9Sstevel@tonic-gate * Creates a property group child of entity_id named 'name', type 'type' 257*7c478bd9Sstevel@tonic-gate * and flags 'flags', and puts the resulting object in child_id. 258*7c478bd9Sstevel@tonic-gate * 259*7c478bd9Sstevel@tonic-gate * ENTITY_DELETE(entity_id, changeid) -> result 260*7c478bd9Sstevel@tonic-gate * Deletes the entity represented by entity_id. 261*7c478bd9Sstevel@tonic-gate * 262*7c478bd9Sstevel@tonic-gate * ENTITY_RESET(entity_id) -> result 263*7c478bd9Sstevel@tonic-gate * Resets the entity. 264*7c478bd9Sstevel@tonic-gate * 265*7c478bd9Sstevel@tonic-gate * ENTITY_TEARDOWN(entity_id) -> result 266*7c478bd9Sstevel@tonic-gate * Destroys the entity entity_id. 267*7c478bd9Sstevel@tonic-gate * 268*7c478bd9Sstevel@tonic-gate * ITER_SETUP(iter_id) -> result 269*7c478bd9Sstevel@tonic-gate * Sets up an iterator id. 270*7c478bd9Sstevel@tonic-gate * 271*7c478bd9Sstevel@tonic-gate * ITER_START(iter_id, entity_id, itertype, flags, pattern) -> result 272*7c478bd9Sstevel@tonic-gate * Sets up an iterator, identified by iter_id, which will iterate the 273*7c478bd9Sstevel@tonic-gate * <itertype> children of entity_id whose names match 'pattern', 274*7c478bd9Sstevel@tonic-gate * with the matching controlled by flags. Initializing an iterator 275*7c478bd9Sstevel@tonic-gate * counts as the first sequence number (1). 276*7c478bd9Sstevel@tonic-gate * 277*7c478bd9Sstevel@tonic-gate * ITER_READ(iter_id, sequence, entity_id) -> result 278*7c478bd9Sstevel@tonic-gate * Retrieves the next element of iterator iter_id. Sequence starts at 2, 279*7c478bd9Sstevel@tonic-gate * and is incremented by the client after each successful iteration. 280*7c478bd9Sstevel@tonic-gate * The result is written to entity_id, which must be of the same type 281*7c478bd9Sstevel@tonic-gate * as the iterator result. The iterator must not be iterating values. 282*7c478bd9Sstevel@tonic-gate * 283*7c478bd9Sstevel@tonic-gate * ITER_READ_VALUE(iter_id, sequence) -> result, type, value 284*7c478bd9Sstevel@tonic-gate * Retrieves the next value for iterator iter_id. Sequence starts at 2, 285*7c478bd9Sstevel@tonic-gate * and is incremented by the client after each successful iteration. 286*7c478bd9Sstevel@tonic-gate * The iterator must be iterating a property's values. 287*7c478bd9Sstevel@tonic-gate * 288*7c478bd9Sstevel@tonic-gate * ITER_RESET(iter_id) -> result 289*7c478bd9Sstevel@tonic-gate * Throws away any accumulated state. 290*7c478bd9Sstevel@tonic-gate * 291*7c478bd9Sstevel@tonic-gate * ITER_TEARDOWN(iter_id) -> result 292*7c478bd9Sstevel@tonic-gate * Destroys the iterator iter_id. 293*7c478bd9Sstevel@tonic-gate * 294*7c478bd9Sstevel@tonic-gate * NEXT_SNAPLEVEL(entity_src, entity_dst) -> result 295*7c478bd9Sstevel@tonic-gate * If entity_src is a snapshot, set entity_dst to the first snaplevel 296*7c478bd9Sstevel@tonic-gate * in it. If entity_src is a snaplevel, set entity_dst to the next 297*7c478bd9Sstevel@tonic-gate * snaplevel, or fail if there isn't one. 298*7c478bd9Sstevel@tonic-gate * 299*7c478bd9Sstevel@tonic-gate * SNAPSHOT_TAKE(entity_id, name, dest_id, flags) -> result 300*7c478bd9Sstevel@tonic-gate * Takes a snapshot of entity_id, creating snaplevels for the instance and 301*7c478bd9Sstevel@tonic-gate * its parent service. If flags is REP_SNAPSHOT_NEW, a new snapshot named 302*7c478bd9Sstevel@tonic-gate * 'name' is created as a child of entity_id, dest_id is pointed to it, 303*7c478bd9Sstevel@tonic-gate * and the new snaplevels are attached to it. If flags is 304*7c478bd9Sstevel@tonic-gate * REP_SNAPSHOT_ATTACH, name must be empty, and the new snaplevels are 305*7c478bd9Sstevel@tonic-gate * attached to the snapshot dest_id points to. 306*7c478bd9Sstevel@tonic-gate * 307*7c478bd9Sstevel@tonic-gate * SNAPSHOT_TAKE_NAMED(entity_id, instname, svcname, name, dest_id) -> result 308*7c478bd9Sstevel@tonic-gate * Like SNAPSHOT_TAKE, but always acts as if REP_SNAPSHOT_NEW is 309*7c478bd9Sstevel@tonic-gate * specified, and instname and svcname override the actual service and 310*7c478bd9Sstevel@tonic-gate * instance names, respectively, written into the snaplevels. 311*7c478bd9Sstevel@tonic-gate * 312*7c478bd9Sstevel@tonic-gate * Note that this is only useful for writing snapshots which will later 313*7c478bd9Sstevel@tonic-gate * be transferred to another instance (svc:/svcname:instname/) 314*7c478bd9Sstevel@tonic-gate * 315*7c478bd9Sstevel@tonic-gate * SNAPSHOT_ATTACH(source_id, dest_id) -> result 316*7c478bd9Sstevel@tonic-gate * The snaplevels attached to the snapshot referenced by source_id are 317*7c478bd9Sstevel@tonic-gate * attached to the snapshot dest_id is pointed at. 318*7c478bd9Sstevel@tonic-gate * 319*7c478bd9Sstevel@tonic-gate * PROPERTY_GET_TYPE(entity_id) -> result, value type 320*7c478bd9Sstevel@tonic-gate * Finds the value type of entity_id, which must be a property. 321*7c478bd9Sstevel@tonic-gate * 322*7c478bd9Sstevel@tonic-gate * PROPERTY_GET_VALUE(entity_id) -> result, type, value 323*7c478bd9Sstevel@tonic-gate * If the property contains a single value, returns it and its type. 324*7c478bd9Sstevel@tonic-gate * 325*7c478bd9Sstevel@tonic-gate * PROPERTYGRP_SETUP_WAIT(entity_id) -> result, [pipe fd] 326*7c478bd9Sstevel@tonic-gate * Sets up a notification for changes to the object entity_id currently 327*7c478bd9Sstevel@tonic-gate * references. On success, returns one side of a pipe -- when there 328*7c478bd9Sstevel@tonic-gate * has been a change (or the daemon dies), the other end of the pipe will 329*7c478bd9Sstevel@tonic-gate * be closed. 330*7c478bd9Sstevel@tonic-gate * 331*7c478bd9Sstevel@tonic-gate * Only one of these can be set up per client -- attempts to set up more 332*7c478bd9Sstevel@tonic-gate * than one will cause the previous one to get closed. 333*7c478bd9Sstevel@tonic-gate * 334*7c478bd9Sstevel@tonic-gate * PROPERTYGRP_TX_START(entity_id_tx, entity_id) -> result 335*7c478bd9Sstevel@tonic-gate * Makes entity_id_tx point to the same property group as entity_id, 336*7c478bd9Sstevel@tonic-gate * then attempts to set up entity_id_tx as a transaction on that group. 337*7c478bd9Sstevel@tonic-gate * entity_id and entity_id_tx must be distinct. On failure, entity_id_tx 338*7c478bd9Sstevel@tonic-gate * is reset. 339*7c478bd9Sstevel@tonic-gate * 340*7c478bd9Sstevel@tonic-gate * PROPERTYGRP_TX_COMMIT(entity_id, data) -> result 341*7c478bd9Sstevel@tonic-gate * Gives the actual steps to follow, and attempts to commit them. 342*7c478bd9Sstevel@tonic-gate * 343*7c478bd9Sstevel@tonic-gate * CLIENT_ADD_NOTIFY(type, pattern) -> result 344*7c478bd9Sstevel@tonic-gate * Adds a new property group name or type pattern to the notify list 345*7c478bd9Sstevel@tonic-gate * (see CLIENT_WAIT). If successful, takes effect immediately. 346*7c478bd9Sstevel@tonic-gate * 347*7c478bd9Sstevel@tonic-gate * CLIENT_WAIT(entity_id) -> result, fmri 348*7c478bd9Sstevel@tonic-gate * Waits for a change to a propertygroup that matches the patterns 349*7c478bd9Sstevel@tonic-gate * set up using CLIENT_ADD_NOTIFY, and puts the resultant propertygroup 350*7c478bd9Sstevel@tonic-gate * in entity_id. Note that if an error occurs, you can loose 351*7c478bd9Sstevel@tonic-gate * notifications. Either entity_id is set to a changed propertygroup, 352*7c478bd9Sstevel@tonic-gate * or fmri is a non-zero-length string identifying a deleted thing. 353*7c478bd9Sstevel@tonic-gate * 354*7c478bd9Sstevel@tonic-gate * BACKUP(name) -> result 355*7c478bd9Sstevel@tonic-gate * Backs up the persistant repository with a particular name. 356*7c478bd9Sstevel@tonic-gate * 357*7c478bd9Sstevel@tonic-gate */ 358*7c478bd9Sstevel@tonic-gate 359*7c478bd9Sstevel@tonic-gate #include <door.h> 360*7c478bd9Sstevel@tonic-gate #include <stddef.h> 361*7c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 362*7c478bd9Sstevel@tonic-gate 363*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 364*7c478bd9Sstevel@tonic-gate extern "C" { 365*7c478bd9Sstevel@tonic-gate #endif 366*7c478bd9Sstevel@tonic-gate 367*7c478bd9Sstevel@tonic-gate /* 368*7c478bd9Sstevel@tonic-gate * svc.configd initial protocol details 369*7c478bd9Sstevel@tonic-gate */ 370*7c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_BASEVER (('R' << 24) | ('e' << 16) | ('p' << 8)) 371*7c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_NAME "/etc/svc/volatile/repository_door" 372*7c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_COOKIE ((void *)REPOSITORY_DOOR_BASEVER) 373*7c478bd9Sstevel@tonic-gate 374*7c478bd9Sstevel@tonic-gate #define REPOSITORY_BOOT_BACKUP ((const char *)"boot") 375*7c478bd9Sstevel@tonic-gate 376*7c478bd9Sstevel@tonic-gate /* 377*7c478bd9Sstevel@tonic-gate * This value should be incremented any time the protocol changes. When in 378*7c478bd9Sstevel@tonic-gate * doubt, bump it. 379*7c478bd9Sstevel@tonic-gate */ 380*7c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_VERSION (19 + REPOSITORY_DOOR_BASEVER) 381*7c478bd9Sstevel@tonic-gate 382*7c478bd9Sstevel@tonic-gate /* 383*7c478bd9Sstevel@tonic-gate * flags for rdr_flags 384*7c478bd9Sstevel@tonic-gate */ 385*7c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_FLAG_DEBUG 0x00000001 /* rdr_debug */ 386*7c478bd9Sstevel@tonic-gate 387*7c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_FLAG_ALL 0x00000001 /* all flags */ 388*7c478bd9Sstevel@tonic-gate 389*7c478bd9Sstevel@tonic-gate /* 390*7c478bd9Sstevel@tonic-gate * Request IDs 391*7c478bd9Sstevel@tonic-gate */ 392*7c478bd9Sstevel@tonic-gate enum repository_door_requestid { 393*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_REQUEST_CONNECT = (('M' << 8) | 1) 394*7c478bd9Sstevel@tonic-gate }; 395*7c478bd9Sstevel@tonic-gate 396*7c478bd9Sstevel@tonic-gate enum repository_door_statusid { 397*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_SUCCESS = 0, 398*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_BAD_REQUEST = 1, 399*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_VERSION_MISMATCH = 2, 400*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_BAD_FLAG = 3, 401*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_NO_RESOURCES = 4, 402*7c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_PERMISSION_DENIED = 5 403*7c478bd9Sstevel@tonic-gate }; 404*7c478bd9Sstevel@tonic-gate 405*7c478bd9Sstevel@tonic-gate /* 406*7c478bd9Sstevel@tonic-gate * You may only add elements to the end of this structure. 407*7c478bd9Sstevel@tonic-gate */ 408*7c478bd9Sstevel@tonic-gate typedef struct repository_door_request { 409*7c478bd9Sstevel@tonic-gate uint32_t rdr_version; /* must be first element */ 410*7c478bd9Sstevel@tonic-gate enum repository_door_requestid rdr_request; 411*7c478bd9Sstevel@tonic-gate uint32_t rdr_flags; 412*7c478bd9Sstevel@tonic-gate uint32_t rdr_debug; 413*7c478bd9Sstevel@tonic-gate } repository_door_request_t; 414*7c478bd9Sstevel@tonic-gate 415*7c478bd9Sstevel@tonic-gate typedef struct repository_door_response { 416*7c478bd9Sstevel@tonic-gate enum repository_door_statusid rdr_status; 417*7c478bd9Sstevel@tonic-gate } repository_door_response_t; 418*7c478bd9Sstevel@tonic-gate 419*7c478bd9Sstevel@tonic-gate /* 420*7c478bd9Sstevel@tonic-gate * Client interface. Used on doors returned by REQUEST_CONNECT 421*7c478bd9Sstevel@tonic-gate */ 422*7c478bd9Sstevel@tonic-gate 423*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_NAME_LEN 120 /* maximum name length */ 424*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_VALUE_LEN 4096 /* maximum value length */ 425*7c478bd9Sstevel@tonic-gate 426*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_FMRI_LEN (6 * REP_PROTOCOL_NAME_LEN) 427*7c478bd9Sstevel@tonic-gate 428*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_BASE ('C' << 8) 429*7c478bd9Sstevel@tonic-gate 430*7c478bd9Sstevel@tonic-gate /* 431*7c478bd9Sstevel@tonic-gate * Request codes 432*7c478bd9Sstevel@tonic-gate */ 433*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid { 434*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_CLOSE = REP_PROTOCOL_BASE, 435*7c478bd9Sstevel@tonic-gate 436*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SETUP, 437*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_NAME, 438*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_PARENT_TYPE, 439*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_GET_CHILD, 440*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_GET_PARENT, 441*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_GET, 442*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_UPDATE, 443*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_CREATE_CHILD, 444*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_CREATE_PG, 445*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_DELETE, 446*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_RESET, 447*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_TEARDOWN, 448*7c478bd9Sstevel@tonic-gate 449*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_SETUP, 450*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_START, 451*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_READ, 452*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_READ_VALUE, 453*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_RESET, 454*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_TEARDOWN, 455*7c478bd9Sstevel@tonic-gate 456*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_NEXT_SNAPLEVEL, 457*7c478bd9Sstevel@tonic-gate 458*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SNAPSHOT_TAKE, 459*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SNAPSHOT_TAKE_NAMED, 460*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SNAPSHOT_ATTACH, 461*7c478bd9Sstevel@tonic-gate 462*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTY_GET_TYPE, 463*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTY_GET_VALUE, 464*7c478bd9Sstevel@tonic-gate 465*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTYGRP_SETUP_WAIT, 466*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTYGRP_TX_START, 467*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTYGRP_TX_COMMIT, 468*7c478bd9Sstevel@tonic-gate 469*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_CLIENT_ADD_NOTIFY, 470*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_CLIENT_WAIT, 471*7c478bd9Sstevel@tonic-gate 472*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_BACKUP, 473*7c478bd9Sstevel@tonic-gate 474*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_MAX_REQUEST 475*7c478bd9Sstevel@tonic-gate }; 476*7c478bd9Sstevel@tonic-gate 477*7c478bd9Sstevel@tonic-gate /* 478*7c478bd9Sstevel@tonic-gate * Response codes. These are returned to the client, and the errors are 479*7c478bd9Sstevel@tonic-gate * translated into scf_error_t's by libscf (see proto_error()). 480*7c478bd9Sstevel@tonic-gate */ 481*7c478bd9Sstevel@tonic-gate typedef int32_t rep_protocol_responseid_t; 482*7c478bd9Sstevel@tonic-gate enum rep_protocol_responseid { 483*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUCCESS = 0, 484*7c478bd9Sstevel@tonic-gate /* iterators: No more values. */ 485*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_DONE = 1, 486*7c478bd9Sstevel@tonic-gate 487*7c478bd9Sstevel@tonic-gate /* Request from client was malformed. */ 488*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BAD_REQUEST = -1, 489*7c478bd9Sstevel@tonic-gate /* Prerequisite call has not been made. */ 490*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_MISORDERED = -2, 491*7c478bd9Sstevel@tonic-gate /* Register for ID has not been created. */ 492*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_UNKNOWN_ID = -3, 493*7c478bd9Sstevel@tonic-gate /* Out of memory or other resource. */ 494*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NO_RESOURCES = -4, 495*7c478bd9Sstevel@tonic-gate /* Type argument is invalid. */ 496*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_INVALID_TYPE = -5, 497*7c478bd9Sstevel@tonic-gate /* Requested object does not exist. */ 498*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_FOUND = -6, 499*7c478bd9Sstevel@tonic-gate /* Register for given ID does not point to an object. */ 500*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_SET = -7, 501*7c478bd9Sstevel@tonic-gate 502*7c478bd9Sstevel@tonic-gate /* Requested name is longer than supplied buffer. */ 503*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_TRUNCATED = -8, 504*7c478bd9Sstevel@tonic-gate /* Operation requires different type. */ 505*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_TYPE_MISMATCH = -9, 506*7c478bd9Sstevel@tonic-gate 507*7c478bd9Sstevel@tonic-gate /* Changeable object has been changed since last update. */ 508*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_LATEST = -10, 509*7c478bd9Sstevel@tonic-gate /* Creation failed because object with given name exists. */ 510*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_EXISTS = -11, 511*7c478bd9Sstevel@tonic-gate /* Transaction is invalid. */ 512*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BAD_TX = -12, 513*7c478bd9Sstevel@tonic-gate /* Operation is not applicable to indicated object. */ 514*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_APPLICABLE = -13, 515*7c478bd9Sstevel@tonic-gate /* Two IDs for operation were unexpectedly equal. */ 516*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_DUPLICATE_ID = -14, 517*7c478bd9Sstevel@tonic-gate 518*7c478bd9Sstevel@tonic-gate /* Permission denied. */ 519*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_PERMISSION_DENIED = -15, 520*7c478bd9Sstevel@tonic-gate /* Backend does not exist or otherwise refused access. */ 521*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BACKEND_ACCESS = -16, 522*7c478bd9Sstevel@tonic-gate /* Backend is read-only. */ 523*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BACKEND_READONLY = -17, 524*7c478bd9Sstevel@tonic-gate 525*7c478bd9Sstevel@tonic-gate /* Object has been deleted. */ 526*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_DELETED = -18, 527*7c478bd9Sstevel@tonic-gate 528*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_UNKNOWN = -0xfd 529*7c478bd9Sstevel@tonic-gate }; 530*7c478bd9Sstevel@tonic-gate 531*7c478bd9Sstevel@tonic-gate /* 532*7c478bd9Sstevel@tonic-gate * Types 533*7c478bd9Sstevel@tonic-gate */ 534*7c478bd9Sstevel@tonic-gate typedef enum rep_protocol_entity { 535*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_NONE, 536*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SCOPE, 537*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SERVICE, 538*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_INSTANCE, 539*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SNAPSHOT, 540*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SNAPLEVEL, 541*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_PROPERTYGRP, 542*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_CPROPERTYGRP, /* "composed" property group */ 543*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_PROPERTY, 544*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_VALUE, 545*7c478bd9Sstevel@tonic-gate 546*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_MAX 547*7c478bd9Sstevel@tonic-gate } rep_protocol_entity_t; 548*7c478bd9Sstevel@tonic-gate 549*7c478bd9Sstevel@tonic-gate typedef enum rep_protocol_value_type { 550*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_INVALID = '\0', 551*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_BOOLEAN = 'b', 552*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_COUNT = 'c', 553*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_INTEGER = 'i', 554*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_TIME = 't', 555*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_STRING = 's', 556*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_OPAQUE = 'o', 557*7c478bd9Sstevel@tonic-gate 558*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_USTRING = REP_PROTOCOL_TYPE_STRING|('u' << 8), 559*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_URI = REP_PROTOCOL_TYPE_STRING|('U' << 8), 560*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_FMRI = REP_PROTOCOL_TYPE_STRING|('f' << 8), 561*7c478bd9Sstevel@tonic-gate 562*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_HOST = REP_PROTOCOL_TYPE_STRING|('h' << 8), 563*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_HOSTNAME = REP_PROTOCOL_TYPE_STRING|('N' << 8), 564*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_NETADDR_V4 = REP_PROTOCOL_TYPE_STRING|('4' << 8), 565*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_NETADDR_V6 = REP_PROTOCOL_TYPE_STRING|('6' << 8) 566*7c478bd9Sstevel@tonic-gate } rep_protocol_value_type_t; 567*7c478bd9Sstevel@tonic-gate 568*7c478bd9Sstevel@tonic-gate 569*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_BASE_TYPE(t) ((t) & 0x00ff) 570*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_SUBTYPE(t) (((t) & 0xff00) >> 8) 571*7c478bd9Sstevel@tonic-gate 572*7c478bd9Sstevel@tonic-gate /* 573*7c478bd9Sstevel@tonic-gate * Request structures 574*7c478bd9Sstevel@tonic-gate */ 575*7c478bd9Sstevel@tonic-gate typedef struct rep_protocol_request { 576*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 577*7c478bd9Sstevel@tonic-gate } rep_protocol_request_t; 578*7c478bd9Sstevel@tonic-gate 579*7c478bd9Sstevel@tonic-gate struct rep_protocol_iter_request { 580*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 581*7c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 582*7c478bd9Sstevel@tonic-gate }; 583*7c478bd9Sstevel@tonic-gate 584*7c478bd9Sstevel@tonic-gate struct rep_protocol_iter_start { 585*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ITER_START */ 586*7c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 587*7c478bd9Sstevel@tonic-gate 588*7c478bd9Sstevel@tonic-gate uint32_t rpr_entity; 589*7c478bd9Sstevel@tonic-gate uint32_t rpr_itertype; 590*7c478bd9Sstevel@tonic-gate uint32_t rpr_flags; 591*7c478bd9Sstevel@tonic-gate char rpr_pattern[REP_PROTOCOL_NAME_LEN]; 592*7c478bd9Sstevel@tonic-gate }; 593*7c478bd9Sstevel@tonic-gate #define RP_ITER_START_ALL 0x00000001 /* ignore pattern, match all */ 594*7c478bd9Sstevel@tonic-gate #define RP_ITER_START_EXACT 0x00000002 /* exact match with pattern */ 595*7c478bd9Sstevel@tonic-gate #define RP_ITER_START_PGTYPE 0x00000003 /* exact match pg type */ 596*7c478bd9Sstevel@tonic-gate #define RP_ITER_START_FILT_MASK 0x00000003 597*7c478bd9Sstevel@tonic-gate #define RP_ITER_START_COMPOSED 0x00000004 /* composed */ 598*7c478bd9Sstevel@tonic-gate 599*7c478bd9Sstevel@tonic-gate struct rep_protocol_iter_read { 600*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ITER_READ */ 601*7c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 602*7c478bd9Sstevel@tonic-gate uint32_t rpr_sequence; /* client increments upon success */ 603*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; /* entity to write result to */ 604*7c478bd9Sstevel@tonic-gate }; 605*7c478bd9Sstevel@tonic-gate 606*7c478bd9Sstevel@tonic-gate struct rep_protocol_iter_read_value { 607*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ITER_READ_VALUE */ 608*7c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 609*7c478bd9Sstevel@tonic-gate uint32_t rpr_sequence; /* client increments upon success */ 610*7c478bd9Sstevel@tonic-gate }; 611*7c478bd9Sstevel@tonic-gate 612*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_setup { 613*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_SETUP */ 614*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 615*7c478bd9Sstevel@tonic-gate uint32_t rpr_entitytype; 616*7c478bd9Sstevel@tonic-gate }; 617*7c478bd9Sstevel@tonic-gate 618*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_name { 619*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_NAME */ 620*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 621*7c478bd9Sstevel@tonic-gate uint32_t rpr_answertype; 622*7c478bd9Sstevel@tonic-gate }; 623*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_NAME 0 624*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_PGTYPE 1 625*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_PGFLAGS 2 626*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_SNAPLEVEL_SCOPE 3 627*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_SNAPLEVEL_SERVICE 4 628*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_SNAPLEVEL_INSTANCE 5 629*7c478bd9Sstevel@tonic-gate 630*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_update { 631*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_UPDATE */ 632*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 633*7c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 634*7c478bd9Sstevel@tonic-gate }; 635*7c478bd9Sstevel@tonic-gate 636*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_parent_type { 637*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_PARENT_TYPE */ 638*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 639*7c478bd9Sstevel@tonic-gate }; 640*7c478bd9Sstevel@tonic-gate 641*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_parent { 642*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_GET_PARENT */ 643*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 644*7c478bd9Sstevel@tonic-gate uint32_t rpr_outid; 645*7c478bd9Sstevel@tonic-gate }; 646*7c478bd9Sstevel@tonic-gate 647*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_get { 648*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_SET */ 649*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 650*7c478bd9Sstevel@tonic-gate uint32_t rpr_object; 651*7c478bd9Sstevel@tonic-gate }; 652*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_GET_INVALIDATE 1 653*7c478bd9Sstevel@tonic-gate #define RP_ENTITY_GET_MOST_LOCAL_SCOPE 2 654*7c478bd9Sstevel@tonic-gate 655*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_create_child { 656*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_CREATE_CHILD */ 657*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 658*7c478bd9Sstevel@tonic-gate uint32_t rpr_childtype; 659*7c478bd9Sstevel@tonic-gate uint32_t rpr_childid; 660*7c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 661*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 662*7c478bd9Sstevel@tonic-gate }; 663*7c478bd9Sstevel@tonic-gate 664*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_create_pg { 665*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_CREATE_PG */ 666*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 667*7c478bd9Sstevel@tonic-gate uint32_t rpr_childtype; 668*7c478bd9Sstevel@tonic-gate uint32_t rpr_childid; 669*7c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 670*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 671*7c478bd9Sstevel@tonic-gate char rpr_type[REP_PROTOCOL_NAME_LEN]; 672*7c478bd9Sstevel@tonic-gate uint32_t rpr_flags; 673*7c478bd9Sstevel@tonic-gate }; 674*7c478bd9Sstevel@tonic-gate 675*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_get_child { 676*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_GET_CHILD */ 677*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 678*7c478bd9Sstevel@tonic-gate uint32_t rpr_childid; 679*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 680*7c478bd9Sstevel@tonic-gate }; 681*7c478bd9Sstevel@tonic-gate 682*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_delete { 683*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_DELETE_CHILD */ 684*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 685*7c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 686*7c478bd9Sstevel@tonic-gate }; 687*7c478bd9Sstevel@tonic-gate 688*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_reset { 689*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_NAME */ 690*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 691*7c478bd9Sstevel@tonic-gate }; 692*7c478bd9Sstevel@tonic-gate 693*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_request { 694*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_NAME */ 695*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 696*7c478bd9Sstevel@tonic-gate }; 697*7c478bd9Sstevel@tonic-gate 698*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_teardown { 699*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_TEARDOWN */ 700*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 701*7c478bd9Sstevel@tonic-gate }; 702*7c478bd9Sstevel@tonic-gate 703*7c478bd9Sstevel@tonic-gate struct rep_protocol_entity_pair { 704*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* NEXT_SNAPLEVEL */ 705*7c478bd9Sstevel@tonic-gate uint32_t rpr_entity_src; 706*7c478bd9Sstevel@tonic-gate uint32_t rpr_entity_dst; 707*7c478bd9Sstevel@tonic-gate }; 708*7c478bd9Sstevel@tonic-gate 709*7c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_start { 710*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* TX_SETUP */ 711*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_tx; /* property group tx entity */ 712*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; /* property group entity */ 713*7c478bd9Sstevel@tonic-gate }; 714*7c478bd9Sstevel@tonic-gate 715*7c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_commit { 716*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* TX_COMMIT */ 717*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 718*7c478bd9Sstevel@tonic-gate uint32_t rpr_size; /* size of entire structure */ 719*7c478bd9Sstevel@tonic-gate uint8_t rpr_cmd[1]; 720*7c478bd9Sstevel@tonic-gate }; 721*7c478bd9Sstevel@tonic-gate 722*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_COMMIT_SIZE(sz) \ 723*7c478bd9Sstevel@tonic-gate (offsetof(struct rep_protocol_transaction_commit, rpr_cmd[sz])) 724*7c478bd9Sstevel@tonic-gate 725*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_COMMIT_MIN_SIZE \ 726*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TRANSACTION_COMMIT_SIZE(0) 727*7c478bd9Sstevel@tonic-gate 728*7c478bd9Sstevel@tonic-gate enum rep_protocol_transaction_action { 729*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_INVALID, /* N/A */ 730*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_NEW, /* new property */ 731*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_CLEAR, /* clear old property */ 732*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_REPLACE, /* change type of old property */ 733*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_DELETE /* delete property (no values) */ 734*7c478bd9Sstevel@tonic-gate }; 735*7c478bd9Sstevel@tonic-gate 736*7c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_cmd { 737*7c478bd9Sstevel@tonic-gate enum rep_protocol_transaction_action rptc_action; 738*7c478bd9Sstevel@tonic-gate uint32_t rptc_type; 739*7c478bd9Sstevel@tonic-gate uint32_t rptc_size; /* size of entire structure */ 740*7c478bd9Sstevel@tonic-gate uint32_t rptc_name_len; 741*7c478bd9Sstevel@tonic-gate uint8_t rptc_data[1]; 742*7c478bd9Sstevel@tonic-gate }; 743*7c478bd9Sstevel@tonic-gate 744*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_CMD_SIZE(sz) \ 745*7c478bd9Sstevel@tonic-gate (offsetof(struct rep_protocol_transaction_cmd, rptc_data[sz])) 746*7c478bd9Sstevel@tonic-gate 747*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_CMD_MIN_SIZE \ 748*7c478bd9Sstevel@tonic-gate REP_PROTOCOL_TRANSACTION_CMD_SIZE(0) 749*7c478bd9Sstevel@tonic-gate 750*7c478bd9Sstevel@tonic-gate #define TX_SIZE(x) P2ROUNDUP((x), sizeof (uint32_t)) 751*7c478bd9Sstevel@tonic-gate 752*7c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_request { 753*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SETUP, ABORT or TEARDOWN */ 754*7c478bd9Sstevel@tonic-gate uint32_t rpr_txid; 755*7c478bd9Sstevel@tonic-gate }; 756*7c478bd9Sstevel@tonic-gate 757*7c478bd9Sstevel@tonic-gate struct rep_protocol_property_request { 758*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 759*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 760*7c478bd9Sstevel@tonic-gate }; 761*7c478bd9Sstevel@tonic-gate 762*7c478bd9Sstevel@tonic-gate struct rep_protocol_propertygrp_request { 763*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 764*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 765*7c478bd9Sstevel@tonic-gate }; 766*7c478bd9Sstevel@tonic-gate 767*7c478bd9Sstevel@tonic-gate struct rep_protocol_notify_request { 768*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 769*7c478bd9Sstevel@tonic-gate uint32_t rpr_type; 770*7c478bd9Sstevel@tonic-gate char rpr_pattern[REP_PROTOCOL_NAME_LEN]; 771*7c478bd9Sstevel@tonic-gate }; 772*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_NOTIFY_PGNAME 1 773*7c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_NOTIFY_PGTYPE 2 774*7c478bd9Sstevel@tonic-gate 775*7c478bd9Sstevel@tonic-gate struct rep_protocol_wait_request { 776*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 777*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 778*7c478bd9Sstevel@tonic-gate }; 779*7c478bd9Sstevel@tonic-gate 780*7c478bd9Sstevel@tonic-gate struct rep_protocol_snapshot_take { 781*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SNAPSHOT_TAKE */ 782*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_src; 783*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_dest; 784*7c478bd9Sstevel@tonic-gate int rpr_flags; 785*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 786*7c478bd9Sstevel@tonic-gate }; 787*7c478bd9Sstevel@tonic-gate #define REP_SNAPSHOT_NEW 0x00000001 788*7c478bd9Sstevel@tonic-gate #define REP_SNAPSHOT_ATTACH 0x00000002 789*7c478bd9Sstevel@tonic-gate 790*7c478bd9Sstevel@tonic-gate struct rep_protocol_snapshot_take_named { 791*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SNAPSHOT_TAKE_NAMED */ 792*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_src; 793*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_dest; 794*7c478bd9Sstevel@tonic-gate char rpr_svcname[REP_PROTOCOL_NAME_LEN]; 795*7c478bd9Sstevel@tonic-gate char rpr_instname[REP_PROTOCOL_NAME_LEN]; 796*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 797*7c478bd9Sstevel@tonic-gate }; 798*7c478bd9Sstevel@tonic-gate 799*7c478bd9Sstevel@tonic-gate struct rep_protocol_snapshot_attach { 800*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SNAPSHOT_ATTACH */ 801*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_src; 802*7c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_dest; 803*7c478bd9Sstevel@tonic-gate }; 804*7c478bd9Sstevel@tonic-gate 805*7c478bd9Sstevel@tonic-gate struct rep_protocol_backup_request { 806*7c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* BACKUP */ 807*7c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 808*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 809*7c478bd9Sstevel@tonic-gate }; 810*7c478bd9Sstevel@tonic-gate 811*7c478bd9Sstevel@tonic-gate /* 812*7c478bd9Sstevel@tonic-gate * Response structures 813*7c478bd9Sstevel@tonic-gate */ 814*7c478bd9Sstevel@tonic-gate typedef struct rep_protocol_response { 815*7c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 816*7c478bd9Sstevel@tonic-gate } rep_protocol_response_t; 817*7c478bd9Sstevel@tonic-gate 818*7c478bd9Sstevel@tonic-gate struct rep_protocol_integer_response { 819*7c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 820*7c478bd9Sstevel@tonic-gate uint32_t rpr_value; 821*7c478bd9Sstevel@tonic-gate }; 822*7c478bd9Sstevel@tonic-gate 823*7c478bd9Sstevel@tonic-gate struct rep_protocol_name_response { /* response to ENTITY_NAME */ 824*7c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 825*7c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 826*7c478bd9Sstevel@tonic-gate }; 827*7c478bd9Sstevel@tonic-gate 828*7c478bd9Sstevel@tonic-gate struct rep_protocol_fmri_response { 829*7c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 830*7c478bd9Sstevel@tonic-gate char rpr_fmri[REP_PROTOCOL_FMRI_LEN]; 831*7c478bd9Sstevel@tonic-gate }; 832*7c478bd9Sstevel@tonic-gate 833*7c478bd9Sstevel@tonic-gate struct rep_protocol_value_response { 834*7c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 835*7c478bd9Sstevel@tonic-gate rep_protocol_value_type_t rpr_type; 836*7c478bd9Sstevel@tonic-gate char rpr_value[2 * REP_PROTOCOL_VALUE_LEN + 1]; 837*7c478bd9Sstevel@tonic-gate }; 838*7c478bd9Sstevel@tonic-gate 839*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 840*7c478bd9Sstevel@tonic-gate } 841*7c478bd9Sstevel@tonic-gate #endif 842*7c478bd9Sstevel@tonic-gate 843*7c478bd9Sstevel@tonic-gate #endif /* _REPCACHE_PROTOCOL_H */ 844