2 * Copyright (C) 1993-2001 by Darren Reed.
4 * See the IPFILTER.LICENCE file for details on licencing.
7 * 29/12/94 Added code from Marc Huber <huber@fzi.de> to allow it to allocate
8 * its own major char number! Way cool patch!
10 #include <sys/types.h>
14 #include <sys/socket.h>
16 #include <sys/syslog.h>
19 #include <sys/param.h>
20 #include <sys/errno.h>
22 #include <sys/vnode.h>
23 #include <sundev/mbvar.h>
24 #include <sun/autoconf.h>
25 #include <sun/vddrv.h>
26 #if defined(sun4c) || defined(sun4m)
27 # include <sun/openprom.h>
29 #include <netinet/in.h>
30 #include <netinet/in_systm.h>
31 #include <netinet/ip.h>
32 #include <netinet/ip_var.h>
33 #include <netinet/tcp.h>
34 #include <netinet/tcpip.h>
37 #include "ip_compat.h"
42 static const char sccsid
[] = "@(#)mls_ipl.c 2.6 10/15/95 (C) 1993-2000 Darren Reed";
43 static const char rcsid
[] = "@(#)$Id: mls_ipl.c,v 2.2.2.2 2002/04/10 05:05:54 darrenr Exp $";
46 extern int ipldetach
__P((void));
48 #define iplread nulldev
50 extern int nulldev
__P((void));
52 extern int iplidentify
__P((char *));
54 extern int nodev
__P((void));
56 static int unload
__P((void));
57 static int ipl_attach
__P((void));
58 int xxxinit
__P((u_int
, struct vddrv
*, caddr_t
, struct vdstat
*));
59 static char *ipf_devfiles
[] = { IPL_NAME
, IPL_NAT
, IPL_STATE
, IPL_AUTH
,
63 struct cdevsw ipldevsw
=
65 iplopen
, iplclose
, iplread
, nulldev
,
66 iplioctl
, nulldev
, nulldev
, nulldev
,
71 struct dev_ops ipl_ops
=
109 VDMAGIC_PSEUDO
, /* magic */
112 &ipl_ops
, /* dev_ops */
114 NULL
, /* struct mb_ctlr *mb_ctlr */
115 NULL
, /* struct mb_driver *mb_driver */
116 NULL
, /* struct mb_device *mb_device */
121 &ipldevsw
, /* cdevsw */
127 extern int vd_unuseddev
__P((void));
128 extern struct cdevsw cdevsw
[];
131 xxxinit(fc
, vdp
, data
, vds
)
137 struct vdioctl_load
*vdi
= (struct vdioctl_load
*)data
;
144 if (vdi
&& vdi
->vdi_userconf
)
145 for (vdc
= vdi
->vdi_userconf
; vdc
->vdc_type
; vdc
++)
146 if (vdc
->vdc_type
== VDCCHARMAJOR
) {
147 ipl_major
= vdc
->vdc_data
;
152 while (ipl_major
< nchrdev
&&
153 cdevsw
[ipl_major
].d_open
!= vd_unuseddev
)
155 if (ipl_major
== nchrdev
)
158 vdp
->vdd_vdtab
= (struct vdlinkage
*)&vd
;
159 vd
.Drv_charmajor
= ipl_major
;
180 for (i
= 0; (name
= ipf_devfiles
[i
]); i
++)
181 (void) vn_remove(name
, UIO_SYSSPACE
, FILE);
186 static int ipl_attach()
190 int error
= 0, fmode
= S_IFCHR
|0600, i
;
197 for (i
= 0; (name
= ipf_devfiles
[i
]); i
++) {
198 (void) vn_remove(name
, UIO_SYSSPACE
, FILE);
200 vattr
.va_type
= MFTOVT(fmode
);
201 vattr
.va_mode
= (fmode
& 07777);
202 vattr
.va_rdev
= (ipl_major
<< 8) | i
;
204 error
= vn_create(name
, UIO_SYSSPACE
, &vattr
, EXCL
, 0, &vp
);
206 printf("IP Filter: vn_create(%s) = %d\n", name
, error
);