1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26fcf3ce44SJohn Forte #ifndef	_FCSYSEVENTBRIDGE_H
27fcf3ce44SJohn Forte #define	_FCSYSEVENTBRIDGE_H
28fcf3ce44SJohn Forte 
29fcf3ce44SJohn Forte 
30fcf3ce44SJohn Forte 
31fcf3ce44SJohn Forte #include "AdapterAddEventBridge.h"
32fcf3ce44SJohn Forte #include "AdapterEventBridge.h"
33fcf3ce44SJohn Forte #include "AdapterPortEventBridge.h"
34fcf3ce44SJohn Forte #include "AdapterDeviceEventBridge.h"
35fcf3ce44SJohn Forte #include "TargetEventBridge.h"
36fcf3ce44SJohn Forte #include "Lockable.h"
37fcf3ce44SJohn Forte #include <vector>
38fcf3ce44SJohn Forte #include <libsysevent.h>
39fcf3ce44SJohn Forte 
40fcf3ce44SJohn Forte /**
41*55fea89dSDan Cross  * Note: Even though we take various arguments in within the API,
42fcf3ce44SJohn Forte  * we don't actually filter anything, since sys-even is either on
43fcf3ce44SJohn Forte  * or off.  The idea is that the actual Listener themselves will perform
44*55fea89dSDan Cross  * a final filter pass, so why do the work twice.  If we were going to
45fcf3ce44SJohn Forte  * use proprietary IOCTLs or some other event plumbing that allowed filtering,
46*55fea89dSDan Cross  * we could use the passed in arguments to do useful work.  In short,
47*55fea89dSDan Cross  * once turned on, we send events of a given type and rely on
48fcf3ce44SJohn Forte  * someone downstream to filter.
49fcf3ce44SJohn Forte  */
50fcf3ce44SJohn Forte class FCSyseventBridge :
51fcf3ce44SJohn Forte 	public AdapterAddEventBridge,
52fcf3ce44SJohn Forte 	public AdapterEventBridge,
53fcf3ce44SJohn Forte 	public AdapterPortEventBridge,
54fcf3ce44SJohn Forte 	public AdapterDeviceEventBridge,
55fcf3ce44SJohn Forte 	public TargetEventBridge,
56fcf3ce44SJohn Forte 	public Lockable {
57fcf3ce44SJohn Forte public:
58fcf3ce44SJohn Forte     static FCSyseventBridge* getInstance();
59fcf3ce44SJohn Forte     virtual int32_t getMaxListener();
60fcf3ce44SJohn Forte     virtual void addListener(AdapterAddEventListener *listener);
61fcf3ce44SJohn Forte     virtual void addListener(AdapterEventListener *listener, HBA *hba);
62fcf3ce44SJohn Forte     virtual void addListener(AdapterPortEventListener *listener, HBAPort *port);
63fcf3ce44SJohn Forte     virtual void addListener(AdapterDeviceEventListener *listener,
64fcf3ce44SJohn Forte 	     HBAPort *port);
65fcf3ce44SJohn Forte     virtual void addListener(TargetEventListener *listener,
66fcf3ce44SJohn Forte 	    HBAPort *port, uint64_t targetWWN, bool filter);
67fcf3ce44SJohn Forte     virtual void removeListener(AdapterAddEventListener *listener);
68fcf3ce44SJohn Forte     virtual void removeListener(AdapterEventListener *listener);
69fcf3ce44SJohn Forte     virtual void removeListener(AdapterPortEventListener *listener);
70fcf3ce44SJohn Forte     virtual void removeListener(AdapterDeviceEventListener *listener);
71fcf3ce44SJohn Forte     virtual void removeListener(TargetEventListener *listener);
72fcf3ce44SJohn Forte 
73fcf3ce44SJohn Forte     /* Private function, called by handler.  Friend maybe? */
74fcf3ce44SJohn Forte     void dispatch(sysevent_t *ev);
75fcf3ce44SJohn Forte 
76fcf3ce44SJohn Forte private:
FCSyseventBridge()77fcf3ce44SJohn Forte     FCSyseventBridge() :handle(NULL) { }
78fcf3ce44SJohn Forte     /**
79fcf3ce44SJohn Forte      * Subscribe if we need to, or unsubscribe if nobody is left
80fcf3ce44SJohn Forte      * Instance lock must already be held!
81fcf3ce44SJohn Forte      */
82fcf3ce44SJohn Forte     void validateRegistration();
83fcf3ce44SJohn Forte     sysevent_handle_t *handle;
84fcf3ce44SJohn Forte     static FCSyseventBridge*	_instance;
85*55fea89dSDan Cross 
86fcf3ce44SJohn Forte 
87fcf3ce44SJohn Forte     std::vector<AdapterAddEventListener*>	adapterAddEventListeners;
88fcf3ce44SJohn Forte     std::vector<AdapterEventListener*>		adapterEventListeners;
89fcf3ce44SJohn Forte     std::vector<AdapterPortEventListener*>	adapterPortEventListeners;
90fcf3ce44SJohn Forte     std::vector<AdapterDeviceEventListener*>	adapterDeviceEventListeners;
91fcf3ce44SJohn Forte     std::vector<TargetEventListener*>		targetEventListeners;
92fcf3ce44SJohn Forte };
93fcf3ce44SJohn Forte 
94fcf3ce44SJohn Forte #endif /* _FCSYSEVENTBRIDGE_H */
95