fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "FCSyseventBridge.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "Exceptions.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "Trace.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "AdapterAddEvent.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "AdapterEvent.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "AdapterPortEvent.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "AdapterDeviceEvent.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "TargetEvent.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include "sun_fc.h"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <libnvpair.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <iostream>
f3aaec0a97c3584095582719a0149d5e94c06ea2Richard Lowe#include <climits>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteusing namespace std;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFCSyseventBridge* FCSyseventBridge::_instance = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn ForteFCSyseventBridge* FCSyseventBridge::getInstance() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCSyseventBridge::getInstance");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (_instance == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte _instance = new FCSyseventBridge();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (_instance);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterAddEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterAddEventListeners.insert(adapterAddEventListeners.begin(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validateRegistration();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterEventListener *listener, HBA *hba) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterEventListeners.insert(adapterEventListeners.begin(), listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validateRegistration();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterPortEventListener *listener,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAPort *port) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterPortEventListeners.insert(adapterPortEventListeners.begin(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validateRegistration();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(AdapterDeviceEventListener *listener,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAPort *port) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterDeviceEventListeners.insert(adapterDeviceEventListeners.begin(),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validateRegistration();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::addListener(TargetEventListener *listener,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte HBAPort *port, uint64_t targetWWN, bool filter) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetEventListeners.insert(targetEventListeners.begin(), listener);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte validateRegistration();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterAddEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterAddEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterAddEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterAddEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*tmp == listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterAddEventListeners.erase(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw InvalidHandleException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*tmp == listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterEventListeners.erase(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw InvalidHandleException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterPortEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterPortEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*tmp == listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterPortEventListeners.erase(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw InvalidHandleException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(AdapterDeviceEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterDeviceEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterDeviceEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterDeviceEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*tmp == listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterDeviceEventListeners.erase(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw InvalidHandleException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::removeListener(TargetEventListener *listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<TargetEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = targetEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != targetEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (*tmp == listener) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetEventListeners.erase(tmp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw InvalidHandleException();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteextern "C" void static_dispatch(sysevent_t *ev) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("static_dispatch");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte FCSyseventBridge::getInstance()->dispatch(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::dispatch(sysevent_t *ev) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCSyseventBridge::dispatch");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_t *list = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte hrtime_t when;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (ev == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Null event.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sysevent_get_attr_list(ev, &list) || list == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.debug("Empty event.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventVendor = sysevent_get_vendor_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventPublisher = sysevent_get_pub_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventClass = sysevent_get_class_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string eventSubClass = sysevent_get_subclass_name(ev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sysevent_get_time(ev, &when);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Now that we know what type of event it is, handle it accordingly
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (eventClass == "EC_sunfc") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // All events of this class type have instance and port-wwn for
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // the HBA port.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t instance;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_uint32(list, (char *)"instance",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &instance)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no instance field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *rawPortWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rawPortWWNLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_byte_array(list, (char *)"port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rawPortWWN, &rawPortWWNLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no port-wwn field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Now deal with the specific details of each subclass type
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (eventSubClass == "ESC_sunfc_port_offline") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent::OFFLINE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterPortEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_online") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent::ONLINE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterPortEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_device_online") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterDeviceEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterDeviceEvent::ONLINE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterDeviceEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterDeviceEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterDeviceEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_device_offline") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterDeviceEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterDeviceEvent::OFFLINE,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterDeviceEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterDeviceEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterDeviceEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_rscn") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * RSCNs are a little tricky. There can be multiple
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * affected page properties, each numbered. To make sure
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * we get them all, we loop through all properties
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * in the nvlist and if their name begins with "affected_page_"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * then we send an event for them.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t affected_page;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvpair_t *attr = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (attr = nvlist_next_nvpair(list, NULL);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr != NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte attr = nvlist_next_nvpair(list, attr)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte string name = nvpair_name(attr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (name.find("affected_page_") != name.npos) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvpair_value_uint32(attr, &affected_page)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: "
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "corrupt affected_page field");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte continue;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent::FABRIC,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte affected_page);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterPortEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_target_add") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *rawTargetPortWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rawTargetPortWWNLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_byte_array(list, (char *)"target-port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rawTargetPortWWN, &rawTargetPortWWNLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no target-port-wwn field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterPortEvent::NEW_TARGETS,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 0);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterPortEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterPortEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterPortEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_target_remove") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uchar_t *rawTargetPortWWN;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint32_t rawTargetPortWWNLength;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (nvlist_lookup_byte_array(list, (char *)"target-port-wwn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte &rawTargetPortWWN, &rawTargetPortWWNLength)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Improperly formed event: no target-port-wwn field.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TargetEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawTargetPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte TargetEvent::REMOVED);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<TargetEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = targetEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != targetEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_attach") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterAddEvent event(wwnConversion(rawPortWWN));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterAddEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterAddEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterAddEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (eventSubClass == "ESC_sunfc_port_detach") {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Technically, we should probably try to coalesce
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // all detach events for the same multi-ported adapter
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // and only send one event to the client, but for now,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // we'll just blindly send duplicates.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Create event instance
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterEvent event(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wwnConversion(rawPortWWN),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte AdapterEvent::REMOVE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Dispatch to interested parties.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte lock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte try {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte typedef vector<AdapterEventListener *>::iterator Iter;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (Iter tmp = adapterEventListeners.begin();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte tmp != adapterEventListeners.end(); tmp++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte (*tmp)->dispatch(event);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } catch (...) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte throw;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte unlock();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unrecognized subclass \"%s\": Ignoring event",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventSubClass.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // This should not happen, as we only asked for specific classes.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unrecognized class \"%s\": Ignoring event",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte eventClass.c_str());
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte nvlist_free(list);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortevoid FCSyseventBridge::validateRegistration() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte Trace log("FCSyseventBridge::validateRegistration");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uint64_t count = 0;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte count = adapterAddEventListeners.size() +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterEventListeners.size() +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte adapterPortEventListeners.size() +
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte targetEventListeners.size();
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (count == 1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = sysevent_bind_handle(static_dispatch);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (handle == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to bind sysevent handle.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte const char *subclass_list[9] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_attach",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_detach",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_offline",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_online",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_port_rscn",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_target_add",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_target_remove",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_device_online",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ESC_sunfc_device_offline"
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte };
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (sysevent_subscribe_event(handle,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "EC_sunfc", (const char **)subclass_list, 9)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte log.genericIOError(
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "Unable to subscribe to sun_fc events.");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sysevent_unbind_handle(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle = NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else if (count == 0 && handle != NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte // Remove subscription
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sysevent_unbind_handle(handle);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte handle == NULL;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } // Else do nothing
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteint32_t FCSyseventBridge::getMaxListener() {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (INT_MAX);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}