xref: /illumos-gate/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.h (revision 14b24e2b79293068c8e016a69ef1d872fb5e2fd5)
1 /*
2  * CDDL HEADER START
3  *
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.
7  *
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.
12  *
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]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  * Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
26  */
27 
28 #ifndef _NWAMCFG_H
29 #define	_NWAMCFG_H
30 
31 /*
32  * header file for nwamcfg command
33  */
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define	NWAM_OK			0
40 #define	NWAM_ERR		1
41 #define	NWAM_REPEAT		2
42 
43 /* max length of "ncu", "ncp", "loc", "enm", "wlan" */
44 #define	NWAM_MAX_TYPE_LEN	5
45 
46 #define	CMD_CANCEL		0
47 #define	CMD_CLEAR		1
48 #define	CMD_COMMIT		2
49 #define	CMD_CREATE		3
50 #define	CMD_DESTROY		4
51 #define	CMD_END			5
52 #define	CMD_EXIT		6
53 #define	CMD_EXPORT		7
54 #define	CMD_GET			8
55 #define	CMD_HELP		9
56 #define	CMD_LIST		10
57 #define	CMD_REVERT		11
58 #define	CMD_SELECT		12
59 #define	CMD_SET			13
60 #define	CMD_VERIFY		14
61 #define	CMD_WALKPROP		15
62 
63 #define	CMD_MIN	CMD_CANCEL
64 #define	CMD_MAX	CMD_WALKPROP
65 
66 /* one-level resource types */
67 #define	RT1_UNKNOWN		0
68 #define	RT1_LOC			1
69 #define	RT1_NCP			2
70 #define	RT1_ENM			3
71 #define	RT1_WLAN		4
72 
73 #define	RT1_MIN			RT1_UNKNOWN
74 #define	RT1_MAX			RT1_WLAN
75 
76 /* two-level resource types */
77 #define	RT2_UNKNOWN		0
78 #define	RT2_NCU			1
79 
80 #define	RT2_MIN			RT2_UNKNOWN
81 #define	RT2_MAX			RT2_NCU
82 
83 /* class types for NCU's */
84 #define	NCU_CLASS_PHYS		0
85 #define	NCU_CLASS_IP		1
86 #define	NCU_CLASS_ANY		2
87 
88 #define	NCU_CLASS_MIN		NCU_CLASS_PHYS
89 #define	NCU_CLASS_MAX		NCU_CLASS_ANY
90 
91 /* property types, matches NWAM_*_PROP_* from libnwam.h */
92 #define	PT_UNKNOWN		0
93 #define	PT_ACTIVATION_MODE	1
94 #define	PT_ENABLED		2
95 #define	PT_TYPE			3
96 #define	PT_CLASS		4
97 #define	PT_PARENT		5
98 #define	PT_PRIORITY_GROUP	6
99 #define	PT_PRIORITY_MODE	7
100 #define	PT_LINK_MACADDR		8
101 #define	PT_LINK_AUTOPUSH	9
102 #define	PT_LINK_MTU		10
103 #define	PT_IP_VERSION		11
104 #define	PT_IPV4_ADDRSRC		12
105 #define	PT_IPV4_ADDR		13
106 #define	PT_IPV4_DEFAULT_ROUTE	14
107 #define	PT_IPV6_ADDRSRC		15
108 #define	PT_IPV6_ADDR		16
109 #define	PT_IPV6_DEFAULT_ROUTE	17
110 #define	PT_CONDITIONS		18
111 #define	PT_ENM_FMRI		19
112 #define	PT_ENM_START		20
113 #define	PT_ENM_STOP		21
114 #define	PT_LOC_NAMESERVICES	22
115 #define	PT_LOC_NAMESERVICES_CONFIG 23
116 #define	PT_LOC_DNS_CONFIGSRC	24
117 #define	PT_LOC_DNS_DOMAIN	25
118 #define	PT_LOC_DNS_SERVERS	26
119 #define	PT_LOC_DNS_SEARCH	27
120 #define	PT_LOC_NIS_CONFIGSRC	28
121 #define	PT_LOC_NIS_SERVERS	29
122 #define	PT_LOC_LDAP_CONFIGSRC	30
123 #define	PT_LOC_LDAP_SERVERS	31
124 #define	PT_LOC_DEFAULT_DOMAIN	32
125 #define	PT_LOC_NFSV4_DOMAIN	33
126 #define	PT_LOC_IPF_CONFIG	34
127 #define	PT_LOC_IPF_V6_CONFIG	35
128 #define	PT_LOC_IPNAT_CONFIG	36
129 #define	PT_LOC_IPPOOL_CONFIG	37
130 #define	PT_LOC_IKE_CONFIG	38
131 #define	PT_LOC_IPSECPOL_CONFIG	39
132 #define	PT_WLAN_BSSIDS		40
133 #define	PT_WLAN_PRIORITY	41
134 #define	PT_WLAN_KEYNAME		42
135 #define	PT_WLAN_KEYSLOT		43
136 #define	PT_WLAN_SECURITY_MODE	44
137 #define	PT_IP_PRIMARY		45
138 #define	PT_IP_REQHOST		46
139 /*
140  * If any new PT_ are defined here, make sure it is added in the same
141  * order into the pt_types array in nwamcfg.c
142  */
143 #define	PT_MIN			PT_UNKNOWN
144 #define	PT_MAX			PT_IP_REQHOST
145 
146 #define	MAX_SUBCMD_ARGS	3
147 
148 typedef struct cmd {
149 	int	cmd_num;
150 	void	(*cmd_handler)(struct cmd *);
151 	int	cmd_res1_type;
152 	int	cmd_res2_type;
153 	int	cmd_prop_type;
154 	int	cmd_ncu_class_type;
155 	int	cmd_argc;
156 	char	*cmd_argv[MAX_SUBCMD_ARGS + 1];
157 } cmd_t;
158 
159 /* Fuctions for each command */
160 typedef void (cmd_func_t)(cmd_t *);
161 
162 extern cmd_func_t cancel_func, clear_func, commit_func, create_func;
163 extern cmd_func_t destroy_func, end_func, exit_func, export_func, get_func;
164 extern cmd_func_t help_func, list_func, revert_func, select_func, set_func;
165 extern cmd_func_t verify_func, walkprop_func;
166 
167 extern cmd_t *alloc_cmd(void);
168 extern void free_cmd(cmd_t *cmd);
169 
170 extern boolean_t check_scope(int);
171 extern const char *cmd_to_str(int);
172 
173 extern void nerr(const char *, ...);
174 extern void properr(const char *);
175 
176 extern boolean_t saw_error;
177 
178 extern FILE *yyin;
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif	/* _NWAMCFG_H */
185