summaryrefslogtreecommitdiffstats
path: root/userspace/patches/incremental-patches/ebtables-v2.0pre6.001.diff
blob: a143d62c63cd2942c986dee7136b740e4d2ec263 (plain)
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
--- ebtables-v2.0pre5/Makefile	Mon May 20 14:06:38 2002
+++ ebtables-v2.0pre6.001/Makefile	Thu May 30 18:39:04 2002
@@ -2,7 +2,7 @@
 
 KERNEL_DIR?=/usr/src/linux
 PROGNAME:=ebtables
-PROGVERSION:="2.0pre5 (May 2002)"
+PROGVERSION:="2.0pre6 (May 2002)"
 
 MANDIR?=/usr/local/man
 CFLAGS:=-Wall -Wunused
@@ -15,6 +15,8 @@
 KERNEL_INCLUDES=headers
 endif
 
+all:	ebtables
+
 .PHONY: headers
 headers:
 	mkdir -p /usr/include/linux/netfilter_bridge
@@ -52,3 +54,5 @@
 
 clean:
 	-rm -f ebtables
+	rm -f *.o *.c~
+	rm -f extensions/*.o extensions/*.c~
--- /dev/null	Thu Aug 24 11:00:32 2000
+++ ebtables-v2.0pre6.001/extensions/ebt_vlan.c	Thu May 30 18:38:44 2002
@@ -0,0 +1,231 @@
+/*
+ * Summary: ebt_vlan userspace module
+ * 
+ * Description: 802.1Q Virtual LAN match support module for ebtables project.
+ * Enable to match 802.1Q VLAN tagged frames by VLAN numeric 
+ * identifier (12-bites field) and frame priority (3-bites field)
+ * 
+ * Authors:
+ * Bart De Schuymer <bart.de.schuymer@pandora.be>
+ * Nick Fedchik <nick@fedchik.org.ua>
+ *  
+ *  May, 2002
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <linux/netfilter_bridge/ebtables.h>
+#include <getopt.h>
+#include "../include/ebtables_u.h"
+#include <linux/netfilter_bridge/ebt_vlan.h>
+
+#define VLAN_ID    '1'
+#define VLAN_PRIO  '2'
+
+static struct option opts[] = {
+	{"vlan-id", required_argument, 0, VLAN_ID},
+	{"vlan-prio", required_argument, 0, VLAN_PRIO},
+	{0}
+};
+
+/*
+ * Print out help for ebtables -h vlan 
+ */
+static void print_help ()
+{
+	printf ("802.1Q VLAN options:\n"
+		"--vlan-id [!] id        : VLAN ID 1-4095 (integer)\n"
+		"--vlan-prio [!] prio    : VLAN Priority 0-7 (integer)\n");
+}
+
+/*
+ * Initialization function 
+ */
+static void init (struct ebt_entry_match *match)
+{
+	struct ebt_vlan_info *vlaninfo =
+	    (struct ebt_vlan_info *) match->data;
+	/*
+	 * Just clean initial values 
+	 */
+	vlaninfo->id = 0;
+	vlaninfo->prio = 0;
+	vlaninfo->invflags = 0;
+	vlaninfo->bitmask = 0;
+}
+
+#define OPT_VLAN_ID     0x01
+#define OPT_VLAN_PRIO   0x02
+static int
+parse (int c, char **argv, int argc,
+       const struct ebt_u_entry *entry, unsigned int *flags,
+       struct ebt_entry_match **match)
+{
+	struct ebt_vlan_info *vlaninfo =
+	    (struct ebt_vlan_info *) (*match)->data;
+	unsigned short i;
+	char *end;
+
+	switch (c) {
+	case VLAN_ID:
+		check_option (flags, OPT_VLAN_ID);
+		/*
+		 * Check If we got inversed arg for VID,
+		 * otherwise unset inversion flag 
+		 */
+		if (check_inverse (optarg))
+			vlaninfo->invflags |= EBT_VLAN_ID;
+		/*
+		 * Check arg value presense 
+		 */
+		if (optind > argc)
+			print_error ("Missing VLAN ID argument\n");
+		/*
+		 * Convert argv to long int,
+		 * set *end to end of argv string, 
+		 * base set 10 for decimal only 
+		 */
+		(unsigned short) i = strtol (argv[optind - 1], &end, 10);
+		/*
+		 * Check arg val range 
+		 */
+		if (i < 1 || i >= 4096 || *end != '\0') {
+			i = 0;
+			print_error
+			    ("Problem with specified VLAN ID range\n");
+		}
+		vlaninfo->id = i;
+		vlaninfo->bitmask|=EBT_VLAN_ID;
+		break;
+
+	case VLAN_PRIO:
+		check_option (flags, OPT_VLAN_PRIO);
+		if (check_inverse (optarg))
+			vlaninfo->invflags |= EBT_VLAN_PRIO;
+		if (optind > argc)
+			print_error
+			    ("Missing VLAN Priority level argument\n");
+		/*
+		 * Convert argv to long int,
+		 * set *end to end of argv string, 
+		 * base set 10 for decimal only 
+		 */
+		(unsigned short) i = strtol (argv[optind - 1], &end, 10);
+		/*
+		 * Check arg val range 
+		 */
+		if (i >= 8 || *end != '\0') {
+			i = 0;
+			print_error
+			    ("Problem with specified VLAN Priority range\n");
+		}
+		vlaninfo->prio = i;
+		vlaninfo->bitmask|=EBT_VLAN_PRIO;
+		break;
+
+	default:
+		return 0;
+	}
+	return 1;
+}
+
+/*
+ * Final check 
+ */
+static void
+final_check (const struct ebt_u_entry *entry,
+	     const struct ebt_entry_match *match,
+	     const char *name, unsigned int hook)
+{
+	/*
+	 * Is any proto supplied there? Or specified proto isn't 802.1Q?
+	 */
+	if (entry->bitmask & EBT_NOPROTO || entry->ethproto != ETH_P_8021Q)
+		print_error
+		    ("For matching 802.1Q VLAN the protocol must be specified as 802_1Q\n");
+}
+
+/*
+ * Print line when listing rules by ebtables -L 
+ */
+static void
+print (const struct ebt_u_entry *entry,
+       const struct ebt_entry_match *match)
+{
+	struct ebt_vlan_info *vlaninfo =
+	    (struct ebt_vlan_info *) match->data;
+
+	/*
+	 * Print VLAN ID if they are specified 
+	 */
+	if (vlaninfo->bitmask & EBT_VLAN_ID) {
+		printf ("vlan id: %s%d, ",
+			vlaninfo->invflags & EBT_VLAN_ID ? "!" : "",
+			vlaninfo->id);
+	}
+	/*
+	 * Print VLAN priority if they are specified 
+	 */
+	if (vlaninfo->bitmask & EBT_VLAN_PRIO) {
+		printf ("vlan prio: %s%d, ",
+			vlaninfo->invflags & EBT_VLAN_PRIO ? "!" : "",
+			vlaninfo->prio);
+	}
+}
+
+
+static int
+compare (const struct ebt_entry_match *vlan1,
+	 const struct ebt_entry_match *vlan2)
+{
+	struct ebt_vlan_info *vlaninfo1 =
+	    (struct ebt_vlan_info *) vlan1->data;
+	struct ebt_vlan_info *vlaninfo2 =
+	    (struct ebt_vlan_info *) vlan2->data;
+	/*
+	 * Compare argc 
+	 */
+	if (vlaninfo1->bitmask != vlaninfo2->bitmask)
+		return 0;
+	/*
+	 * Compare inv flags  
+	 */
+	if (vlaninfo1->invflags != vlaninfo2->invflags)
+		return 0;
+	/*
+	 * Compare VLAN ID if they are present 
+	 */
+	if (vlaninfo1->bitmask & EBT_VLAN_ID) {
+		if (vlaninfo1->id != vlaninfo2->id)
+			return 0;
+	};
+	/*
+	 * Compare VLAN Prio if they are present 
+	 */
+	if (vlaninfo1->bitmask & EBT_VLAN_PRIO) {
+		if (vlaninfo1->prio != vlaninfo2->prio)
+			return 0;
+	};
+	return 1;
+}
+
+static struct ebt_u_match vlan_match = {
+	EBT_VLAN_MATCH,
+	sizeof (struct ebt_vlan_info),
+	print_help,
+	init,
+	parse,
+	final_check,
+	print,
+	compare,
+	opts,
+};
+
+static void _init (void) __attribute__ ((constructor));
+static void _init (void)
+{
+	register_match (&vlan_match);
+}
--- ebtables-v2.0pre5/extensions/Makefile	Sat Apr 27 22:31:21 2002
+++ ebtables-v2.0pre6.001/extensions/Makefile	Thu May 30 18:38:44 2002
@@ -1,6 +1,6 @@
 #! /usr/bin/make
 
-EXT_FUNC+=nat arp ip standard log redirect
+EXT_FUNC+=nat arp ip standard log redirect vlan
 EXT_TABLES+=filter nat broute
 EXT_OBJS+=$(foreach T,$(EXT_FUNC), extensions/ebt_$(T).o)
 EXT_OBJS+=$(foreach T,$(EXT_TABLES), extensions/ebtable_$(T).o)
--- ebtables-v2.0pre5/ebtables.8	Fri May  3 21:08:25 2002
+++ ebtables-v2.0pre6.001/ebtables.8	Thu May 30 18:43:19 2002
@@ -315,6 +315,17 @@
 .TP
 .BR "--arp-ip-dst " "[!] \fIaddress\fP[/\fImask\fP]"
 The ARP IP destination address specification.
+.SS vlan
+Specify 802.1Q VLAN specific fields. These will only work if the protocol equals
+.BR 802_1Q .
+For more details see
+.BR "ebtables -h vlan" .
+.TP
+.BR "--vlan-id " "[!] \fIid\fP"
+The VLAN identifier (decimal number from 0 to 4095).
+.TP
+.BR "--vlan-prio " "[!] \fIprio\fP"
+The VLAN priority type, this can be a decimal number from 0 to 7. The default value is 0.
 .SH WATCHER EXTENSION(S)
 Watchers are things that only look at frames passing by. These watchers only see the
 frame if the frame passes all the matches of the rule.
--- ebtables-v2.0pre5/ethertypes	Sat May 18 10:30:10 2002
+++ ebtables-v2.0pre6.001/ethertypes	Thu May 30 18:38:44 2002
@@ -1,15 +1,15 @@
-  # all whitespace is ignored
-  # comment lines must have a '#' as the first character
-  # all protocol numbers are in hexadecimal form
-	# maximum namesize = 20 characters
-	# always put tabs or spaces between the name and the protocol number
+# all whitespace is ignored
+# comment lines must have a '#' as the first character
+# all protocol numbers are in hexadecimal form
+# maximum namesize = 20 characters
+# always put tabs or spaces between the name and the protocol number
 # don't use more than 4 digits for the protocol number
 # programs using this file should not be case sensitive
 # that's all :-))
 IPV4 	0800	put your comments behind, on the same line, after a tab
 X25	0800    or whitespace
 ARP	0806
-VLAN	8100
+802_1Q	8100	802.1Q Virtual LAN tagged frame
 IPX	8137
 IPV6	86DD
 NetBEUI	8191