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 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #pragma ident "%Z%%M% %I% %E% SMI"
27
28 #include <sys/param.h>
29 #include <sys/types.h>
30 #include <sys/systm.h>
31 #include <sys/cred.h>
32 #include <sys/user.h>
33 #include <sys/file.h>
34 #include <sys/stream.h>
35 #include <sys/strsubr.h>
36 #include <sys/stropts.h>
37 #include <sys/strsun.h>
38 #include <sys/debug.h>
39 #include <sys/tiuser.h>
40 #include <sys/sockio.h>
41 #include <sys/socket.h>
42 #include <sys/t_kuser.h>
43 #include <sys/utsname.h>
44 #include <sys/systeminfo.h>
45 #include <sys/netconfig.h>
46 #include <sys/ethernet.h>
47 #include <sys/dlpi.h>
145 struct mountres3 {
146 enum mountstat3 fhs_status;
147 union {
148 struct mountres3_ok mountinfo;
149 } mountres3_u;
150 };
151
152 /*
153 * DLPI address format.
154 */
155 struct dladdr {
156 uchar_t dl_phys[6];
157 ushort_t dl_sap;
158 };
159
160 static struct modlmisc modlmisc = {
161 &mod_miscops, "Boot diskless"
162 };
163
164 static struct modlinkage modlinkage = {
165 MODREV_1, (void *)&modlmisc, NULL
166 };
167
168 static int dldebug;
169
170 int
171 _init(void)
172 {
173 return (mod_install(&modlinkage));
174 }
175
176 int
177 _fini(void)
178 {
179 return (mod_remove(&modlinkage));
180 }
181
182 int
183 _info(struct modinfo *modinfop)
184 {
185 return (mod_info(&modlinkage, modinfop));
221 static void init_netbuf(struct netbuf *);
222 static void free_netbuf(struct netbuf *);
223 static int rtioctl(TIUSER *, int, struct rtentry *);
224 static void init_config(void);
225
226 static void cacheinit(void);
227 static int cacheinfo(char *, int, struct netbuf *, char *, int);
228 static int dlifconfig(TIUSER *, struct in_addr *, struct in_addr *,
229 struct in_addr *, uint_t);
230 static int setifflags(TIUSER *, uint_t);
231
232 static char *inet_ntoa(struct in_addr);
233 static int inet_aton(char *, uchar_t *);
234 static int isdigit(int);
235
236 /*
237 * Should be in some common
238 * ethernet source file.
239 */
240 static struct ether_addr etherbroadcastaddr = {
241 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
242 };
243
244 static struct ether_addr myether;
245
246 /*
247 * "ifname" is the interface name/unit as read from the boot
248 * arguments.
249 * "ndev" is the major device number of the network interface
250 * used to boot from.
251 * "ifunit" it the physical point of attachment for the network
252 * interface used to boot from.
253 *
254 * Both of these are initialized in "init_config()".
255 */
256
257 static char ifname[IFNAMSIZ];
258 static char ndev_path[MAXPATHLEN];
259 static int ifunit;
260
261 /*
|
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 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
24 */
25
26 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <sys/systm.h>
29 #include <sys/cred.h>
30 #include <sys/user.h>
31 #include <sys/file.h>
32 #include <sys/stream.h>
33 #include <sys/strsubr.h>
34 #include <sys/stropts.h>
35 #include <sys/strsun.h>
36 #include <sys/debug.h>
37 #include <sys/tiuser.h>
38 #include <sys/sockio.h>
39 #include <sys/socket.h>
40 #include <sys/t_kuser.h>
41 #include <sys/utsname.h>
42 #include <sys/systeminfo.h>
43 #include <sys/netconfig.h>
44 #include <sys/ethernet.h>
45 #include <sys/dlpi.h>
143 struct mountres3 {
144 enum mountstat3 fhs_status;
145 union {
146 struct mountres3_ok mountinfo;
147 } mountres3_u;
148 };
149
150 /*
151 * DLPI address format.
152 */
153 struct dladdr {
154 uchar_t dl_phys[6];
155 ushort_t dl_sap;
156 };
157
158 static struct modlmisc modlmisc = {
159 &mod_miscops, "Boot diskless"
160 };
161
162 static struct modlinkage modlinkage = {
163 MODREV_1, { (void *)&modlmisc, NULL }
164 };
165
166 static int dldebug;
167
168 int
169 _init(void)
170 {
171 return (mod_install(&modlinkage));
172 }
173
174 int
175 _fini(void)
176 {
177 return (mod_remove(&modlinkage));
178 }
179
180 int
181 _info(struct modinfo *modinfop)
182 {
183 return (mod_info(&modlinkage, modinfop));
219 static void init_netbuf(struct netbuf *);
220 static void free_netbuf(struct netbuf *);
221 static int rtioctl(TIUSER *, int, struct rtentry *);
222 static void init_config(void);
223
224 static void cacheinit(void);
225 static int cacheinfo(char *, int, struct netbuf *, char *, int);
226 static int dlifconfig(TIUSER *, struct in_addr *, struct in_addr *,
227 struct in_addr *, uint_t);
228 static int setifflags(TIUSER *, uint_t);
229
230 static char *inet_ntoa(struct in_addr);
231 static int inet_aton(char *, uchar_t *);
232 static int isdigit(int);
233
234 /*
235 * Should be in some common
236 * ethernet source file.
237 */
238 static struct ether_addr etherbroadcastaddr = {
239 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }
240 };
241
242 static struct ether_addr myether;
243
244 /*
245 * "ifname" is the interface name/unit as read from the boot
246 * arguments.
247 * "ndev" is the major device number of the network interface
248 * used to boot from.
249 * "ifunit" it the physical point of attachment for the network
250 * interface used to boot from.
251 *
252 * Both of these are initialized in "init_config()".
253 */
254
255 static char ifname[IFNAMSIZ];
256 static char ndev_path[MAXPATHLEN];
257 static int ifunit;
258
259 /*
|