<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>command line on The Official Wireshark Blog</title>
    <link>https://blog.wireshark.org/tags/command-line/</link>
    <description>Recent content in command line on The Official Wireshark Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 05 Oct 2009 13:03:53 +0000</lastBuildDate><atom:link href="https://blog.wireshark.org/tags/command-line/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Capture Filters and Offsets</title>
      <link>https://blog.wireshark.org/2009/10/capture-filters-and-offsets/</link>
      <pubDate>Mon, 05 Oct 2009 13:03:53 +0000</pubDate>
      
      <guid>https://blog.wireshark.org/2009/10/capture-filters-and-offsets/</guid>
      <description>&lt;p&gt;A couple of questions have come up on the &lt;a href=&#34;http://www.wireshark.org/lists/&#34;&gt;wireshark-users&lt;/a&gt; mailing list recently about using capture filters for MPLS and VLANs. Each user was having the same problem yet these are different network technologies — what do they have to do with each other?&lt;/p&gt;
&lt;p&gt;The answer is &lt;em&gt;offsets&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Let’s take an up-close and personal look at the capture filter “ip src host 10.16.32.48”. We can do this by running &lt;em&gt;tcpdump -d&lt;/em&gt;, which takes a filter, compiles it, and dumps out the result. The dump of our filter looks like this:&lt;/p&gt;
&lt;pre&gt;&lt;span style=&#34;color: #008000;&#34;&gt;(000) ldh      [12]
(001) jeq      #0x800           jt 2    jf 5&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(002) ld       [26]&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(003) jeq      #0xa102030       jt 4    jf 5&lt;/span&gt;
(004) ret      #96
(005) ret      #0&lt;/pre&gt;
&lt;p&gt;If this makes no sense don’t worry. You just need to know that the &lt;span style=&#34;color: #008000;&#34;&gt;first two lines look for the IP ethertype (0x800) starting at byte 12&lt;/span&gt; and the &lt;span style=&#34;color: #0000ff;&#34;&gt;next two lines look for the IP address 10.16.32.48 (0xa102030) starting at byte 26&lt;/span&gt;. This is the minimum amount of checking required for that capture filter if you’re running IP over Ethernet.&lt;/p&gt;
&lt;p&gt;What happens if you’re using 802.1q?&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://en.wikipedia.org/wiki/802.1q&#34;&gt;802.1q inserts an extra four bytes in front of the ethertype&lt;/a&gt;, so this filter won’t do what you want. The ethertype will be at offset 16 instead of 12, and the IP source address will be at offset 30 instead of 26. Libpcap and WinPcap don’t know you’re using .1q, and adding a check to the filter code would add a lot of unnecessary overhead. We have to add the word “vlan” to our filter to get the right offsets, e.g. “vlan and ip src host 10.16.32.48”:&lt;/p&gt;
&lt;pre&gt;(000) ldh      [12]
(001) jeq      #0x8100          jt 2    jf 7
(002) ldh      [16]
(003) jeq      #0x800           jt 4    jf 7
&lt;span style=&#34;color: #0000ff;&#34;&gt;(004) ld       [30]&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(005) jeq      #0xa102030       jt 6    jf 7&lt;/span&gt;
(006) ret      #96
(007) ret      #0&lt;/pre&gt;
&lt;p&gt;There’s a gotcha here, though. What if we change the “and” to an “or”?&lt;/p&gt;
&lt;pre&gt;(000) ldh      [12]
(001) jeq      #0x8100          jt 6    jf 2
(002) ldh      [16]
(003) jeq      #0x800           jt 4    jf 7
&lt;span style=&#34;color: #0000ff;&#34;&gt;(004) ld       [30]&lt;/span&gt;
&lt;span style=&#34;color: #0000ff;&#34;&gt;(005) jeq      #0xa102030       jt 6    jf 7&lt;/span&gt;
(006) ret      #96
(007) ret      #0&lt;/pre&gt;
&lt;p&gt;We’re looking for the IP address at byte 30. Shouldn’t we be looking at both 26 and 30?&lt;/p&gt;
&lt;p&gt;The filter compiler uses a base offset for fetching data from the packet. Any time you use “vlan”, “mpls”, or “pppoes” in a capture filter, this offset is increased &lt;strong&gt;from that point on&lt;/strong&gt;. It’s also &lt;strong&gt;cumulative&lt;/strong&gt;. That is, while all of these filters are logically equivalent, they’re not in practice:&lt;/p&gt;
&lt;p style=&#34;padding-left: 30px;&#34;&gt;
  ip src host 10.16.32.48 or vlan or vlan &lt;span style=&#34;color: #808080;&#34;&gt;&lt;em&gt;(Looks for 10.16.32.48 at offset 26)&lt;/em&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style=&#34;padding-left: 30px;&#34;&gt;
  vlan or ip src host 10.16.32.48 or vlan &lt;span style=&#34;color: #808080;&#34;&gt;&lt;em&gt;(Now it&amp;#8217;s looking at offset 30)&lt;/em&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style=&#34;padding-left: 30px;&#34;&gt;
  vlan or vlan or ip src host 10.16.32.48 &lt;span style=&#34;color: #808080;&#34;&gt;&lt;em&gt;(Offset 34. When will it ever end?)&lt;/em&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;“vlan” and “mpls” increase the base offset by 4. “pppoes” increases it by 8.&lt;/p&gt;</description>
    </item>
    
    <item>
      <title>Video: Custom Wireshark Shortcuts</title>
      <link>https://blog.wireshark.org/2009/10/video-custom-shortcuts/</link>
      <pubDate>Thu, 01 Oct 2009 21:28:04 +0000</pubDate>
      
      <guid>https://blog.wireshark.org/2009/10/video-custom-shortcuts/</guid>
      <description>&lt;p&gt;I made a video that shows you how to create a Windows shortcut that starts capturing immediately.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;http://media-2.cacetech.com/video/wireshark/custom-shortcuts/&#34;&gt;Watch it now&lt;/a&gt;!&lt;/p&gt;
</description>
    </item>
    
  </channel>
</rss>
