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