11ae08745Sheppo /* 21ae08745Sheppo * CDDL HEADER START 31ae08745Sheppo * 41ae08745Sheppo * The contents of this file are subject to the terms of the 51ae08745Sheppo * Common Development and Distribution License (the "License"). 61ae08745Sheppo * You may not use this file except in compliance with the License. 71ae08745Sheppo * 81ae08745Sheppo * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91ae08745Sheppo * or http://www.opensolaris.org/os/licensing. 101ae08745Sheppo * See the License for the specific language governing permissions 111ae08745Sheppo * and limitations under the License. 121ae08745Sheppo * 131ae08745Sheppo * When distributing Covered Code, include this CDDL HEADER in each 141ae08745Sheppo * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151ae08745Sheppo * If applicable, add the following below this CDDL HEADER, with the 161ae08745Sheppo * fields enclosed by brackets "[]" replaced with your own identifying 171ae08745Sheppo * information: Portions Copyright [yyyy] [name of copyright owner] 181ae08745Sheppo * 191ae08745Sheppo * CDDL HEADER END 201ae08745Sheppo */ 211ae08745Sheppo 221ae08745Sheppo /* 23*30588217SMike Christensen * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 241ae08745Sheppo * Use is subject to license terms. 251ae08745Sheppo */ 261ae08745Sheppo 271ae08745Sheppo #ifndef _DS_H 281ae08745Sheppo #define _DS_H 291ae08745Sheppo 301ae08745Sheppo 311ae08745Sheppo /* 321ae08745Sheppo * Domain Services Client Interface 331ae08745Sheppo */ 341ae08745Sheppo 351ae08745Sheppo #ifdef __cplusplus 361ae08745Sheppo extern "C" { 371ae08745Sheppo #endif 381ae08745Sheppo 391ae08745Sheppo typedef uint64_t ds_svc_hdl_t; /* opaque service handle */ 401ae08745Sheppo typedef void *ds_cb_arg_t; /* client specified callback arg */ 411ae08745Sheppo 421ae08745Sheppo #define DS_INVALID_HDL (0) /* a ds handle cannot be zero */ 431ae08745Sheppo 441ae08745Sheppo /* 451ae08745Sheppo * Domain Services Versioning 461ae08745Sheppo */ 471ae08745Sheppo typedef struct ds_ver { 481ae08745Sheppo uint16_t major; 491ae08745Sheppo uint16_t minor; 501ae08745Sheppo } ds_ver_t; 511ae08745Sheppo 521ae08745Sheppo /* 531ae08745Sheppo * Domain Services Capability 541ae08745Sheppo * 551ae08745Sheppo * A DS capability is exported by a client using a unique service 561ae08745Sheppo * identifier string. Along with this identifier is the list of 571ae08745Sheppo * versions of the capability that the client supports. 581ae08745Sheppo */ 591ae08745Sheppo typedef struct ds_capability { 601ae08745Sheppo char *svc_id; /* service identifier */ 611ae08745Sheppo ds_ver_t *vers; /* list of supported versions */ 621ae08745Sheppo int nvers; /* number of supported versions */ 631ae08745Sheppo } ds_capability_t; 641ae08745Sheppo 651ae08745Sheppo /* 661ae08745Sheppo * Domain Services Client Event Callbacks 671ae08745Sheppo * 681ae08745Sheppo * A client implementing a DS capability provides a set of callbacks 691ae08745Sheppo * when it registers with the DS framework. The use of these callbacks 701ae08745Sheppo * is described below: 711ae08745Sheppo * 721ae08745Sheppo * ds_reg_cb(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl) 731ae08745Sheppo * 741ae08745Sheppo * The ds_reg_cb() callback is invoked when the DS framework 751ae08745Sheppo * has successfully completed version negotiation with the 761ae08745Sheppo * remote endpoint for the capability. It provides the client 771ae08745Sheppo * with the negotiated version and a handle to use when sending 781ae08745Sheppo * data. 791ae08745Sheppo * 801ae08745Sheppo * ds_unreg_cb(ds_cb_arg_t arg) 811ae08745Sheppo * 821ae08745Sheppo * The ds_unreg_cb() callback is invoked when the DS framework 831ae08745Sheppo * detects an event that causes the registered capability to 841ae08745Sheppo * become unavailable. This includes an explicit unregister 851ae08745Sheppo * message, a failure in the underlying communication transport, 861ae08745Sheppo * etc. Any such event invalidates the service handle that was 871ae08745Sheppo * received from the register callback. 881ae08745Sheppo * 891ae08745Sheppo * ds_data_cb(ds_cb_arg_t arg, void *buf, size_t buflen) 901ae08745Sheppo * 911ae08745Sheppo * The ds_data_cb() callback is invoked whenever there is an 921ae08745Sheppo * incoming data message for the client to process. It provides 931ae08745Sheppo * the contents of the message along with the message length. 941ae08745Sheppo */ 951ae08745Sheppo typedef struct ds_clnt_ops { 961ae08745Sheppo void (*ds_reg_cb)(ds_cb_arg_t arg, ds_ver_t *ver, ds_svc_hdl_t hdl); 971ae08745Sheppo void (*ds_unreg_cb)(ds_cb_arg_t arg); 981ae08745Sheppo void (*ds_data_cb)(ds_cb_arg_t arg, void *buf, size_t buflen); 991ae08745Sheppo ds_cb_arg_t cb_arg; 1001ae08745Sheppo } ds_clnt_ops_t; 1011ae08745Sheppo 1021ae08745Sheppo /* 1031ae08745Sheppo * Domain Services Capability Interface 1041ae08745Sheppo */ 1051ae08745Sheppo extern int ds_cap_init(ds_capability_t *cap, ds_clnt_ops_t *ops); 1061ae08745Sheppo extern int ds_cap_fini(ds_capability_t *cap); 1071ae08745Sheppo extern int ds_cap_send(ds_svc_hdl_t hdl, void *buf, size_t buflen); 1081ae08745Sheppo 1091ae08745Sheppo #ifdef __cplusplus 1101ae08745Sheppo } 1111ae08745Sheppo #endif 1121ae08745Sheppo 1131ae08745Sheppo #endif /* _DS_H */ 114