dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * CDDL HEADER START
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * The contents of this file are subject to the terms of the
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Common Development and Distribution License (the "License").
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * You may not use this file except in compliance with the License.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * or http://www.opensolaris.org/os/licensing.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * See the License for the specific language governing permissions
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * and limitations under the License.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * When distributing Covered Code, include this CDDL HEADER in each
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * If applicable, add the following below this CDDL HEADER, with the
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * fields enclosed by brackets "[]" replaced with your own identifying
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * information: Portions Copyright [yyyy] [name of copyright owner]
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * CDDL HEADER END
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Use is subject to license terms.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Create a health check, returning a health check handle upon success.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Health check created will be recorded in persistent datastore.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_create_hc(ilb_handle_t h, const ilb_hc_info_t *hc)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if (h == ILB_INVALID_HANDLE || hc == NULL || *hc->hci_name == '\0' ||
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra hc->hci_interval <= hc->hci_timeout * hc->hci_count)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if ((ic = i_ilb_alloc_req(ILBD_CREATE_HC, &ic_sz)) == NULL)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra (void) memcpy(&ic->ic_data, hc, sizeof (ilb_hc_info_t));
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_do_comm(h, ic, ic_sz, ic, &ic_sz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Given a health check handle, destroy the corresponding health check.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Persistent datastore will be updated as well.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_destroy_hc(ilb_handle_t h, const char *hcname)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if (h == ILB_INVALID_HANDLE || hcname == NULL || *hcname == '\0')
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if ((ic = i_ilb_alloc_req(ILBD_DESTROY_HC, &ic_sz)) == NULL)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra (void) strlcpy((char *)&ic->ic_data, hcname, sizeof (ilbd_name_t));
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_do_comm(h, ic, ic_sz, ic, &ic_sz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Given a health check name, get hc info associated with this handle
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_get_hc_info(ilb_handle_t h, const char *name, ilb_hc_info_t *hcp)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if (h == ILB_INVALID_HANDLE || name == NULL || hcp == NULL)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if ((ic = i_ilb_alloc_req(ILBD_GET_HC_INFO, &ic_sz)) == NULL)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rbufsz = sizeof (ilb_comm_t) + sizeof (ilb_hc_info_t);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra (void) strlcpy((char *)&ic->ic_data, name, sizeof (ilbd_name_t));
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_do_comm(h, ic, ic_sz, rbuf, &rbufsz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra (void) memcpy(hcp, &rbuf->ic_data, sizeof (*hcp));
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Walk through all health checks, will need if we implement list-hc
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_walk_hc(ilb_handle_t h, hc_walkerfunc_t func, void *arg)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_do_comm(h, &ic, sizeof (ic), rbuf, &rbufsz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra hc_names = (ilbd_namelist_t *)&rbuf->ic_data;
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = ilb_get_hc_info(h, hc_names->ilbl_name[i], &hc_info);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Since getting the list of hc names and getting the info
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * of each of them are not atomic, some hc objects may have
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * been deleted. If this is the case, just skip them.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_get_hc_srvs(ilb_handle_t h, const char *rulename, ilb_comm_t **rbuf,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra if ((ic = i_ilb_alloc_req(ILBD_GET_HC_SRVS, &ic_sz)) == NULL)
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra (void) strlcpy((char *)&ic->ic_data, rulename,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_do_comm(h, ic, ic_sz, tmp_rbuf, rbufsz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_walk_hc_srvs(ilb_handle_t h, hc_srvwalkerfunc_t fn, const char *rulename,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = ilb_get_hc_srvs(h, rulename, &rbuf, &rbufsz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_retrieve_rule_names(h, &rbuf, &rbufsz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra /* Not all rules have HC, so reset the error to OK. */