Commit | Line | Data |
---|---|---|
b04903a2 | 1 | /******************************************************************************* |
ed902a2b | 2 | * Copyright (c) 2014, 2015 Ericsson |
b04903a2 AM |
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 | * Alexandre Montplaisir - Update to new ITmfEventAspect API | |
0214cc07 | 12 | * Patrick Tasse - Make pcap aspects singletons |
b04903a2 AM |
13 | *******************************************************************************/ |
14 | ||
15 | package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect; | |
16 | ||
2a28075c | 17 | import org.eclipse.jdt.annotation.Nullable; |
b04903a2 AM |
18 | import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent; |
19 | import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol; | |
20 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
21 | import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; | |
22 | ||
23 | /** | |
24 | * The "packet destination" aspect for pcap events. | |
25 | * | |
26 | * @author Alexandre Montplaisir | |
27 | */ | |
1ad849b8 | 28 | public final class PcapDestinationAspect implements ITmfEventAspect<String> { |
b04903a2 | 29 | |
0214cc07 PT |
30 | /** Singleton instance */ |
31 | public static final PcapDestinationAspect INSTANCE = new PcapDestinationAspect(); | |
32 | ||
33 | private PcapDestinationAspect() { | |
34 | } | |
35 | ||
b04903a2 AM |
36 | @Override |
37 | public String getName() { | |
38 | return Messages.getMessage(Messages.PcapAspectName_Destination); | |
39 | } | |
40 | ||
41 | @Override | |
42 | public String getHelpText() { | |
43 | return EMPTY_STRING; | |
44 | } | |
45 | ||
46 | @Override | |
2a28075c | 47 | public @Nullable String resolve(ITmfEvent event) { |
b04903a2 | 48 | if (!(event instanceof PcapEvent)) { |
2a28075c | 49 | return null; |
b04903a2 AM |
50 | } |
51 | PcapEvent pcapEvent = (PcapEvent) event; | |
52 | TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol(); | |
53 | ||
2a28075c | 54 | return pcapEvent.getDestinationEndpoint(protocol); |
b04903a2 | 55 | } |
b04903a2 | 56 | } |