4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
42 #define ILBADM_VERSION "1.0"
43 #define ILBADM_COPYRIGHT \
44 "Copyright 2009 Sun Microsystems, Inc. All rights reserved.\n" \
45 "Use is subject to license terms.\n"
50 #define OPT_VALUE_LIST 0x0001
51 #define OPT_IP_RANGE 0x0002
52 #define OPT_PORTS 0x0004
53 #define OPT_PORTS_ONLY 0x0008
54 #define OPT_NAT 0x0010
55 #define OPT_NUMERIC_ONLY 0x0020
57 #define ILBD_BAD_VAL (-1)
59 #define ILBADM_LIST_FULL 0x0001
60 #define ILBADM_LIST_PARSE 0x0002
61 #define ILBADM_LIST_ENABLED 0x0004
62 #define ILBADM_LIST_NOENABLED (~ILBADM_LIST_ENABLED)
63 #define ILBADM_LIST_DISABLED 0x0008
64 #define ILBADM_LIST_NODISABLED (~ILBADM_LIST_DISABLED)
66 #define ILBADM_IMPORT_PRESERVE 0x1000
68 #define V6_ADDRONLY 0x1 /* don't print surrounding "[]"s */
70 #define ILB_SRVID_SZ (ILB_NAMESZ - 5)
71 #define ILBD_NAMESZ ILB_NAMESZ
73 #define ILB_MAX_PORT UINT16_MAX
77 ILBADM_ASSIGNREQ
, /* assignment '=' required */
78 ILBADM_EINVAL
, /* invalid value */
79 ILBADM_ENOMEM
, /* malloc failed */
80 ILBADM_ENOOPTION
, /* mandatory option missing */
81 ILBADM_ENOPROTO
, /* protocol not found in database */
82 ILBADM_ENOPROXY
, /* proxy-src is missing */
83 ILBADM_ENOSERVICE
, /* servicename not found in database */
84 ILBADM_ENOSGNAME
, /* servergroup name missing */
85 ILBADM_ENORULE
, /* rulename missing or no such rule */
86 ILBADM_ENOSERVER
, /* rulename missing or no such rule */
87 ILBADM_EXPORTFAIL
, /* too little space to do export servergroup */
88 ILBADM_FAIL
, /* processing of command failed */
89 ILBADM_HCPRINT
, /* failed to print healthcheck */
90 ILBADM_INVAL_ADDR
, /* invalid address */
91 ILBADM_INVAL_AF
, /* invalid address family */
92 ILBADM_INVAL_ALG
, /* LB algorithm failure */
93 ILBADM_INVAL_ARGS
, /* invalid arguments to command */
94 ILBADM_INVAL_COMMAND
, /* invalid command */
95 ILBADM_INVAL_KEYWORD
, /* invalid keyword */
96 ILBADM_INVAL_OPER
, /* invalid operation type */
97 ILBADM_INVAL_PORT
, /* invalid value specified for port */
98 ILBADM_INVAL_PROXY
, /* proxy-src not allowed */
99 ILBADM_INVAL_SYNTAX
, /* syntax error */
100 ILBADM_INVAL_SRVID
, /* server id is invalid (missing "_" ?) */
101 ILBADM_LIBERR
, /* translation of libilb errors. We also */
102 /* set it in ilbadm fuctions to indicate */
103 /* printing of non-generic error messages */
104 ILBADM_NORECURSIVE
, /* recursive import not allowed */
105 ILBADM_TOOMANYIPADDR
, /* too many addresses */
106 ILBADM_NOKEYWORD_VAL
/* no value specified for a keyword */
113 ILB_KEY_SERVRANGE
, /* pseudo-key for SG creation */
126 ILB_KEY_CONNDRAIN
, /* otional timers ... */
136 * we need a few codes for commands, can't use libilb ones
148 /* filched from snoop_ether.c */
149 typedef struct val_type
{
152 char v_alias
[8]; /* undocumented */
155 typedef struct key_names
{
156 ilbadm_key_code_t k_key
;
158 char k_alias
[12]; /* undocumented */
161 typedef struct servnode
{
163 ilb_server_data_t s_spec
;
166 typedef struct sgroup
{
167 list_t sg_serv_list
; /* list of servnode_t elements */
172 typedef struct cmd_hlp
{
176 typedef ilbadm_status_t (* cmdfunc_t
)(int, char **);
178 typedef struct cmd_names
{
180 char c_alias
[20]; /* undocumented */
182 ilbadm_cmd_help_t
*c_help
; /* for "usage" */
185 ilbadm_status_t
ilbadm_add_server_to_group(int, char **);
186 ilbadm_status_t
ilbadm_create_servergroup(int, char **);
187 ilbadm_status_t
ilbadm_destroy_servergroup(int, char **);
188 ilbadm_status_t
ilbadm_rem_server_from_group(int, char **);
190 ilbadm_status_t
ilbadm_create_rule(int, char **);
191 ilbadm_status_t
ilbadm_destroy_rule(int, char **);
192 ilbadm_status_t
ilbadm_enable_rule(int, char **);
193 ilbadm_status_t
ilbadm_disable_rule(int, char **);
194 ilbadm_status_t
ilbadm_show_server(int, char **);
195 ilbadm_status_t
ilbadm_enable_server(int, char **);
196 ilbadm_status_t
ilbadm_disable_server(int, char **);
198 ilbadm_status_t
ilbadm_show_servergroups(int, char **);
199 ilbadm_status_t
ilbadm_show_rules(int, char **);
200 ilbadm_status_t
ilbadm_show_stats(int, char **);
202 ilbadm_status_t
ilbadm_create_hc(int, char **);
203 ilbadm_status_t
ilbadm_destroy_hc(int, char **);
204 ilbadm_status_t
ilbadm_show_hc(int, char **);
205 ilbadm_status_t
ilbadm_show_hc_result(int, char **);
207 ilbadm_status_t
ilbadm_noimport(int, char **);
209 ilbadm_status_t
ilbadm_show_nat(int, char **);
210 ilbadm_status_t
ilbadm_show_persist(int, char **);
212 ilbadm_status_t
i_parse_optstring(char *, void *, ilbadm_key_name_t
*,
214 ilbadm_servnode_t
*i_new_sg_elem(ilbadm_sgroup_t
*);
215 ilbadm_status_t
ilbadm_import(int, int, char *[], int);
216 ilbadm_status_t
ilbadm_export(int, char *[]);
217 ilbadm_status_t
ilbadm_export_servergroups(ilb_handle_t h
, FILE *);
218 ilbadm_status_t
ilbadm_export_hc(ilb_handle_t h
, FILE *);
219 ilbadm_status_t
ilbadm_export_rules(ilb_handle_t h
, FILE *);
221 ilbadm_status_t
i_check_rule_spec(ilb_rule_data_t
*);
222 ilbadm_status_t
ilbadm_set_netmask(char *, ilb_ip_addr_t
*, int);
223 int ilbadm_mask_to_prefixlen(ilb_ip_addr_t
*);
225 void print_cmdlist_short(char *, FILE *);
226 extern int ilb_cmp_ipaddr(ilb_ip_addr_t
*, ilb_ip_addr_t
*,
229 void ip2str(ilb_ip_addr_t
*, char *, size_t, int);
230 char *i_str_from_val(int, ilbadm_val_type_t
*);
231 char *ilbadm_key_to_opt(ilbadm_key_code_t
);
234 void unknown_opt(char **, int);
235 const char *ilbadm_errstr(ilbadm_status_t
);
236 void ilbadm_err(const char *format
, ...);
242 #endif /* _ILBADM_H */