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 Event Transport Module Transport Layer API implementation.
29 *
30 * Library for establishing connections and transporting FMA events between
31 * ETMs (event-transport modules) in separate fault domains.
32 *
33 * The transport for this library is internet socket based and uses the DSCP
34 * client services library (libdscp).
35 */
36
37#ifndef _EX_DSCP_H
38#define	_EX_DSCP_H
39
40#pragma ident	"%Z%%M%	%I%	%E% SMI"
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46#include <unistd.h>
47#include <strings.h>
48#include <sys/socket.h>
49#include <fcntl.h>
50#include <netdb.h>
51#include <pthread.h>
52#include <errno.h>
53#include <time.h>
54#include <poll.h>
55#include <dlfcn.h>
56#include <libdscp.h>
57#include "etm_xport_api.h"
58
59/* Connection handle */
60typedef struct etm_xport_sock_conn {
61	int c_len;			/* Length of saddr */
62	int c_sd;			/* Socket descriptor */
63	struct sockaddr_in c_saddr;	/* Sockaddr for DSCP connection */
64} exs_conn_t;
65
66/* Transport instance handle */
67typedef struct etm_xport_sock_hdl {
68	exs_conn_t h_client;		/* Sending connection handle */
69	exs_conn_t h_server;		/* Receiving connection handle */
70	pthread_t h_tid;		/* Thread ID of server thread */
71	int h_destroy;			/* Destroy the server thread? */
72	char *h_endpt_id;		/* Endpoint id from ETM common */
73	int h_dom;			/* Domain ID from platform (libdscp) */
74	fmd_hdl_t *h_hdl;		/* fmd handle */
75	int (*h_cb_func)(fmd_hdl_t *, etm_xport_conn_t, etm_cb_flag_t, void *);
76					/* Callback function for ETM common */
77	void *h_cb_func_arg;		/* Arg to pass when calling h_cb_func */
78	int h_quit;			/* Signal to quit */
79	struct etm_xport_sock_hdl *h_next;
80} exs_hdl_t;
81
82#define	EXS_SERVER_PORT 24		/* Port number for server */
83#define	EXS_SERVER_ADDR in6addr_any	/* Address for server */
84#define	EXS_CLIENT_PORT 12		/* Port number for client */
85#define	EXS_NUM_SOCKS 24		/* Length of socket queue */
86#define	EXS_SD_FREE -1			/* Socket descr value when unset */
87#define	EXS_TID_FREE 0			/* Thread ID value when unset */
88#define	EXS_DOMAIN_PREFIX "dom"		/* Domain auth prefix in FMRI string */
89#define	EXS_DOMAIN_PREFIX_LEN 3		/* Length of domain prefix */
90#define	EXS_SP_PREFIX "sp"		/* SP auth prefix in FMRI string */
91#define	EXS_IO_SLEEP_DIV 100		/* Divisor for I/O sleeptime */
92
93#define	EXS_CLOSE_CLR(x) { (void) close(x.c_sd); x.c_sd = EXS_SD_FREE; }
94
95#ifdef __cplusplus
96}
97#endif
98
99#endif /* _EX_DSCP_H */
100