lttng: Move plugins to the Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.pcap.core / src / org / eclipse / linuxtools / internal / pcap / core / endpoint / ProtocolEndpoint.java
CommitLineData
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 13package org.eclipse.linuxtools.internal.pcap.core.endpoint;
5255c030
VP
14
15import org.eclipse.jdt.annotation.Nullable;
93d1d135 16import org.eclipse.linuxtools.internal.pcap.core.packet.Packet;
5255c030
VP
17
18/**
19 * Abstract class that represents an endpoint. An endpoint is an address where a
20 * packet is received or sent. Therefore, it is protocol dependent. For
21 * instance, an Ethernet II endpoint is the MAC address. An Ipv4 endpoint is the
22 * combination of the MAC address and the IP address. This is useful for
23 * building packet streams.
24 *
25 * @author Vincent Perot
26 */
27public abstract class ProtocolEndpoint {
28
29 /**
30 * Empty string for child classes.
31 */
32 protected static final String EMPTY_STRING = ""; //$NON-NLS-1$
33
34 /**
35 * The encapsulating endpoint. Much like packets, endpoints are
36 * encapsulated. The higher the layer of the packet protocol is, the more
37 * parents an endpoint will have.
38 */
39 private final @Nullable ProtocolEndpoint fParentEndpoint;
40
41 /**
42 * Constructor of the {@link ProtocolEndpoint} class. It takes a packet to
43 * get its endpoint. Since every packet has two endpoints (source and
44 * destination), the isSourceEndpoint parameter is used to specify which
45 * endpoint to take.
46 *
47 * @param packet
48 * The packet that contains the endpoints.
49 * @param isSourceEndpoint
50 * Whether to take the source or the destination endpoint of the
51 * packet.
52 */
53 public ProtocolEndpoint(Packet packet, boolean isSourceEndpoint) {
e20e3d49 54 Packet parentPacket = packet.getParentPacket();
5255c030
VP
55 if (parentPacket == null) {
56 fParentEndpoint = null;
57 } else {
58 fParentEndpoint = isSourceEndpoint ?
59 parentPacket.getSourceEndpoint() :
60 parentPacket.getDestinationEndpoint();
61 }
62 }
63
64 /**
65 * Getter method that returns the parent endpoint.
66 *
67 * @return The parent endpoint.
68 */
69 public @Nullable ProtocolEndpoint getParentEndpoint() {
70 return fParentEndpoint;
71 }
72
73 @Override
74 public abstract int hashCode();
75
76 @Override
77 public abstract boolean equals(@Nullable Object obj);
78
79 @Override
80 public abstract String toString();
81
82}
This page took 0.031359 seconds and 5 git commands to generate.