alshabib | 86ac11c | 2014-08-14 16:14:41 -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.ver10; |
| 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 OFStatsTypeSerializerVer10 { |
| 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 EXPERIMENTER_VAL = (short) 0xffff; |
| 39 | |
| 40 | public static OFStatsType readFrom(ChannelBuffer bb) throws OFParseError { |
| 41 | try { |
| 42 | return ofWireValue(bb.readShort()); |
| 43 | } catch (IllegalArgumentException e) { |
| 44 | throw new OFParseError(e); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | public static void writeTo(ChannelBuffer bb, OFStatsType e) { |
| 49 | bb.writeShort(toWireValue(e)); |
| 50 | } |
| 51 | |
| 52 | public static void putTo(OFStatsType e, PrimitiveSink sink) { |
| 53 | sink.putShort(toWireValue(e)); |
| 54 | } |
| 55 | |
| 56 | public static OFStatsType ofWireValue(short val) { |
| 57 | switch(val) { |
| 58 | case DESC_VAL: |
| 59 | return OFStatsType.DESC; |
| 60 | case FLOW_VAL: |
| 61 | return OFStatsType.FLOW; |
| 62 | case AGGREGATE_VAL: |
| 63 | return OFStatsType.AGGREGATE; |
| 64 | case TABLE_VAL: |
| 65 | return OFStatsType.TABLE; |
| 66 | case PORT_VAL: |
| 67 | return OFStatsType.PORT; |
| 68 | case QUEUE_VAL: |
| 69 | return OFStatsType.QUEUE; |
| 70 | case EXPERIMENTER_VAL: |
| 71 | return OFStatsType.EXPERIMENTER; |
| 72 | default: |
| 73 | throw new IllegalArgumentException("Illegal wire value for type OFStatsType in version 1.0: " + val); |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | |
| 78 | public static short toWireValue(OFStatsType e) { |
| 79 | switch(e) { |
| 80 | case DESC: |
| 81 | return DESC_VAL; |
| 82 | case FLOW: |
| 83 | return FLOW_VAL; |
| 84 | case AGGREGATE: |
| 85 | return AGGREGATE_VAL; |
| 86 | case TABLE: |
| 87 | return TABLE_VAL; |
| 88 | case PORT: |
| 89 | return PORT_VAL; |
| 90 | case QUEUE: |
| 91 | return QUEUE_VAL; |
| 92 | case EXPERIMENTER: |
| 93 | return EXPERIMENTER_VAL; |
| 94 | default: |
| 95 | throw new IllegalArgumentException("Illegal enum value for type OFStatsType in version 1.0: " + e); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | } |