blob: 3f36f7403d97265f0a7c04581ee38b91d0bdfe41 [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_set_serializer.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol.ver11;
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.OFTableConfig;
27import java.util.Set;
28import org.jboss.netty.buffer.ChannelBuffer;
29import com.google.common.hash.PrimitiveSink;
30import java.util.EnumSet;
31import java.util.Collections;
32
33
34public class OFTableConfigSerializerVer11 {
35
36 public final static int TABLE_MISS_CONTROLLER_VAL = 0x0;
37 public final static int TABLE_MISS_CONTINUE_VAL = 0x1;
38 public final static int TABLE_MISS_DROP_VAL = 0x2;
39 public final static int TABLE_MISS_MASK_VAL = 0x3;
40
41 public static Set<OFTableConfig> readFrom(ChannelBuffer bb) throws OFParseError {
42 try {
43 return ofWireValue(bb.readInt());
44 } catch (IllegalArgumentException e) {
45 throw new OFParseError(e);
46 }
47 }
48
49 public static void writeTo(ChannelBuffer bb, Set<OFTableConfig> set) {
50 bb.writeInt(toWireValue(set));
51 }
52
53 public static void putTo(Set<OFTableConfig> set, PrimitiveSink sink) {
54 sink.putInt(toWireValue(set));
55 }
56
57
58 public static Set<OFTableConfig> ofWireValue(int val) {
59 EnumSet<OFTableConfig> set = EnumSet.noneOf(OFTableConfig.class);
60
61 if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_CONTROLLER_VAL)
62 set.add(OFTableConfig.TABLE_MISS_CONTROLLER);
63 else if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_CONTINUE_VAL)
64 set.add(OFTableConfig.TABLE_MISS_CONTINUE);
65 else if((val & TABLE_MISS_MASK_VAL) == TABLE_MISS_DROP_VAL)
66 set.add(OFTableConfig.TABLE_MISS_DROP);
67 return Collections.unmodifiableSet(set);
68 }
69
70 public static int toWireValue(Set<OFTableConfig> set) {
71 int wireValue = 0;
72
73 for(OFTableConfig e: set) {
74 switch(e) {
75 case TABLE_MISS_CONTROLLER:
76 wireValue |= TABLE_MISS_CONTROLLER_VAL;
77 break;
78 case TABLE_MISS_CONTINUE:
79 wireValue |= TABLE_MISS_CONTINUE_VAL;
80 break;
81 case TABLE_MISS_DROP:
82 wireValue |= TABLE_MISS_DROP_VAL;
83 break;
84 default:
85 throw new IllegalArgumentException("Illegal enum value for type OFTableConfig in version 1.1: " + e);
86 }
87 }
88 return wireValue;
89 }
90
91}