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
.internal
.tmf
.pcap
.core
.protocol
;
15 import java
.util
.ArrayList
;
16 import java
.util
.Arrays
;
17 import java
.util
.List
;
19 import org
.eclipse
.jdt
.annotation
.NonNull
;
20 import org
.eclipse
.linuxtools
.internal
.pcap
.core
.protocol
.PcapProtocol
;
23 * Enumeration as a TMF wrapper of the different Protocols. To register a
24 * protocol in TMF, it must be present in
25 * org.eclipse.linuxtools.pcap.core.protocol.Protocol and must have the same
28 * @author Vincent Perot
30 public enum TmfPcapProtocol
{
34 * The Pcap Protocol is not a real protocol but is used as an helper to
35 * generate Pcap packets.
40 // Should always be empty.
44 * The description of the Ethernet II Protocol.
50 * The description of the Internet Protocol Version 4.
56 * The description of the Transmission Control Protocol.
60 * The description of the User Datagram Protocol.
70 * This protocol is used as an helper if the protocol of a packet is not
71 * recognized. Since all its data goes into payload, it can also be seen as
72 * a "payload packet". This is considered to be on layer 7 since its always
73 * the most encapsulated packet if present.
77 private final String fName
;
78 private final String fShortName
;
79 private final int fLayer
;
80 private final boolean fSupportsStream
;
82 private TmfPcapProtocol() {
83 @SuppressWarnings("null")
84 @NonNull String name
= this.name();
85 fName
= PcapProtocol
.valueOf(name
).getName();
86 fShortName
= PcapProtocol
.valueOf(name
).getShortName();
87 fLayer
= PcapProtocol
.valueOf(name
).getLayer();
88 fSupportsStream
= PcapProtocol
.valueOf(name
).supportsStream();
92 * Getter method for the long name of the protocol.
94 * @return The long name of the protocol, as a string.
96 public String
getName() {
101 * Getter method for the short name of the protocol.
103 * @return The short name of the protocol, as a string.
105 public String
getShortName() {
110 * Getter method for the OSI layer of the protocol.
112 * @return The layer of the protocol.
114 public int getLayer() {
119 * Getter method that indicates if the protocol supports streams.
121 * @return Whether the protocol supports streams or not.
123 public boolean supportsStream() {
124 return fSupportsStream
;
128 * Method that returns all the protocol defined.
130 * @return A list containing all the protocols.
132 public static List
<TmfPcapProtocol
> getAllProtocols() {
133 return new ArrayList
<>(Arrays
.asList(TmfPcapProtocol
.values()));
This page took 0.034099 seconds and 5 git commands to generate.