Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 1 | package org.openflow.types; |
| 2 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 3 | import org.jboss.netty.buffer.ChannelBuffer; |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 4 | |
| 5 | /** |
| 6 | * IP-Protocol field representation |
| 7 | * |
| 8 | * @author Yotam Harchol (yotam.harchol@bigswitch.com) |
| 9 | */ |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 10 | public class IpProtocol implements OFValueType<IpProtocol> { |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 11 | |
| 12 | static final short MAX_PROTO = 0xFF; |
| 13 | static final int LENGTH = 1; |
| 14 | |
| 15 | private final short proto; |
| 16 | |
| 17 | static final short IP_PROTO_NUM_HOPOPT = 0x00; |
| 18 | static final short IP_PROTO_NUM_ICMP = 0x01; |
| 19 | static final short IP_PROTO_NUM_IGMP = 0x02; |
| 20 | static final short IP_PROTO_NUM_GGP = 0x03; |
| 21 | static final short IP_PROTO_NUM_IPv4 = 0x04; |
| 22 | static final short IP_PROTO_NUM_ST = 0x05; |
| 23 | static final short IP_PROTO_NUM_TCP = 0x06; |
| 24 | static final short IP_PROTO_NUM_CBT = 0x07; |
| 25 | static final short IP_PROTO_NUM_EGP = 0x08; |
| 26 | static final short IP_PROTO_NUM_IGP = 0x09; |
| 27 | static final short IP_PROTO_NUM_BBN_RCC_MON = 0x0A; |
| 28 | static final short IP_PROTO_NUM_NVP_II = 0x0B; |
| 29 | static final short IP_PROTO_NUM_PUP = 0x0C; |
| 30 | static final short IP_PROTO_NUM_ARGUS = 0x0D; |
| 31 | static final short IP_PROTO_NUM_EMCON = 0x0E; |
| 32 | static final short IP_PROTO_NUM_XNET = 0x0F; |
| 33 | static final short IP_PROTO_NUM_CHAOS = 0x10; |
| 34 | static final short IP_PROTO_NUM_UDP = 0x11; |
| 35 | static final short IP_PROTO_NUM_MUX = 0x12; |
| 36 | static final short IP_PROTO_NUM_DCN_MEAS = 0x13; |
| 37 | static final short IP_PROTO_NUM_HMP = 0x14; |
| 38 | static final short IP_PROTO_NUM_PRM = 0x15; |
| 39 | static final short IP_PROTO_NUM_XNS_IDP = 0x16; |
| 40 | static final short IP_PROTO_NUM_TRUNK_1 = 0x17; |
| 41 | static final short IP_PROTO_NUM_TRUNK_2 = 0x18; |
| 42 | static final short IP_PROTO_NUM_LEAF_1 = 0x19; |
| 43 | static final short IP_PROTO_NUM_LEAF_2 = 0x1A; |
| 44 | static final short IP_PROTO_NUM_RDP = 0x1B; |
| 45 | static final short IP_PROTO_NUM_IRTP = 0x1C; |
| 46 | static final short IP_PROTO_NUM_ISO_TP4 = 0x1D; |
| 47 | static final short IP_PROTO_NUM_NETBLT = 0x1E; |
| 48 | static final short IP_PROTO_NUM_MFE_NSP = 0x1F; |
| 49 | static final short IP_PROTO_NUM_MERIT_INP = 0x20; |
| 50 | static final short IP_PROTO_NUM_DCCP = 0x21; |
| 51 | static final short IP_PROTO_NUM_3PC = 0x22; |
| 52 | static final short IP_PROTO_NUM_IDPR = 0x23; |
| 53 | static final short IP_PROTO_NUM_XTP = 0x24; |
| 54 | static final short IP_PROTO_NUM_DDP = 0x25; |
| 55 | static final short IP_PROTO_NUM_IDPR_CMTP = 0x26; |
| 56 | static final short IP_PROTO_NUM_TP_PP = 0x27; |
| 57 | static final short IP_PROTO_NUM_IL = 0x28; |
| 58 | static final short IP_PROTO_NUM_IPv6 = 0x29; |
| 59 | static final short IP_PROTO_NUM_SDRP = 0x2A; |
| 60 | static final short IP_PROTO_NUM_IPv6_ROUTE = 0x2B; |
| 61 | static final short IP_PROTO_NUM_IPv6_FRAG = 0x2C; |
| 62 | static final short IP_PROTO_NUM_IDRP = 0x2D; |
| 63 | static final short IP_PROTO_NUM_RSVP = 0x2E; |
| 64 | static final short IP_PROTO_NUM_GRE = 0x2F; |
| 65 | static final short IP_PROTO_NUM_MHRP = 0x30; |
| 66 | static final short IP_PROTO_NUM_BNA = 0x31; |
| 67 | static final short IP_PROTO_NUM_ESP = 0x32; |
| 68 | static final short IP_PROTO_NUM_AH = 0x33; |
| 69 | static final short IP_PROTO_NUM_I_NLSP = 0x34; |
| 70 | static final short IP_PROTO_NUM_SWIPE = 0x35; |
| 71 | static final short IP_PROTO_NUM_NARP = 0x36; |
| 72 | static final short IP_PROTO_NUM_MOBILE = 0x37; |
| 73 | static final short IP_PROTO_NUM_TLSP = 0x38; |
| 74 | static final short IP_PROTO_NUM_SKIP = 0x39; |
| 75 | static final short IP_PROTO_NUM_IPv6_ICMP = 0x3A; |
| 76 | static final short IP_PROTO_NUM_IPv6_NO_NXT = 0x3B; |
| 77 | static final short IP_PROTO_NUM_IPv6_OPTS = 0x3C; |
| 78 | static final short IP_PROTO_NUM_HOST_INTERNAL = 0x3D; |
| 79 | static final short IP_PROTO_NUM_CFTP = 0x3E; |
| 80 | static final short IP_PROTO_NUM_LOCAL_NET = 0x3F; |
| 81 | static final short IP_PROTO_NUM_SAT_EXPAK = 0x40; |
| 82 | static final short IP_PROTO_NUM_KRYPTOLAN = 0x41; |
| 83 | static final short IP_PROTO_NUM_RVD = 0x42; |
| 84 | static final short IP_PROTO_NUM_IPPC = 0x43; |
| 85 | static final short IP_PROTO_NUM_DIST_FS = 0x44; |
| 86 | static final short IP_PROTO_NUM_SAT_MON = 0x45; |
| 87 | static final short IP_PROTO_NUM_VISA = 0x46; |
| 88 | static final short IP_PROTO_NUM_IPCV = 0x47; |
| 89 | static final short IP_PROTO_NUM_CPNX = 0x48; |
| 90 | static final short IP_PROTO_NUM_CPHB = 0x49; |
| 91 | static final short IP_PROTO_NUM_WSN = 0x4A; |
| 92 | static final short IP_PROTO_NUM_PVP = 0x4B; |
| 93 | static final short IP_PROTO_NUM_BR_SAT_MON = 0x4C; |
| 94 | static final short IP_PROTO_NUM_SUN_ND = 0x4D; |
| 95 | static final short IP_PROTO_NUM_WB_MON = 0x4E; |
| 96 | static final short IP_PROTO_NUM_WB_EXPAK = 0x4F; |
| 97 | static final short IP_PROTO_NUM_ISO_IP = 0x50; |
| 98 | static final short IP_PROTO_NUM_VMTP = 0x51; |
| 99 | static final short IP_PROTO_NUM_SECURE_VMTP = 0x52; |
| 100 | static final short IP_PROTO_NUM_VINES = 0x53; |
| 101 | static final short IP_PROTO_NUM_TTP_IPTM = 0x54; |
| 102 | static final short IP_PROTO_NUM_NSFNET_IGP = 0x55; |
| 103 | static final short IP_PROTO_NUM_DGP = 0x56; |
| 104 | static final short IP_PROTO_NUM_TCF = 0x57; |
| 105 | static final short IP_PROTO_NUM_EIGRP = 0x58; |
| 106 | static final short IP_PROTO_NUM_OSPF = 0x59; |
| 107 | static final short IP_PROTO_NUM_Sprite_RPC = 0x5A; |
| 108 | static final short IP_PROTO_NUM_LARP = 0x5B; |
| 109 | static final short IP_PROTO_NUM_MTP = 0x5C; |
| 110 | static final short IP_PROTO_NUM_AX_25 = 0x5D; |
| 111 | static final short IP_PROTO_NUM_IPIP = 0x5E; |
| 112 | static final short IP_PROTO_NUM_MICP = 0x5F; |
| 113 | static final short IP_PROTO_NUM_SCC_SP = 0x60; |
| 114 | static final short IP_PROTO_NUM_ETHERIP = 0x61; |
| 115 | static final short IP_PROTO_NUM_ENCAP = 0x62; |
| 116 | static final short IP_PROTO_NUM_PRIVATE_ENCRYPT = 0x63; |
| 117 | static final short IP_PROTO_NUM_GMTP = 0x64; |
| 118 | static final short IP_PROTO_NUM_IFMP = 0x65; |
| 119 | static final short IP_PROTO_NUM_PNNI = 0x66; |
| 120 | static final short IP_PROTO_NUM_PIM = 0x67; |
| 121 | static final short IP_PROTO_NUM_ARIS = 0x68; |
| 122 | static final short IP_PROTO_NUM_SCPS = 0x69; |
| 123 | static final short IP_PROTO_NUM_QNX = 0x6A; |
| 124 | static final short IP_PROTO_NUM_A_N = 0x6B; |
| 125 | static final short IP_PROTO_NUM_IP_COMP = 0x6C; |
| 126 | static final short IP_PROTO_NUM_SNP = 0x6D; |
| 127 | static final short IP_PROTO_NUM_COMPAQ_PEER = 0x6E; |
| 128 | static final short IP_PROTO_NUM_IPX_IN_IP = 0x6F; |
| 129 | static final short IP_PROTO_NUM_VRRP = 0x70; |
| 130 | static final short IP_PROTO_NUM_PGM = 0x71; |
| 131 | static final short IP_PROTO_NUM_ZERO_HOP = 0x72; |
| 132 | static final short IP_PROTO_NUM_L2TP = 0x73; |
| 133 | static final short IP_PROTO_NUM_DDX = 0x74; |
| 134 | static final short IP_PROTO_NUM_IATP = 0x75; |
| 135 | static final short IP_PROTO_NUM_STP = 0x76; |
| 136 | static final short IP_PROTO_NUM_SRP = 0x77; |
| 137 | static final short IP_PROTO_NUM_UTI = 0x78; |
| 138 | static final short IP_PROTO_NUM_SMP = 0x79; |
| 139 | static final short IP_PROTO_NUM_SM = 0x7A; |
| 140 | static final short IP_PROTO_NUM_PTP = 0x7B; |
| 141 | static final short IP_PROTO_NUM_IS_IS_OVER_IPv4 = 0x7C; |
| 142 | static final short IP_PROTO_NUM_FIRE = 0x7D; |
| 143 | static final short IP_PROTO_NUM_CRTP = 0x7E; |
| 144 | static final short IP_PROTO_NUM_CRUDP = 0x7F; |
| 145 | static final short IP_PROTO_NUM_SSCOPMCE = 0x80; |
| 146 | static final short IP_PROTO_NUM_IPLT = 0x81; |
| 147 | static final short IP_PROTO_NUM_SPS = 0x82; |
| 148 | static final short IP_PROTO_NUM_PIPE = 0x83; |
| 149 | static final short IP_PROTO_NUM_SCTP = 0x84; |
| 150 | static final short IP_PROTO_NUM_FC = 0x85; |
| 151 | static final short IP_PROTO_NUM_RSVP_E2E_IGNORE = 0x86; |
| 152 | static final short IP_PROTO_NUM_MOBILITY_HEADER = 0x87; |
| 153 | static final short IP_PROTO_NUM_UDP_LITE = 0x88; |
| 154 | static final short IP_PROTO_NUM_MPLS_IN_IP = 0x89; |
| 155 | static final short IP_PROTO_NUM_MANET = 0x8A; |
| 156 | static final short IP_PROTO_NUM_HIP = 0x8B; |
| 157 | static final short IP_PROTO_NUM_SHIM6 = 0x8C; |
| 158 | |
| 159 | public static final IpProtocol IP_PROTO_HOPOPT = new IpProtocol(IP_PROTO_NUM_HOPOPT); |
| 160 | public static final IpProtocol IP_PROTO_ICMP = new IpProtocol(IP_PROTO_NUM_ICMP); |
| 161 | public static final IpProtocol IP_PROTO_IGMP = new IpProtocol(IP_PROTO_NUM_IGMP); |
| 162 | public static final IpProtocol IP_PROTO_GGP = new IpProtocol(IP_PROTO_NUM_GGP); |
| 163 | public static final IpProtocol IP_PROTO_IPv4 = new IpProtocol(IP_PROTO_NUM_IPv4); |
| 164 | public static final IpProtocol IP_PROTO_ST = new IpProtocol(IP_PROTO_NUM_ST); |
| 165 | public static final IpProtocol IP_PROTO_TCP = new IpProtocol(IP_PROTO_NUM_TCP); |
| 166 | public static final IpProtocol IP_PROTO_CBT = new IpProtocol(IP_PROTO_NUM_CBT); |
| 167 | public static final IpProtocol IP_PROTO_EGP = new IpProtocol(IP_PROTO_NUM_EGP); |
| 168 | public static final IpProtocol IP_PROTO_IGP = new IpProtocol(IP_PROTO_NUM_IGP); |
| 169 | public static final IpProtocol IP_PROTO_BBN_RCC_MON = new IpProtocol(IP_PROTO_NUM_BBN_RCC_MON); |
| 170 | public static final IpProtocol IP_PROTO_NVP_II = new IpProtocol(IP_PROTO_NUM_NVP_II); |
| 171 | public static final IpProtocol IP_PROTO_PUP = new IpProtocol(IP_PROTO_NUM_PUP); |
| 172 | public static final IpProtocol IP_PROTO_ARGUS = new IpProtocol(IP_PROTO_NUM_ARGUS); |
| 173 | public static final IpProtocol IP_PROTO_EMCON = new IpProtocol(IP_PROTO_NUM_EMCON); |
| 174 | public static final IpProtocol IP_PROTO_XNET = new IpProtocol(IP_PROTO_NUM_XNET); |
| 175 | public static final IpProtocol IP_PROTO_CHAOS = new IpProtocol(IP_PROTO_NUM_CHAOS); |
| 176 | public static final IpProtocol IP_PROTO_UDP = new IpProtocol(IP_PROTO_NUM_UDP); |
| 177 | public static final IpProtocol IP_PROTO_MUX = new IpProtocol(IP_PROTO_NUM_MUX); |
| 178 | public static final IpProtocol IP_PROTO_DCN_MEAS = new IpProtocol(IP_PROTO_NUM_DCN_MEAS); |
| 179 | public static final IpProtocol IP_PROTO_HMP = new IpProtocol(IP_PROTO_NUM_HMP); |
| 180 | public static final IpProtocol IP_PROTO_PRM = new IpProtocol(IP_PROTO_NUM_PRM); |
| 181 | public static final IpProtocol IP_PROTO_XNS_IDP = new IpProtocol(IP_PROTO_NUM_XNS_IDP); |
| 182 | public static final IpProtocol IP_PROTO_TRUNK_1 = new IpProtocol(IP_PROTO_NUM_TRUNK_1); |
| 183 | public static final IpProtocol IP_PROTO_TRUNK_2 = new IpProtocol(IP_PROTO_NUM_TRUNK_2); |
| 184 | public static final IpProtocol IP_PROTO_LEAF_1 = new IpProtocol(IP_PROTO_NUM_LEAF_1); |
| 185 | public static final IpProtocol IP_PROTO_LEAF_2 = new IpProtocol(IP_PROTO_NUM_LEAF_2); |
| 186 | public static final IpProtocol IP_PROTO_RDP = new IpProtocol(IP_PROTO_NUM_RDP); |
| 187 | public static final IpProtocol IP_PROTO_IRTP = new IpProtocol(IP_PROTO_NUM_IRTP); |
| 188 | public static final IpProtocol IP_PROTO_ISO_TP4 = new IpProtocol(IP_PROTO_NUM_ISO_TP4); |
| 189 | public static final IpProtocol IP_PROTO_NETBLT = new IpProtocol(IP_PROTO_NUM_NETBLT); |
| 190 | public static final IpProtocol IP_PROTO_MFE_NSP = new IpProtocol(IP_PROTO_NUM_MFE_NSP); |
| 191 | public static final IpProtocol IP_PROTO_MERIT_INP = new IpProtocol(IP_PROTO_NUM_MERIT_INP); |
| 192 | public static final IpProtocol IP_PROTO_DCCP = new IpProtocol(IP_PROTO_NUM_DCCP); |
| 193 | public static final IpProtocol IP_PROTO_3PC = new IpProtocol(IP_PROTO_NUM_3PC); |
| 194 | public static final IpProtocol IP_PROTO_IDPR = new IpProtocol(IP_PROTO_NUM_IDPR); |
| 195 | public static final IpProtocol IP_PROTO_XTP = new IpProtocol(IP_PROTO_NUM_XTP); |
| 196 | public static final IpProtocol IP_PROTO_DDP = new IpProtocol(IP_PROTO_NUM_DDP); |
| 197 | public static final IpProtocol IP_PROTO_IDPR_CMTP = new IpProtocol(IP_PROTO_NUM_IDPR_CMTP); |
| 198 | public static final IpProtocol IP_PROTO_TP_PP = new IpProtocol(IP_PROTO_NUM_TP_PP); |
| 199 | public static final IpProtocol IP_PROTO_IL = new IpProtocol(IP_PROTO_NUM_IL); |
| 200 | public static final IpProtocol IP_PROTO_IPv6 = new IpProtocol(IP_PROTO_NUM_IPv6); |
| 201 | public static final IpProtocol IP_PROTO_SDRP = new IpProtocol(IP_PROTO_NUM_SDRP); |
| 202 | public static final IpProtocol IP_PROTO_IPv6_ROUTE = new IpProtocol(IP_PROTO_NUM_IPv6_ROUTE); |
| 203 | public static final IpProtocol IP_PROTO_IPv6_FRAG = new IpProtocol(IP_PROTO_NUM_IPv6_FRAG); |
| 204 | public static final IpProtocol IP_PROTO_IDRP = new IpProtocol(IP_PROTO_NUM_IDRP); |
| 205 | public static final IpProtocol IP_PROTO_RSVP = new IpProtocol(IP_PROTO_NUM_RSVP); |
| 206 | public static final IpProtocol IP_PROTO_GRE = new IpProtocol(IP_PROTO_NUM_GRE); |
| 207 | public static final IpProtocol IP_PROTO_MHRP = new IpProtocol(IP_PROTO_NUM_MHRP); |
| 208 | public static final IpProtocol IP_PROTO_BNA = new IpProtocol(IP_PROTO_NUM_BNA); |
| 209 | public static final IpProtocol IP_PROTO_ESP = new IpProtocol(IP_PROTO_NUM_ESP); |
| 210 | public static final IpProtocol IP_PROTO_AH = new IpProtocol(IP_PROTO_NUM_AH); |
| 211 | public static final IpProtocol IP_PROTO_I_NLSP = new IpProtocol(IP_PROTO_NUM_I_NLSP); |
| 212 | public static final IpProtocol IP_PROTO_SWIPE = new IpProtocol(IP_PROTO_NUM_SWIPE); |
| 213 | public static final IpProtocol IP_PROTO_NARP = new IpProtocol(IP_PROTO_NUM_NARP); |
| 214 | public static final IpProtocol IP_PROTO_MOBILE = new IpProtocol(IP_PROTO_NUM_MOBILE); |
| 215 | public static final IpProtocol IP_PROTO_TLSP = new IpProtocol(IP_PROTO_NUM_TLSP); |
| 216 | public static final IpProtocol IP_PROTO_SKIP = new IpProtocol(IP_PROTO_NUM_SKIP); |
| 217 | public static final IpProtocol IP_PROTO_IPv6_ICMP = new IpProtocol(IP_PROTO_NUM_IPv6_ICMP); |
| 218 | public static final IpProtocol IP_PROTO_IPv6_NO_NXT = new IpProtocol(IP_PROTO_NUM_IPv6_NO_NXT); |
| 219 | public static final IpProtocol IP_PROTO_IPv6_OPTS = new IpProtocol(IP_PROTO_NUM_IPv6_OPTS); |
| 220 | public static final IpProtocol IP_PROTO_HOST_INTERNAL = new IpProtocol(IP_PROTO_NUM_HOST_INTERNAL); |
| 221 | public static final IpProtocol IP_PROTO_CFTP = new IpProtocol(IP_PROTO_NUM_CFTP); |
| 222 | public static final IpProtocol IP_PROTO_LOCAL_NET = new IpProtocol(IP_PROTO_NUM_LOCAL_NET); |
| 223 | public static final IpProtocol IP_PROTO_SAT_EXPAK = new IpProtocol(IP_PROTO_NUM_SAT_EXPAK); |
| 224 | public static final IpProtocol IP_PROTO_KRYPTOLAN = new IpProtocol(IP_PROTO_NUM_KRYPTOLAN); |
| 225 | public static final IpProtocol IP_PROTO_RVD = new IpProtocol(IP_PROTO_NUM_RVD); |
| 226 | public static final IpProtocol IP_PROTO_IPPC = new IpProtocol(IP_PROTO_NUM_IPPC); |
| 227 | public static final IpProtocol IP_PROTO_DIST_FS = new IpProtocol(IP_PROTO_NUM_DIST_FS); |
| 228 | public static final IpProtocol IP_PROTO_SAT_MON = new IpProtocol(IP_PROTO_NUM_SAT_MON); |
| 229 | public static final IpProtocol IP_PROTO_VISA = new IpProtocol(IP_PROTO_NUM_VISA); |
| 230 | public static final IpProtocol IP_PROTO_IPCV = new IpProtocol(IP_PROTO_NUM_IPCV); |
| 231 | public static final IpProtocol IP_PROTO_CPNX = new IpProtocol(IP_PROTO_NUM_CPNX); |
| 232 | public static final IpProtocol IP_PROTO_CPHB = new IpProtocol(IP_PROTO_NUM_CPHB); |
| 233 | public static final IpProtocol IP_PROTO_WSN = new IpProtocol(IP_PROTO_NUM_WSN); |
| 234 | public static final IpProtocol IP_PROTO_PVP = new IpProtocol(IP_PROTO_NUM_PVP); |
| 235 | public static final IpProtocol IP_PROTO_BR_SAT_MON = new IpProtocol(IP_PROTO_NUM_BR_SAT_MON); |
| 236 | public static final IpProtocol IP_PROTO_SUN_ND = new IpProtocol(IP_PROTO_NUM_SUN_ND); |
| 237 | public static final IpProtocol IP_PROTO_WB_MON = new IpProtocol(IP_PROTO_NUM_WB_MON); |
| 238 | public static final IpProtocol IP_PROTO_WB_EXPAK = new IpProtocol(IP_PROTO_NUM_WB_EXPAK); |
| 239 | public static final IpProtocol IP_PROTO_ISO_IP = new IpProtocol(IP_PROTO_NUM_ISO_IP); |
| 240 | public static final IpProtocol IP_PROTO_VMTP = new IpProtocol(IP_PROTO_NUM_VMTP); |
| 241 | public static final IpProtocol IP_PROTO_SECURE_VMTP = new IpProtocol(IP_PROTO_NUM_SECURE_VMTP); |
| 242 | public static final IpProtocol IP_PROTO_VINES = new IpProtocol(IP_PROTO_NUM_VINES); |
| 243 | public static final IpProtocol IP_PROTO_TTP_IPTM = new IpProtocol(IP_PROTO_NUM_TTP_IPTM); |
| 244 | public static final IpProtocol IP_PROTO_NSFNET_IGP = new IpProtocol(IP_PROTO_NUM_NSFNET_IGP); |
| 245 | public static final IpProtocol IP_PROTO_DGP = new IpProtocol(IP_PROTO_NUM_DGP); |
| 246 | public static final IpProtocol IP_PROTO_TCF = new IpProtocol(IP_PROTO_NUM_TCF); |
| 247 | public static final IpProtocol IP_PROTO_EIGRP = new IpProtocol(IP_PROTO_NUM_EIGRP); |
| 248 | public static final IpProtocol IP_PROTO_OSPF = new IpProtocol(IP_PROTO_NUM_OSPF); |
| 249 | public static final IpProtocol IP_PROTO_Sprite_RPC = new IpProtocol(IP_PROTO_NUM_Sprite_RPC); |
| 250 | public static final IpProtocol IP_PROTO_LARP = new IpProtocol(IP_PROTO_NUM_LARP); |
| 251 | public static final IpProtocol IP_PROTO_MTP = new IpProtocol(IP_PROTO_NUM_MTP); |
| 252 | public static final IpProtocol IP_PROTO_AX_25 = new IpProtocol(IP_PROTO_NUM_AX_25); |
| 253 | public static final IpProtocol IP_PROTO_IPIP = new IpProtocol(IP_PROTO_NUM_IPIP); |
| 254 | public static final IpProtocol IP_PROTO_MICP = new IpProtocol(IP_PROTO_NUM_MICP); |
| 255 | public static final IpProtocol IP_PROTO_SCC_SP = new IpProtocol(IP_PROTO_NUM_SCC_SP); |
| 256 | public static final IpProtocol IP_PROTO_ETHERIP = new IpProtocol(IP_PROTO_NUM_ETHERIP); |
| 257 | public static final IpProtocol IP_PROTO_ENCAP = new IpProtocol(IP_PROTO_NUM_ENCAP); |
| 258 | public static final IpProtocol IP_PROTO_PRIVATE_ENCRYPT = new IpProtocol(IP_PROTO_NUM_PRIVATE_ENCRYPT); |
| 259 | public static final IpProtocol IP_PROTO_GMTP = new IpProtocol(IP_PROTO_NUM_GMTP); |
| 260 | public static final IpProtocol IP_PROTO_IFMP = new IpProtocol(IP_PROTO_NUM_IFMP); |
| 261 | public static final IpProtocol IP_PROTO_PNNI = new IpProtocol(IP_PROTO_NUM_PNNI); |
| 262 | public static final IpProtocol IP_PROTO_PIM = new IpProtocol(IP_PROTO_NUM_PIM); |
| 263 | public static final IpProtocol IP_PROTO_ARIS = new IpProtocol(IP_PROTO_NUM_ARIS); |
| 264 | public static final IpProtocol IP_PROTO_SCPS = new IpProtocol(IP_PROTO_NUM_SCPS); |
| 265 | public static final IpProtocol IP_PROTO_QNX = new IpProtocol(IP_PROTO_NUM_QNX); |
| 266 | public static final IpProtocol IP_PROTO_A_N = new IpProtocol(IP_PROTO_NUM_A_N); |
| 267 | public static final IpProtocol IP_PROTO_IP_COMP = new IpProtocol(IP_PROTO_NUM_IP_COMP); |
| 268 | public static final IpProtocol IP_PROTO_SNP = new IpProtocol(IP_PROTO_NUM_SNP); |
| 269 | public static final IpProtocol IP_PROTO_COMPAQ_PEER = new IpProtocol(IP_PROTO_NUM_COMPAQ_PEER); |
| 270 | public static final IpProtocol IP_PROTO_IPX_IN_IP = new IpProtocol(IP_PROTO_NUM_IPX_IN_IP); |
| 271 | public static final IpProtocol IP_PROTO_VRRP = new IpProtocol(IP_PROTO_NUM_VRRP); |
| 272 | public static final IpProtocol IP_PROTO_PGM = new IpProtocol(IP_PROTO_NUM_PGM); |
| 273 | public static final IpProtocol IP_PROTO_ZERO_HOP = new IpProtocol(IP_PROTO_NUM_ZERO_HOP); |
| 274 | public static final IpProtocol IP_PROTO_L2TP = new IpProtocol(IP_PROTO_NUM_L2TP); |
| 275 | public static final IpProtocol IP_PROTO_DDX = new IpProtocol(IP_PROTO_NUM_DDX); |
| 276 | public static final IpProtocol IP_PROTO_IATP = new IpProtocol(IP_PROTO_NUM_IATP); |
| 277 | public static final IpProtocol IP_PROTO_STP = new IpProtocol(IP_PROTO_NUM_STP); |
| 278 | public static final IpProtocol IP_PROTO_SRP = new IpProtocol(IP_PROTO_NUM_SRP); |
| 279 | public static final IpProtocol IP_PROTO_UTI = new IpProtocol(IP_PROTO_NUM_UTI); |
| 280 | public static final IpProtocol IP_PROTO_SMP = new IpProtocol(IP_PROTO_NUM_SMP); |
| 281 | public static final IpProtocol IP_PROTO_SM = new IpProtocol(IP_PROTO_NUM_SM); |
| 282 | public static final IpProtocol IP_PROTO_PTP = new IpProtocol(IP_PROTO_NUM_PTP); |
| 283 | public static final IpProtocol IP_PROTO_IS_IS_OVER_IPv4 = new IpProtocol(IP_PROTO_NUM_IS_IS_OVER_IPv4); |
| 284 | public static final IpProtocol IP_PROTO_FIRE = new IpProtocol(IP_PROTO_NUM_FIRE); |
| 285 | public static final IpProtocol IP_PROTO_CRTP = new IpProtocol(IP_PROTO_NUM_CRTP); |
| 286 | public static final IpProtocol IP_PROTO_CRUDP = new IpProtocol(IP_PROTO_NUM_CRUDP); |
| 287 | public static final IpProtocol IP_PROTO_SSCOPMCE = new IpProtocol(IP_PROTO_NUM_SSCOPMCE); |
| 288 | public static final IpProtocol IP_PROTO_IPLT = new IpProtocol(IP_PROTO_NUM_IPLT); |
| 289 | public static final IpProtocol IP_PROTO_SPS = new IpProtocol(IP_PROTO_NUM_SPS); |
| 290 | public static final IpProtocol IP_PROTO_PIPE = new IpProtocol(IP_PROTO_NUM_PIPE); |
| 291 | public static final IpProtocol IP_PROTO_SCTP = new IpProtocol(IP_PROTO_NUM_SCTP); |
| 292 | public static final IpProtocol IP_PROTO_FC = new IpProtocol(IP_PROTO_NUM_FC); |
| 293 | public static final IpProtocol IP_PROTO_RSVP_E2E_IGNORE = new IpProtocol(IP_PROTO_NUM_RSVP_E2E_IGNORE); |
| 294 | public static final IpProtocol IP_PROTO_MOBILITY_HEADER = new IpProtocol(IP_PROTO_NUM_MOBILITY_HEADER); |
| 295 | public static final IpProtocol IP_PROTO_UDP_LITE = new IpProtocol(IP_PROTO_NUM_UDP_LITE); |
| 296 | public static final IpProtocol IP_PROTO_MPLS_IN_IP = new IpProtocol(IP_PROTO_NUM_MPLS_IN_IP); |
| 297 | public static final IpProtocol IP_PROTO_MANET = new IpProtocol(IP_PROTO_NUM_MANET); |
| 298 | public static final IpProtocol IP_PROTO_HIP = new IpProtocol(IP_PROTO_NUM_HIP); |
| 299 | public static final IpProtocol IP_PROTO_SHIM6 = new IpProtocol(IP_PROTO_NUM_SHIM6); |
| 300 | |
| 301 | private IpProtocol(short version) { |
| 302 | this.proto = version; |
| 303 | } |
| 304 | |
| 305 | |
| 306 | @Override |
| 307 | public int getLength() { |
| 308 | return LENGTH; |
| 309 | } |
| 310 | |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 311 | public static IpProtocol of(short proto) { |
| 312 | switch (proto) { |
| 313 | case IP_PROTO_NUM_HOPOPT: |
| 314 | return IP_PROTO_HOPOPT; |
| 315 | case IP_PROTO_NUM_ICMP: |
| 316 | return IP_PROTO_ICMP; |
| 317 | case IP_PROTO_NUM_IGMP: |
| 318 | return IP_PROTO_IGMP; |
| 319 | case IP_PROTO_NUM_GGP: |
| 320 | return IP_PROTO_GGP; |
| 321 | case IP_PROTO_NUM_IPv4: |
| 322 | return IP_PROTO_IPv4; |
| 323 | case IP_PROTO_NUM_ST: |
| 324 | return IP_PROTO_ST; |
| 325 | case IP_PROTO_NUM_TCP: |
| 326 | return IP_PROTO_TCP; |
| 327 | case IP_PROTO_NUM_CBT: |
| 328 | return IP_PROTO_CBT; |
| 329 | case IP_PROTO_NUM_EGP: |
| 330 | return IP_PROTO_EGP; |
| 331 | case IP_PROTO_NUM_IGP: |
| 332 | return IP_PROTO_IGP; |
| 333 | case IP_PROTO_NUM_BBN_RCC_MON: |
| 334 | return IP_PROTO_BBN_RCC_MON; |
| 335 | case IP_PROTO_NUM_NVP_II: |
| 336 | return IP_PROTO_NVP_II; |
| 337 | case IP_PROTO_NUM_PUP: |
| 338 | return IP_PROTO_PUP; |
| 339 | case IP_PROTO_NUM_ARGUS: |
| 340 | return IP_PROTO_ARGUS; |
| 341 | case IP_PROTO_NUM_EMCON: |
| 342 | return IP_PROTO_EMCON; |
| 343 | case IP_PROTO_NUM_XNET: |
| 344 | return IP_PROTO_XNET; |
| 345 | case IP_PROTO_NUM_CHAOS: |
| 346 | return IP_PROTO_CHAOS; |
| 347 | case IP_PROTO_NUM_UDP: |
| 348 | return IP_PROTO_UDP; |
| 349 | case IP_PROTO_NUM_MUX: |
| 350 | return IP_PROTO_MUX; |
| 351 | case IP_PROTO_NUM_DCN_MEAS: |
| 352 | return IP_PROTO_DCN_MEAS; |
| 353 | case IP_PROTO_NUM_HMP: |
| 354 | return IP_PROTO_HMP; |
| 355 | case IP_PROTO_NUM_PRM: |
| 356 | return IP_PROTO_PRM; |
| 357 | case IP_PROTO_NUM_XNS_IDP: |
| 358 | return IP_PROTO_XNS_IDP; |
| 359 | case IP_PROTO_NUM_TRUNK_1: |
| 360 | return IP_PROTO_TRUNK_1; |
| 361 | case IP_PROTO_NUM_TRUNK_2: |
| 362 | return IP_PROTO_TRUNK_2; |
| 363 | case IP_PROTO_NUM_LEAF_1: |
| 364 | return IP_PROTO_LEAF_1; |
| 365 | case IP_PROTO_NUM_LEAF_2: |
| 366 | return IP_PROTO_LEAF_2; |
| 367 | case IP_PROTO_NUM_RDP: |
| 368 | return IP_PROTO_RDP; |
| 369 | case IP_PROTO_NUM_IRTP: |
| 370 | return IP_PROTO_IRTP; |
| 371 | case IP_PROTO_NUM_ISO_TP4: |
| 372 | return IP_PROTO_ISO_TP4; |
| 373 | case IP_PROTO_NUM_NETBLT: |
| 374 | return IP_PROTO_NETBLT; |
| 375 | case IP_PROTO_NUM_MFE_NSP: |
| 376 | return IP_PROTO_MFE_NSP; |
| 377 | case IP_PROTO_NUM_MERIT_INP: |
| 378 | return IP_PROTO_MERIT_INP; |
| 379 | case IP_PROTO_NUM_DCCP: |
| 380 | return IP_PROTO_DCCP; |
| 381 | case IP_PROTO_NUM_3PC: |
| 382 | return IP_PROTO_3PC; |
| 383 | case IP_PROTO_NUM_IDPR: |
| 384 | return IP_PROTO_IDPR; |
| 385 | case IP_PROTO_NUM_XTP: |
| 386 | return IP_PROTO_XTP; |
| 387 | case IP_PROTO_NUM_DDP: |
| 388 | return IP_PROTO_DDP; |
| 389 | case IP_PROTO_NUM_IDPR_CMTP: |
| 390 | return IP_PROTO_IDPR_CMTP; |
| 391 | case IP_PROTO_NUM_TP_PP: |
| 392 | return IP_PROTO_TP_PP; |
| 393 | case IP_PROTO_NUM_IL: |
| 394 | return IP_PROTO_IL; |
| 395 | case IP_PROTO_NUM_IPv6: |
| 396 | return IP_PROTO_IPv6; |
| 397 | case IP_PROTO_NUM_SDRP: |
| 398 | return IP_PROTO_SDRP; |
| 399 | case IP_PROTO_NUM_IPv6_ROUTE: |
| 400 | return IP_PROTO_IPv6_ROUTE; |
| 401 | case IP_PROTO_NUM_IPv6_FRAG: |
| 402 | return IP_PROTO_IPv6_FRAG; |
| 403 | case IP_PROTO_NUM_IDRP: |
| 404 | return IP_PROTO_IDRP; |
| 405 | case IP_PROTO_NUM_RSVP: |
| 406 | return IP_PROTO_RSVP; |
| 407 | case IP_PROTO_NUM_GRE: |
| 408 | return IP_PROTO_GRE; |
| 409 | case IP_PROTO_NUM_MHRP: |
| 410 | return IP_PROTO_MHRP; |
| 411 | case IP_PROTO_NUM_BNA: |
| 412 | return IP_PROTO_BNA; |
| 413 | case IP_PROTO_NUM_ESP: |
| 414 | return IP_PROTO_ESP; |
| 415 | case IP_PROTO_NUM_AH: |
| 416 | return IP_PROTO_AH; |
| 417 | case IP_PROTO_NUM_I_NLSP: |
| 418 | return IP_PROTO_I_NLSP; |
| 419 | case IP_PROTO_NUM_SWIPE: |
| 420 | return IP_PROTO_SWIPE; |
| 421 | case IP_PROTO_NUM_NARP: |
| 422 | return IP_PROTO_NARP; |
| 423 | case IP_PROTO_NUM_MOBILE: |
| 424 | return IP_PROTO_MOBILE; |
| 425 | case IP_PROTO_NUM_TLSP: |
| 426 | return IP_PROTO_TLSP; |
| 427 | case IP_PROTO_NUM_SKIP: |
| 428 | return IP_PROTO_SKIP; |
| 429 | case IP_PROTO_NUM_IPv6_ICMP: |
| 430 | return IP_PROTO_IPv6_ICMP; |
| 431 | case IP_PROTO_NUM_IPv6_NO_NXT: |
| 432 | return IP_PROTO_IPv6_NO_NXT; |
| 433 | case IP_PROTO_NUM_IPv6_OPTS: |
| 434 | return IP_PROTO_IPv6_OPTS; |
| 435 | case IP_PROTO_NUM_HOST_INTERNAL: |
| 436 | return IP_PROTO_HOST_INTERNAL; |
| 437 | case IP_PROTO_NUM_CFTP: |
| 438 | return IP_PROTO_CFTP; |
| 439 | case IP_PROTO_NUM_LOCAL_NET: |
| 440 | return IP_PROTO_LOCAL_NET; |
| 441 | case IP_PROTO_NUM_SAT_EXPAK: |
| 442 | return IP_PROTO_SAT_EXPAK; |
| 443 | case IP_PROTO_NUM_KRYPTOLAN: |
| 444 | return IP_PROTO_KRYPTOLAN; |
| 445 | case IP_PROTO_NUM_RVD: |
| 446 | return IP_PROTO_RVD; |
| 447 | case IP_PROTO_NUM_IPPC: |
| 448 | return IP_PROTO_IPPC; |
| 449 | case IP_PROTO_NUM_DIST_FS: |
| 450 | return IP_PROTO_DIST_FS; |
| 451 | case IP_PROTO_NUM_SAT_MON: |
| 452 | return IP_PROTO_SAT_MON; |
| 453 | case IP_PROTO_NUM_VISA: |
| 454 | return IP_PROTO_VISA; |
| 455 | case IP_PROTO_NUM_IPCV: |
| 456 | return IP_PROTO_IPCV; |
| 457 | case IP_PROTO_NUM_CPNX: |
| 458 | return IP_PROTO_CPNX; |
| 459 | case IP_PROTO_NUM_CPHB: |
| 460 | return IP_PROTO_CPHB; |
| 461 | case IP_PROTO_NUM_WSN: |
| 462 | return IP_PROTO_WSN; |
| 463 | case IP_PROTO_NUM_PVP: |
| 464 | return IP_PROTO_PVP; |
| 465 | case IP_PROTO_NUM_BR_SAT_MON: |
| 466 | return IP_PROTO_BR_SAT_MON; |
| 467 | case IP_PROTO_NUM_SUN_ND: |
| 468 | return IP_PROTO_SUN_ND; |
| 469 | case IP_PROTO_NUM_WB_MON: |
| 470 | return IP_PROTO_WB_MON; |
| 471 | case IP_PROTO_NUM_WB_EXPAK: |
| 472 | return IP_PROTO_WB_EXPAK; |
| 473 | case IP_PROTO_NUM_ISO_IP: |
| 474 | return IP_PROTO_ISO_IP; |
| 475 | case IP_PROTO_NUM_VMTP: |
| 476 | return IP_PROTO_VMTP; |
| 477 | case IP_PROTO_NUM_SECURE_VMTP: |
| 478 | return IP_PROTO_SECURE_VMTP; |
| 479 | case IP_PROTO_NUM_VINES: |
| 480 | return IP_PROTO_VINES; |
| 481 | case IP_PROTO_NUM_TTP_IPTM: |
| 482 | return IP_PROTO_TTP_IPTM; |
| 483 | case IP_PROTO_NUM_NSFNET_IGP: |
| 484 | return IP_PROTO_NSFNET_IGP; |
| 485 | case IP_PROTO_NUM_DGP: |
| 486 | return IP_PROTO_DGP; |
| 487 | case IP_PROTO_NUM_TCF: |
| 488 | return IP_PROTO_TCF; |
| 489 | case IP_PROTO_NUM_EIGRP: |
| 490 | return IP_PROTO_EIGRP; |
| 491 | case IP_PROTO_NUM_OSPF: |
| 492 | return IP_PROTO_OSPF; |
| 493 | case IP_PROTO_NUM_Sprite_RPC: |
| 494 | return IP_PROTO_Sprite_RPC; |
| 495 | case IP_PROTO_NUM_LARP: |
| 496 | return IP_PROTO_LARP; |
| 497 | case IP_PROTO_NUM_MTP: |
| 498 | return IP_PROTO_MTP; |
| 499 | case IP_PROTO_NUM_AX_25: |
| 500 | return IP_PROTO_AX_25; |
| 501 | case IP_PROTO_NUM_IPIP: |
| 502 | return IP_PROTO_IPIP; |
| 503 | case IP_PROTO_NUM_MICP: |
| 504 | return IP_PROTO_MICP; |
| 505 | case IP_PROTO_NUM_SCC_SP: |
| 506 | return IP_PROTO_SCC_SP; |
| 507 | case IP_PROTO_NUM_ETHERIP: |
| 508 | return IP_PROTO_ETHERIP; |
| 509 | case IP_PROTO_NUM_ENCAP: |
| 510 | return IP_PROTO_ENCAP; |
| 511 | case IP_PROTO_NUM_PRIVATE_ENCRYPT: |
| 512 | return IP_PROTO_PRIVATE_ENCRYPT; |
| 513 | case IP_PROTO_NUM_GMTP: |
| 514 | return IP_PROTO_GMTP; |
| 515 | case IP_PROTO_NUM_IFMP: |
| 516 | return IP_PROTO_IFMP; |
| 517 | case IP_PROTO_NUM_PNNI: |
| 518 | return IP_PROTO_PNNI; |
| 519 | case IP_PROTO_NUM_PIM: |
| 520 | return IP_PROTO_PIM; |
| 521 | case IP_PROTO_NUM_ARIS: |
| 522 | return IP_PROTO_ARIS; |
| 523 | case IP_PROTO_NUM_SCPS: |
| 524 | return IP_PROTO_SCPS; |
| 525 | case IP_PROTO_NUM_QNX: |
| 526 | return IP_PROTO_QNX; |
| 527 | case IP_PROTO_NUM_A_N: |
| 528 | return IP_PROTO_A_N; |
| 529 | case IP_PROTO_NUM_IP_COMP: |
| 530 | return IP_PROTO_IP_COMP; |
| 531 | case IP_PROTO_NUM_SNP: |
| 532 | return IP_PROTO_SNP; |
| 533 | case IP_PROTO_NUM_COMPAQ_PEER: |
| 534 | return IP_PROTO_COMPAQ_PEER; |
| 535 | case IP_PROTO_NUM_IPX_IN_IP: |
| 536 | return IP_PROTO_IPX_IN_IP; |
| 537 | case IP_PROTO_NUM_VRRP: |
| 538 | return IP_PROTO_VRRP; |
| 539 | case IP_PROTO_NUM_PGM: |
| 540 | return IP_PROTO_PGM; |
| 541 | case IP_PROTO_NUM_ZERO_HOP: |
| 542 | return IP_PROTO_ZERO_HOP; |
| 543 | case IP_PROTO_NUM_L2TP: |
| 544 | return IP_PROTO_L2TP; |
| 545 | case IP_PROTO_NUM_DDX: |
| 546 | return IP_PROTO_DDX; |
| 547 | case IP_PROTO_NUM_IATP: |
| 548 | return IP_PROTO_IATP; |
| 549 | case IP_PROTO_NUM_STP: |
| 550 | return IP_PROTO_STP; |
| 551 | case IP_PROTO_NUM_SRP: |
| 552 | return IP_PROTO_SRP; |
| 553 | case IP_PROTO_NUM_UTI: |
| 554 | return IP_PROTO_UTI; |
| 555 | case IP_PROTO_NUM_SMP: |
| 556 | return IP_PROTO_SMP; |
| 557 | case IP_PROTO_NUM_SM: |
| 558 | return IP_PROTO_SM; |
| 559 | case IP_PROTO_NUM_PTP: |
| 560 | return IP_PROTO_PTP; |
| 561 | case IP_PROTO_NUM_IS_IS_OVER_IPv4: |
| 562 | return IP_PROTO_IS_IS_OVER_IPv4; |
| 563 | case IP_PROTO_NUM_FIRE: |
| 564 | return IP_PROTO_FIRE; |
| 565 | case IP_PROTO_NUM_CRTP: |
| 566 | return IP_PROTO_CRTP; |
| 567 | case IP_PROTO_NUM_CRUDP: |
| 568 | return IP_PROTO_CRUDP; |
| 569 | case IP_PROTO_NUM_SSCOPMCE: |
| 570 | return IP_PROTO_SSCOPMCE; |
| 571 | case IP_PROTO_NUM_IPLT: |
| 572 | return IP_PROTO_IPLT; |
| 573 | case IP_PROTO_NUM_SPS: |
| 574 | return IP_PROTO_SPS; |
| 575 | case IP_PROTO_NUM_PIPE: |
| 576 | return IP_PROTO_PIPE; |
| 577 | case IP_PROTO_NUM_SCTP: |
| 578 | return IP_PROTO_SCTP; |
| 579 | case IP_PROTO_NUM_FC: |
| 580 | return IP_PROTO_FC; |
| 581 | case IP_PROTO_NUM_RSVP_E2E_IGNORE: |
| 582 | return IP_PROTO_RSVP_E2E_IGNORE; |
| 583 | case IP_PROTO_NUM_MOBILITY_HEADER: |
| 584 | return IP_PROTO_MOBILITY_HEADER; |
| 585 | case IP_PROTO_NUM_UDP_LITE: |
| 586 | return IP_PROTO_UDP_LITE; |
| 587 | case IP_PROTO_NUM_MPLS_IN_IP: |
| 588 | return IP_PROTO_MPLS_IN_IP; |
| 589 | case IP_PROTO_NUM_MANET: |
| 590 | return IP_PROTO_MANET; |
| 591 | case IP_PROTO_NUM_HIP: |
| 592 | return IP_PROTO_HIP; |
| 593 | case IP_PROTO_NUM_SHIM6: |
| 594 | return IP_PROTO_SHIM6; |
| 595 | default: |
| 596 | if (proto >= MAX_PROTO) { |
| 597 | throw new IllegalArgumentException("Illegal IP protocol number: " |
| 598 | + proto); |
| 599 | } else { |
| 600 | return new IpProtocol(proto); |
| 601 | } |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | @Override |
| 606 | public boolean equals(Object obj) { |
| 607 | if (!(obj instanceof IpProtocol)) |
| 608 | return false; |
| 609 | IpProtocol o = (IpProtocol)obj; |
| 610 | if (o.proto != this.proto) |
| 611 | return false; |
| 612 | return true; |
| 613 | } |
| 614 | |
| 615 | @Override |
| 616 | public int hashCode() { |
| 617 | final int prime = 37; |
| 618 | int result = 1; |
| 619 | result = prime * result + proto; |
| 620 | return result; |
| 621 | } |
| 622 | |
| 623 | @Override |
| 624 | public String toString() { |
| 625 | return Integer.toHexString(proto); |
| 626 | } |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 627 | |
| 628 | public void writeByte(ChannelBuffer c) { |
| 629 | c.writeByte(this.proto); |
Yotam Harchol | 161a5d5 | 2013-07-25 17:17:48 -0700 | [diff] [blame] | 630 | } |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 631 | |
Yotam Harchol | d7b8420 | 2013-07-26 16:08:10 -0700 | [diff] [blame] | 632 | public static IpProtocol readByte(ChannelBuffer c) { |
| 633 | return IpProtocol.of(c.readUnsignedByte()); |
| 634 | } |
Yotam Harchol | 5c9d6f4 | 2013-08-01 11:09:20 -0700 | [diff] [blame^] | 635 | |
| 636 | @Override |
| 637 | public IpProtocol applyMask(IpProtocol mask) { |
| 638 | return IpProtocol.of((short)(this.proto & mask.proto)); |
| 639 | } |
| 640 | |
| 641 | public short getIpProtocolNumber() { |
| 642 | return proto; |
| 643 | } |
| 644 | |
Andreas Wundsam | 40e14f7 | 2013-05-06 14:49:08 -0700 | [diff] [blame] | 645 | } |