blob: dc111028fbd1a21b59000f7b8b75d1b3abcc5be0 [file] [log] [blame]
tom0eb04ca2014-08-25 14:34:51 -07001// Copyright (c) 2008 The Board of Trustees of The Leland Stanford Junior University
2// Copyright (c) 2011, 2012 Open Networking Foundation
3// Copyright (c) 2012, 2013 Big Switch Networks, Inc.
4// This library was generated by the LoxiGen Compiler.
5// See the file LICENSE.txt which should have been included in the source distribution
6
7// Automatically generated by LOXI from template const_serializer.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver12;
11
12import org.projectfloodlight.openflow.protocol.*;
13import org.projectfloodlight.openflow.protocol.action.*;
14import org.projectfloodlight.openflow.protocol.actionid.*;
15import org.projectfloodlight.openflow.protocol.bsntlv.*;
16import org.projectfloodlight.openflow.protocol.errormsg.*;
17import org.projectfloodlight.openflow.protocol.meterband.*;
18import org.projectfloodlight.openflow.protocol.instruction.*;
19import org.projectfloodlight.openflow.protocol.instructionid.*;
20import org.projectfloodlight.openflow.protocol.match.*;
21import org.projectfloodlight.openflow.protocol.oxm.*;
22import org.projectfloodlight.openflow.protocol.queueprop.*;
23import org.projectfloodlight.openflow.types.*;
24import org.projectfloodlight.openflow.util.*;
25import org.projectfloodlight.openflow.exceptions.*;
26import org.projectfloodlight.openflow.protocol.OFStatsType;
27import org.jboss.netty.buffer.ChannelBuffer;
28import com.google.common.hash.PrimitiveSink;
29
30public class OFStatsTypeSerializerVer12 {
31
32 public final static short DESC_VAL = (short) 0x0;
33 public final static short FLOW_VAL = (short) 0x1;
34 public final static short AGGREGATE_VAL = (short) 0x2;
35 public final static short TABLE_VAL = (short) 0x3;
36 public final static short PORT_VAL = (short) 0x4;
37 public final static short QUEUE_VAL = (short) 0x5;
38 public final static short GROUP_VAL = (short) 0x6;
39 public final static short GROUP_DESC_VAL = (short) 0x7;
40 public final static short GROUP_FEATURES_VAL = (short) 0x8;
41 public final static short EXPERIMENTER_VAL = (short) 0xffff;
42
43 public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError {
44 try {
45 return ofWireValue(bb.readShort());
46 } catch (IllegalArgumentException e) {
47 throw new OFParseError(e);
48 }
49 }
50
51 public static void writeTo(ChannelBuffer bb, OFStatsType e) {
52 bb.writeShort(toWireValue(e));
53 }
54
55 public static void putTo(OFStatsType e, PrimitiveSink sink) {
56 sink.putShort(toWireValue(e));
57 }
58
59 public static OFStatsType ofWireValue(short val) {
60 switch(val) {
61 case DESC_VAL:
62 return OFStatsType.DESC;
63 case FLOW_VAL:
64 return OFStatsType.FLOW;
65 case AGGREGATE_VAL:
66 return OFStatsType.AGGREGATE;
67 case TABLE_VAL:
68 return OFStatsType.TABLE;
69 case PORT_VAL:
70 return OFStatsType.PORT;
71 case QUEUE_VAL:
72 return OFStatsType.QUEUE;
73 case GROUP_VAL:
74 return OFStatsType.GROUP;
75 case GROUP_DESC_VAL:
76 return OFStatsType.GROUP_DESC;
77 case GROUP_FEATURES_VAL:
78 return OFStatsType.GROUP_FEATURES;
79 case EXPERIMENTER_VAL:
80 return OFStatsType.EXPERIMENTER;
81 default:
82 throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.2: " + val);
83 }
84 }
85
86
87 public static short toWireValue(OFStatsType e) {
88 switch(e) {
89 case DESC:
90 return DESC_VAL;
91 case FLOW:
92 return FLOW_VAL;
93 case AGGREGATE:
94 return AGGREGATE_VAL;
95 case TABLE:
96 return TABLE_VAL;
97 case PORT:
98 return PORT_VAL;
99 case QUEUE:
100 return QUEUE_VAL;
101 case GROUP:
102 return GROUP_VAL;
103 case GROUP_DESC:
104 return GROUP_DESC_VAL;
105 case GROUP_FEATURES:
106 return GROUP_FEATURES_VAL;
107 case EXPERIMENTER:
108 return EXPERIMENTER_VAL;
109 default:
110 throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.2: " + e);
111 }
112 }
113
114}