tom | 0eb04ca | 2014-08-25 14:34:51 -0700 | [diff] [blame] | 1 | // 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 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver13; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.projectfloodlight.openflow.protocol.OFStatsType; |
| 27 | import org.jboss.netty.buffer.ChannelBuffer; |
| 28 | import com.google.common.hash.PrimitiveSink; |
| 29 | |
| 30 | public class OFStatsTypeSerializerVer13 { |
| 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 METER_VAL = (short) 0x9; |
| 42 | public final static short METER_CONFIG_VAL = (short) 0xa; |
| 43 | public final static short METER_FEATURES_VAL = (short) 0xb; |
| 44 | public final static short TABLE_FEATURES_VAL = (short) 0xc; |
| 45 | public final static short PORT_DESC_VAL = (short) 0xd; |
| 46 | public final static short EXPERIMENTER_VAL = (short) 0xffff; |
| 47 | |
| 48 | public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError { |
| 49 | try { |
| 50 | return ofWireValue(bb.readShort()); |
| 51 | } catch (IllegalArgumentException e) { |
| 52 | throw new OFParseError(e); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public static void writeTo(ChannelBuffer bb, OFStatsType e) { |
| 57 | bb.writeShort(toWireValue(e)); |
| 58 | } |
| 59 | |
| 60 | public static void putTo(OFStatsType e, PrimitiveSink sink) { |
| 61 | sink.putShort(toWireValue(e)); |
| 62 | } |
| 63 | |
| 64 | public static OFStatsType ofWireValue(short val) { |
| 65 | switch(val) { |
| 66 | case DESC_VAL: |
| 67 | return OFStatsType.DESC; |
| 68 | case FLOW_VAL: |
| 69 | return OFStatsType.FLOW; |
| 70 | case AGGREGATE_VAL: |
| 71 | return OFStatsType.AGGREGATE; |
| 72 | case TABLE_VAL: |
| 73 | return OFStatsType.TABLE; |
| 74 | case PORT_VAL: |
| 75 | return OFStatsType.PORT; |
| 76 | case QUEUE_VAL: |
| 77 | return OFStatsType.QUEUE; |
| 78 | case GROUP_VAL: |
| 79 | return OFStatsType.GROUP; |
| 80 | case GROUP_DESC_VAL: |
| 81 | return OFStatsType.GROUP_DESC; |
| 82 | case GROUP_FEATURES_VAL: |
| 83 | return OFStatsType.GROUP_FEATURES; |
| 84 | case METER_VAL: |
| 85 | return OFStatsType.METER; |
| 86 | case METER_CONFIG_VAL: |
| 87 | return OFStatsType.METER_CONFIG; |
| 88 | case METER_FEATURES_VAL: |
| 89 | return OFStatsType.METER_FEATURES; |
| 90 | case TABLE_FEATURES_VAL: |
| 91 | return OFStatsType.TABLE_FEATURES; |
| 92 | case PORT_DESC_VAL: |
| 93 | return OFStatsType.PORT_DESC; |
| 94 | case EXPERIMENTER_VAL: |
| 95 | return OFStatsType.EXPERIMENTER; |
| 96 | default: |
| 97 | throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.3: " + val); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | public static short toWireValue(OFStatsType e) { |
| 103 | switch(e) { |
| 104 | case DESC: |
| 105 | return DESC_VAL; |
| 106 | case FLOW: |
| 107 | return FLOW_VAL; |
| 108 | case AGGREGATE: |
| 109 | return AGGREGATE_VAL; |
| 110 | case TABLE: |
| 111 | return TABLE_VAL; |
| 112 | case PORT: |
| 113 | return PORT_VAL; |
| 114 | case QUEUE: |
| 115 | return QUEUE_VAL; |
| 116 | case GROUP: |
| 117 | return GROUP_VAL; |
| 118 | case GROUP_DESC: |
| 119 | return GROUP_DESC_VAL; |
| 120 | case GROUP_FEATURES: |
| 121 | return GROUP_FEATURES_VAL; |
| 122 | case METER: |
| 123 | return METER_VAL; |
| 124 | case METER_CONFIG: |
| 125 | return METER_CONFIG_VAL; |
| 126 | case METER_FEATURES: |
| 127 | return METER_FEATURES_VAL; |
| 128 | case TABLE_FEATURES: |
| 129 | return TABLE_FEATURES_VAL; |
| 130 | case PORT_DESC: |
| 131 | return PORT_DESC_VAL; |
| 132 | case EXPERIMENTER: |
| 133 | return EXPERIMENTER_VAL; |
| 134 | default: |
| 135 | throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.3: " + e); |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | } |