Commit | Line | Data |
---|---|---|
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 | 13 | package org.eclipse.linuxtools.internal.pcap.core.util; |
5255c030 VP |
14 | |
15 | // TODO finish this | |
16 | // TODO map to protocol instead of string? that would make more sense imo. | |
17 | ||
18 | /** | |
19 | * Helper that is used to help mapping a certain linktype to a particular | |
20 | * protocol (i.e. ethernet). | |
21 | * | |
22 | * See http://www.tcpdump.org/linktypes.html | |
23 | * | |
24 | * @author Vincent Perot | |
25 | */ | |
26 | public final class LinkTypeHelper { | |
27 | ||
28 | /** Linktype Null */ | |
29 | public static final int LINKTYPE_NULL = 0; | |
30 | ||
31 | /** Linktype Ethernet II */ | |
32 | public static final int LINKTYPE_ETHERNET = 1; | |
33 | ||
34 | /** Linktype AX25 */ | |
35 | public static final int LINKTYPE_AX25 = 3; | |
36 | ||
37 | /** Linktype IEEE802.5 */ | |
38 | public static final int LINKTYPE_IEEE802_5 = 6; | |
39 | ||
40 | /** Linktype Raw */ | |
41 | public static final int LINKTYPE_RAW = 101; | |
42 | ||
43 | /** Linktype IEEE802.11 */ | |
44 | public static final int LINKTYPE_IEEE802_11 = 105; | |
45 | ||
46 | /** Linktype Linux SLL */ | |
47 | public static final int LINKTYPE_LINUX_SLL = 113; | |
48 | ||
49 | private LinkTypeHelper() {} | |
50 | ||
51 | /** | |
52 | * Method that match the linktype as an int to a protocol as a string. | |
53 | * | |
54 | * @param linkType | |
55 | * The linkType as an int. | |
56 | * @return The protocol as a string. | |
57 | */ | |
58 | public static String toString(int linkType) { | |
59 | switch (linkType) { | |
60 | case LINKTYPE_NULL: | |
61 | return "null"; //$NON-NLS-1$ | |
62 | case LINKTYPE_ETHERNET: | |
63 | return "ethernet"; //$NON-NLS-1$ | |
64 | case LINKTYPE_AX25: | |
65 | return "ax25"; //$NON-NLS-1$ | |
66 | case LINKTYPE_IEEE802_5: | |
67 | return "ieee802.5"; //$NON-NLS-1$ | |
68 | case LINKTYPE_RAW: | |
69 | return "raw"; //$NON-NLS-1$ | |
70 | case LINKTYPE_IEEE802_11: | |
71 | return "ieee802.11"; //$NON-NLS-1$ | |
72 | case LINKTYPE_LINUX_SLL: | |
73 | return "linux_sll"; //$NON-NLS-1$ | |
74 | default: | |
75 | return "unknown"; //$NON-NLS-1$ | |
76 | } | |
77 | } | |
78 | ||
79 | } |