ilbadm_nat.c revision dbed73cbda2229fd1aa6dc5743993cae7f0a7ee9
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
#include <libilb.h>
#include "ilbadm.h"
/*
* For each iteration through the kernel table, ask for at most NUM_ENTRIES
* entries to be returned.
*/
#define NUM_ENTRIES 500
static void
{
char *tmp;
char addr[INET6_ADDRSTRLEN];
tmp = "TCP";
tmp = "UDP";
else
tmp = "Unknown";
} else {
}
}
static void
{
char addr[INET6_ADDRSTRLEN];
} else {
}
}
/* Tell ilbadm_show_info() which table to show. */
enum which_tbl {
show_nat = 1,
};
typedef union {
char *buf;
} show_buf_t;
static ilbadm_status_t
{
int32_t i, num_entries;
/*
* If the user does not specify a count, return the whole table.
* This requires setting the fourth param to ilb_show_nat/persist()
* end to B_FALSE. Otherwise, set end to B_TRUE;
*/
switch (argc) {
case 1:
num_entries = -1;
break;
case 2:
if (num_entries < 1) {
rc = ILBADM_EINVAL;
goto out;
}
break;
default:
rc = ILBADM_EINVAL;
goto out;
}
entry_sz = sizeof (ilb_nat_info_t);
else
entry_sz = sizeof (ilb_persist_info_t);
rc = ILBADM_ENOMEM;
goto out;
}
if (rclib != ILB_STATUS_OK)
goto out;
do {
else
if (rclib != ILB_STATUS_OK)
break;
for (i = 0; i < num; i++) {
else
}
if (num_entries > 0) {
num_entries -= num;
if (num_entries <= 0)
break;
}
} while (!end);
out:
if (h != ILB_INVALID_HANDLE)
(void) ilb_close(h);
if (rclib != ILB_STATUS_OK) {
rc = ILBADM_LIBERR;
}
return (rc);
}
{
}
{
}