blob: 69f497e03b560debbcc6a2eb2c270c807cd88e5e [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001package org.projectfloodlight.openflow.types;
2
3import org.jboss.netty.buffer.ChannelBuffer;
4
5import com.google.common.hash.PrimitiveSink;
6import com.google.common.primitives.Shorts;
7
8/**
9 * IP-Protocol field representation
10 *
11 * @author Yotam Harchol (yotam.harchol@bigswitch.com)
12 */
13public class IpProtocol implements OFValueType<IpProtocol> {
14
15 static final short MAX_PROTO = 0xFF;
16 static final int LENGTH = 1;
17
18 private final short proto;
19
20 static final short NUM_HOPOPT = 0x00;
21 static final short NUM_ICMP = 0x01;
22 static final short NUM_IGMP = 0x02;
23 static final short NUM_GGP = 0x03;
24 static final short NUM_IPv4 = 0x04;
25 static final short NUM_ST = 0x05;
26 static final short NUM_TCP = 0x06;
27 static final short NUM_CBT = 0x07;
28 static final short NUM_EGP = 0x08;
29 static final short NUM_IGP = 0x09;
30 static final short NUM_BBN_RCC_MON = 0x0A;
31 static final short NUM_NVP_II = 0x0B;
32 static final short NUM_PUP = 0x0C;
33 static final short NUM_ARGUS = 0x0D;
34 static final short NUM_EMCON = 0x0E;
35 static final short NUM_XNET = 0x0F;
36 static final short NUM_CHAOS = 0x10;
37 static final short NUM_UDP = 0x11;
38 static final short NUM_MUX = 0x12;
39 static final short NUM_DCN_MEAS = 0x13;
40 static final short NUM_HMP = 0x14;
41 static final short NUM_PRM = 0x15;
42 static final short NUM_XNS_IDP = 0x16;
43 static final short NUM_TRUNK_1 = 0x17;
44 static final short NUM_TRUNK_2 = 0x18;
45 static final short NUM_LEAF_1 = 0x19;
46 static final short NUM_LEAF_2 = 0x1A;
47 static final short NUM_RDP = 0x1B;
48 static final short NUM_IRTP = 0x1C;
49 static final short NUM_ISO_TP4 = 0x1D;
50 static final short NUM_NETBLT = 0x1E;
51 static final short NUM_MFE_NSP = 0x1F;
52 static final short NUM_MERIT_INP = 0x20;
53 static final short NUM_DCCP = 0x21;
54 static final short NUM_3PC = 0x22;
55 static final short NUM_IDPR = 0x23;
56 static final short NUM_XTP = 0x24;
57 static final short NUM_DDP = 0x25;
58 static final short NUM_IDPR_CMTP = 0x26;
59 static final short NUM_TP_PP = 0x27;
60 static final short NUM_IL = 0x28;
61 static final short NUM_IPv6 = 0x29;
62 static final short NUM_SDRP = 0x2A;
63 static final short NUM_IPv6_ROUTE = 0x2B;
64 static final short NUM_IPv6_FRAG = 0x2C;
65 static final short NUM_IDRP = 0x2D;
66 static final short NUM_RSVP = 0x2E;
67 static final short NUM_GRE = 0x2F;
68 static final short NUM_MHRP = 0x30;
69 static final short NUM_BNA = 0x31;
70 static final short NUM_ESP = 0x32;
71 static final short NUM_AH = 0x33;
72 static final short NUM_I_NLSP = 0x34;
73 static final short NUM_SWIPE = 0x35;
74 static final short NUM_NARP = 0x36;
75 static final short NUM_MOBILE = 0x37;
76 static final short NUM_TLSP = 0x38;
77 static final short NUM_SKIP = 0x39;
78 static final short NUM_IPv6_ICMP = 0x3A;
79 static final short NUM_IPv6_NO_NXT = 0x3B;
80 static final short NUM_IPv6_OPTS = 0x3C;
81 static final short NUM_HOST_INTERNAL = 0x3D;
82 static final short NUM_CFTP = 0x3E;
83 static final short NUM_LOCAL_NET = 0x3F;
84 static final short NUM_SAT_EXPAK = 0x40;
85 static final short NUM_KRYPTOLAN = 0x41;
86 static final short NUM_RVD = 0x42;
87 static final short NUM_IPPC = 0x43;
88 static final short NUM_DIST_FS = 0x44;
89 static final short NUM_SAT_MON = 0x45;
90 static final short NUM_VISA = 0x46;
91 static final short NUM_IPCV = 0x47;
92 static final short NUM_CPNX = 0x48;
93 static final short NUM_CPHB = 0x49;
94 static final short NUM_WSN = 0x4A;
95 static final short NUM_PVP = 0x4B;
96 static final short NUM_BR_SAT_MON = 0x4C;
97 static final short NUM_SUN_ND = 0x4D;
98 static final short NUM_WB_MON = 0x4E;
99 static final short NUM_WB_EXPAK = 0x4F;
100 static final short NUM_ISO_IP = 0x50;
101 static final short NUM_VMTP = 0x51;
102 static final short NUM_SECURE_VMTP = 0x52;
103 static final short NUM_VINES = 0x53;
104 static final short NUM_TTP_IPTM = 0x54;
105 static final short NUM_NSFNET_IGP = 0x55;
106 static final short NUM_DGP = 0x56;
107 static final short NUM_TCF = 0x57;
108 static final short NUM_EIGRP = 0x58;
109 static final short NUM_OSPF = 0x59;
110 static final short NUM_Sprite_RPC = 0x5A;
111 static final short NUM_LARP = 0x5B;
112 static final short NUM_MTP = 0x5C;
113 static final short NUM_AX_25 = 0x5D;
114 static final short NUM_IPIP = 0x5E;
115 static final short NUM_MICP = 0x5F;
116 static final short NUM_SCC_SP = 0x60;
117 static final short NUM_ETHERIP = 0x61;
118 static final short NUM_ENCAP = 0x62;
119 static final short NUM_PRIVATE_ENCRYPT = 0x63;
120 static final short NUM_GMTP = 0x64;
121 static final short NUM_IFMP = 0x65;
122 static final short NUM_PNNI = 0x66;
123 static final short NUM_PIM = 0x67;
124 static final short NUM_ARIS = 0x68;
125 static final short NUM_SCPS = 0x69;
126 static final short NUM_QNX = 0x6A;
127 static final short NUM_A_N = 0x6B;
128 static final short NUM_IP_COMP = 0x6C;
129 static final short NUM_SNP = 0x6D;
130 static final short NUM_COMPAQ_PEER = 0x6E;
131 static final short NUM_IPX_IN_IP = 0x6F;
132 static final short NUM_VRRP = 0x70;
133 static final short NUM_PGM = 0x71;
134 static final short NUM_ZERO_HOP = 0x72;
135 static final short NUM_L2TP = 0x73;
136 static final short NUM_DDX = 0x74;
137 static final short NUM_IATP = 0x75;
138 static final short NUM_STP = 0x76;
139 static final short NUM_SRP = 0x77;
140 static final short NUM_UTI = 0x78;
141 static final short NUM_SMP = 0x79;
142 static final short NUM_SM = 0x7A;
143 static final short NUM_PTP = 0x7B;
144 static final short NUM_IS_IS_OVER_IPv4 = 0x7C;
145 static final short NUM_FIRE = 0x7D;
146 static final short NUM_CRTP = 0x7E;
147 static final short NUM_CRUDP = 0x7F;
148 static final short NUM_SSCOPMCE = 0x80;
149 static final short NUM_IPLT = 0x81;
150 static final short NUM_SPS = 0x82;
151 static final short NUM_PIPE = 0x83;
152 static final short NUM_SCTP = 0x84;
153 static final short NUM_FC = 0x85;
154 static final short NUM_RSVP_E2E_IGNORE = 0x86;
155 static final short NUM_MOBILITY_HEADER = 0x87;
156 static final short NUM_UDP_LITE = 0x88;
157 static final short NUM_MPLS_IN_IP = 0x89;
158 static final short NUM_MANET = 0x8A;
159 static final short NUM_HIP = 0x8B;
160 static final short NUM_SHIM6 = 0x8C;
161
162 public static final IpProtocol HOPOPT = new IpProtocol(NUM_HOPOPT);
163 public static final IpProtocol ICMP = new IpProtocol(NUM_ICMP);
164 public static final IpProtocol IGMP = new IpProtocol(NUM_IGMP);
165 public static final IpProtocol GGP = new IpProtocol(NUM_GGP);
166 public static final IpProtocol IPv4 = new IpProtocol(NUM_IPv4);
167 public static final IpProtocol ST = new IpProtocol(NUM_ST);
168 public static final IpProtocol TCP = new IpProtocol(NUM_TCP);
169 public static final IpProtocol CBT = new IpProtocol(NUM_CBT);
170 public static final IpProtocol EGP = new IpProtocol(NUM_EGP);
171 public static final IpProtocol IGP = new IpProtocol(NUM_IGP);
172 public static final IpProtocol BBN_RCC_MON = new IpProtocol(NUM_BBN_RCC_MON);
173 public static final IpProtocol NVP_II = new IpProtocol(NUM_NVP_II);
174 public static final IpProtocol PUP = new IpProtocol(NUM_PUP);
175 public static final IpProtocol ARGUS = new IpProtocol(NUM_ARGUS);
176 public static final IpProtocol EMCON = new IpProtocol(NUM_EMCON);
177 public static final IpProtocol XNET = new IpProtocol(NUM_XNET);
178 public static final IpProtocol CHAOS = new IpProtocol(NUM_CHAOS);
179 public static final IpProtocol UDP = new IpProtocol(NUM_UDP);
180 public static final IpProtocol MUX = new IpProtocol(NUM_MUX);
181 public static final IpProtocol DCN_MEAS = new IpProtocol(NUM_DCN_MEAS);
182 public static final IpProtocol HMP = new IpProtocol(NUM_HMP);
183 public static final IpProtocol PRM = new IpProtocol(NUM_PRM);
184 public static final IpProtocol XNS_IDP = new IpProtocol(NUM_XNS_IDP);
185 public static final IpProtocol TRUNK_1 = new IpProtocol(NUM_TRUNK_1);
186 public static final IpProtocol TRUNK_2 = new IpProtocol(NUM_TRUNK_2);
187 public static final IpProtocol LEAF_1 = new IpProtocol(NUM_LEAF_1);
188 public static final IpProtocol LEAF_2 = new IpProtocol(NUM_LEAF_2);
189 public static final IpProtocol RDP = new IpProtocol(NUM_RDP);
190 public static final IpProtocol IRTP = new IpProtocol(NUM_IRTP);
191 public static final IpProtocol ISO_TP4 = new IpProtocol(NUM_ISO_TP4);
192 public static final IpProtocol NETBLT = new IpProtocol(NUM_NETBLT);
193 public static final IpProtocol MFE_NSP = new IpProtocol(NUM_MFE_NSP);
194 public static final IpProtocol MERIT_INP = new IpProtocol(NUM_MERIT_INP);
195 public static final IpProtocol DCCP = new IpProtocol(NUM_DCCP);
196 public static final IpProtocol _3PC = new IpProtocol(NUM_3PC);
197 public static final IpProtocol IDPR = new IpProtocol(NUM_IDPR);
198 public static final IpProtocol XTP = new IpProtocol(NUM_XTP);
199 public static final IpProtocol DDP = new IpProtocol(NUM_DDP);
200 public static final IpProtocol IDPR_CMTP = new IpProtocol(NUM_IDPR_CMTP);
201 public static final IpProtocol TP_PP = new IpProtocol(NUM_TP_PP);
202 public static final IpProtocol IL = new IpProtocol(NUM_IL);
203 public static final IpProtocol IPv6 = new IpProtocol(NUM_IPv6);
204 public static final IpProtocol SDRP = new IpProtocol(NUM_SDRP);
205 public static final IpProtocol IPv6_ROUTE = new IpProtocol(NUM_IPv6_ROUTE);
206 public static final IpProtocol IPv6_FRAG = new IpProtocol(NUM_IPv6_FRAG);
207 public static final IpProtocol IDRP = new IpProtocol(NUM_IDRP);
208 public static final IpProtocol RSVP = new IpProtocol(NUM_RSVP);
209 public static final IpProtocol GRE = new IpProtocol(NUM_GRE);
210 public static final IpProtocol MHRP = new IpProtocol(NUM_MHRP);
211 public static final IpProtocol BNA = new IpProtocol(NUM_BNA);
212 public static final IpProtocol ESP = new IpProtocol(NUM_ESP);
213 public static final IpProtocol AH = new IpProtocol(NUM_AH);
214 public static final IpProtocol I_NLSP = new IpProtocol(NUM_I_NLSP);
215 public static final IpProtocol SWIPE = new IpProtocol(NUM_SWIPE);
216 public static final IpProtocol NARP = new IpProtocol(NUM_NARP);
217 public static final IpProtocol MOBILE = new IpProtocol(NUM_MOBILE);
218 public static final IpProtocol TLSP = new IpProtocol(NUM_TLSP);
219 public static final IpProtocol SKIP = new IpProtocol(NUM_SKIP);
220 public static final IpProtocol IPv6_ICMP = new IpProtocol(NUM_IPv6_ICMP);
221 public static final IpProtocol IPv6_NO_NXT = new IpProtocol(NUM_IPv6_NO_NXT);
222 public static final IpProtocol IPv6_OPTS = new IpProtocol(NUM_IPv6_OPTS);
223 public static final IpProtocol HOST_INTERNAL = new IpProtocol(NUM_HOST_INTERNAL);
224 public static final IpProtocol CFTP = new IpProtocol(NUM_CFTP);
225 public static final IpProtocol LOCAL_NET = new IpProtocol(NUM_LOCAL_NET);
226 public static final IpProtocol SAT_EXPAK = new IpProtocol(NUM_SAT_EXPAK);
227 public static final IpProtocol KRYPTOLAN = new IpProtocol(NUM_KRYPTOLAN);
228 public static final IpProtocol RVD = new IpProtocol(NUM_RVD);
229 public static final IpProtocol IPPC = new IpProtocol(NUM_IPPC);
230 public static final IpProtocol DIST_FS = new IpProtocol(NUM_DIST_FS);
231 public static final IpProtocol SAT_MON = new IpProtocol(NUM_SAT_MON);
232 public static final IpProtocol VISA = new IpProtocol(NUM_VISA);
233 public static final IpProtocol IPCV = new IpProtocol(NUM_IPCV);
234 public static final IpProtocol CPNX = new IpProtocol(NUM_CPNX);
235 public static final IpProtocol CPHB = new IpProtocol(NUM_CPHB);
236 public static final IpProtocol WSN = new IpProtocol(NUM_WSN);
237 public static final IpProtocol PVP = new IpProtocol(NUM_PVP);
238 public static final IpProtocol BR_SAT_MON = new IpProtocol(NUM_BR_SAT_MON);
239 public static final IpProtocol SUN_ND = new IpProtocol(NUM_SUN_ND);
240 public static final IpProtocol WB_MON = new IpProtocol(NUM_WB_MON);
241 public static final IpProtocol WB_EXPAK = new IpProtocol(NUM_WB_EXPAK);
242 public static final IpProtocol ISO_IP = new IpProtocol(NUM_ISO_IP);
243 public static final IpProtocol VMTP = new IpProtocol(NUM_VMTP);
244 public static final IpProtocol SECURE_VMTP = new IpProtocol(NUM_SECURE_VMTP);
245 public static final IpProtocol VINES = new IpProtocol(NUM_VINES);
246 public static final IpProtocol TTP_IPTM = new IpProtocol(NUM_TTP_IPTM);
247 public static final IpProtocol NSFNET_IGP = new IpProtocol(NUM_NSFNET_IGP);
248 public static final IpProtocol DGP = new IpProtocol(NUM_DGP);
249 public static final IpProtocol TCF = new IpProtocol(NUM_TCF);
250 public static final IpProtocol EIGRP = new IpProtocol(NUM_EIGRP);
251 public static final IpProtocol OSPF = new IpProtocol(NUM_OSPF);
252 public static final IpProtocol Sprite_RPC = new IpProtocol(NUM_Sprite_RPC);
253 public static final IpProtocol LARP = new IpProtocol(NUM_LARP);
254 public static final IpProtocol MTP = new IpProtocol(NUM_MTP);
255 public static final IpProtocol AX_25 = new IpProtocol(NUM_AX_25);
256 public static final IpProtocol IPIP = new IpProtocol(NUM_IPIP);
257 public static final IpProtocol MICP = new IpProtocol(NUM_MICP);
258 public static final IpProtocol SCC_SP = new IpProtocol(NUM_SCC_SP);
259 public static final IpProtocol ETHERIP = new IpProtocol(NUM_ETHERIP);
260 public static final IpProtocol ENCAP = new IpProtocol(NUM_ENCAP);
261 public static final IpProtocol PRIVATE_ENCRYPT = new IpProtocol(NUM_PRIVATE_ENCRYPT);
262 public static final IpProtocol GMTP = new IpProtocol(NUM_GMTP);
263 public static final IpProtocol IFMP = new IpProtocol(NUM_IFMP);
264 public static final IpProtocol PNNI = new IpProtocol(NUM_PNNI);
265 public static final IpProtocol PIM = new IpProtocol(NUM_PIM);
266 public static final IpProtocol ARIS = new IpProtocol(NUM_ARIS);
267 public static final IpProtocol SCPS = new IpProtocol(NUM_SCPS);
268 public static final IpProtocol QNX = new IpProtocol(NUM_QNX);
269 public static final IpProtocol A_N = new IpProtocol(NUM_A_N);
270 public static final IpProtocol IP_COMP = new IpProtocol(NUM_IP_COMP);
271 public static final IpProtocol SNP = new IpProtocol(NUM_SNP);
272 public static final IpProtocol COMPAQ_PEER = new IpProtocol(NUM_COMPAQ_PEER);
273 public static final IpProtocol IPX_IN_IP = new IpProtocol(NUM_IPX_IN_IP);
274 public static final IpProtocol VRRP = new IpProtocol(NUM_VRRP);
275 public static final IpProtocol PGM = new IpProtocol(NUM_PGM);
276 public static final IpProtocol ZERO_HOP = new IpProtocol(NUM_ZERO_HOP);
277 public static final IpProtocol L2TP = new IpProtocol(NUM_L2TP);
278 public static final IpProtocol DDX = new IpProtocol(NUM_DDX);
279 public static final IpProtocol IATP = new IpProtocol(NUM_IATP);
280 public static final IpProtocol STP = new IpProtocol(NUM_STP);
281 public static final IpProtocol SRP = new IpProtocol(NUM_SRP);
282 public static final IpProtocol UTI = new IpProtocol(NUM_UTI);
283 public static final IpProtocol SMP = new IpProtocol(NUM_SMP);
284 public static final IpProtocol SM = new IpProtocol(NUM_SM);
285 public static final IpProtocol PTP = new IpProtocol(NUM_PTP);
286 public static final IpProtocol IS_IS_OVER_IPv4 = new IpProtocol(NUM_IS_IS_OVER_IPv4);
287 public static final IpProtocol FIRE = new IpProtocol(NUM_FIRE);
288 public static final IpProtocol CRTP = new IpProtocol(NUM_CRTP);
289 public static final IpProtocol CRUDP = new IpProtocol(NUM_CRUDP);
290 public static final IpProtocol SSCOPMCE = new IpProtocol(NUM_SSCOPMCE);
291 public static final IpProtocol IPLT = new IpProtocol(NUM_IPLT);
292 public static final IpProtocol SPS = new IpProtocol(NUM_SPS);
293 public static final IpProtocol PIPE = new IpProtocol(NUM_PIPE);
294 public static final IpProtocol SCTP = new IpProtocol(NUM_SCTP);
295 public static final IpProtocol FC = new IpProtocol(NUM_FC);
296 public static final IpProtocol RSVP_E2E_IGNORE = new IpProtocol(NUM_RSVP_E2E_IGNORE);
297 public static final IpProtocol MOBILITY_HEADER = new IpProtocol(NUM_MOBILITY_HEADER);
298 public static final IpProtocol UDP_LITE = new IpProtocol(NUM_UDP_LITE);
299 public static final IpProtocol MPLS_IN_IP = new IpProtocol(NUM_MPLS_IN_IP);
300 public static final IpProtocol MANET = new IpProtocol(NUM_MANET);
301 public static final IpProtocol HIP = new IpProtocol(NUM_HIP);
302 public static final IpProtocol SHIM6 = new IpProtocol(NUM_SHIM6);
303
304 public static final IpProtocol NONE = HOPOPT;
305
306 public static final IpProtocol NO_MASK = HOPOPT;
307 public static final IpProtocol FULL_MASK = new IpProtocol((short)0x0000);
308
309 private IpProtocol(short version) {
310 this.proto = version;
311 }
312
313
314 @Override
315 public int getLength() {
316 return LENGTH;
317 }
318
319 public static IpProtocol of(short proto) {
320 switch (proto) {
321 case NUM_HOPOPT:
322 return HOPOPT;
323 case NUM_ICMP:
324 return ICMP;
325 case NUM_IGMP:
326 return IGMP;
327 case NUM_GGP:
328 return GGP;
329 case NUM_IPv4:
330 return IPv4;
331 case NUM_ST:
332 return ST;
333 case NUM_TCP:
334 return TCP;
335 case NUM_CBT:
336 return CBT;
337 case NUM_EGP:
338 return EGP;
339 case NUM_IGP:
340 return IGP;
341 case NUM_BBN_RCC_MON:
342 return BBN_RCC_MON;
343 case NUM_NVP_II:
344 return NVP_II;
345 case NUM_PUP:
346 return PUP;
347 case NUM_ARGUS:
348 return ARGUS;
349 case NUM_EMCON:
350 return EMCON;
351 case NUM_XNET:
352 return XNET;
353 case NUM_CHAOS:
354 return CHAOS;
355 case NUM_UDP:
356 return UDP;
357 case NUM_MUX:
358 return MUX;
359 case NUM_DCN_MEAS:
360 return DCN_MEAS;
361 case NUM_HMP:
362 return HMP;
363 case NUM_PRM:
364 return PRM;
365 case NUM_XNS_IDP:
366 return XNS_IDP;
367 case NUM_TRUNK_1:
368 return TRUNK_1;
369 case NUM_TRUNK_2:
370 return TRUNK_2;
371 case NUM_LEAF_1:
372 return LEAF_1;
373 case NUM_LEAF_2:
374 return LEAF_2;
375 case NUM_RDP:
376 return RDP;
377 case NUM_IRTP:
378 return IRTP;
379 case NUM_ISO_TP4:
380 return ISO_TP4;
381 case NUM_NETBLT:
382 return NETBLT;
383 case NUM_MFE_NSP:
384 return MFE_NSP;
385 case NUM_MERIT_INP:
386 return MERIT_INP;
387 case NUM_DCCP:
388 return DCCP;
389 case NUM_3PC:
390 return _3PC;
391 case NUM_IDPR:
392 return IDPR;
393 case NUM_XTP:
394 return XTP;
395 case NUM_DDP:
396 return DDP;
397 case NUM_IDPR_CMTP:
398 return IDPR_CMTP;
399 case NUM_TP_PP:
400 return TP_PP;
401 case NUM_IL:
402 return IL;
403 case NUM_IPv6:
404 return IPv6;
405 case NUM_SDRP:
406 return SDRP;
407 case NUM_IPv6_ROUTE:
408 return IPv6_ROUTE;
409 case NUM_IPv6_FRAG:
410 return IPv6_FRAG;
411 case NUM_IDRP:
412 return IDRP;
413 case NUM_RSVP:
414 return RSVP;
415 case NUM_GRE:
416 return GRE;
417 case NUM_MHRP:
418 return MHRP;
419 case NUM_BNA:
420 return BNA;
421 case NUM_ESP:
422 return ESP;
423 case NUM_AH:
424 return AH;
425 case NUM_I_NLSP:
426 return I_NLSP;
427 case NUM_SWIPE:
428 return SWIPE;
429 case NUM_NARP:
430 return NARP;
431 case NUM_MOBILE:
432 return MOBILE;
433 case NUM_TLSP:
434 return TLSP;
435 case NUM_SKIP:
436 return SKIP;
437 case NUM_IPv6_ICMP:
438 return IPv6_ICMP;
439 case NUM_IPv6_NO_NXT:
440 return IPv6_NO_NXT;
441 case NUM_IPv6_OPTS:
442 return IPv6_OPTS;
443 case NUM_HOST_INTERNAL:
444 return HOST_INTERNAL;
445 case NUM_CFTP:
446 return CFTP;
447 case NUM_LOCAL_NET:
448 return LOCAL_NET;
449 case NUM_SAT_EXPAK:
450 return SAT_EXPAK;
451 case NUM_KRYPTOLAN:
452 return KRYPTOLAN;
453 case NUM_RVD:
454 return RVD;
455 case NUM_IPPC:
456 return IPPC;
457 case NUM_DIST_FS:
458 return DIST_FS;
459 case NUM_SAT_MON:
460 return SAT_MON;
461 case NUM_VISA:
462 return VISA;
463 case NUM_IPCV:
464 return IPCV;
465 case NUM_CPNX:
466 return CPNX;
467 case NUM_CPHB:
468 return CPHB;
469 case NUM_WSN:
470 return WSN;
471 case NUM_PVP:
472 return PVP;
473 case NUM_BR_SAT_MON:
474 return BR_SAT_MON;
475 case NUM_SUN_ND:
476 return SUN_ND;
477 case NUM_WB_MON:
478 return WB_MON;
479 case NUM_WB_EXPAK:
480 return WB_EXPAK;
481 case NUM_ISO_IP:
482 return ISO_IP;
483 case NUM_VMTP:
484 return VMTP;
485 case NUM_SECURE_VMTP:
486 return SECURE_VMTP;
487 case NUM_VINES:
488 return VINES;
489 case NUM_TTP_IPTM:
490 return TTP_IPTM;
491 case NUM_NSFNET_IGP:
492 return NSFNET_IGP;
493 case NUM_DGP:
494 return DGP;
495 case NUM_TCF:
496 return TCF;
497 case NUM_EIGRP:
498 return EIGRP;
499 case NUM_OSPF:
500 return OSPF;
501 case NUM_Sprite_RPC:
502 return Sprite_RPC;
503 case NUM_LARP:
504 return LARP;
505 case NUM_MTP:
506 return MTP;
507 case NUM_AX_25:
508 return AX_25;
509 case NUM_IPIP:
510 return IPIP;
511 case NUM_MICP:
512 return MICP;
513 case NUM_SCC_SP:
514 return SCC_SP;
515 case NUM_ETHERIP:
516 return ETHERIP;
517 case NUM_ENCAP:
518 return ENCAP;
519 case NUM_PRIVATE_ENCRYPT:
520 return PRIVATE_ENCRYPT;
521 case NUM_GMTP:
522 return GMTP;
523 case NUM_IFMP:
524 return IFMP;
525 case NUM_PNNI:
526 return PNNI;
527 case NUM_PIM:
528 return PIM;
529 case NUM_ARIS:
530 return ARIS;
531 case NUM_SCPS:
532 return SCPS;
533 case NUM_QNX:
534 return QNX;
535 case NUM_A_N:
536 return A_N;
537 case NUM_IP_COMP:
538 return IP_COMP;
539 case NUM_SNP:
540 return SNP;
541 case NUM_COMPAQ_PEER:
542 return COMPAQ_PEER;
543 case NUM_IPX_IN_IP:
544 return IPX_IN_IP;
545 case NUM_VRRP:
546 return VRRP;
547 case NUM_PGM:
548 return PGM;
549 case NUM_ZERO_HOP:
550 return ZERO_HOP;
551 case NUM_L2TP:
552 return L2TP;
553 case NUM_DDX:
554 return DDX;
555 case NUM_IATP:
556 return IATP;
557 case NUM_STP:
558 return STP;
559 case NUM_SRP:
560 return SRP;
561 case NUM_UTI:
562 return UTI;
563 case NUM_SMP:
564 return SMP;
565 case NUM_SM:
566 return SM;
567 case NUM_PTP:
568 return PTP;
569 case NUM_IS_IS_OVER_IPv4:
570 return IS_IS_OVER_IPv4;
571 case NUM_FIRE:
572 return FIRE;
573 case NUM_CRTP:
574 return CRTP;
575 case NUM_CRUDP:
576 return CRUDP;
577 case NUM_SSCOPMCE:
578 return SSCOPMCE;
579 case NUM_IPLT:
580 return IPLT;
581 case NUM_SPS:
582 return SPS;
583 case NUM_PIPE:
584 return PIPE;
585 case NUM_SCTP:
586 return SCTP;
587 case NUM_FC:
588 return FC;
589 case NUM_RSVP_E2E_IGNORE:
590 return RSVP_E2E_IGNORE;
591 case NUM_MOBILITY_HEADER:
592 return MOBILITY_HEADER;
593 case NUM_UDP_LITE:
594 return UDP_LITE;
595 case NUM_MPLS_IN_IP:
596 return MPLS_IN_IP;
597 case NUM_MANET:
598 return MANET;
599 case NUM_HIP:
600 return HIP;
601 case NUM_SHIM6:
602 return SHIM6;
603 default:
604 if (proto >= MAX_PROTO) {
605 throw new IllegalArgumentException("Illegal IP protocol number: "
606 + proto);
607 } else {
608 return new IpProtocol(proto);
609 }
610 }
611 }
612
613 @Override
614 public String toString() {
615 return Integer.toHexString(proto);
616 }
617
618 public void writeByte(ChannelBuffer c) {
619 c.writeByte(this.proto);
620 }
621
622 public static IpProtocol readByte(ChannelBuffer c) {
623 return IpProtocol.of(c.readUnsignedByte());
624 }
625
626 @Override
627 public IpProtocol applyMask(IpProtocol mask) {
628 return IpProtocol.of((short)(this.proto & mask.proto));
629 }
630
631 public short getIpProtocolNumber() {
632 return proto;
633 }
634
635 @Override
636 public boolean equals(Object obj) {
637 if (!(obj instanceof IpProtocol))
638 return false;
639 IpProtocol o = (IpProtocol)obj;
640 if (o.proto != this.proto)
641 return false;
642 return true;
643 }
644
645 @Override
646 public int hashCode() {
647 final int prime = 37;
648 int result = 1;
649 result = prime * result + proto;
650 return result;
651 }
652
653
654 @Override
655 public int compareTo(IpProtocol o) {
656 return Shorts.compare(proto, o.proto);
657 }
658
659
660 @Override
661 public void putTo(PrimitiveSink sink) {
662 sink.putShort(proto);
663 }
664
665}