Commit | Line | Data |
---|---|---|
5255c030 VP |
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 | ||
93d1d135 | 13 | package org.eclipse.linuxtools.internal.pcap.core.filter; |
5255c030 | 14 | |
93d1d135 | 15 | import org.eclipse.linuxtools.internal.pcap.core.packet.Packet; |
c88feda9 | 16 | import org.eclipse.linuxtools.internal.pcap.core.protocol.PcapProtocol; |
5255c030 VP |
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 | ||
c88feda9 | 26 | private final PcapProtocol fProtocol; |
5255c030 VP |
27 | |
28 | /** | |
29 | * Constructor of the PacketFilterByProtocol class. | |
30 | * | |
31 | * @param protocol | |
32 | * The protocol that the incoming packets must contain. | |
33 | */ | |
c88feda9 | 34 | public PacketFilterByProtocol(PcapProtocol protocol) { |
5255c030 VP |
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 | */ | |
c88feda9 | 48 | public PcapProtocol getProtocol() { |
5255c030 VP |
49 | return fProtocol; |
50 | } | |
51 | ||
52 | } |