10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7128Samaguire * Common Development and Distribution License (the "License"). 6*7128Samaguire * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*7128Samaguire * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _LOWLEVEL_IMPL_H 270Sstevel@tonic-gate #define _LOWLEVEL_IMPL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate #include "libscf_impl.h" 320Sstevel@tonic-gate 330Sstevel@tonic-gate #include <door.h> 340Sstevel@tonic-gate #include <libuutil.h> 350Sstevel@tonic-gate #include <limits.h> 360Sstevel@tonic-gate #include <pthread.h> 370Sstevel@tonic-gate #include <stddef.h> 380Sstevel@tonic-gate 390Sstevel@tonic-gate #include "repcache_protocol.h" 400Sstevel@tonic-gate 410Sstevel@tonic-gate #ifdef __cplusplus 420Sstevel@tonic-gate extern "C" { 430Sstevel@tonic-gate #endif 440Sstevel@tonic-gate 450Sstevel@tonic-gate typedef struct scf_datael { 460Sstevel@tonic-gate scf_handle_t *rd_handle; 470Sstevel@tonic-gate uint32_t rd_entity; 480Sstevel@tonic-gate uint32_t rd_type; 490Sstevel@tonic-gate uint32_t rd_reset; 500Sstevel@tonic-gate uu_list_node_t rd_node; 510Sstevel@tonic-gate } scf_datael_t; 520Sstevel@tonic-gate #define DATAEL_VALID 0x0001 530Sstevel@tonic-gate 540Sstevel@tonic-gate /* 550Sstevel@tonic-gate * Handle structure. 560Sstevel@tonic-gate * 570Sstevel@tonic-gate * Access to handles is serialized -- access to and modification of a handle 580Sstevel@tonic-gate * and all of its children is protected by rh_lock. 590Sstevel@tonic-gate * 600Sstevel@tonic-gate * Different handles don't interfere with each other. 610Sstevel@tonic-gate */ 620Sstevel@tonic-gate struct scf_handle { 630Sstevel@tonic-gate pthread_mutex_t rh_lock; 640Sstevel@tonic-gate pthread_cond_t rh_cv; 650Sstevel@tonic-gate 660Sstevel@tonic-gate uint32_t rh_nextiter; 670Sstevel@tonic-gate uint32_t rh_nextentity; 680Sstevel@tonic-gate uint32_t rh_nextchangeid; 690Sstevel@tonic-gate 700Sstevel@tonic-gate int rh_doorfd; 710Sstevel@tonic-gate int rh_doorfd_old; /* fd to close once rh_fd_users == 0 */ 720Sstevel@tonic-gate door_id_t rh_doorid; 730Sstevel@tonic-gate pid_t rh_doorpid; /* pid at bind time */ 740Sstevel@tonic-gate 750Sstevel@tonic-gate uid_t rh_uid; 760Sstevel@tonic-gate uint32_t rh_debug; 770Sstevel@tonic-gate uint32_t rh_flags; /* HANDLE_*, below */ 780Sstevel@tonic-gate uint32_t rh_fd_users; /* non-locked users of rh_doorfd */ 790Sstevel@tonic-gate 800Sstevel@tonic-gate uu_list_t *rh_dataels; 810Sstevel@tonic-gate uu_list_t *rh_iters; 820Sstevel@tonic-gate long rh_entries; 830Sstevel@tonic-gate long rh_values; 840Sstevel@tonic-gate 850Sstevel@tonic-gate long rh_extrefs; /* user-created subhandle count */ 860Sstevel@tonic-gate long rh_intrefs; /* handle-internal subhandle count */ 870Sstevel@tonic-gate 880Sstevel@tonic-gate char rh_doorpath[PATH_MAX + 1]; 890Sstevel@tonic-gate 900Sstevel@tonic-gate pthread_t rh_holder; /* thread using subhandles */ 910Sstevel@tonic-gate uint32_t rh_hold_flags; /* which are in use */ 920Sstevel@tonic-gate 930Sstevel@tonic-gate scf_iter_t *rh_iter; 940Sstevel@tonic-gate scf_scope_t *rh_scope; 950Sstevel@tonic-gate scf_service_t *rh_service; 960Sstevel@tonic-gate scf_instance_t *rh_instance; 970Sstevel@tonic-gate scf_snapshot_t *rh_snapshot; 980Sstevel@tonic-gate scf_snaplevel_t *rh_snaplvl; 990Sstevel@tonic-gate scf_propertygroup_t *rh_pg; 1000Sstevel@tonic-gate scf_property_t *rh_property; 1010Sstevel@tonic-gate scf_value_t *rh_value; 1020Sstevel@tonic-gate }; 103407Sjwadams #define HANDLE_DEAD 0x0001 104407Sjwadams #define HANDLE_UNREFED 0x0002 105407Sjwadams #define HANDLE_WRAPPED_ENTITY 0x0004 106407Sjwadams #define HANDLE_WRAPPED_ITER 0x0008 1070Sstevel@tonic-gate 1080Sstevel@tonic-gate #define RH_HOLD_ITER 0x0001 1090Sstevel@tonic-gate #define RH_HOLD_SCOPE 0x0002 1100Sstevel@tonic-gate #define RH_HOLD_SERVICE 0x0004 1110Sstevel@tonic-gate #define RH_HOLD_INSTANCE 0x0008 1120Sstevel@tonic-gate #define RH_HOLD_SNAPSHOT 0x0010 1130Sstevel@tonic-gate #define RH_HOLD_SNAPLVL 0x0020 1140Sstevel@tonic-gate #define RH_HOLD_PG 0x0040 1150Sstevel@tonic-gate #define RH_HOLD_PROPERTY 0x0080 1160Sstevel@tonic-gate #define RH_HOLD_VALUE 0x0100 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate #define RH_HOLD_ALL 0x01ff 1190Sstevel@tonic-gate 1200Sstevel@tonic-gate struct scf_scope { 1210Sstevel@tonic-gate scf_datael_t rd_d; 1220Sstevel@tonic-gate }; 1230Sstevel@tonic-gate 1240Sstevel@tonic-gate struct scf_service { 1250Sstevel@tonic-gate scf_datael_t rd_d; 1260Sstevel@tonic-gate }; 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate struct scf_instance { 1290Sstevel@tonic-gate scf_datael_t rd_d; 1300Sstevel@tonic-gate }; 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate struct scf_snapshot { 1330Sstevel@tonic-gate scf_datael_t rd_d; 1340Sstevel@tonic-gate }; 1350Sstevel@tonic-gate 1360Sstevel@tonic-gate /* 1370Sstevel@tonic-gate * note: be careful of adding more state here -- snaplevel_next() relies on 1380Sstevel@tonic-gate * the fact that the entityid is the only library-level state. 1390Sstevel@tonic-gate */ 1400Sstevel@tonic-gate struct scf_snaplevel { 1410Sstevel@tonic-gate scf_datael_t rd_d; 1420Sstevel@tonic-gate }; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate struct scf_propertygroup { 1450Sstevel@tonic-gate scf_datael_t rd_d; 1460Sstevel@tonic-gate }; 1470Sstevel@tonic-gate 1480Sstevel@tonic-gate struct scf_property { 1490Sstevel@tonic-gate scf_datael_t rd_d; 1500Sstevel@tonic-gate }; 1510Sstevel@tonic-gate 1520Sstevel@tonic-gate struct scf_value { 1530Sstevel@tonic-gate scf_handle_t *value_handle; 1540Sstevel@tonic-gate scf_value_t *value_next; 1550Sstevel@tonic-gate scf_transaction_entry_t *value_tx; 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate rep_protocol_value_type_t value_type; 1580Sstevel@tonic-gate size_t value_size; /* only for opaque values */ 1590Sstevel@tonic-gate char value_value[REP_PROTOCOL_VALUE_LEN]; 1600Sstevel@tonic-gate }; 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate enum scf_entry_state { 1630Sstevel@tonic-gate ENTRY_STATE_INVALID, 1640Sstevel@tonic-gate ENTRY_STATE_IN_TX_ACTION 1650Sstevel@tonic-gate }; 1660Sstevel@tonic-gate struct scf_transaction_entry { 1670Sstevel@tonic-gate const char *entry_property; 1680Sstevel@tonic-gate scf_handle_t *entry_handle; 1690Sstevel@tonic-gate scf_transaction_t *entry_tx; 1700Sstevel@tonic-gate enum scf_entry_state entry_state; 1710Sstevel@tonic-gate uu_list_node_t entry_link; /* for property name list */ 1720Sstevel@tonic-gate 173*7128Samaguire scf_value_t *entry_head; 174*7128Samaguire scf_value_t *entry_tail; /* for linked values */ 1750Sstevel@tonic-gate 1760Sstevel@tonic-gate enum rep_protocol_transaction_action entry_action; 1770Sstevel@tonic-gate rep_protocol_value_type_t entry_type; 1780Sstevel@tonic-gate char entry_namebuf[REP_PROTOCOL_NAME_LEN]; 1790Sstevel@tonic-gate }; 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate enum scf_tx_state { 1820Sstevel@tonic-gate TRAN_STATE_NEW, 1830Sstevel@tonic-gate TRAN_STATE_SETUP, 1840Sstevel@tonic-gate TRAN_STATE_COMMITTED 1850Sstevel@tonic-gate }; 1860Sstevel@tonic-gate 1870Sstevel@tonic-gate struct scf_transaction { 1880Sstevel@tonic-gate enum scf_tx_state tran_state; 1890Sstevel@tonic-gate scf_propertygroup_t tran_pg; 1900Sstevel@tonic-gate int tran_invalid; 1910Sstevel@tonic-gate uu_list_t *tran_props; 1920Sstevel@tonic-gate }; 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate struct scf_iter { 1950Sstevel@tonic-gate scf_handle_t *iter_handle; 1960Sstevel@tonic-gate int iter_type; 1970Sstevel@tonic-gate uint32_t iter_id; 1980Sstevel@tonic-gate uint32_t iter_sequence; 1990Sstevel@tonic-gate uu_list_node_t iter_node; 2000Sstevel@tonic-gate }; 2010Sstevel@tonic-gate 2020Sstevel@tonic-gate #ifdef __cplusplus 2030Sstevel@tonic-gate } 2040Sstevel@tonic-gate #endif 2050Sstevel@tonic-gate 2060Sstevel@tonic-gate #endif /* _LOWLEVEL_IMPL_H */ 207