1/* $FreeBSD$ */
2
3/*
4 * Copyright (C) 2012 by Darren Reed.
5 *
6 * See the IPFILTER.LICENCE file for details on licencing.
7 */
8/*
9 * 29/12/94 Added code from Marc Huber <huber@fzi.de> to allow it to allocate
10 * its own major char number! Way cool patch!
11 */
12#include <sys/types.h>
13#include <sys/stat.h>
14#include <sys/time.h>
15#include <sys/file.h>
16#include <sys/socket.h>
17#include <sys/conf.h>
18#include <sys/syslog.h>
19#include <sys/buf.h>
20#include <sys/mbuf.h>
21#include <sys/param.h>
22#include <sys/errno.h>
23#include <sys/uio.h>
24#include <sys/vnode.h>
25#include <sundev/mbvar.h>
26#include <sun/autoconf.h>
27#include <sun/vddrv.h>
28#if defined(sun4c) || defined(sun4m)
29# include <sun/openprom.h>
30#endif
31#include <netinet/in.h>
32#include <netinet/in_systm.h>
33#include <netinet/ip.h>
34#include <netinet/ip_var.h>
35#include <netinet/tcp.h>
36#include <netinet/tcpip.h>
37#include <net/if.h>
38#include "ip_compat.h"
39#include "ip_fil.h"
40#include "ip_rules.h"
41
42
43extern	int	errno;
44
45
46int	xxxinit __P((u_int, struct vddrv *, caddr_t, struct vdstat *));
47
48int	ipl_major = 0;
49
50#ifdef sun4m
51struct	vdldrv	vd =
52{
53	VDMAGIC_USER,
54	"IP Filter rules",
55	NULL,
56	NULL,
57	NULL,
58	0,
59	0,
60	NULL,
61	NULL,
62	NULL,
63	0,
64	1,
65};
66#else /* sun4m */
67struct vdldrv vd =
68{
69	VDMAGIC_USER,	/* magic */
70	"IP Filter rules",
71#ifdef sun4c
72	NULL,	/* dev_ops */
73#else
74	NULL,		/* struct mb_ctlr *mb_ctlr */
75	NULL,		/* struct mb_driver *mb_driver */
76	NULL,		/* struct mb_device *mb_device */
77	0,		/* num ctlrs */
78	1,		/* numdevs */
79#endif /* sun4c */
80	NULL,		/* bdevsw */
81	NULL,		/* cdevsw */
82	0,		/* block major */
83	0,		/* char major */
84};
85#endif /* sun4m */
86
87
88xxxinit(fc, vdp, data, vds)
89	u_int	fc;
90	struct	vddrv	*vdp;
91	caddr_t	data;
92	struct	vdstat	*vds;
93{
94	struct vdioctl_load *vdi = (struct vdioctl_load *)data;
95	int err;
96
97	switch (fc)
98	{
99	case VDLOAD:
100		err = ipfrule_add();
101		if (!err)
102			ipf_refcnt++;
103		break;
104	case VDUNLOAD:
105		err = ipfrule_remove();
106		if (!err)
107			ipf_refcnt--;
108		break;
109	case VDSTAT:
110		err = 0;
111		break;
112	default:
113		err = EIO;
114		break;
115	}
116}
117