[package] fix strange LED behavior with Netgear WGT634U (#3552)
[openwrt.git] / package / libpcap / patches / 104-no_rej_files.patch
1 diff -urN libpcap-0.9.8/gencode.c.rej libpcap-0.9.8.new/gencode.c.rej
2 --- libpcap-0.9.8/gencode.c.rej 2007-07-10 21:38:15.000000000 +0200
3 +++ libpcap-0.9.8.new/gencode.c.rej 1970-01-01 01:00:00.000000000 +0100
4 @@ -1,465 +0,0 @@
5 -***************
6 -*** 24,29 ****
7 - "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.221.2.51 2007/06/14 20:54:12 gianluca Exp $ (LBL)";
8 - #endif
9 -
10 - #ifdef HAVE_CONFIG_H
11 - #include "config.h"
12 - #endif
13 ---- 24,31 ----
14 - "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.221.2.51 2007/06/14 20:54:12 gianluca Exp $ (LBL)";
15 - #endif
16 -
17 -+ #define ENABLE_WLAN_FILTERING_PATCH
18 -+
19 - #ifdef HAVE_CONFIG_H
20 - #include "config.h"
21 - #endif
22 -***************
23 -*** 144,150 ****
24 - OR_NET, /* relative to the network-layer header */
25 - OR_NET_NOSNAP, /* relative to the network-layer header, with no SNAP header at the link layer */
26 - OR_TRAN_IPV4, /* relative to the transport-layer header, with IPv4 network layer */
27 -- OR_TRAN_IPV6 /* relative to the transport-layer header, with IPv6 network layer */
28 - };
29 -
30 - /*
31 ---- 146,153 ----
32 - OR_NET, /* relative to the network-layer header */
33 - OR_NET_NOSNAP, /* relative to the network-layer header, with no SNAP header at the link layer */
34 - OR_TRAN_IPV4, /* relative to the transport-layer header, with IPv4 network layer */
35 -+ OR_TRAN_IPV6, /* relative to the transport-layer header, with IPv6 network layer */
36 -+ OR_LINK_AFTER_WIRELESS_HDR /* After the 802.11 variable length header */
37 - };
38 -
39 - /*
40 -***************
41 -*** 199,204 ****
42 - static struct block *gen_linktype(int);
43 - static struct block *gen_snap(bpf_u_int32, bpf_u_int32, u_int);
44 - static struct block *gen_llc_linktype(int);
45 - static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
46 - #ifdef INET6
47 - static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
48 ---- 202,208 ----
49 - static struct block *gen_linktype(int);
50 - static struct block *gen_snap(bpf_u_int32, bpf_u_int32, u_int);
51 - static struct block *gen_llc_linktype(int);
52 -+ static struct block *gen_802_11_llc_linktype(int);
53 - static struct block *gen_hostop(bpf_u_int32, bpf_u_int32, int, int, u_int, u_int);
54 - #ifdef INET6
55 - static struct block *gen_hostop6(struct in6_addr *, struct in6_addr *, int, int, u_int, u_int);
56 -***************
57 -*** 242,247 ****
58 - static struct slist *xfer_to_a(struct arth *);
59 - static struct block *gen_mac_multicast(int);
60 - static struct block *gen_len(int, int);
61 -
62 - static struct block *gen_ppi_dlt_check();
63 - static struct block *gen_msg_abbrev(int type);
64 ---- 246,252 ----
65 - static struct slist *xfer_to_a(struct arth *);
66 - static struct block *gen_mac_multicast(int);
67 - static struct block *gen_len(int, int);
68 -+ static struct block *gen_check_802_11_data_frame();
69 -
70 - static struct block *gen_ppi_dlt_check();
71 - static struct block *gen_msg_abbrev(int type);
72 -***************
73 -*** 1345,1350 ****
74 - return s;
75 - }
76 -
77 -
78 - /*
79 - * Load a value relative to the beginning of the specified header.
80 ---- 1350,1487 ----
81 - return s;
82 - }
83 -
84 -+ /*
85 -+ * Load a value relative to the beginning of the link-layer header after the 802.11
86 -+ * header, i.e. LLC_SNAP.
87 -+ * The link-layer header doesn't necessarily begin at the beginning
88 -+ * of the packet data; there might be a variable-length prefix containing
89 -+ * radio information.
90 -+ */
91 -+ static struct slist *
92 -+ gen_load_ll_after_802_11_rel(offset, size)
93 -+ u_int offset, size;
94 -+ {
95 -+ struct slist *s, *s_load_fc;
96 -+ struct slist *sjset_qos;
97 -+ struct slist *s_load;
98 -+ struct slist *s_ld_a_2;
99 -+ struct slist *s_add_a_x;
100 -+ struct slist *s_a_to_x;
101 -+ struct slist *sjset_data_frame_1;
102 -+ struct slist *sjset_data_frame_2;
103 -+ struct slist *s_load_x_0;
104 -+
105 -+ /*
106 -+ * This code is not compatible with the optimizer, as
107 -+ * we are generating jmp instructions within a normal
108 -+ * slist of instructions
109 -+ *
110 -+ */
111 -+ no_optimize = 1;
112 -+
113 -+ s = gen_llprefixlen();
114 -+
115 -+ /*
116 -+ * If "s" is non-null, it has code to arrange that the X register
117 -+ * contains the length of the prefix preceding the link-layer
118 -+ * header.
119 -+ *
120 -+ * Otherwise, the length of the prefix preceding the link-layer
121 -+ * header is "off_ll".
122 -+ */
123 -+ if (s != NULL) {
124 -+ /*
125 -+ * There's a variable-length prefix preceding the
126 -+ * link-layer header. "s" points to a list of statements
127 -+ * that put the length of that prefix into the X register.
128 -+ * do an indirect load, to use the X register as an offset.
129 -+ */
130 -+
131 -+ /*
132 -+ * Load the Frame Control field
133 -+ */
134 -+ s_load_fc = new_stmt(BPF_LD|BPF_IND|BPF_B);
135 -+ s_load_fc->s.k = 0;
136 -+ } else {
137 -+ /*
138 -+ * There is no variable-length header preceding the
139 -+ * link-layer header; add in off_ll, which, if there's
140 -+ * a fixed-length header preceding the link-layer header,
141 -+ * is the length of that header.
142 -+ */
143 -+
144 -+ /*
145 -+ * We need to load the Frame control directly, and
146 -+ * then load X with a fake 0, i.e. the length of the
147 -+ * non-existing prepended header
148 -+ */
149 -+
150 -+ /*
151 -+ * TODO GV: I'm not sure if 0 is the right constant in this
152 -+ * case. If the link layer has a fixed length prepended header,
153 -+ * that should be the value that we put here
154 -+ */
155 -+
156 -+ /* Load 0 into X */
157 -+ s_load_x_0 = new_stmt(BPF_LDX|BPF_IMM);
158 -+ s_load_x_0->s.k = 0;
159 -+
160 -+ /*
161 -+ * TODO GV: I'm not sure if 0 is the right constant in this
162 -+ * case. If the link layer has a fixed length prepended header,
163 -+ * that should be the value that we put here
164 -+ */
165 -+
166 -+ /*
167 -+ * load the Frame Control with absolute access
168 -+ */
169 -+ s_load_fc = new_stmt(BPF_LD|BPF_ABS|BPF_B);
170 -+ s_load_fc->s.k = 0;
171 -+ s = s_load_x_0;
172 -+ }
173 -+
174 -+ /*
175 -+ * Generate the common instructions to check if it's a data frame
176 -+ * and if so compute the 802.11 header length
177 -+ */
178 -+ sjset_data_frame_1 = new_stmt(JMP(BPF_JSET)); // b3 should be 1
179 -+ sjset_data_frame_1->s.k = 0x8;
180 -+
181 -+ sjset_data_frame_2 = new_stmt(JMP(BPF_JSET)); // b2 should be 0
182 -+ sjset_data_frame_2->s.k = 0x04;
183 -+
184 -+ sjset_qos = new_stmt(JMP(BPF_JSET));
185 -+ sjset_qos->s.k = 0x80; //QOS bit
186 -+
187 -+ s_ld_a_2 = new_stmt(BPF_LD|BPF_IMM);
188 -+ s_ld_a_2->s.k = 2;
189 -+
190 -+ s_add_a_x = new_stmt(BPF_ALU|BPF_ADD|BPF_X);
191 -+ s_a_to_x = new_stmt(BPF_MISC|BPF_TAX);
192 -+
193 -+ s_load = new_stmt(BPF_LD|BPF_IND|size);
194 -+ s_load->s.k = offset;
195 -+
196 -+ sjset_data_frame_1->s.jt = sjset_data_frame_2;
197 -+ sjset_data_frame_1->s.jf = s_load;
198 -+
199 -+ sjset_data_frame_2->s.jt = s_load;
200 -+ sjset_data_frame_2->s.jf = sjset_qos;
201 -+
202 -+ sjset_qos->s.jt = s_ld_a_2;
203 -+ sjset_qos->s.jf = s_load;
204 -+
205 -+ sappend(s, s_load_fc);
206 -+ sappend(s_load_fc, sjset_data_frame_1);
207 -+ sappend(sjset_data_frame_1, sjset_data_frame_2);
208 -+ sappend(sjset_data_frame_2, sjset_qos);
209 -+ sappend(sjset_qos, s_ld_a_2);
210 -+ sappend(s_ld_a_2, s_add_a_x);
211 -+ sappend(s_add_a_x,s_a_to_x);
212 -+ sappend(s_a_to_x, s_load);
213 -+
214 -+ return s;
215 -+ }
216 -
217 - /*
218 - * Load a value relative to the beginning of the specified header.
219 -***************
220 -*** 1367,1372 ****
221 - s = gen_load_llrel(offset, size);
222 - break;
223 -
224 - case OR_NET:
225 - s = gen_load_llrel(off_nl + offset, size);
226 - break;
227 ---- 1504,1525 ----
228 - s = gen_load_llrel(offset, size);
229 - break;
230 -
231 -+ #ifdef ENABLE_WLAN_FILTERING_PATCH
232 -+
233 -+ case OR_LINK_AFTER_WIRELESS_HDR:
234 -+ if (linktype != DLT_IEEE802_11_RADIO
235 -+ && linktype != DLT_PPI
236 -+ && linktype != DLT_IEEE802_11
237 -+ && linktype != DLT_PRISM_HEADER
238 -+ && linktype != DLT_IEEE802_11_RADIO_AVS)
239 -+ {
240 -+ abort();
241 -+ return NULL;
242 -+ }
243 -+ s = gen_load_ll_after_802_11_rel(offset + 24, size);
244 -+ break;
245 -+ #endif /* ENABLE_WLAN_FILTERING_PATCH */
246 -+
247 - case OR_NET:
248 - s = gen_load_llrel(off_nl + offset, size);
249 - break;
250 -***************
251 -*** 2163,2173 ****
252 - break;
253 -
254 - case DLT_PPI:
255 - case DLT_FDDI:
256 - case DLT_IEEE802:
257 -- case DLT_IEEE802_11:
258 - case DLT_IEEE802_11_RADIO_AVS:
259 -- case DLT_IEEE802_11_RADIO:
260 - case DLT_PRISM_HEADER:
261 - case DLT_ATM_RFC1483:
262 - case DLT_ATM_CLIP:
263 ---- 2316,2332 ----
264 - break;
265 -
266 - case DLT_PPI:
267 -+ case DLT_IEEE802_11_RADIO:
268 -+ case DLT_IEEE802_11:
269 -+ #ifdef ENABLE_WLAN_FILTERING_PATCH
270 -+ return gen_802_11_llc_linktype(proto);
271 -+ /*NOTREACHED*/
272 -+ break;
273 -+ #endif /* ENABLE_WLAN_FILTERING_PATCH */
274 -+
275 - case DLT_FDDI:
276 - case DLT_IEEE802:
277 - case DLT_IEEE802_11_RADIO_AVS:
278 - case DLT_PRISM_HEADER:
279 - case DLT_ATM_RFC1483:
280 - case DLT_ATM_CLIP:
281 -***************
282 -*** 2711,2716 ****
283 - }
284 - }
285 -
286 - static struct block *
287 - gen_hostop(addr, mask, dir, proto, src_off, dst_off)
288 - bpf_u_int32 addr;
289 ---- 2870,2982 ----
290 - }
291 - }
292 -
293 -+ /*
294 -+ * Generate code to match a particular packet type, for link-layer types
295 -+ * using 802.2 LLC headers.
296 -+ *
297 -+ * This is *NOT* used for Ethernet; "gen_ether_linktype()" is used
298 -+ * for that - it handles the D/I/X Ethernet vs. 802.3+802.2 issues.
299 -+ *
300 -+ * "proto" is an Ethernet type value, if > ETHERMTU, or an LLC SAP
301 -+ * value, if <= ETHERMTU. We use that to determine whether to
302 -+ * match the DSAP or both DSAP and LSAP or to check the OUI and
303 -+ * protocol ID in a SNAP header.
304 -+ */
305 -+ static struct block *
306 -+ gen_802_11_llc_linktype(proto)
307 -+ int proto;
308 -+ {
309 -+ struct block *b_check_data_frame;
310 -+ struct block *b_check_linktype;
311 -+
312 -+ b_check_data_frame = gen_check_802_11_data_frame();
313 -+
314 -+ /*
315 -+ * XXX - generate the code that discards non data frames
316 -+ */
317 -+ switch (proto) {
318 -+
319 -+ case LLCSAP_IP:
320 -+ case LLCSAP_ISONS:
321 -+ case LLCSAP_NETBEUI:
322 -+ /*
323 -+ * XXX - should we check both the DSAP and the
324 -+ * SSAP, like this, or should we check just the
325 -+ * DSAP, as we do for other types <= ETHERMTU
326 -+ * (i.e., other SAP values)?
327 -+ */
328 -+ b_check_linktype = gen_cmp(OR_LINK_AFTER_WIRELESS_HDR, 0, BPF_H, (bpf_u_int32)
329 -+ ((proto << 8) | proto));
330 -+ break;
331 -+
332 -+ case LLCSAP_IPX:
333 -+ /*
334 -+ * XXX - are there ever SNAP frames for IPX on
335 -+ * non-Ethernet 802.x networks?
336 -+ */
337 -+ b_check_linktype = gen_cmp(OR_LINK_AFTER_WIRELESS_HDR, 0, BPF_B,
338 -+ (bpf_int32)LLCSAP_IPX);
339 -+
340 -+ break;
341 -+
342 -+ #if 0
343 -+ case ETHERTYPE_ATALK:
344 -+ /*
345 -+ * 802.2-encapsulated ETHERTYPE_ATALK packets are
346 -+ * SNAP packets with an organization code of
347 -+ * 0x080007 (Apple, for Appletalk) and a protocol
348 -+ * type of ETHERTYPE_ATALK (Appletalk).
349 -+ *
350 -+ * XXX - check for an organization code of
351 -+ * encapsulated Ethernet as well?
352 -+ */
353 -+ return gen_snap(0x080007, ETHERTYPE_ATALK, off_linktype);
354 -+ #endif
355 -+ default:
356 -+ /*
357 -+ * XXX - we don't have to check for IPX 802.3
358 -+ * here, but should we check for the IPX Ethertype?
359 -+ */
360 -+ if (proto <= ETHERMTU) {
361 -+ /*
362 -+ * This is an LLC SAP value, so check
363 -+ * the DSAP.
364 -+ */
365 -+ b_check_linktype = gen_cmp(OR_LINK_AFTER_WIRELESS_HDR, 0, BPF_B,
366 -+ (bpf_int32)proto);
367 -+ } else {
368 -+ /*
369 -+ * This is an Ethernet type; we assume that it's
370 -+ * unlikely that it'll appear in the right place
371 -+ * at random, and therefore check only the
372 -+ * location that would hold the Ethernet type
373 -+ * in a SNAP frame with an organization code of
374 -+ * 0x000000 (encapsulated Ethernet).
375 -+ *
376 -+ * XXX - if we were to check for the SNAP DSAP and
377 -+ * LSAP, as per XXX, and were also to check for an
378 -+ * organization code of 0x000000 (encapsulated
379 -+ * Ethernet), we'd do
380 -+ *
381 -+ * return gen_snap(0x000000, proto,
382 -+ * off_linktype);
383 -+ *
384 -+ * here; for now, we don't, as per the above.
385 -+ * I don't know whether it's worth the extra CPU
386 -+ * time to do the right check or not.
387 -+ */
388 -+ b_check_linktype = gen_cmp(OR_LINK_AFTER_WIRELESS_HDR, 0+6, BPF_H,
389 -+ (bpf_int32)proto);
390 -+ }
391 -+ }
392 -+
393 -+ gen_and(b_check_data_frame, b_check_linktype);
394 -+ return b_check_linktype;
395 -+
396 -+ }
397 -+
398 -+
399 -+
400 - static struct block *
401 - gen_hostop(addr, mask, dir, proto, src_off, dst_off)
402 - bpf_u_int32 addr;
403 -***************
404 -*** 2925,2930 ****
405 - register struct block *b0, *b1, *b2;
406 - register struct slist *s;
407 -
408 - switch (dir) {
409 - case Q_SRC:
410 - /*
411 ---- 3191,3207 ----
412 - register struct block *b0, *b1, *b2;
413 - register struct slist *s;
414 -
415 -+ #ifdef ENABLE_WLAN_FILTERING_PATCH
416 -+ /*
417 -+ * TODO GV 20070613
418 -+ * We need to disable the optimizer because the optimizer is buggy
419 -+ * and wipes out some LD instructions generated by the below
420 -+ * code to validate the Frame Control bits
421 -+ *
422 -+ */
423 -+ no_optimize = 1;
424 -+ #endif /* ENABLE_WLAN_FILTERING_PATCH */
425 -+
426 - switch (dir) {
427 - case Q_SRC:
428 - /*
429 -***************
430 -*** 4713,4718 ****
431 - #endif
432 - }
433 -
434 -
435 - /*
436 - * Generate code that checks whether the packet is a packet for protocol
437 ---- 4990,5021 ----
438 - #endif
439 - }
440 -
441 -+ static struct block *
442 -+ gen_check_802_11_data_frame()
443 -+ {
444 -+ struct slist *s;
445 -+ struct block *b0, *b1;
446 -+ /*
447 -+ * Now check for a data frame.
448 -+ * I.e, check "link[0] & 0x08".
449 -+ */
450 -+ s = gen_load_a(OR_LINK, 0, BPF_B);
451 -+ b0 = new_block(JMP(BPF_JSET));
452 -+ b0->s.k = 0x08;
453 -+ b0->stmts = s;
454 -+
455 -+ s = gen_load_a(OR_LINK, 0, BPF_B);
456 -+ b1 = new_block(JMP(BPF_JSET));
457 -+ b1->s.k = 0x04;
458 -+ b1->stmts = s;
459 -+ gen_not(b1);
460 -+
461 -+
462 -+ gen_and(b1, b0);
463 -+
464 -+ return b0;
465 -+ }
466 -+
467 -
468 - /*
469 - * Generate code that checks whether the packet is a packet for protocol
This page took 0.065653 seconds and 5 git commands to generate.