17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 53eae19d9Swesolows * Common Development and Distribution License (the "License"). 63eae19d9Swesolows * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 213eae19d9Swesolows 227c478bd9Sstevel@tonic-gate /* 23*b56bf881SAntonello Cruz * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _REPCACHE_PROTOCOL_H 277c478bd9Sstevel@tonic-gate #define _REPCACHE_PROTOCOL_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate /* 307c478bd9Sstevel@tonic-gate * The Repository Cache Protocol 317c478bd9Sstevel@tonic-gate * ----------------------------- 327c478bd9Sstevel@tonic-gate * 337c478bd9Sstevel@tonic-gate * 1. Introduction 347c478bd9Sstevel@tonic-gate * --------------- 357c478bd9Sstevel@tonic-gate * This header file defines the private protocols between libscf(3lib) and 367c478bd9Sstevel@tonic-gate * svc.configd(1m). There are two separate protocols: 377c478bd9Sstevel@tonic-gate * 387c478bd9Sstevel@tonic-gate * 1. The 'global' protocol, accessible via an fattach(3C)ed door located 397c478bd9Sstevel@tonic-gate * at REPOSITORY_DOOR_NAME. 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * 2. The 'client' protocol, accessible through a door created using the 427c478bd9Sstevel@tonic-gate * global protocol, which allows access to the repository. 437c478bd9Sstevel@tonic-gate * 447c478bd9Sstevel@tonic-gate * 1.1 Design restrictions 457c478bd9Sstevel@tonic-gate * ----------------------- 467c478bd9Sstevel@tonic-gate * A basic constraint of the door IPC mechanism is that there is no reliable 477c478bd9Sstevel@tonic-gate * delivery. In particular: 487c478bd9Sstevel@tonic-gate * 497c478bd9Sstevel@tonic-gate * 1. If libscf(3lib) recieves an EINTR from door_call(), it doesn't know 507c478bd9Sstevel@tonic-gate * whether or not the server recieved (and is processing) its request. 517c478bd9Sstevel@tonic-gate * 527c478bd9Sstevel@tonic-gate * 2. When svc.configd(1M) calls door_return(), the client may have already 537c478bd9Sstevel@tonic-gate * received an EINTR, aborting its door_call(). In this case, the 547c478bd9Sstevel@tonic-gate * returned values are dropped on the floor. 557c478bd9Sstevel@tonic-gate * 567c478bd9Sstevel@tonic-gate * The practical upshot of all of this is simple: 577c478bd9Sstevel@tonic-gate * 587c478bd9Sstevel@tonic-gate * Every individual protocol action must be idempotent. 597c478bd9Sstevel@tonic-gate * 607c478bd9Sstevel@tonic-gate * That is, a client must be able to retry any single request multiple times, 617c478bd9Sstevel@tonic-gate * and get the correct results. 627c478bd9Sstevel@tonic-gate * 637c478bd9Sstevel@tonic-gate * 1.2. Protocol shorthand 647c478bd9Sstevel@tonic-gate * ----------------------- 657c478bd9Sstevel@tonic-gate * We represent by "REQUEST(arg1, arg2) -> result, res1, [desc]" a request code 667c478bd9Sstevel@tonic-gate * of REP_PROTOCOL_REQUEST (or REPOSITORY_DOOR_REQUEST), which takes two 677c478bd9Sstevel@tonic-gate * additional arguments, arg1 and arg2, and returns a result code, res1, and 687c478bd9Sstevel@tonic-gate * a file descriptor desc. 697c478bd9Sstevel@tonic-gate * 707c478bd9Sstevel@tonic-gate * If an error occurs, the server will usually only send the result code. (a 717c478bd9Sstevel@tonic-gate * short return) 727c478bd9Sstevel@tonic-gate * 737c478bd9Sstevel@tonic-gate * Inside the protocol destription, <foo> indicates the type foo indicates. 747c478bd9Sstevel@tonic-gate * 757c478bd9Sstevel@tonic-gate * 2. The Global protocol 767c478bd9Sstevel@tonic-gate * ---------------------- 777c478bd9Sstevel@tonic-gate * Everything starting with "REPOSITORY_DOOR" or "repository_door" belongs 787c478bd9Sstevel@tonic-gate * to the global protocol. 797c478bd9Sstevel@tonic-gate * 807c478bd9Sstevel@tonic-gate * 2.1. Global requests 817c478bd9Sstevel@tonic-gate * -------------------- 827c478bd9Sstevel@tonic-gate * 837c478bd9Sstevel@tonic-gate * REQUEST_CONNECT(rdr_flags, ...) -> result, [new_door] 847c478bd9Sstevel@tonic-gate * Request a new Client door. rdr_flags determines attributes of the 857c478bd9Sstevel@tonic-gate * connection: 867c478bd9Sstevel@tonic-gate * 877c478bd9Sstevel@tonic-gate * FLAG_DEBUG 887c478bd9Sstevel@tonic-gate * Sets connection debugging flags to those in rdr_debug. 897c478bd9Sstevel@tonic-gate * 907c478bd9Sstevel@tonic-gate * The new door is returned with DOOR_RELEASE set, so if the client does 917c478bd9Sstevel@tonic-gate * not recieve the response, the new door will recieve an unref 927c478bd9Sstevel@tonic-gate * notification. This makes this request idempotent. 937c478bd9Sstevel@tonic-gate * 947c478bd9Sstevel@tonic-gate * 2.2. Global reponse codes 957c478bd9Sstevel@tonic-gate * ------------------------- 967c478bd9Sstevel@tonic-gate * GLXXX: This needs to be thought through. 977c478bd9Sstevel@tonic-gate * 987c478bd9Sstevel@tonic-gate * SUCCESS 997c478bd9Sstevel@tonic-gate * FAIL_BAD_REQUEST 1007c478bd9Sstevel@tonic-gate * FAIL_VERSION_MISMATCH 1017c478bd9Sstevel@tonic-gate * FAIL_BAD_FLAG 1027c478bd9Sstevel@tonic-gate * FAIL_BAD_USER 1037c478bd9Sstevel@tonic-gate * FAIL_NO_RESOURCES 1047c478bd9Sstevel@tonic-gate * 1057c478bd9Sstevel@tonic-gate * 3. The Client protocol 1067c478bd9Sstevel@tonic-gate * ---------------------- 1077c478bd9Sstevel@tonic-gate * Everything starting with "REP_PROTOCOL" or "rep_protocol" belongs to the 1087c478bd9Sstevel@tonic-gate * client protocol. 1097c478bd9Sstevel@tonic-gate * 1107c478bd9Sstevel@tonic-gate * 3.1. Techniques used 1117c478bd9Sstevel@tonic-gate * -------------------- 1127c478bd9Sstevel@tonic-gate * 3.1.1. Client-controlled identifiers 1137c478bd9Sstevel@tonic-gate * 1147c478bd9Sstevel@tonic-gate * An idiom the protocol uses to lower the number of round trips is 1157c478bd9Sstevel@tonic-gate * client-controlled identifiers. The basic idea is this: whenever a 1167c478bd9Sstevel@tonic-gate * client wants to set up and use a piece of server state, he picks an 1177c478bd9Sstevel@tonic-gate * integer *which he knows is not in use* to identify it. The server then 1187c478bd9Sstevel@tonic-gate * maintains per-client, per-resource id->resource maps. This has a number 1197c478bd9Sstevel@tonic-gate * of advantages: 1207c478bd9Sstevel@tonic-gate * 1217c478bd9Sstevel@tonic-gate * 1. Since the client allocates the identifiers, we don't need to do 1227c478bd9Sstevel@tonic-gate * a round-trip just to allocate a number. 1237c478bd9Sstevel@tonic-gate * 1247c478bd9Sstevel@tonic-gate * 2. Since it is the client's job to make sure identifiers don't collide, 1257c478bd9Sstevel@tonic-gate * idempotency for setup (destroy) are simple: If the identifier 1267c478bd9Sstevel@tonic-gate * already exists (does not exist), we just return success. 1277c478bd9Sstevel@tonic-gate * 1287c478bd9Sstevel@tonic-gate * 3. Since the identifiers are per-client, the design automatically 1297c478bd9Sstevel@tonic-gate * precludes clients being able to manipulate other client's state. 1307c478bd9Sstevel@tonic-gate * 1317c478bd9Sstevel@tonic-gate * 3.1.2 Sequence numbers 1327c478bd9Sstevel@tonic-gate * 1337c478bd9Sstevel@tonic-gate * A standard way of gaining idempotency is introducing sequence numbers. 1347c478bd9Sstevel@tonic-gate * These are simply integers which get incremented at points in the protocol, 1357c478bd9Sstevel@tonic-gate * and make sure the client and server are in sync. 1367c478bd9Sstevel@tonic-gate * 1377c478bd9Sstevel@tonic-gate * In this protocol, we use sequence numbers for requests (like ITER_READ) 1387c478bd9Sstevel@tonic-gate * which are repeated, returning different data each time. Since requests 1397c478bd9Sstevel@tonic-gate * can also be repeated due to unreliable dispatch, the client increments 1407c478bd9Sstevel@tonic-gate * the sequence number after every successful request. This allows the server 1417c478bd9Sstevel@tonic-gate * to differentiate the two cases. (note that this means that failing 1427c478bd9Sstevel@tonic-gate * requests have no side effects and are repeatable) 1437c478bd9Sstevel@tonic-gate * 1447c478bd9Sstevel@tonic-gate * 3.2. Client abstractions 1457c478bd9Sstevel@tonic-gate * ------------------------ 1467c478bd9Sstevel@tonic-gate * 3.2.1 Entities 1477c478bd9Sstevel@tonic-gate * 1487c478bd9Sstevel@tonic-gate * An "entity" is a typed register which the client can manipulate. 1497c478bd9Sstevel@tonic-gate * Entities are named in the protocol by client-controlled identifiers. 1507c478bd9Sstevel@tonic-gate * They have a fixed type for their entire lifetime, and may be in one 1517c478bd9Sstevel@tonic-gate * of two states: 1527c478bd9Sstevel@tonic-gate * 1537c478bd9Sstevel@tonic-gate * valid 1547c478bd9Sstevel@tonic-gate * The entity has a valid value, and may be read from. This state 1557c478bd9Sstevel@tonic-gate * is reached by a successful write to the entity by some protocol 1567c478bd9Sstevel@tonic-gate * step. 1577c478bd9Sstevel@tonic-gate * 1587c478bd9Sstevel@tonic-gate * invalid 1597c478bd9Sstevel@tonic-gate * The entity does not contain a valid value. There are a number 1607c478bd9Sstevel@tonic-gate * of ways to reach this state: 1617c478bd9Sstevel@tonic-gate * 1627c478bd9Sstevel@tonic-gate * 1. The entity was just created. 1637c478bd9Sstevel@tonic-gate * 2. The underlying object that this entity refers to was destroyed. 1647c478bd9Sstevel@tonic-gate * 3. A protocol request which would have modified this entity 1657c478bd9Sstevel@tonic-gate * failed. 1667c478bd9Sstevel@tonic-gate * 1677c478bd9Sstevel@tonic-gate * An entity is an element in the tree of repository data. Every entity 1687c478bd9Sstevel@tonic-gate * (except for the most distant SCOPE) has exactly one parent. Entities 1697c478bd9Sstevel@tonic-gate * can have multiple children of different types, restricted by its base 1707c478bd9Sstevel@tonic-gate * type. 1717c478bd9Sstevel@tonic-gate * 1727c478bd9Sstevel@tonic-gate * The ENTITY_GET call is used to get the root of the tree (the most local 1737c478bd9Sstevel@tonic-gate * scope) 1747c478bd9Sstevel@tonic-gate * 1757c478bd9Sstevel@tonic-gate * 3.2.2. The entity tree 1767c478bd9Sstevel@tonic-gate * ---------------------- 1777c478bd9Sstevel@tonic-gate * The structure of a scope is as follows: 1787c478bd9Sstevel@tonic-gate * 1797c478bd9Sstevel@tonic-gate * _______ 1807c478bd9Sstevel@tonic-gate * | SCOPE | 1817c478bd9Sstevel@tonic-gate * |_______| 1827c478bd9Sstevel@tonic-gate * \ . 1837c478bd9Sstevel@tonic-gate * \ . 1847c478bd9Sstevel@tonic-gate * \_________ 1857c478bd9Sstevel@tonic-gate * | SERVICE | 1867c478bd9Sstevel@tonic-gate * |_________| 1877c478bd9Sstevel@tonic-gate * /. \ . 1887c478bd9Sstevel@tonic-gate * /. \ . 1897c478bd9Sstevel@tonic-gate * ____/ \__________ 1907c478bd9Sstevel@tonic-gate * | PG | | INSTANCE | 1917c478bd9Sstevel@tonic-gate * |____| |__________| 1927c478bd9Sstevel@tonic-gate * /. \ . 1937c478bd9Sstevel@tonic-gate * /. \ . 1947c478bd9Sstevel@tonic-gate * ____/ \__________ 1957c478bd9Sstevel@tonic-gate * | PG | | SNAPSHOT | 1967c478bd9Sstevel@tonic-gate * |____| |__________| 1977c478bd9Sstevel@tonic-gate * \ . 1987c478bd9Sstevel@tonic-gate * \ . 1997c478bd9Sstevel@tonic-gate * \___________ 2007c478bd9Sstevel@tonic-gate * | SNAPLEVEL | 2017c478bd9Sstevel@tonic-gate * |___________| 2027c478bd9Sstevel@tonic-gate * /. 2037c478bd9Sstevel@tonic-gate * /. 2047c478bd9Sstevel@tonic-gate * ____/ 2057c478bd9Sstevel@tonic-gate * | PG | 2067c478bd9Sstevel@tonic-gate * |____| 2077c478bd9Sstevel@tonic-gate * 2087c478bd9Sstevel@tonic-gate * Where the dots indicate an arbitrary number (including 0) of children. 2097c478bd9Sstevel@tonic-gate * 2107c478bd9Sstevel@tonic-gate * For a given scope, the next scope (in the sense of distance) is its 2117c478bd9Sstevel@tonic-gate * TYPE_SCOPE parent. The furthest out scope has no parent. 2127c478bd9Sstevel@tonic-gate * 2137c478bd9Sstevel@tonic-gate * 3.2.2 Iterators 2147c478bd9Sstevel@tonic-gate * 2157c478bd9Sstevel@tonic-gate * GLXXX 2167c478bd9Sstevel@tonic-gate * 2177c478bd9Sstevel@tonic-gate * 3.3. Client requests 2187c478bd9Sstevel@tonic-gate * -------------------- 2197c478bd9Sstevel@tonic-gate * 2207c478bd9Sstevel@tonic-gate * CLOSE() -> result 2217c478bd9Sstevel@tonic-gate * Closes the connection, revoking the door. After this call completes, 2227c478bd9Sstevel@tonic-gate * no further calls will succeed. 2237c478bd9Sstevel@tonic-gate * 2247c478bd9Sstevel@tonic-gate * ENTITY_SETUP(entity_id, type) -> result 2257c478bd9Sstevel@tonic-gate * Sets up an entity, identified by entity_id, to identify a single 2267c478bd9Sstevel@tonic-gate * <type>. <type> may not be TYPE_NONE. 2277c478bd9Sstevel@tonic-gate * 2287c478bd9Sstevel@tonic-gate * ENTITY_NAME(entity_id, name_type) -> result, name 2297c478bd9Sstevel@tonic-gate * Returns the name of entity_id. name_type determines which type of 2307c478bd9Sstevel@tonic-gate * name to get. 2317c478bd9Sstevel@tonic-gate * 2327c478bd9Sstevel@tonic-gate * ENTITY_PARENT_TYPE(entity_id) -> result, parent_type 2337c478bd9Sstevel@tonic-gate * Retrieves the type of entity_id's parent 2347c478bd9Sstevel@tonic-gate * 2357c478bd9Sstevel@tonic-gate * ENTITY_GET_CHILD(entity_id, child_id, name) -> result 2367c478bd9Sstevel@tonic-gate * Puts entity_id's child (of child_id's type) named 'name' into child_id. 2377c478bd9Sstevel@tonic-gate * 2387c478bd9Sstevel@tonic-gate * ENTITY_GET_PARENT(entity_id, out_id) -> result 2397c478bd9Sstevel@tonic-gate * Puts entity_id's parent into out_id. 2407c478bd9Sstevel@tonic-gate * 2417c478bd9Sstevel@tonic-gate * ENTITY_GET(entity_id, number) -> result 2427c478bd9Sstevel@tonic-gate * Makes entity_id point to a particular object. If any error 2437c478bd9Sstevel@tonic-gate * occurs, dest_id will be invalid. 2447c478bd9Sstevel@tonic-gate * 2457c478bd9Sstevel@tonic-gate * ENTITY_UPDATE(entity_id, changeid) -> result 2467c478bd9Sstevel@tonic-gate * Updates the entity to pick up any new changes. 2477c478bd9Sstevel@tonic-gate * 2487c478bd9Sstevel@tonic-gate * ENTITY_CREATE_CHILD(entity_id, type, name, child_id, changeid) -> result 2497c478bd9Sstevel@tonic-gate * Attaches the object of type /type/ in child_id as the child of 2507c478bd9Sstevel@tonic-gate * entity_id named 'name'. 2517c478bd9Sstevel@tonic-gate * 2527c478bd9Sstevel@tonic-gate * ENTITY_CREATE_PG(entity_id, name, type, flags, child_id, changeid) -> result 2537c478bd9Sstevel@tonic-gate * Creates a property group child of entity_id named 'name', type 'type' 2547c478bd9Sstevel@tonic-gate * and flags 'flags', and puts the resulting object in child_id. 2557c478bd9Sstevel@tonic-gate * 2567c478bd9Sstevel@tonic-gate * ENTITY_DELETE(entity_id, changeid) -> result 2577c478bd9Sstevel@tonic-gate * Deletes the entity represented by entity_id. 2587c478bd9Sstevel@tonic-gate * 2597c478bd9Sstevel@tonic-gate * ENTITY_RESET(entity_id) -> result 2607c478bd9Sstevel@tonic-gate * Resets the entity. 2617c478bd9Sstevel@tonic-gate * 2627c478bd9Sstevel@tonic-gate * ENTITY_TEARDOWN(entity_id) -> result 2637c478bd9Sstevel@tonic-gate * Destroys the entity entity_id. 2647c478bd9Sstevel@tonic-gate * 2657c478bd9Sstevel@tonic-gate * ITER_SETUP(iter_id) -> result 2667c478bd9Sstevel@tonic-gate * Sets up an iterator id. 2677c478bd9Sstevel@tonic-gate * 2687c478bd9Sstevel@tonic-gate * ITER_START(iter_id, entity_id, itertype, flags, pattern) -> result 2697c478bd9Sstevel@tonic-gate * Sets up an iterator, identified by iter_id, which will iterate the 2707c478bd9Sstevel@tonic-gate * <itertype> children of entity_id whose names match 'pattern', 2717c478bd9Sstevel@tonic-gate * with the matching controlled by flags. Initializing an iterator 2727c478bd9Sstevel@tonic-gate * counts as the first sequence number (1). 2737c478bd9Sstevel@tonic-gate * 2747c478bd9Sstevel@tonic-gate * ITER_READ(iter_id, sequence, entity_id) -> result 2757c478bd9Sstevel@tonic-gate * Retrieves the next element of iterator iter_id. Sequence starts at 2, 2767c478bd9Sstevel@tonic-gate * and is incremented by the client after each successful iteration. 2777c478bd9Sstevel@tonic-gate * The result is written to entity_id, which must be of the same type 2787c478bd9Sstevel@tonic-gate * as the iterator result. The iterator must not be iterating values. 2797c478bd9Sstevel@tonic-gate * 2807c478bd9Sstevel@tonic-gate * ITER_READ_VALUE(iter_id, sequence) -> result, type, value 2817c478bd9Sstevel@tonic-gate * Retrieves the next value for iterator iter_id. Sequence starts at 2, 2827c478bd9Sstevel@tonic-gate * and is incremented by the client after each successful iteration. 2837c478bd9Sstevel@tonic-gate * The iterator must be iterating a property's values. 2847c478bd9Sstevel@tonic-gate * 2857c478bd9Sstevel@tonic-gate * ITER_RESET(iter_id) -> result 2867c478bd9Sstevel@tonic-gate * Throws away any accumulated state. 2877c478bd9Sstevel@tonic-gate * 2887c478bd9Sstevel@tonic-gate * ITER_TEARDOWN(iter_id) -> result 2897c478bd9Sstevel@tonic-gate * Destroys the iterator iter_id. 2907c478bd9Sstevel@tonic-gate * 2917c478bd9Sstevel@tonic-gate * NEXT_SNAPLEVEL(entity_src, entity_dst) -> result 2927c478bd9Sstevel@tonic-gate * If entity_src is a snapshot, set entity_dst to the first snaplevel 2937c478bd9Sstevel@tonic-gate * in it. If entity_src is a snaplevel, set entity_dst to the next 2947c478bd9Sstevel@tonic-gate * snaplevel, or fail if there isn't one. 2957c478bd9Sstevel@tonic-gate * 2967c478bd9Sstevel@tonic-gate * SNAPSHOT_TAKE(entity_id, name, dest_id, flags) -> result 2977c478bd9Sstevel@tonic-gate * Takes a snapshot of entity_id, creating snaplevels for the instance and 2987c478bd9Sstevel@tonic-gate * its parent service. If flags is REP_SNAPSHOT_NEW, a new snapshot named 2997c478bd9Sstevel@tonic-gate * 'name' is created as a child of entity_id, dest_id is pointed to it, 3007c478bd9Sstevel@tonic-gate * and the new snaplevels are attached to it. If flags is 3017c478bd9Sstevel@tonic-gate * REP_SNAPSHOT_ATTACH, name must be empty, and the new snaplevels are 3027c478bd9Sstevel@tonic-gate * attached to the snapshot dest_id points to. 3037c478bd9Sstevel@tonic-gate * 3047c478bd9Sstevel@tonic-gate * SNAPSHOT_TAKE_NAMED(entity_id, instname, svcname, name, dest_id) -> result 3057c478bd9Sstevel@tonic-gate * Like SNAPSHOT_TAKE, but always acts as if REP_SNAPSHOT_NEW is 3067c478bd9Sstevel@tonic-gate * specified, and instname and svcname override the actual service and 3077c478bd9Sstevel@tonic-gate * instance names, respectively, written into the snaplevels. 3087c478bd9Sstevel@tonic-gate * 3097c478bd9Sstevel@tonic-gate * Note that this is only useful for writing snapshots which will later 3107c478bd9Sstevel@tonic-gate * be transferred to another instance (svc:/svcname:instname/) 3117c478bd9Sstevel@tonic-gate * 3127c478bd9Sstevel@tonic-gate * SNAPSHOT_ATTACH(source_id, dest_id) -> result 3137c478bd9Sstevel@tonic-gate * The snaplevels attached to the snapshot referenced by source_id are 3147c478bd9Sstevel@tonic-gate * attached to the snapshot dest_id is pointed at. 3157c478bd9Sstevel@tonic-gate * 3167c478bd9Sstevel@tonic-gate * PROPERTY_GET_TYPE(entity_id) -> result, value type 3177c478bd9Sstevel@tonic-gate * Finds the value type of entity_id, which must be a property. 3187c478bd9Sstevel@tonic-gate * 3197c478bd9Sstevel@tonic-gate * PROPERTY_GET_VALUE(entity_id) -> result, type, value 3207c478bd9Sstevel@tonic-gate * If the property contains a single value, returns it and its type. 3217c478bd9Sstevel@tonic-gate * 3227c478bd9Sstevel@tonic-gate * PROPERTYGRP_SETUP_WAIT(entity_id) -> result, [pipe fd] 3237c478bd9Sstevel@tonic-gate * Sets up a notification for changes to the object entity_id currently 3247c478bd9Sstevel@tonic-gate * references. On success, returns one side of a pipe -- when there 3257c478bd9Sstevel@tonic-gate * has been a change (or the daemon dies), the other end of the pipe will 3267c478bd9Sstevel@tonic-gate * be closed. 3277c478bd9Sstevel@tonic-gate * 3287c478bd9Sstevel@tonic-gate * Only one of these can be set up per client -- attempts to set up more 3297c478bd9Sstevel@tonic-gate * than one will cause the previous one to get closed. 3307c478bd9Sstevel@tonic-gate * 3317c478bd9Sstevel@tonic-gate * PROPERTYGRP_TX_START(entity_id_tx, entity_id) -> result 3327c478bd9Sstevel@tonic-gate * Makes entity_id_tx point to the same property group as entity_id, 3337c478bd9Sstevel@tonic-gate * then attempts to set up entity_id_tx as a transaction on that group. 3347c478bd9Sstevel@tonic-gate * entity_id and entity_id_tx must be distinct. On failure, entity_id_tx 3357c478bd9Sstevel@tonic-gate * is reset. 3367c478bd9Sstevel@tonic-gate * 3377c478bd9Sstevel@tonic-gate * PROPERTYGRP_TX_COMMIT(entity_id, data) -> result 3387c478bd9Sstevel@tonic-gate * Gives the actual steps to follow, and attempts to commit them. 3397c478bd9Sstevel@tonic-gate * 3407c478bd9Sstevel@tonic-gate * CLIENT_ADD_NOTIFY(type, pattern) -> result 3417c478bd9Sstevel@tonic-gate * Adds a new property group name or type pattern to the notify list 3427c478bd9Sstevel@tonic-gate * (see CLIENT_WAIT). If successful, takes effect immediately. 3437c478bd9Sstevel@tonic-gate * 3447c478bd9Sstevel@tonic-gate * CLIENT_WAIT(entity_id) -> result, fmri 3457c478bd9Sstevel@tonic-gate * Waits for a change to a propertygroup that matches the patterns 3467c478bd9Sstevel@tonic-gate * set up using CLIENT_ADD_NOTIFY, and puts the resultant propertygroup 3477c478bd9Sstevel@tonic-gate * in entity_id. Note that if an error occurs, you can loose 3487c478bd9Sstevel@tonic-gate * notifications. Either entity_id is set to a changed propertygroup, 3497c478bd9Sstevel@tonic-gate * or fmri is a non-zero-length string identifying a deleted thing. 3507c478bd9Sstevel@tonic-gate * 3517c478bd9Sstevel@tonic-gate * BACKUP(name) -> result 3527c478bd9Sstevel@tonic-gate * Backs up the persistant repository with a particular name. 3535b7f77adStw21770 * 3545b7f77adStw21770 * SET_ANNOTATION(operation, file) 3555b7f77adStw21770 * Set up a security audit annotation event. operation is the name of 3565b7f77adStw21770 * the operation that is being annotated, and file is the file being 3575b7f77adStw21770 * processed. This will be used to mark operations which comprise 3585b7f77adStw21770 * multiple primitive operations such as svccfg import. 359c0889d7aSstevep * 360c0889d7aSstevep * SWITCH(flag) -> result 361c0889d7aSstevep * The flag is used to indicate the direction of the switch operation. 362c0889d7aSstevep * When the flag is set to 'fast', move the main repository from the 363c0889d7aSstevep * default location (/etc/svc) to the tmpfs locationa (/etc/svc/volatile). 364c0889d7aSstevep * When it is set to 'perm', the switch is reversed. 3657c478bd9Sstevel@tonic-gate */ 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate #include <door.h> 3687c478bd9Sstevel@tonic-gate #include <stddef.h> 3697c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h> 3707c478bd9Sstevel@tonic-gate 3717c478bd9Sstevel@tonic-gate #ifdef __cplusplus 3727c478bd9Sstevel@tonic-gate extern "C" { 3737c478bd9Sstevel@tonic-gate #endif 3747c478bd9Sstevel@tonic-gate 3757c478bd9Sstevel@tonic-gate /* 3767c478bd9Sstevel@tonic-gate * svc.configd initial protocol details 3777c478bd9Sstevel@tonic-gate */ 3787c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_BASEVER (('R' << 24) | ('e' << 16) | ('p' << 8)) 3797c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_NAME "/etc/svc/volatile/repository_door" 3807c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_COOKIE ((void *)REPOSITORY_DOOR_BASEVER) 3817c478bd9Sstevel@tonic-gate 3827c478bd9Sstevel@tonic-gate #define REPOSITORY_BOOT_BACKUP ((const char *)"boot") 3837c478bd9Sstevel@tonic-gate 3847c478bd9Sstevel@tonic-gate /* 3857c478bd9Sstevel@tonic-gate * This value should be incremented any time the protocol changes. When in 3867c478bd9Sstevel@tonic-gate * doubt, bump it. 3877c478bd9Sstevel@tonic-gate */ 388c0889d7aSstevep #define REPOSITORY_DOOR_VERSION (21 + REPOSITORY_DOOR_BASEVER) 3897c478bd9Sstevel@tonic-gate 3907c478bd9Sstevel@tonic-gate /* 3917c478bd9Sstevel@tonic-gate * flags for rdr_flags 3927c478bd9Sstevel@tonic-gate */ 3937c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_FLAG_DEBUG 0x00000001 /* rdr_debug */ 3947c478bd9Sstevel@tonic-gate 3957c478bd9Sstevel@tonic-gate #define REPOSITORY_DOOR_FLAG_ALL 0x00000001 /* all flags */ 3967c478bd9Sstevel@tonic-gate 3977c478bd9Sstevel@tonic-gate /* 3987c478bd9Sstevel@tonic-gate * Request IDs 3997c478bd9Sstevel@tonic-gate */ 4007c478bd9Sstevel@tonic-gate enum repository_door_requestid { 4017c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_REQUEST_CONNECT = (('M' << 8) | 1) 4027c478bd9Sstevel@tonic-gate }; 4037c478bd9Sstevel@tonic-gate 4047c478bd9Sstevel@tonic-gate enum repository_door_statusid { 4057c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_SUCCESS = 0, 4067c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_BAD_REQUEST = 1, 4077c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_VERSION_MISMATCH = 2, 4087c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_BAD_FLAG = 3, 4097c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_NO_RESOURCES = 4, 4107c478bd9Sstevel@tonic-gate REPOSITORY_DOOR_FAIL_PERMISSION_DENIED = 5 4117c478bd9Sstevel@tonic-gate }; 4127c478bd9Sstevel@tonic-gate 4137c478bd9Sstevel@tonic-gate /* 4147c478bd9Sstevel@tonic-gate * You may only add elements to the end of this structure. 4157c478bd9Sstevel@tonic-gate */ 4167c478bd9Sstevel@tonic-gate typedef struct repository_door_request { 4177c478bd9Sstevel@tonic-gate uint32_t rdr_version; /* must be first element */ 4187c478bd9Sstevel@tonic-gate enum repository_door_requestid rdr_request; 4197c478bd9Sstevel@tonic-gate uint32_t rdr_flags; 4207c478bd9Sstevel@tonic-gate uint32_t rdr_debug; 4217c478bd9Sstevel@tonic-gate } repository_door_request_t; 4227c478bd9Sstevel@tonic-gate 4237c478bd9Sstevel@tonic-gate typedef struct repository_door_response { 4247c478bd9Sstevel@tonic-gate enum repository_door_statusid rdr_status; 4257c478bd9Sstevel@tonic-gate } repository_door_response_t; 4267c478bd9Sstevel@tonic-gate 4277c478bd9Sstevel@tonic-gate /* 4287c478bd9Sstevel@tonic-gate * Client interface. Used on doors returned by REQUEST_CONNECT 4297c478bd9Sstevel@tonic-gate */ 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_NAME_LEN 120 /* maximum name length */ 4327c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_VALUE_LEN 4096 /* maximum value length */ 4337c478bd9Sstevel@tonic-gate 4347c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_FMRI_LEN (6 * REP_PROTOCOL_NAME_LEN) 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_BASE ('C' << 8) 4377c478bd9Sstevel@tonic-gate 4387c478bd9Sstevel@tonic-gate /* 4397c478bd9Sstevel@tonic-gate * Request codes 4407c478bd9Sstevel@tonic-gate */ 4417c478bd9Sstevel@tonic-gate enum rep_protocol_requestid { 4427c478bd9Sstevel@tonic-gate REP_PROTOCOL_CLOSE = REP_PROTOCOL_BASE, 4437c478bd9Sstevel@tonic-gate 4447c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SETUP, 4457c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_NAME, 4467c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_PARENT_TYPE, 4477c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_GET_CHILD, 4487c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_GET_PARENT, 4497c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_GET, 4507c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_UPDATE, 4517c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_CREATE_CHILD, 4527c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_CREATE_PG, 4537c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_DELETE, 4547c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_RESET, 4557c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_TEARDOWN, 4567c478bd9Sstevel@tonic-gate 4577c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_SETUP, 4587c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_START, 4597c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_READ, 4607c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_READ_VALUE, 4617c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_RESET, 4627c478bd9Sstevel@tonic-gate REP_PROTOCOL_ITER_TEARDOWN, 4637c478bd9Sstevel@tonic-gate 4647c478bd9Sstevel@tonic-gate REP_PROTOCOL_NEXT_SNAPLEVEL, 4657c478bd9Sstevel@tonic-gate 4667c478bd9Sstevel@tonic-gate REP_PROTOCOL_SNAPSHOT_TAKE, 4677c478bd9Sstevel@tonic-gate REP_PROTOCOL_SNAPSHOT_TAKE_NAMED, 4687c478bd9Sstevel@tonic-gate REP_PROTOCOL_SNAPSHOT_ATTACH, 4697c478bd9Sstevel@tonic-gate 4707c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTY_GET_TYPE, 4717c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTY_GET_VALUE, 4727c478bd9Sstevel@tonic-gate 4737c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTYGRP_SETUP_WAIT, 4747c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTYGRP_TX_START, 4757c478bd9Sstevel@tonic-gate REP_PROTOCOL_PROPERTYGRP_TX_COMMIT, 4767c478bd9Sstevel@tonic-gate 4777c478bd9Sstevel@tonic-gate REP_PROTOCOL_CLIENT_ADD_NOTIFY, 4787c478bd9Sstevel@tonic-gate REP_PROTOCOL_CLIENT_WAIT, 4797c478bd9Sstevel@tonic-gate 4807c478bd9Sstevel@tonic-gate REP_PROTOCOL_BACKUP, 4817c478bd9Sstevel@tonic-gate 4825b7f77adStw21770 REP_PROTOCOL_SET_AUDIT_ANNOTATION, 4835b7f77adStw21770 484c0889d7aSstevep REP_PROTOCOL_SWITCH, 485c0889d7aSstevep 4867c478bd9Sstevel@tonic-gate REP_PROTOCOL_MAX_REQUEST 4877c478bd9Sstevel@tonic-gate }; 4887c478bd9Sstevel@tonic-gate 4897c478bd9Sstevel@tonic-gate /* 4907c478bd9Sstevel@tonic-gate * Response codes. These are returned to the client, and the errors are 4917c478bd9Sstevel@tonic-gate * translated into scf_error_t's by libscf (see proto_error()). 4927c478bd9Sstevel@tonic-gate */ 4937c478bd9Sstevel@tonic-gate typedef int32_t rep_protocol_responseid_t; 4947c478bd9Sstevel@tonic-gate enum rep_protocol_responseid { 4957c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUCCESS = 0, 4967c478bd9Sstevel@tonic-gate /* iterators: No more values. */ 4977c478bd9Sstevel@tonic-gate REP_PROTOCOL_DONE = 1, 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate /* Request from client was malformed. */ 5007c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BAD_REQUEST = -1, 5017c478bd9Sstevel@tonic-gate /* Prerequisite call has not been made. */ 5027c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_MISORDERED = -2, 5037c478bd9Sstevel@tonic-gate /* Register for ID has not been created. */ 5047c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_UNKNOWN_ID = -3, 5057c478bd9Sstevel@tonic-gate /* Out of memory or other resource. */ 5067c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NO_RESOURCES = -4, 5077c478bd9Sstevel@tonic-gate /* Type argument is invalid. */ 5087c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_INVALID_TYPE = -5, 5097c478bd9Sstevel@tonic-gate /* Requested object does not exist. */ 5107c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_FOUND = -6, 5117c478bd9Sstevel@tonic-gate /* Register for given ID does not point to an object. */ 5127c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_SET = -7, 5137c478bd9Sstevel@tonic-gate 5147c478bd9Sstevel@tonic-gate /* Requested name is longer than supplied buffer. */ 5157c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_TRUNCATED = -8, 5167c478bd9Sstevel@tonic-gate /* Operation requires different type. */ 5177c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_TYPE_MISMATCH = -9, 5187c478bd9Sstevel@tonic-gate 5197c478bd9Sstevel@tonic-gate /* Changeable object has been changed since last update. */ 5207c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_LATEST = -10, 5217c478bd9Sstevel@tonic-gate /* Creation failed because object with given name exists. */ 5227c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_EXISTS = -11, 5237c478bd9Sstevel@tonic-gate /* Transaction is invalid. */ 5247c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BAD_TX = -12, 5257c478bd9Sstevel@tonic-gate /* Operation is not applicable to indicated object. */ 5267c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_NOT_APPLICABLE = -13, 5277c478bd9Sstevel@tonic-gate /* Two IDs for operation were unexpectedly equal. */ 5287c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_DUPLICATE_ID = -14, 5297c478bd9Sstevel@tonic-gate 5307c478bd9Sstevel@tonic-gate /* Permission denied. */ 5317c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_PERMISSION_DENIED = -15, 5327c478bd9Sstevel@tonic-gate /* Backend does not exist or otherwise refused access. */ 5337c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BACKEND_ACCESS = -16, 5347c478bd9Sstevel@tonic-gate /* Backend is read-only. */ 5357c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_BACKEND_READONLY = -17, 5367c478bd9Sstevel@tonic-gate 5377c478bd9Sstevel@tonic-gate /* Object has been deleted. */ 5387c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_DELETED = -18, 5397c478bd9Sstevel@tonic-gate 5407c478bd9Sstevel@tonic-gate REP_PROTOCOL_FAIL_UNKNOWN = -0xfd 5417c478bd9Sstevel@tonic-gate }; 5427c478bd9Sstevel@tonic-gate 5437c478bd9Sstevel@tonic-gate /* 5447c478bd9Sstevel@tonic-gate * Types 5457c478bd9Sstevel@tonic-gate */ 5467c478bd9Sstevel@tonic-gate typedef enum rep_protocol_entity { 5477c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_NONE, 5487c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SCOPE, 5497c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SERVICE, 5507c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_INSTANCE, 5517c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SNAPSHOT, 5527c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_SNAPLEVEL, 5537c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_PROPERTYGRP, 5547c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_CPROPERTYGRP, /* "composed" property group */ 5557c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_PROPERTY, 5567c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_VALUE, 5577c478bd9Sstevel@tonic-gate 5587c478bd9Sstevel@tonic-gate REP_PROTOCOL_ENTITY_MAX 5597c478bd9Sstevel@tonic-gate } rep_protocol_entity_t; 5607c478bd9Sstevel@tonic-gate 5617c478bd9Sstevel@tonic-gate typedef enum rep_protocol_value_type { 5627c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_INVALID = '\0', 5637c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_BOOLEAN = 'b', 5647c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_COUNT = 'c', 5657c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_INTEGER = 'i', 5667c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_TIME = 't', 5677c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_STRING = 's', 5687c478bd9Sstevel@tonic-gate REP_PROTOCOL_TYPE_OPAQUE = 'o', 5697c478bd9Sstevel@tonic-gate 5707c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_USTRING = REP_PROTOCOL_TYPE_STRING|('u' << 8), 5717c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_URI = REP_PROTOCOL_TYPE_STRING|('U' << 8), 5727c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_FMRI = REP_PROTOCOL_TYPE_STRING|('f' << 8), 5737c478bd9Sstevel@tonic-gate 5747c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_HOST = REP_PROTOCOL_TYPE_STRING|('h' << 8), 5757c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_HOSTNAME = REP_PROTOCOL_TYPE_STRING|('N' << 8), 576*b56bf881SAntonello Cruz REP_PROTOCOL_SUBTYPE_NETADDR = REP_PROTOCOL_TYPE_STRING|('n' << 8), 5777c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_NETADDR_V4 = REP_PROTOCOL_TYPE_STRING|('4' << 8), 5787c478bd9Sstevel@tonic-gate REP_PROTOCOL_SUBTYPE_NETADDR_V6 = REP_PROTOCOL_TYPE_STRING|('6' << 8) 5797c478bd9Sstevel@tonic-gate } rep_protocol_value_type_t; 5807c478bd9Sstevel@tonic-gate 5817c478bd9Sstevel@tonic-gate 5827c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_BASE_TYPE(t) ((t) & 0x00ff) 5837c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_SUBTYPE(t) (((t) & 0xff00) >> 8) 5847c478bd9Sstevel@tonic-gate 5857c478bd9Sstevel@tonic-gate /* 5867c478bd9Sstevel@tonic-gate * Request structures 5877c478bd9Sstevel@tonic-gate */ 5887c478bd9Sstevel@tonic-gate typedef struct rep_protocol_request { 5897c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 5907c478bd9Sstevel@tonic-gate } rep_protocol_request_t; 5917c478bd9Sstevel@tonic-gate 5927c478bd9Sstevel@tonic-gate struct rep_protocol_iter_request { 5937c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 5947c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 5957c478bd9Sstevel@tonic-gate }; 5967c478bd9Sstevel@tonic-gate 5977c478bd9Sstevel@tonic-gate struct rep_protocol_iter_start { 5987c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ITER_START */ 5997c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 6007c478bd9Sstevel@tonic-gate 6017c478bd9Sstevel@tonic-gate uint32_t rpr_entity; 6027c478bd9Sstevel@tonic-gate uint32_t rpr_itertype; 6037c478bd9Sstevel@tonic-gate uint32_t rpr_flags; 6047c478bd9Sstevel@tonic-gate char rpr_pattern[REP_PROTOCOL_NAME_LEN]; 6057c478bd9Sstevel@tonic-gate }; 6067c478bd9Sstevel@tonic-gate #define RP_ITER_START_ALL 0x00000001 /* ignore pattern, match all */ 6077c478bd9Sstevel@tonic-gate #define RP_ITER_START_EXACT 0x00000002 /* exact match with pattern */ 6087c478bd9Sstevel@tonic-gate #define RP_ITER_START_PGTYPE 0x00000003 /* exact match pg type */ 6097c478bd9Sstevel@tonic-gate #define RP_ITER_START_FILT_MASK 0x00000003 6107c478bd9Sstevel@tonic-gate #define RP_ITER_START_COMPOSED 0x00000004 /* composed */ 6117c478bd9Sstevel@tonic-gate 6127c478bd9Sstevel@tonic-gate struct rep_protocol_iter_read { 6137c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ITER_READ */ 6147c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 6157c478bd9Sstevel@tonic-gate uint32_t rpr_sequence; /* client increments upon success */ 6167c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; /* entity to write result to */ 6177c478bd9Sstevel@tonic-gate }; 6187c478bd9Sstevel@tonic-gate 6197c478bd9Sstevel@tonic-gate struct rep_protocol_iter_read_value { 6207c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ITER_READ_VALUE */ 6217c478bd9Sstevel@tonic-gate uint32_t rpr_iterid; 6227c478bd9Sstevel@tonic-gate uint32_t rpr_sequence; /* client increments upon success */ 6237c478bd9Sstevel@tonic-gate }; 6247c478bd9Sstevel@tonic-gate 6257c478bd9Sstevel@tonic-gate struct rep_protocol_entity_setup { 6267c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_SETUP */ 6277c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6287c478bd9Sstevel@tonic-gate uint32_t rpr_entitytype; 6297c478bd9Sstevel@tonic-gate }; 6307c478bd9Sstevel@tonic-gate 6317c478bd9Sstevel@tonic-gate struct rep_protocol_entity_name { 6327c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_NAME */ 6337c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6347c478bd9Sstevel@tonic-gate uint32_t rpr_answertype; 6357c478bd9Sstevel@tonic-gate }; 6367c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_NAME 0 6377c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_PGTYPE 1 6387c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_PGFLAGS 2 6397c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_SNAPLEVEL_SCOPE 3 6407c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_SNAPLEVEL_SERVICE 4 6417c478bd9Sstevel@tonic-gate #define RP_ENTITY_NAME_SNAPLEVEL_INSTANCE 5 6423eae19d9Swesolows #define RP_ENTITY_NAME_PGREADPROT 6 6437c478bd9Sstevel@tonic-gate 6447c478bd9Sstevel@tonic-gate struct rep_protocol_entity_update { 6457c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_UPDATE */ 6467c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6477c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 6487c478bd9Sstevel@tonic-gate }; 6497c478bd9Sstevel@tonic-gate 6507c478bd9Sstevel@tonic-gate struct rep_protocol_entity_parent_type { 6517c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_PARENT_TYPE */ 6527c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6537c478bd9Sstevel@tonic-gate }; 6547c478bd9Sstevel@tonic-gate 6557c478bd9Sstevel@tonic-gate struct rep_protocol_entity_parent { 6567c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_GET_PARENT */ 6577c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6587c478bd9Sstevel@tonic-gate uint32_t rpr_outid; 6597c478bd9Sstevel@tonic-gate }; 6607c478bd9Sstevel@tonic-gate 6617c478bd9Sstevel@tonic-gate struct rep_protocol_entity_get { 6627c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_SET */ 6637c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6647c478bd9Sstevel@tonic-gate uint32_t rpr_object; 6657c478bd9Sstevel@tonic-gate }; 6667c478bd9Sstevel@tonic-gate #define RP_ENTITY_GET_INVALIDATE 1 6677c478bd9Sstevel@tonic-gate #define RP_ENTITY_GET_MOST_LOCAL_SCOPE 2 6687c478bd9Sstevel@tonic-gate 6697c478bd9Sstevel@tonic-gate struct rep_protocol_entity_create_child { 6707c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_CREATE_CHILD */ 6717c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6727c478bd9Sstevel@tonic-gate uint32_t rpr_childtype; 6737c478bd9Sstevel@tonic-gate uint32_t rpr_childid; 6747c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 6757c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 6767c478bd9Sstevel@tonic-gate }; 6777c478bd9Sstevel@tonic-gate 6787c478bd9Sstevel@tonic-gate struct rep_protocol_entity_create_pg { 6797c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_CREATE_PG */ 6807c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6817c478bd9Sstevel@tonic-gate uint32_t rpr_childtype; 6827c478bd9Sstevel@tonic-gate uint32_t rpr_childid; 6837c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 6847c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 6857c478bd9Sstevel@tonic-gate char rpr_type[REP_PROTOCOL_NAME_LEN]; 6867c478bd9Sstevel@tonic-gate uint32_t rpr_flags; 6877c478bd9Sstevel@tonic-gate }; 6887c478bd9Sstevel@tonic-gate 6897c478bd9Sstevel@tonic-gate struct rep_protocol_entity_get_child { 6907c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_GET_CHILD */ 6917c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6927c478bd9Sstevel@tonic-gate uint32_t rpr_childid; 6937c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 6947c478bd9Sstevel@tonic-gate }; 6957c478bd9Sstevel@tonic-gate 6967c478bd9Sstevel@tonic-gate struct rep_protocol_entity_delete { 6977c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_DELETE_CHILD */ 6987c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 6997c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 7007c478bd9Sstevel@tonic-gate }; 7017c478bd9Sstevel@tonic-gate 7027c478bd9Sstevel@tonic-gate struct rep_protocol_entity_reset { 7037c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_NAME */ 7047c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7057c478bd9Sstevel@tonic-gate }; 7067c478bd9Sstevel@tonic-gate 7077c478bd9Sstevel@tonic-gate struct rep_protocol_entity_request { 7087c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_NAME */ 7097c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7107c478bd9Sstevel@tonic-gate }; 7117c478bd9Sstevel@tonic-gate 7127c478bd9Sstevel@tonic-gate struct rep_protocol_entity_teardown { 7137c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* ENTITY_TEARDOWN */ 7147c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7157c478bd9Sstevel@tonic-gate }; 7167c478bd9Sstevel@tonic-gate 7177c478bd9Sstevel@tonic-gate struct rep_protocol_entity_pair { 7187c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* NEXT_SNAPLEVEL */ 7197c478bd9Sstevel@tonic-gate uint32_t rpr_entity_src; 7207c478bd9Sstevel@tonic-gate uint32_t rpr_entity_dst; 7217c478bd9Sstevel@tonic-gate }; 7227c478bd9Sstevel@tonic-gate 7237c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_start { 7247c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* TX_SETUP */ 7257c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_tx; /* property group tx entity */ 7267c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; /* property group entity */ 7277c478bd9Sstevel@tonic-gate }; 7287c478bd9Sstevel@tonic-gate 7297c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_commit { 7307c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* TX_COMMIT */ 7317c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7327c478bd9Sstevel@tonic-gate uint32_t rpr_size; /* size of entire structure */ 7337c478bd9Sstevel@tonic-gate uint8_t rpr_cmd[1]; 7347c478bd9Sstevel@tonic-gate }; 7357c478bd9Sstevel@tonic-gate 7367c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_COMMIT_SIZE(sz) \ 7377c478bd9Sstevel@tonic-gate (offsetof(struct rep_protocol_transaction_commit, rpr_cmd[sz])) 7387c478bd9Sstevel@tonic-gate 7397c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_COMMIT_MIN_SIZE \ 7407c478bd9Sstevel@tonic-gate REP_PROTOCOL_TRANSACTION_COMMIT_SIZE(0) 7417c478bd9Sstevel@tonic-gate 7427c478bd9Sstevel@tonic-gate enum rep_protocol_transaction_action { 7437c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_INVALID, /* N/A */ 7447c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_NEW, /* new property */ 7457c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_CLEAR, /* clear old property */ 7467c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_REPLACE, /* change type of old property */ 7477c478bd9Sstevel@tonic-gate REP_PROTOCOL_TX_ENTRY_DELETE /* delete property (no values) */ 7487c478bd9Sstevel@tonic-gate }; 7497c478bd9Sstevel@tonic-gate 7507c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_cmd { 7517c478bd9Sstevel@tonic-gate enum rep_protocol_transaction_action rptc_action; 7527c478bd9Sstevel@tonic-gate uint32_t rptc_type; 7537c478bd9Sstevel@tonic-gate uint32_t rptc_size; /* size of entire structure */ 7547c478bd9Sstevel@tonic-gate uint32_t rptc_name_len; 7557c478bd9Sstevel@tonic-gate uint8_t rptc_data[1]; 7567c478bd9Sstevel@tonic-gate }; 7577c478bd9Sstevel@tonic-gate 7587c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_CMD_SIZE(sz) \ 7597c478bd9Sstevel@tonic-gate (offsetof(struct rep_protocol_transaction_cmd, rptc_data[sz])) 7607c478bd9Sstevel@tonic-gate 7617c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_TRANSACTION_CMD_MIN_SIZE \ 7627c478bd9Sstevel@tonic-gate REP_PROTOCOL_TRANSACTION_CMD_SIZE(0) 7637c478bd9Sstevel@tonic-gate 7647c478bd9Sstevel@tonic-gate #define TX_SIZE(x) P2ROUNDUP((x), sizeof (uint32_t)) 7657c478bd9Sstevel@tonic-gate 7667c478bd9Sstevel@tonic-gate struct rep_protocol_transaction_request { 7677c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SETUP, ABORT or TEARDOWN */ 7687c478bd9Sstevel@tonic-gate uint32_t rpr_txid; 7697c478bd9Sstevel@tonic-gate }; 7707c478bd9Sstevel@tonic-gate 7717c478bd9Sstevel@tonic-gate struct rep_protocol_property_request { 7727c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 7737c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7747c478bd9Sstevel@tonic-gate }; 7757c478bd9Sstevel@tonic-gate 7767c478bd9Sstevel@tonic-gate struct rep_protocol_propertygrp_request { 7777c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 7787c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7797c478bd9Sstevel@tonic-gate }; 7807c478bd9Sstevel@tonic-gate 7817c478bd9Sstevel@tonic-gate struct rep_protocol_notify_request { 7827c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 7837c478bd9Sstevel@tonic-gate uint32_t rpr_type; 7847c478bd9Sstevel@tonic-gate char rpr_pattern[REP_PROTOCOL_NAME_LEN]; 7857c478bd9Sstevel@tonic-gate }; 7867c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_NOTIFY_PGNAME 1 7877c478bd9Sstevel@tonic-gate #define REP_PROTOCOL_NOTIFY_PGTYPE 2 7887c478bd9Sstevel@tonic-gate 7897c478bd9Sstevel@tonic-gate struct rep_protocol_wait_request { 7907c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; 7917c478bd9Sstevel@tonic-gate uint32_t rpr_entityid; 7927c478bd9Sstevel@tonic-gate }; 7937c478bd9Sstevel@tonic-gate 7947c478bd9Sstevel@tonic-gate struct rep_protocol_snapshot_take { 7957c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SNAPSHOT_TAKE */ 7967c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_src; 7977c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_dest; 7987c478bd9Sstevel@tonic-gate int rpr_flags; 7997c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 8007c478bd9Sstevel@tonic-gate }; 8017c478bd9Sstevel@tonic-gate #define REP_SNAPSHOT_NEW 0x00000001 8027c478bd9Sstevel@tonic-gate #define REP_SNAPSHOT_ATTACH 0x00000002 8037c478bd9Sstevel@tonic-gate 8047c478bd9Sstevel@tonic-gate struct rep_protocol_snapshot_take_named { 8057c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SNAPSHOT_TAKE_NAMED */ 8067c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_src; 8077c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_dest; 8087c478bd9Sstevel@tonic-gate char rpr_svcname[REP_PROTOCOL_NAME_LEN]; 8097c478bd9Sstevel@tonic-gate char rpr_instname[REP_PROTOCOL_NAME_LEN]; 8107c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 8117c478bd9Sstevel@tonic-gate }; 8127c478bd9Sstevel@tonic-gate 8137c478bd9Sstevel@tonic-gate struct rep_protocol_snapshot_attach { 8147c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* SNAPSHOT_ATTACH */ 8157c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_src; 8167c478bd9Sstevel@tonic-gate uint32_t rpr_entityid_dest; 8177c478bd9Sstevel@tonic-gate }; 8187c478bd9Sstevel@tonic-gate 8197c478bd9Sstevel@tonic-gate struct rep_protocol_backup_request { 8207c478bd9Sstevel@tonic-gate enum rep_protocol_requestid rpr_request; /* BACKUP */ 8217c478bd9Sstevel@tonic-gate uint32_t rpr_changeid; 8227c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 8237c478bd9Sstevel@tonic-gate }; 8247c478bd9Sstevel@tonic-gate 8255b7f77adStw21770 struct rep_protocol_annotation { 8265b7f77adStw21770 enum rep_protocol_requestid rpr_request; /* SET_ANNOTATION */ 8275b7f77adStw21770 char rpr_operation[REP_PROTOCOL_NAME_LEN]; 8285b7f77adStw21770 char rpr_file[MAXPATHLEN]; 8295b7f77adStw21770 }; 8305b7f77adStw21770 831c0889d7aSstevep struct rep_protocol_switch_request { 832c0889d7aSstevep enum rep_protocol_requestid rpr_request; /* SWITCH */ 833c0889d7aSstevep uint32_t rpr_changeid; 834c0889d7aSstevep int rpr_flag; 835c0889d7aSstevep }; 836c0889d7aSstevep 8377c478bd9Sstevel@tonic-gate /* 8387c478bd9Sstevel@tonic-gate * Response structures 8397c478bd9Sstevel@tonic-gate */ 8407c478bd9Sstevel@tonic-gate typedef struct rep_protocol_response { 8417c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 8427c478bd9Sstevel@tonic-gate } rep_protocol_response_t; 8437c478bd9Sstevel@tonic-gate 8447c478bd9Sstevel@tonic-gate struct rep_protocol_integer_response { 8457c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 8467c478bd9Sstevel@tonic-gate uint32_t rpr_value; 8477c478bd9Sstevel@tonic-gate }; 8487c478bd9Sstevel@tonic-gate 8497c478bd9Sstevel@tonic-gate struct rep_protocol_name_response { /* response to ENTITY_NAME */ 8507c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 8517c478bd9Sstevel@tonic-gate char rpr_name[REP_PROTOCOL_NAME_LEN]; 8527c478bd9Sstevel@tonic-gate }; 8537c478bd9Sstevel@tonic-gate 8547c478bd9Sstevel@tonic-gate struct rep_protocol_fmri_response { 8557c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 8567c478bd9Sstevel@tonic-gate char rpr_fmri[REP_PROTOCOL_FMRI_LEN]; 8577c478bd9Sstevel@tonic-gate }; 8587c478bd9Sstevel@tonic-gate 8597c478bd9Sstevel@tonic-gate struct rep_protocol_value_response { 8607c478bd9Sstevel@tonic-gate rep_protocol_responseid_t rpr_response; 8617c478bd9Sstevel@tonic-gate rep_protocol_value_type_t rpr_type; 8627c478bd9Sstevel@tonic-gate char rpr_value[2 * REP_PROTOCOL_VALUE_LEN + 1]; 8637c478bd9Sstevel@tonic-gate }; 8647c478bd9Sstevel@tonic-gate 8657c478bd9Sstevel@tonic-gate #ifdef __cplusplus 8667c478bd9Sstevel@tonic-gate } 8677c478bd9Sstevel@tonic-gate #endif 8687c478bd9Sstevel@tonic-gate 8697c478bd9Sstevel@tonic-gate #endif /* _REPCACHE_PROTOCOL_H */ 870