Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

per suggestion from Paolo Lucente <paolo.lucente@ic.cnr.it>:

  centralize the MPLS check into gen_linktype() and backout the
  specific checks in gen_proto_abrev(), gen_proto(), gen_host()

  this adds as a by-product support for IPv6
  • Loading branch information...
commit 20937040b8535ab51737146586f8bab3ce689091 1 parent ade329d
hannes authored
Showing with 21 additions and 13 deletions.
  1. +21 −13 gencode.c
34 gencode.c
View
@@ -21,7 +21,7 @@
*/
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.221.2.26 2005-07-11 13:58:52 hannes Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/gencode.c,v 1.221.2.27 2005-07-14 16:01:46 hannes Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -1853,6 +1853,23 @@ gen_linktype(proto)
{
struct block *b0, *b1, *b2;
+ /* has the linktype been poisoned by MPLS expression ? */
+ if (off_linktype == (u_int)-1) {
+ switch(proto) {
+ /* FIXME add other L3 proto IDs */
+ case ETHERTYPE_IP:
+ case PPP_IP:
+ return gen_null(Q_IP);
+ /* FIXME add other L3 proto IDs */
+ case ETHERTYPE_IPV6:
+ case PPP_IPV6:
+ return gen_null(Q_IPV6);
+ default:
+ bpf_error("unsupported protocol over mpls");
+ /* NOTREACHED */
+ }
+ }
+
switch (linktype) {
case DLT_EN10MB:
@@ -2450,10 +2467,7 @@ gen_hostop(addr, mask, dir, proto, src_off, dst_off)
default:
abort();
}
- if (off_linktype != (u_int)-1)
- b0 = gen_linktype(proto);
- else
- b0 = gen_null(Q_IP);
+ b0 = gen_linktype(proto);
b1 = gen_mcmp(OR_NET, offset, BPF_W, (bpf_int32)addr, mask);
gen_and(b0, b1);
return b1;
@@ -3438,10 +3452,7 @@ gen_proto_abbrev(proto)
break;
case Q_IP:
- if (off_linktype != (u_int)-1)
- b1 = gen_linktype(ETHERTYPE_IP);
- else
- b1 = gen_null(Q_IP);
+ b1 = gen_linktype(ETHERTYPE_IP);
break;
case Q_ARP:
@@ -4434,10 +4445,7 @@ gen_proto(v, proto, dir)
* So we always check for ETHERTYPE_IP.
*/
- if (off_linktype != (u_int)-1)
- b0 = gen_linktype(ETHERTYPE_IP);
- else
- b0 = gen_null(Q_IP);
+ b0 = gen_linktype(ETHERTYPE_IP);
#ifndef CHASE_CHAIN
b1 = gen_cmp(OR_NET, 9, BPF_B, (bpf_int32)v);
#else
Please sign in to comment.
Something went wrong with that request. Please try again.