blob: 14e469645a5bd89b4999dd6559d8cf8643f68ab9 [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.ver10;
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.OFErrorType;
27import org.jboss.netty.buffer.ChannelBuffer;
28import com.google.common.hash.PrimitiveSink;
29
30public class OFErrorTypeSerializerVer10 {
31
32 public final static short HELLO_FAILED_VAL = (short) 0x0;
33 public final static short BAD_REQUEST_VAL = (short) 0x1;
34 public final static short BAD_ACTION_VAL = (short) 0x2;
35 public final static short FLOW_MOD_FAILED_VAL = (short) 0x3;
36 public final static short PORT_MOD_FAILED_VAL = (short) 0x4;
37 public final static short QUEUE_OP_FAILED_VAL = (short) 0x5;
38
39 public static OFErrorType readFrom(ChannelBuffer bb) throws OFParseError {
40 try {
41 return ofWireValue(bb.readShort());
42 } catch (IllegalArgumentException e) {
43 throw new OFParseError(e);
44 }
45 }
46
47 public static void writeTo(ChannelBuffer bb, OFErrorType e) {
48 bb.writeShort(toWireValue(e));
49 }
50
51 public static void putTo(OFErrorType e, PrimitiveSink sink) {
52 sink.putShort(toWireValue(e));
53 }
54
55 public static OFErrorType ofWireValue(short val) {
56 switch(val) {
57 case HELLO_FAILED_VAL:
58 return OFErrorType.HELLO_FAILED;
59 case BAD_REQUEST_VAL:
60 return OFErrorType.BAD_REQUEST;
61 case BAD_ACTION_VAL:
62 return OFErrorType.BAD_ACTION;
63 case FLOW_MOD_FAILED_VAL:
64 return OFErrorType.FLOW_MOD_FAILED;
65 case PORT_MOD_FAILED_VAL:
66 return OFErrorType.PORT_MOD_FAILED;
67 case QUEUE_OP_FAILED_VAL:
68 return OFErrorType.QUEUE_OP_FAILED;
69 default:
70 throw new IllegalArgumentException("Illegal wire value for type OFErrorType in version 1.0: " + val);
71 }
72 }
73
74
75 public static short toWireValue(OFErrorType e) {
76 switch(e) {
77 case HELLO_FAILED:
78 return HELLO_FAILED_VAL;
79 case BAD_REQUEST:
80 return BAD_REQUEST_VAL;
81 case BAD_ACTION:
82 return BAD_ACTION_VAL;
83 case FLOW_MOD_FAILED:
84 return FLOW_MOD_FAILED_VAL;
85 case PORT_MOD_FAILED:
86 return PORT_MOD_FAILED_VAL;
87 case QUEUE_OP_FAILED:
88 return QUEUE_OP_FAILED_VAL;
89 default:
90 throw new IllegalArgumentException("Illegal enum value for type OFErrorType in version 1.0: " + e);
91 }
92 }
93
94}