967ed658df21668075cc1ed8d985cbaa0b9d3bba
[deliverable/tracecompass.git] / org.eclipse.tracecompass.pcap.core / src / org / eclipse / tracecompass / internal / pcap / core / filter / PacketFilterByProtocol.java
1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.internal.pcap.core.filter;
14
15 import org.eclipse.tracecompass.internal.pcap.core.packet.Packet;
16 import org.eclipse.tracecompass.internal.pcap.core.protocol.PcapProtocol;
17
18 /**
19 * Class used to filter the packets by protocol. This is used, for instance, to
20 * build the packet streams.
21 *
22 * @author Vincent Perot
23 */
24 public class PacketFilterByProtocol implements IPacketFilter {
25
26 private final PcapProtocol fProtocol;
27
28 /**
29 * Constructor of the PacketFilterByProtocol class.
30 *
31 * @param protocol
32 * The protocol that the incoming packets must contain.
33 */
34 public PacketFilterByProtocol(PcapProtocol protocol) {
35 fProtocol = protocol;
36 }
37
38 @Override
39 public boolean accepts(Packet packet) {
40 return packet.hasProtocol(fProtocol);
41 }
42
43 /**
44 * Getter method for the protocol of this filter.
45 *
46 * @return The protocol of this filter.
47 */
48 public PcapProtocol getProtocol() {
49 return fProtocol;
50 }
51
52 }
This page took 0.273722 seconds and 4 git commands to generate.