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 | |
12 | *******************************************************************************/ | |
13 | ||
14 | package org.eclipse.tracecompass.internal.tmf.pcap.core.event.aspect; | |
15 | ||
2a28075c | 16 | import org.eclipse.jdt.annotation.Nullable; |
b04903a2 AM |
17 | import org.eclipse.tracecompass.internal.tmf.pcap.core.event.PcapEvent; |
18 | import org.eclipse.tracecompass.internal.tmf.pcap.core.protocol.TmfPcapProtocol; | |
19 | import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; | |
20 | import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect; | |
21 | ||
22 | /** | |
23 | * The packet source aspect for pcap events. | |
24 | * | |
25 | * This normally represents the source address of the packet, and the format | |
26 | * depends on the protocol (e.g. source IP address, source port, etc.) | |
27 | * | |
28 | * @author Alexandre Montplaisir | |
29 | */ | |
30 | public class PcapSourceAspect implements ITmfEventAspect { | |
31 | ||
32 | @Override | |
33 | public String getName() { | |
34 | return Messages.getMessage(Messages.PcapAspectName_Source); | |
35 | } | |
36 | ||
37 | @Override | |
38 | public String getHelpText() { | |
39 | return EMPTY_STRING; | |
40 | } | |
41 | ||
42 | @Override | |
2a28075c | 43 | public @Nullable String resolve(ITmfEvent event) { |
b04903a2 | 44 | if (!(event instanceof PcapEvent)) { |
2a28075c | 45 | return null; |
b04903a2 AM |
46 | } |
47 | PcapEvent pcapEvent = (PcapEvent) event; | |
48 | TmfPcapProtocol protocol = pcapEvent.getMostEncapsulatedProtocol(); | |
49 | ||
2a28075c | 50 | return pcapEvent.getSourceEndpoint(protocol); |
b04903a2 | 51 | } |
c409f16b | 52 | } |