]> The Tcpdump Group git mirrors - libpcap/commitdiff
Include fixed offset when computing variable MAC headers.
authorJesse Gross <[email protected]>
Fri, 6 Feb 2015 08:14:23 +0000 (00:14 -0800)
committerGuy Harris <[email protected]>
Fri, 6 Feb 2015 08:14:23 +0000 (00:14 -0800)
Some filters (such as VLAN) increment off_macpl as they are parsed.
In the fixed MAC header case, this is handled properly since it is
simply incorporated into the header length. However, currently with
variable length headers we only look at the variable component and ignore
the fixed part, so the VLAN stack can't be handled.

This includes both pieces for variable headers; in cases where there
are no VLAN filters, off_macpl is zero so things still work.

gencode.c

index 8eb8cd216da9963833adb28deab1d3b49dade0aa..6383a7a785572ebac76a8bc92499c481d049012d 100644 (file)
--- a/gencode.c
+++ b/gencode.c
@@ -806,6 +806,11 @@ static u_int off_mac;
  * for example, any 802.2 LLC header, so it's the MAC-layer
  * portion of that header), plus any prefix preceding the
  * link-layer header.
+ *
+ * In the event of a variable length MAC header, this is typically
+ * 0. However, it can be used as a fixed component added to the
+ * variable piece, such as in the case of a VLAN increasing the size
+ * of the header.
  */
 static u_int off_macpl;
 
@@ -1554,7 +1559,7 @@ gen_load_macplrel(offset, size)
                 * as an offset.
                 */
                s2 = new_stmt(BPF_LD|BPF_IND|size);
-               s2->s.k = offset;
+               s2->s.k = off_macpl + offset;
                sappend(s, s2);
        } else {
                /*