1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
/*
* 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
* or http://www.opensolaris.org/os/licensing.
* 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.
*/
#ifndef _ILBADM_H
#define _ILBADM_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <sys/list.h>
#include <net/if.h>
#include <stdarg.h>
#include <inttypes.h>
#include <libilb.h>
#include <libintl.h>
#include <locale.h>
#define ILBADM_VERSION "1.0"
#define ILBADM_COPYRIGHT \
"Copyright 2009 Sun Microsystems, Inc. All rights reserved.\n" \
"Use is subject to license terms.\n"
/*
* flag values
*/
#define OPT_VALUE_LIST 0x0001
#define OPT_IP_RANGE 0x0002
#define OPT_PORTS 0x0004
#define OPT_PORTS_ONLY 0x0008
#define OPT_NAT 0x0010
#define OPT_NUMERIC_ONLY 0x0020
#define ILBD_BAD_VAL (-1)
#define ILBADM_LIST_FULL 0x0001
#define ILBADM_LIST_PARSE 0x0002
#define ILBADM_LIST_ENABLED 0x0004
#define ILBADM_LIST_NOENABLED (~ILBADM_LIST_ENABLED)
#define ILBADM_LIST_DISABLED 0x0008
#define ILBADM_LIST_NODISABLED (~ILBADM_LIST_DISABLED)
#define ILBADM_IMPORT_PRESERVE 0x1000
#define V6_ADDRONLY 0x1 /* don't print surrounding "[]"s */
#define ILB_SRVID_SZ (ILB_NAMESZ - 5)
#define ILBD_NAMESZ ILB_NAMESZ
#define ILB_MAX_PORT UINT16_MAX
typedef enum {
ILBADM_OK = 0,
ILBADM_ASSIGNREQ, /* assignment '=' required */
ILBADM_EINVAL, /* invalid value */
ILBADM_ENOMEM, /* malloc failed */
ILBADM_ENOOPTION, /* mandatory option missing */
ILBADM_ENOPROTO, /* protocol not found in database */
ILBADM_ENOPROXY, /* proxy-src is missing */
ILBADM_ENOSERVICE, /* servicename not found in database */
ILBADM_ENOSGNAME, /* servergroup name missing */
ILBADM_ENORULE, /* rulename missing or no such rule */
ILBADM_ENOSERVER, /* rulename missing or no such rule */
ILBADM_EXPORTFAIL, /* too little space to do export servergroup */
ILBADM_FAIL, /* processing of command failed */
ILBADM_HCPRINT, /* failed to print healthcheck */
ILBADM_INVAL_ADDR, /* invalid address */
ILBADM_INVAL_AF, /* invalid address family */
ILBADM_INVAL_ALG, /* LB algorithm failure */
ILBADM_INVAL_ARGS, /* invalid arguments to command */
ILBADM_INVAL_COMMAND, /* invalid command */
ILBADM_INVAL_KEYWORD, /* invalid keyword */
ILBADM_INVAL_OPER, /* invalid operation type */
ILBADM_INVAL_PORT, /* invalid value specified for port */
ILBADM_INVAL_PROXY, /* proxy-src not allowed */
ILBADM_INVAL_SYNTAX, /* syntax error */
ILBADM_INVAL_SRVID, /* server id is invalid (missing "_" ?) */
ILBADM_LIBERR, /* translation of libilb errors. We also */
/* set it in ilbadm fuctions to indicate */
/* printing of non-generic error messages */
ILBADM_NORECURSIVE, /* recursive import not allowed */
ILBADM_TOOMANYIPADDR, /* too many addresses */
ILBADM_NOKEYWORD_VAL /* no value specified for a keyword */
} ilbadm_status_t;
typedef enum {
ILB_KEY_BAD = -1,
ILB_KEY_SERVER,
ILB_KEY_SERVRANGE, /* pseudo-key for SG creation */
ILB_KEY_SERVERID,
ILB_KEY_VIP,
ILB_KEY_PORT,
ILB_KEY_PROTOCOL,
ILB_KEY_IPVERSION,
ILB_KEY_ALGORITHM,
ILB_KEY_TYPE,
ILB_KEY_SERVERGROUP,
ILB_KEY_HEALTHCHECK,
ILB_KEY_HCPORT,
ILB_KEY_SRC,
ILB_KEY_STICKY,
ILB_KEY_CONNDRAIN, /* otional timers ... */
ILB_KEY_NAT_TO,
ILB_KEY_STICKY_TO,
ILB_KEY_HC_TEST,
ILB_KEY_HC_COUNT,
ILB_KEY_HC_INTERVAL,
ILB_KEY_HC_TIMEOUT
} ilbadm_key_code_t;
/*
* we need a few codes for commands, can't use libilb ones
*/
typedef enum {
cmd_create_sg,
cmd_add_srv,
cmd_rem_srv,
cmd_enable_rule,
cmd_disable_rule,
cmd_enable_server,
cmd_disable_server
} ilbadm_cmd_t;
/* filched from snoop_ether.c */
typedef struct val_type {
int v_type;
char v_name[20];
char v_alias[8]; /* undocumented */
} ilbadm_val_type_t;
typedef struct key_names {
ilbadm_key_code_t k_key;
char k_name[20];
char k_alias[12]; /* undocumented */
} ilbadm_key_name_t;
typedef struct servnode {
list_node_t s_link;
ilb_server_data_t s_spec;
} ilbadm_servnode_t;
typedef struct sgroup {
list_t sg_serv_list; /* list of servnode_t elements */
int sg_count;
char *sg_name;
} ilbadm_sgroup_t;
typedef struct cmd_hlp {
char *h_help;
} ilbadm_cmd_help_t;
typedef ilbadm_status_t (* cmdfunc_t)(int, char **);
typedef struct cmd_names {
char c_name[25];
char c_alias[20]; /* undocumented */
cmdfunc_t c_action;
ilbadm_cmd_help_t *c_help; /* for "usage" */
} ilbadm_cmd_desc_t;
ilbadm_status_t ilbadm_add_server_to_group(int, char **);
ilbadm_status_t ilbadm_create_servergroup(int, char **);
ilbadm_status_t ilbadm_destroy_servergroup(int, char **);
ilbadm_status_t ilbadm_rem_server_from_group(int, char **);
ilbadm_status_t ilbadm_create_rule(int, char **);
ilbadm_status_t ilbadm_destroy_rule(int, char **);
ilbadm_status_t ilbadm_enable_rule(int, char **);
ilbadm_status_t ilbadm_disable_rule(int, char **);
ilbadm_status_t ilbadm_show_server(int, char **);
ilbadm_status_t ilbadm_enable_server(int, char **);
ilbadm_status_t ilbadm_disable_server(int, char **);
ilbadm_status_t ilbadm_show_servergroups(int, char **);
ilbadm_status_t ilbadm_show_rules(int, char **);
ilbadm_status_t ilbadm_show_stats(int, char **);
ilbadm_status_t ilbadm_create_hc(int, char **);
ilbadm_status_t ilbadm_destroy_hc(int, char **);
ilbadm_status_t ilbadm_show_hc(int, char **);
ilbadm_status_t ilbadm_show_hc_result(int, char **);
ilbadm_status_t ilbadm_noimport(int, char **);
ilbadm_status_t ilbadm_show_nat(int, char **);
ilbadm_status_t ilbadm_show_persist(int, char **);
ilbadm_status_t i_parse_optstring(char *, void *, ilbadm_key_name_t *,
int, int *);
ilbadm_servnode_t *i_new_sg_elem(ilbadm_sgroup_t *);
ilbadm_status_t ilbadm_import(int, int, char *[], int);
ilbadm_status_t ilbadm_export(int, char *[]);
ilbadm_status_t ilbadm_export_servergroups(ilb_handle_t h, FILE *);
ilbadm_status_t ilbadm_export_hc(ilb_handle_t h, FILE *);
ilbadm_status_t ilbadm_export_rules(ilb_handle_t h, FILE *);
ilbadm_status_t i_check_rule_spec(ilb_rule_data_t *);
ilbadm_status_t ilbadm_set_netmask(char *, ilb_ip_addr_t *, int);
int ilbadm_mask_to_prefixlen(ilb_ip_addr_t *);
void print_cmdlist_short(char *, FILE *);
extern int ilb_cmp_ipaddr(ilb_ip_addr_t *, ilb_ip_addr_t *,
longlong_t *);
void ip2str(ilb_ip_addr_t *, char *, size_t, int);
char *i_str_from_val(int, ilbadm_val_type_t *);
char *ilbadm_key_to_opt(ilbadm_key_code_t);
void Usage(char *);
void unknown_opt(char **, int);
const char *ilbadm_errstr(ilbadm_status_t);
void ilbadm_err(const char *format, ...);
#ifdef __cplusplus
}
#endif
#endif /* _ILBADM_H */
|