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.
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.
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]
22 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #ifndef _FCSYSEVENTBRIDGE_H
27 #define _FCSYSEVENTBRIDGE_H
31 #include "AdapterAddEventBridge.h"
32 #include "AdapterEventBridge.h"
33 #include "AdapterPortEventBridge.h"
34 #include "AdapterDeviceEventBridge.h"
35 #include "TargetEventBridge.h"
38 #include <libsysevent.h>
41 * Note: Even though we take various arguments in within the API,
42 * we don't actually filter anything, since sys-even is either on
43 * or off. The idea is that the actual Listener themselves will perform
44 * a final filter pass, so why do the work twice. If we were going to
45 * use proprietary IOCTLs or some other event plumbing that allowed filtering,
46 * we could use the passed in arguments to do useful work. In short,
47 * once turned on, we send events of a given type and rely on
48 * someone downstream to filter.
50 class FCSyseventBridge
:
51 public AdapterAddEventBridge
,
52 public AdapterEventBridge
,
53 public AdapterPortEventBridge
,
54 public AdapterDeviceEventBridge
,
55 public TargetEventBridge
,
58 static FCSyseventBridge
* getInstance();
59 virtual int32_t getMaxListener();
60 virtual void addListener(AdapterAddEventListener
*listener
);
61 virtual void addListener(AdapterEventListener
*listener
, HBA
*hba
);
62 virtual void addListener(AdapterPortEventListener
*listener
, HBAPort
*port
);
63 virtual void addListener(AdapterDeviceEventListener
*listener
,
65 virtual void addListener(TargetEventListener
*listener
,
66 HBAPort
*port
, uint64_t targetWWN
, bool filter
);
67 virtual void removeListener(AdapterAddEventListener
*listener
);
68 virtual void removeListener(AdapterEventListener
*listener
);
69 virtual void removeListener(AdapterPortEventListener
*listener
);
70 virtual void removeListener(AdapterDeviceEventListener
*listener
);
71 virtual void removeListener(TargetEventListener
*listener
);
73 /* Private function, called by handler. Friend maybe? */
74 void dispatch(sysevent_t
*ev
);
77 FCSyseventBridge() :handle(NULL
) { }
79 * Subscribe if we need to, or unsubscribe if nobody is left
80 * Instance lock must already be held!
82 void validateRegistration();
83 sysevent_handle_t
*handle
;
84 static FCSyseventBridge
* _instance
;
87 std::vector
<AdapterAddEventListener
*> adapterAddEventListeners
;
88 std::vector
<AdapterEventListener
*> adapterEventListeners
;
89 std::vector
<AdapterPortEventListener
*> adapterPortEventListeners
;
90 std::vector
<AdapterDeviceEventListener
*> adapterDeviceEventListeners
;
91 std::vector
<TargetEventListener
*> targetEventListeners
;
94 #endif /* _FCSYSEVENTBRIDGE_H */