1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* 28 * FMA ETM-to-Transport API header 29 * 30 * const/type defns for transporting data between an Event Transport 31 * Module (ETM) and its associated Transport Layer within a fault domain. 32 */ 33 34 #ifndef _ETM_XPORT_API_H 35 #define _ETM_XPORT_API_H 36 37 #pragma ident "%Z%%M% %I% %E% SMI" 38 39 #ifdef __cplusplus 40 extern "C" { 41 #endif 42 43 #include <fm/fmd_api.h> 44 45 typedef void* etm_xport_hdl_t; /* transport instance handle */ 46 typedef void* etm_xport_conn_t; /* transport connection handle */ 47 48 typedef enum etm_callback_flag { 49 ETM_CBFLAG_REINIT, /* reinitialize connection */ 50 ETM_CBFLAG_RECV /* receive message */ 51 } etm_cb_flag_t; 52 53 /* 54 * Connection Management 55 */ 56 57 /* 58 * Initialize/setup transport instance before any connections are opened. 59 * Return transport instance handle if successful, or NULL for failure. 60 */ 61 etm_xport_hdl_t 62 etm_xport_init(fmd_hdl_t *hdl, char *endpoint_id, 63 int (*cb_func)(fmd_hdl_t *hdl, etm_xport_conn_t conn, etm_cb_flag_t flag, 64 void *arg), void *cb_func_arg); 65 66 /* 67 * Callback function provided to etm_xport_init(). 68 * This function is called by the transport layer to notify the common layer 69 * that action is required (receive a message, reinitialize a connection, etc.). 70 * Return zero for success. 71 * For any non-zero return value, the connection should be closed. 72 */ 73 int 74 etm_xport_cb_func(fmd_hdl_t *hdl, etm_xport_conn_t conn, etm_cb_flag_t flag, 75 void *arg); 76 77 /* 78 * Finish/teardown any transport infrastructure. 79 * Return zero if successful, or nonzero for failure. 80 */ 81 int 82 etm_xport_fini(fmd_hdl_t *hdl, etm_xport_hdl_t tlhdl); 83 84 /* 85 * Open a connection with the given endpoint. 86 * Return the transport connection handle if successful, or NULL for failure. 87 */ 88 etm_xport_conn_t 89 etm_xport_open(fmd_hdl_t *hdl, etm_xport_hdl_t tlhdl); 90 91 /* 92 * Close a connection. 93 * Return zero if successful, or nonzero for failure. 94 */ 95 int 96 etm_xport_close(fmd_hdl_t *hdl, etm_xport_conn_t conn); 97 98 /* 99 * Input/Output 100 */ 101 102 /* 103 * Try to read byte_cnt bytes from the connection into the given buffer. 104 * Return number of bytes successfully read, or a value < 0 for failure. 105 */ 106 ssize_t 107 etm_xport_read(fmd_hdl_t *hdl, etm_xport_conn_t conn, hrtime_t timeout, 108 void *buf, size_t byte_cnt); 109 110 /* 111 * Try to write byte_cnt bytes to the connection from the given buffer. 112 * Return number of bytes successfully written, or a value < 0 for failure. 113 */ 114 ssize_t 115 etm_xport_write(fmd_hdl_t *hdl, etm_xport_conn_t conn, hrtime_t timeout, 116 void *buf, size_t byte_cnt); 117 118 /* 119 * Filter 120 */ 121 122 #define ETM_XPORT_FILTER_OK (1) /* OK to send/post event */ 123 #define ETM_XPORT_FILTER_DROP (0) /* Do not send/post event */ 124 #define ETM_XPORT_FILTER_ERROR (-1) /* Error */ 125 126 /* 127 * Make a decision whether or not to send an event to a remote endpoint. 128 * Return ETM_XPORT_FILTER_OK, ETM_XPORT_FILTER_DROP, or ETM_XPORT_FILTER_ERROR 129 * and set errno for failure. 130 */ 131 int 132 etm_xport_send_filter(fmd_hdl_t *hdl, nvlist_t *event, const char *dest); 133 134 /* 135 * Make a decision whether or not to post an event to FMD. 136 * Return ETM_XPORT_FILTER_OK, ETM_XPORT_FILTER_DROP, or ETM_XPORT_FILTER_ERROR 137 * and set errno for failure. 138 */ 139 int 140 etm_xport_post_filter(fmd_hdl_t *hdl, nvlist_t *event, const char *src); 141 142 #ifdef __cplusplus 143 } 144 #endif 145 146 #endif /* _ETM_XPORT_API_H */ 147