Donate Share

jNetStream Protocol Decoder

The forum address has changed, you have been automatically redirected. Please update any bookmarks to use the new URL.

Subscribe

Filter

You are viewing a single message from this topic. View all messages.

  1. 2008-07-29 18:58:10 UTC
    I am using version 0-2-4 and am trying to use a filter. I simply want to filter on a packet that has a tcp dest port of 80. The following does not seem to work. Any ideas?

    import com.slytechs.jnetstream.system.RuntimeEnvironment;
    import com.voytechs.jnetstream.codec.Decoder;
    import com.voytechs.jnetstream.codec.Linker;
    import com.voytechs.jnetstream.codec.Packet;
    import com.voytechs.jnetstream.codec.filter.Filter;

    public class FilterTest {

    public static void main(String[] args) {

    try {
    new FilterTest();
    } catch (Exception e) {
    e.printStackTrace();
    }
    }

    public FilterTest() throws Exception {
    Decoder decoder = null;
    decoder = new Decoder("test.pcap");
    String filterExpression = "TCP.dst==80";
    Filter filter = new Filter(filterExpression, (Linker) RuntimeEnvironment
    .getProtocolLinker());
    // Filter filter = new Filter(filterExpression, new Linker());

    decoder.addListener(filter);
    Packet packet = null;

    int i = 0;
    while ((packet = decoder.nextPacket()) != null) {
    String sport = packet.getHeader("TCP").getField("src").toString();
    System.out.println(sport);
    String dport = packet.getHeader("TCP").getField("dst").toString();
    System.out.println(dport);
    String saddr = packet.SADDR;
    System.out.println(saddr);
    String daddr = packet.DADDR;
    System.out.println(daddr);
    }
    }

    }


    Thx!

    Birch
< Previous | 1 | Next >

Add a Reply

This forum does not allow anonymous participation.

Log in to add a reply. Not registered? Create an account to participate and receive email updates when replies are posted to this topic.