1 /*******************************************************************************
2 * Copyright (c) 2014 Ericsson
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
10 * Vincent Perot - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.pcap
.core
.endpoint
;
15 import org
.eclipse
.jdt
.annotation
.Nullable
;
16 import org
.eclipse
.linuxtools
.pcap
.core
.packet
.Packet
;
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.
25 * @author Vincent Perot
27 public abstract class ProtocolEndpoint
{
30 * Empty string for child classes.
32 protected static final String EMPTY_STRING
= ""; //$NON-NLS-1$
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.
39 private final @Nullable ProtocolEndpoint fParentEndpoint
;
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
48 * The packet that contains the endpoints.
49 * @param isSourceEndpoint
50 * Whether to take the source or the destination endpoint of the
53 public ProtocolEndpoint(Packet packet
, boolean isSourceEndpoint
) {
54 @Nullable Packet parentPacket
= packet
.getParentPacket();
55 if (parentPacket
== null) {
56 fParentEndpoint
= null;
58 fParentEndpoint
= isSourceEndpoint ?
59 parentPacket
.getSourceEndpoint() :
60 parentPacket
.getDestinationEndpoint();
65 * Getter method that returns the parent endpoint.
67 * @return The parent endpoint.
69 public @Nullable ProtocolEndpoint
getParentEndpoint() {
70 return fParentEndpoint
;
74 public abstract int hashCode();
77 public abstract boolean equals(@Nullable Object obj
);
80 public abstract String
toString();