ilb_nat.c revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CDDL HEADER START
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The contents of this file are subject to the terms of the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Common Development and Distribution License (the "License").
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * You may not use this file except in compliance with the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * See the License for the specific language governing permissions
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * and limitations under the License.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * When distributing Covered Code, include this CDDL HEADER in each
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * If applicable, add the following below this CDDL HEADER, with the
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * fields enclosed by brackets "[]" replaced with your own identifying
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * information: Portions Copyright [yyyy] [name of copyright owner]
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * CDDL HEADER END
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Use is subject to license terms.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota/* The common function to show kernel info. */
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otastatic ilb_status_t ilb_show_info(ilb_handle_t, char *, size_t *, boolean_t *,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * To get the ILB NAT table.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * buf: The buffer to return the NAT table entries.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * num: The caller sets it to the number of ilb_nat_info_t entries buf can
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * hold. On return, it contains the actual number of entries put in buf.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * end: The caller sets it to B_TRUE if it only wants at most num entries to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * be returned. The transaction to ilbd will be termianted when this
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * call returns.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The caller sets it to B_FALSE if it intends to get the whole table.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * If the whole table has more than num entries, the caller can call
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * this function again to retrieve the rest of the table.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * On return, end is set to B_TRUE if end of table is reached; B_FALSE
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * if there are still remaining entries.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otailb_show_nat(ilb_handle_t h, ilb_nat_info_t buf[], size_t *num,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota return (ilb_show_info(h, (char *)buf, num, end, show_nat));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * To get the ILB persistent entry table.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * buf: The buffer to return the persistent table entries.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * num: The caller sets it to the number of ilb_persist_info_t entries buf can
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * hold. On return, it contains the actual number of entries put in buf.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * end: The caller sets it to B_TRUE if it only wants at most num entries to
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * be returned. The transaction to ilbd will be termianted when this
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * call returns.
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The caller sets it to B_FALSE if it intends to get the whole table.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * If the whole table has more than num entries, the caller can call
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * this function again to retrieve the rest of the table.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * On return, end is set to B_TRUE if end of table is reached; B_FALSE
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * if there are still remaining entries.
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Otailb_show_persist(ilb_handle_t h, ilb_persist_info_t buf[], size_t *num,
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota return (ilb_show_info(h, (char *)buf, num, end, show_persist));
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * The function doing the work... The tbl parameter determines whith table
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Otailb_show_info(ilb_handle_t h, char *buf, size_t *num, boolean_t *end,
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota reqsz = sizeof (ilb_comm_t) + sizeof (ilb_show_info_t);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * Need to allocate a receive buffer and then copy the buffer
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * content to the passed in buf. The reason is that the
cadbfdc3bdb156e92d7a88978bc98ea87f6e037fEiji Ota * communication to ilbd is message based and the protocol
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * includes a header in the reply. We need to remove this header
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota * from the message, hence the copying...
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota rc = i_ilb_do_comm(h, req, reqsz, rbuf, &tmp_rbufsz);
c0dd49bdd68c0d758a67d56f07826f3b45cfc664Eiji Ota bcopy(&tmp_si->sn_data, buf, tmp_si->sn_num * entry_sz);
if (*end) {
out:
return (rc);