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