tmf: Support + and - keys for histogram zoom
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.pcap.core / src / org / eclipse / linuxtools / tmf / pcap / core / protocol / TmfProtocol.java
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
13 package org.eclipse.linuxtools.tmf.pcap.core.protocol;
14
15 import java.util.ArrayList;
16 import java.util.Arrays;
17 import java.util.List;
18
19 import org.eclipse.jdt.annotation.NonNull;
20 import org.eclipse.linuxtools.pcap.core.protocol.Protocol;
21
22 /**
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
26 * name.
27 *
28 * @author Vincent Perot
29 */
30 public enum TmfProtocol {
31
32 // Layer 0
33 /**
34 * The Pcap Protocol is not a real protocol but is used as an helper to
35 * generate Pcap packets.
36 */
37 PCAP,
38
39 // Layer 1
40 // Should always be empty.
41
42 // Layer 2
43 /**
44 * The description of the Ethernet II Protocol.
45 */
46 ETHERNET_II,
47
48 // Layer 3
49 /**
50 * The description of the Internet Protocol Version 4.
51 */
52 IPV4,
53
54 // Layer 4
55 /**
56 * The description of the Transmission Control Protocol.
57 */
58 TCP,
59 /**
60 * The description of the User Datagram Protocol.
61 */
62 UDP,
63
64 // Layer 5
65
66 // Layer 6
67
68 // Layer 7
69 /**
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.
74 */
75 UNKNOWN;
76
77 private final String fName;
78 private final String fShortName;
79 private final int fLayer;
80 private final boolean fSupportsStream;
81
82 private TmfProtocol() {
83 @SuppressWarnings("null")
84 @NonNull String name = this.name();
85 fName = Protocol.valueOf(name).getName();
86 fShortName = Protocol.valueOf(name).getShortName();
87 fLayer = Protocol.valueOf(name).getLayer();
88 fSupportsStream = Protocol.valueOf(name).supportsStream();
89 }
90
91 /**
92 * Getter method for the long name of the protocol.
93 *
94 * @return The long name of the protocol, as a string.
95 */
96 public String getName() {
97 return fName;
98 }
99
100 /**
101 * Getter method for the short name of the protocol.
102 *
103 * @return The short name of the protocol, as a string.
104 */
105 public String getShortName() {
106 return fShortName;
107 }
108
109 /**
110 * Getter method for the OSI layer of the protocol.
111 *
112 * @return The layer of the protocol.
113 */
114 public int getLayer() {
115 return fLayer;
116 }
117
118 /**
119 * Getter method that indicates if the protocol supports streams.
120 *
121 * @return Whether the protocol supports streams or not.
122 */
123 public boolean supportsStream() {
124 return fSupportsStream;
125 }
126
127 /**
128 * Method that returns all the protocol defined.
129 *
130 * @return A list containing all the protocols.
131 */
132 public static List<TmfProtocol> getAllProtocols() {
133 return new ArrayList<>(Arrays.asList(TmfProtocol.values()));
134 }
135
136 }
This page took 0.032946 seconds and 5 git commands to generate.