mls_rule.c revision 254219
1/*
2 * Copyright (C) 2012 by Darren Reed.
3 *
4 * See the IPFILTER.LICENCE file for details on licencing.
5 */
6/*
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!
9 */
10#include <sys/types.h>
11#include <sys/stat.h>
12#include <sys/time.h>
13#include <sys/file.h>
14#include <sys/socket.h>
15#include <sys/conf.h>
16#include <sys/syslog.h>
17#include <sys/buf.h>
18#include <sys/mbuf.h>
19#include <sys/param.h>
20#include <sys/errno.h>
21#include <sys/uio.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>
28#endif
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>
35#include <net/if.h>
36#include "ip_compat.h"
37#include "ip_fil.h"
38#include "ip_rules.h"
39
40
41extern	int	errno;
42
43
44int	xxxinit __P((u_int, struct vddrv *, caddr_t, struct vdstat *));
45
46int	ipl_major = 0;
47
48#ifdef sun4m
49struct	vdldrv	vd =
50{
51	VDMAGIC_USER,
52	"IP Filter rules",
53	NULL,
54	NULL,
55	NULL,
56	0,
57	0,
58	NULL,
59	NULL,
60	NULL,
61	0,
62	1,
63};
64#else /* sun4m */
65struct vdldrv vd =
66{
67	VDMAGIC_USER,	/* magic */
68	"IP Filter rules",
69#ifdef sun4c
70	NULL,	/* dev_ops */
71#else
72	NULL,		/* struct mb_ctlr *mb_ctlr */
73	NULL,		/* struct mb_driver *mb_driver */
74	NULL,		/* struct mb_device *mb_device */
75	0,		/* num ctlrs */
76	1,		/* numdevs */
77#endif /* sun4c */
78	NULL,		/* bdevsw */
79	NULL,		/* cdevsw */
80	0,		/* block major */
81	0,		/* char major */
82};
83#endif /* sun4m */
84
85
86xxxinit(fc, vdp, data, vds)
87	u_int	fc;
88	struct	vddrv	*vdp;
89	caddr_t	data;
90	struct	vdstat	*vds;
91{
92	struct vdioctl_load *vdi = (struct vdioctl_load *)data;
93	int err;
94
95	switch (fc)
96	{
97	case VDLOAD:
98		err = ipfrule_add();
99		if (!err)
100			ipf_refcnt++;
101		break;
102	case VDUNLOAD:
103		err = ipfrule_remove();
104		if (!err)
105			ipf_refcnt--;
106		break;
107	case VDSTAT:
108		err = 0;
109		break;
110	default:
111		err = EIO;
112		break;
113	}
114}
115