forked from freebsd/freebsd-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmlh_rule.c
114 lines (97 loc) · 2.15 KB
/
mlh_rule.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/* $FreeBSD$ */
/*
* Copyright (C) 2012 by Darren Reed.
*
* See the IPFILTER.LICENCE file for details on licencing.
*
*/
/* #pragma ident "@(#)solaris.c 1.12 6/5/96 (C) 1995 Darren Reed"*/
/*typedef unsigned int spustate_t;*/
struct uio;
#include <sys/types.h>
#include <sys/cmn_err.h>
#include <sys/kernel.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/conf.h>
#include <sys/callout.h>
#include <sys/moddefs.h>
#include <sys/io.h>
#include <sys/wsio.h>
#include <sys/param.h>
#include <sys/errno.h>
#include <sys/byteorder.h>
#include <sys/socket.h>
#include <sys/stropts.h>
#include <net/if.h>
#include <net/af.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/in_systm.h>
#include <netinet/if_ether.h>
#include <netinet/ip.h>
#include <netinet/ip_var.h>
#include <netinet/tcp.h>
#include <netinet/udp.h>
#include <netinet/tcpip.h>
#include <netinet/ip_icmp.h>
#include "ip_compat.h"
#include "ip_fil.h"
#include "ip_rules.h"
/*
* Driver Header
*/
static drv_info_t ipf_drv_info = {
"IP Filter Rules", /* type */
"pseudo", /* class */
DRV_PSEUDO|DRV_SAVE_CONF|DRV_MP_SAFE, /* flags */
-1, /* b_major */
-1, /* c_major */
NULL, /* cdio */
NULL, /* gio_private */
NULL, /* cdio_private */
};
extern struct mod_operations gio_mod_ops;
static drv_info_t ipf_drv_info;
extern struct mod_conf_data ipf_conf_data;
static struct mod_type_data ipf_drv_link = {
IPL_VERSION, (void *)NULL
};
static struct modlink ipf_mod_link[] = {
{ &gio_mod_ops, (void *)&ipf_drv_link },
{ NULL, (void *)NULL }
};
struct modwrapper ipf_wrapper = {
MODREV,
ipf_load,
ipf_unload,
(void (*)())NULL,
(void *)&ipf_conf_data,
ipf_mod_link
};
static int ipf_load(void *arg)
{
int i;
i = ipfrule_add();
if (!i)
ipf_refcnt--;
#ifdef IPFDEBUG
printf("IP Filter Rules: ipfrule_add() = %d\n", i);
#endif
if (!i)
cmn_err(CE_CONT, "IP Filter Rules: Loaded\n");
return i;
}
static int ipf_unload(void *arg)
{
int i;
i = ipfrule_remove();
if (!i)
ipf_refcnt--;
#ifdef IPFDEBUG
printf("IP Filter Rules: ipfrule_remove() = %d\n", i);
#endif
if (!i)
cmn_err(CE_CONT, "IP Filter Rules: Unloaded\n");
return i;
}