Deleted Added
full compact
alias_pptp.c (190841) alias_pptp.c (259858)
1/*
2 * alias_pptp.c
3 *
4 * Copyright (c) 2000 Whistle Communications, Inc.
5 * All rights reserved.
6 *
7 * Subject to the following obligations and disclaimer of warranty, use and
8 * redistribution of this software, in source or object code forms, with or

--- 23 unchanged lines hidden (view full) ---

32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
34 * OF SUCH DAMAGE.
35 *
36 * Author: Erik Salander <erik@whistle.com>
37 */
38
39#include <sys/cdefs.h>
1/*
2 * alias_pptp.c
3 *
4 * Copyright (c) 2000 Whistle Communications, Inc.
5 * All rights reserved.
6 *
7 * Subject to the following obligations and disclaimer of warranty, use and
8 * redistribution of this software, in source or object code forms, with or

--- 23 unchanged lines hidden (view full) ---

32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33 * THIS SOFTWARE, EVEN IF WHISTLE COMMUNICATIONS IS ADVISED OF THE POSSIBILITY
34 * OF SUCH DAMAGE.
35 *
36 * Author: Erik Salander <erik@whistle.com>
37 */
38
39#include <sys/cdefs.h>
40__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_pptp.c 190841 2009-04-08 11:56:49Z piso $");
40__FBSDID("$FreeBSD: head/sys/netinet/libalias/alias_pptp.c 259858 2013-12-25 02:06:57Z glebius $");
41
42/* Includes */
43#ifdef _KERNEL
44#include <sys/param.h>
45#include <sys/limits.h>
46#include <sys/kernel.h>
47#include <sys/module.h>
48#else

--- 24 unchanged lines hidden (view full) ---

73AliasHandlePptpIn(struct libalias *, struct ip *, struct alias_link *);
74
75static int
76AliasHandlePptpGreOut(struct libalias *, struct ip *);
77
78static int
79AliasHandlePptpGreIn(struct libalias *, struct ip *);
80
41
42/* Includes */
43#ifdef _KERNEL
44#include <sys/param.h>
45#include <sys/limits.h>
46#include <sys/kernel.h>
47#include <sys/module.h>
48#else

--- 24 unchanged lines hidden (view full) ---

73AliasHandlePptpIn(struct libalias *, struct ip *, struct alias_link *);
74
75static int
76AliasHandlePptpGreOut(struct libalias *, struct ip *);
77
78static int
79AliasHandlePptpGreIn(struct libalias *, struct ip *);
80
81static int
81static int
82fingerprint(struct libalias *la, struct alias_data *ah)
83{
84
85 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL)
86 return (-1);
87 if (ntohs(*ah->dport) == PPTP_CONTROL_PORT_NUMBER
88 || ntohs(*ah->sport) == PPTP_CONTROL_PORT_NUMBER)
89 return (0);
90 return (-1);
91}
92
82fingerprint(struct libalias *la, struct alias_data *ah)
83{
84
85 if (ah->dport == NULL || ah->sport == NULL || ah->lnk == NULL)
86 return (-1);
87 if (ntohs(*ah->dport) == PPTP_CONTROL_PORT_NUMBER
88 || ntohs(*ah->sport) == PPTP_CONTROL_PORT_NUMBER)
89 return (0);
90 return (-1);
91}
92
93static int
93static int
94fingerprintgre(struct libalias *la, struct alias_data *ah)
95{
96
97 return (0);
98}
99
94fingerprintgre(struct libalias *la, struct alias_data *ah)
95{
96
97 return (0);
98}
99
100static int
100static int
101protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
102{
103
104 AliasHandlePptpIn(la, pip, ah->lnk);
105 return (0);
106}
107
101protohandlerin(struct libalias *la, struct ip *pip, struct alias_data *ah)
102{
103
104 AliasHandlePptpIn(la, pip, ah->lnk);
105 return (0);
106}
107
108static int
108static int
109protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
110{
111
112 AliasHandlePptpOut(la, pip, ah->lnk);
113 return (0);
114}
115
109protohandlerout(struct libalias *la, struct ip *pip, struct alias_data *ah)
110{
111
112 AliasHandlePptpOut(la, pip, ah->lnk);
113 return (0);
114}
115
116static int
116static int
117protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah)
118{
119
120 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY ||
121 AliasHandlePptpGreIn(la, pip) == 0)
122 return (0);
123 return (-1);
124}
125
117protohandlergrein(struct libalias *la, struct ip *pip, struct alias_data *ah)
118{
119
120 if (la->packetAliasMode & PKT_ALIAS_PROXY_ONLY ||
121 AliasHandlePptpGreIn(la, pip) == 0)
122 return (0);
123 return (-1);
124}
125
126static int
126static int
127protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah)
128{
129
130 if (AliasHandlePptpGreOut(la, pip) == 0)
131 return (0);
132 return (-1);
133}
134
135/* Kernel module definition. */
136struct proto_handler handlers[] = {
127protohandlergreout(struct libalias *la, struct ip *pip, struct alias_data *ah)
128{
129
130 if (AliasHandlePptpGreOut(la, pip) == 0)
131 return (0);
132 return (-1);
133}
134
135/* Kernel module definition. */
136struct proto_handler handlers[] = {
137 {
138 .pri = 200,
139 .dir = IN,
140 .proto = TCP,
141 .fingerprint = &fingerprint,
137 {
138 .pri = 200,
139 .dir = IN,
140 .proto = TCP,
141 .fingerprint = &fingerprint,
142 .protohandler = &protohandlerin
143 },
142 .protohandler = &protohandlerin
143 },
144 {
145 .pri = 210,
146 .dir = OUT,
147 .proto = TCP,
148 .fingerprint = &fingerprint,
144 {
145 .pri = 210,
146 .dir = OUT,
147 .proto = TCP,
148 .fingerprint = &fingerprint,
149 .protohandler = &protohandlerout
150 },
149 .protohandler = &protohandlerout
150 },
151/*
152 * WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible)
151/*
152 * WATCH OUT!!! these 2 handlers NEED a priority of INT_MAX (highest possible)
153 * cause they will ALWAYS process packets, so they must be the last one
154 * in chain: look fingerprintgre() above.
155 */
153 * cause they will ALWAYS process packets, so they must be the last one
154 * in chain: look fingerprintgre() above.
155 */
156 {
157 .pri = INT_MAX,
158 .dir = IN,
159 .proto = IP,
160 .fingerprint = &fingerprintgre,
156 {
157 .pri = INT_MAX,
158 .dir = IN,
159 .proto = IP,
160 .fingerprint = &fingerprintgre,
161 .protohandler = &protohandlergrein
162 },
161 .protohandler = &protohandlergrein
162 },
163 {
164 .pri = INT_MAX,
165 .dir = OUT,
166 .proto = IP,
167 .fingerprint = &fingerprintgre,
163 {
164 .pri = INT_MAX,
165 .dir = OUT,
166 .proto = IP,
167 .fingerprint = &fingerprintgre,
168 .protohandler = &protohandlergreout
168 .protohandler = &protohandlergreout
169 },
169 },
170 { EOH }
171};
172static int
173mod_handler(module_t mod, int type, void *data)
174{
175 int error;
176
177 switch (type) {

--- 7 unchanged lines hidden (view full) ---

185 break;
186 default:
187 error = EINVAL;
188 }
189 return (error);
190}
191
192#ifdef _KERNEL
170 { EOH }
171};
172static int
173mod_handler(module_t mod, int type, void *data)
174{
175 int error;
176
177 switch (type) {

--- 7 unchanged lines hidden (view full) ---

185 break;
186 default:
187 error = EINVAL;
188 }
189 return (error);
190}
191
192#ifdef _KERNEL
193static
193static
194#endif
195moduledata_t alias_mod = {
196 "alias_pptp", mod_handler, NULL
197};
198
199#ifdef _KERNEL
200DECLARE_MODULE(alias_pptp, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
201MODULE_VERSION(alias_pptp, 1);

--- 322 unchanged lines hidden ---
194#endif
195moduledata_t alias_mod = {
196 "alias_pptp", mod_handler, NULL
197};
198
199#ifdef _KERNEL
200DECLARE_MODULE(alias_pptp, alias_mod, SI_SUB_DRIVERS, SI_ORDER_SECOND);
201MODULE_VERSION(alias_pptp, 1);

--- 322 unchanged lines hidden ---