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/* The common function to show kernel info. */
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrastatic ilb_status_t ilb_show_info(ilb_handle_t, char *, size_t *, boolean_t *,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * To get the ILB NAT table.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * buf: The buffer to return the NAT table entries.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * num: The caller sets it to the number of ilb_nat_info_t entries buf can
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * hold. On return, it contains the actual number of entries put in buf.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * end: The caller sets it to B_TRUE if it only wants at most num entries to
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * be returned. The transaction to ilbd will be termianted when this
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * call returns.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * The caller sets it to B_FALSE if it intends to get the whole table.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * If the whole table has more than num entries, the caller can call
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * this function again to retrieve the rest of the table.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * On return, end is set to B_TRUE if end of table is reached; B_FALSE
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * if there are still remaining entries.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_show_nat(ilb_handle_t h, ilb_nat_info_t buf[], size_t *num,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra return (ilb_show_info(h, (char *)buf, num, end, show_nat));
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * To get the ILB persistent entry table.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * buf: The buffer to return the persistent table entries.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * num: The caller sets it to the number of ilb_persist_info_t entries buf can
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * hold. On return, it contains the actual number of entries put in buf.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * end: The caller sets it to B_TRUE if it only wants at most num entries to
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * be returned. The transaction to ilbd will be termianted when this
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * call returns.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * The caller sets it to B_FALSE if it intends to get the whole table.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * If the whole table has more than num entries, the caller can call
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * this function again to retrieve the rest of the table.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * On return, end is set to B_TRUE if end of table is reached; B_FALSE
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * if there are still remaining entries.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_show_persist(ilb_handle_t h, ilb_persist_info_t buf[], size_t *num,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra return (ilb_show_info(h, (char *)buf, num, end, show_persist));
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * The function doing the work... The tbl parameter determines whith table
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misrailb_show_info(ilb_handle_t h, char *buf, size_t *num, boolean_t *end,
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra reqsz = sizeof (ilb_comm_t) + sizeof (ilb_show_info_t);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Need to allocate a receive buffer and then copy the buffer
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * content to the passed in buf. The reason is that the
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * communication to ilbd is message based and the protocol
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * includes a header in the reply. We need to remove this header
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * from the message, hence the copying...
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rbufsz = *num * entry_sz + sizeof (ilb_comm_t) +
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra rc = i_ilb_do_comm(h, req, reqsz, rbuf, &tmp_rbufsz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra bcopy(&tmp_si->sn_data, buf, tmp_si->sn_num * entry_sz);
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * Buffer is filled, regardless of this is the end of table or
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra * not, we need to stop.
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra /* Try to fill in the rest. */
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra /* End of transaction, let the caller know. */
dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9Sangeeta Misra /* The user wants to terminate the transaction */