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.ver12; |
| 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.OFType; |
| 27 | import org.jboss.netty.buffer.ChannelBuffer; |
| 28 | import com.google.common.hash.PrimitiveSink; |
| 29 | |
| 30 | public class OFTypeSerializerVer12 { |
| 31 | |
| 32 | public final static byte HELLO_VAL = (byte) 0x0; |
| 33 | public final static byte ERROR_VAL = (byte) 0x1; |
| 34 | public final static byte ECHO_REQUEST_VAL = (byte) 0x2; |
| 35 | public final static byte ECHO_REPLY_VAL = (byte) 0x3; |
| 36 | public final static byte EXPERIMENTER_VAL = (byte) 0x4; |
| 37 | public final static byte FEATURES_REQUEST_VAL = (byte) 0x5; |
| 38 | public final static byte FEATURES_REPLY_VAL = (byte) 0x6; |
| 39 | public final static byte GET_CONFIG_REQUEST_VAL = (byte) 0x7; |
| 40 | public final static byte GET_CONFIG_REPLY_VAL = (byte) 0x8; |
| 41 | public final static byte SET_CONFIG_VAL = (byte) 0x9; |
| 42 | public final static byte PACKET_IN_VAL = (byte) 0xa; |
| 43 | public final static byte FLOW_REMOVED_VAL = (byte) 0xb; |
| 44 | public final static byte PORT_STATUS_VAL = (byte) 0xc; |
| 45 | public final static byte PACKET_OUT_VAL = (byte) 0xd; |
| 46 | public final static byte FLOW_MOD_VAL = (byte) 0xe; |
| 47 | public final static byte GROUP_MOD_VAL = (byte) 0xf; |
| 48 | public final static byte PORT_MOD_VAL = (byte) 0x10; |
| 49 | public final static byte TABLE_MOD_VAL = (byte) 0x11; |
| 50 | public final static byte STATS_REQUEST_VAL = (byte) 0x12; |
| 51 | public final static byte STATS_REPLY_VAL = (byte) 0x13; |
| 52 | public final static byte BARRIER_REQUEST_VAL = (byte) 0x14; |
| 53 | public final static byte BARRIER_REPLY_VAL = (byte) 0x15; |
| 54 | public final static byte QUEUE_GET_CONFIG_REQUEST_VAL = (byte) 0x16; |
| 55 | public final static byte QUEUE_GET_CONFIG_REPLY_VAL = (byte) 0x17; |
| 56 | public final static byte ROLE_REQUEST_VAL = (byte) 0x18; |
| 57 | public final static byte ROLE_REPLY_VAL = (byte) 0x19; |
| 58 | |
| 59 | public static OFType readFrom(ChannelBuffer bb) throws OFParseError { |
| 60 | try { |
| 61 | return ofWireValue(bb.readByte()); |
| 62 | } catch (IllegalArgumentException e) { |
| 63 | throw new OFParseError(e); |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | public static void writeTo(ChannelBuffer bb, OFType e) { |
| 68 | bb.writeByte(toWireValue(e)); |
| 69 | } |
| 70 | |
| 71 | public static void putTo(OFType e, PrimitiveSink sink) { |
| 72 | sink.putByte(toWireValue(e)); |
| 73 | } |
| 74 | |
| 75 | public static OFType ofWireValue(byte val) { |
| 76 | switch(val) { |
| 77 | case HELLO_VAL: |
| 78 | return OFType.HELLO; |
| 79 | case ERROR_VAL: |
| 80 | return OFType.ERROR; |
| 81 | case ECHO_REQUEST_VAL: |
| 82 | return OFType.ECHO_REQUEST; |
| 83 | case ECHO_REPLY_VAL: |
| 84 | return OFType.ECHO_REPLY; |
| 85 | case EXPERIMENTER_VAL: |
| 86 | return OFType.EXPERIMENTER; |
| 87 | case FEATURES_REQUEST_VAL: |
| 88 | return OFType.FEATURES_REQUEST; |
| 89 | case FEATURES_REPLY_VAL: |
| 90 | return OFType.FEATURES_REPLY; |
| 91 | case GET_CONFIG_REQUEST_VAL: |
| 92 | return OFType.GET_CONFIG_REQUEST; |
| 93 | case GET_CONFIG_REPLY_VAL: |
| 94 | return OFType.GET_CONFIG_REPLY; |
| 95 | case SET_CONFIG_VAL: |
| 96 | return OFType.SET_CONFIG; |
| 97 | case PACKET_IN_VAL: |
| 98 | return OFType.PACKET_IN; |
| 99 | case FLOW_REMOVED_VAL: |
| 100 | return OFType.FLOW_REMOVED; |
| 101 | case PORT_STATUS_VAL: |
| 102 | return OFType.PORT_STATUS; |
| 103 | case PACKET_OUT_VAL: |
| 104 | return OFType.PACKET_OUT; |
| 105 | case FLOW_MOD_VAL: |
| 106 | return OFType.FLOW_MOD; |
| 107 | case GROUP_MOD_VAL: |
| 108 | return OFType.GROUP_MOD; |
| 109 | case PORT_MOD_VAL: |
| 110 | return OFType.PORT_MOD; |
| 111 | case TABLE_MOD_VAL: |
| 112 | return OFType.TABLE_MOD; |
| 113 | case STATS_REQUEST_VAL: |
| 114 | return OFType.STATS_REQUEST; |
| 115 | case STATS_REPLY_VAL: |
| 116 | return OFType.STATS_REPLY; |
| 117 | case BARRIER_REQUEST_VAL: |
| 118 | return OFType.BARRIER_REQUEST; |
| 119 | case BARRIER_REPLY_VAL: |
| 120 | return OFType.BARRIER_REPLY; |
| 121 | case QUEUE_GET_CONFIG_REQUEST_VAL: |
| 122 | return OFType.QUEUE_GET_CONFIG_REQUEST; |
| 123 | case QUEUE_GET_CONFIG_REPLY_VAL: |
| 124 | return OFType.QUEUE_GET_CONFIG_REPLY; |
| 125 | case ROLE_REQUEST_VAL: |
| 126 | return OFType.ROLE_REQUEST; |
| 127 | case ROLE_REPLY_VAL: |
| 128 | return OFType.ROLE_REPLY; |
| 129 | default: |
| 130 | throw new IllegalArgumentException("Illegal wire value for type OFType in version 1.2: " + val); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | |
| 135 | public static byte toWireValue(OFType e) { |
| 136 | switch(e) { |
| 137 | case HELLO: |
| 138 | return HELLO_VAL; |
| 139 | case ERROR: |
| 140 | return ERROR_VAL; |
| 141 | case ECHO_REQUEST: |
| 142 | return ECHO_REQUEST_VAL; |
| 143 | case ECHO_REPLY: |
| 144 | return ECHO_REPLY_VAL; |
| 145 | case EXPERIMENTER: |
| 146 | return EXPERIMENTER_VAL; |
| 147 | case FEATURES_REQUEST: |
| 148 | return FEATURES_REQUEST_VAL; |
| 149 | case FEATURES_REPLY: |
| 150 | return FEATURES_REPLY_VAL; |
| 151 | case GET_CONFIG_REQUEST: |
| 152 | return GET_CONFIG_REQUEST_VAL; |
| 153 | case GET_CONFIG_REPLY: |
| 154 | return GET_CONFIG_REPLY_VAL; |
| 155 | case SET_CONFIG: |
| 156 | return SET_CONFIG_VAL; |
| 157 | case PACKET_IN: |
| 158 | return PACKET_IN_VAL; |
| 159 | case FLOW_REMOVED: |
| 160 | return FLOW_REMOVED_VAL; |
| 161 | case PORT_STATUS: |
| 162 | return PORT_STATUS_VAL; |
| 163 | case PACKET_OUT: |
| 164 | return PACKET_OUT_VAL; |
| 165 | case FLOW_MOD: |
| 166 | return FLOW_MOD_VAL; |
| 167 | case GROUP_MOD: |
| 168 | return GROUP_MOD_VAL; |
| 169 | case PORT_MOD: |
| 170 | return PORT_MOD_VAL; |
| 171 | case TABLE_MOD: |
| 172 | return TABLE_MOD_VAL; |
| 173 | case STATS_REQUEST: |
| 174 | return STATS_REQUEST_VAL; |
| 175 | case STATS_REPLY: |
| 176 | return STATS_REPLY_VAL; |
| 177 | case BARRIER_REQUEST: |
| 178 | return BARRIER_REQUEST_VAL; |
| 179 | case BARRIER_REPLY: |
| 180 | return BARRIER_REPLY_VAL; |
| 181 | case QUEUE_GET_CONFIG_REQUEST: |
| 182 | return QUEUE_GET_CONFIG_REQUEST_VAL; |
| 183 | case QUEUE_GET_CONFIG_REPLY: |
| 184 | return QUEUE_GET_CONFIG_REPLY_VAL; |
| 185 | case ROLE_REQUEST: |
| 186 | return ROLE_REQUEST_VAL; |
| 187 | case ROLE_REPLY: |
| 188 | return ROLE_REPLY_VAL; |
| 189 | default: |
| 190 | throw new IllegalArgumentException("Illegal enum value for type OFType in version 1.2: " + e); |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | } |