blob: f90d25606bf2cdd6fd67c5bef90a562953647126 [file] [log] [blame]
tom7ef8ff92014-09-17 13:08:06 -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.OFPortConfig;
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 OFPortConfigSerializerVer11 {
35
36 public final static int PORT_DOWN_VAL = 0x1;
37 public final static int NO_RECV_VAL = 0x4;
38 public final static int NO_FWD_VAL = 0x20;
39 public final static int NO_PACKET_IN_VAL = 0x40;
40 public final static int BSN_MIRROR_DEST_VAL = (int) 0x80000000;
41
42 public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
43 try {
44 return ofWireValue(bb.readInt());
45 } catch (IllegalArgumentException e) {
46 throw new OFParseError(e);
47 }
48 }
49
50 public static void writeTo(ChannelBuffer bb, Set<OFPortConfig> set) {
51 bb.writeInt(toWireValue(set));
52 }
53
54 public static void putTo(Set<OFPortConfig> set, PrimitiveSink sink) {
55 sink.putInt(toWireValue(set));
56 }
57
58
59 public static Set<OFPortConfig> ofWireValue(int val) {
60 EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);
61
62 if((val & PORT_DOWN_VAL) != 0)
63 set.add(OFPortConfig.PORT_DOWN);
64 if((val & NO_RECV_VAL) != 0)
65 set.add(OFPortConfig.NO_RECV);
66 if((val & NO_FWD_VAL) != 0)
67 set.add(OFPortConfig.NO_FWD);
68 if((val & NO_PACKET_IN_VAL) != 0)
69 set.add(OFPortConfig.NO_PACKET_IN);
70 if((val & BSN_MIRROR_DEST_VAL) != 0)
71 set.add(OFPortConfig.BSN_MIRROR_DEST);
72 return Collections.unmodifiableSet(set);
73 }
74
75 public static int toWireValue(Set<OFPortConfig> set) {
76 int wireValue = 0;
77
78 for(OFPortConfig e: set) {
79 switch(e) {
80 case PORT_DOWN:
81 wireValue |= PORT_DOWN_VAL;
82 break;
83 case NO_RECV:
84 wireValue |= NO_RECV_VAL;
85 break;
86 case NO_FWD:
87 wireValue |= NO_FWD_VAL;
88 break;
89 case NO_PACKET_IN:
90 wireValue |= NO_PACKET_IN_VAL;
91 break;
92 case BSN_MIRROR_DEST:
93 wireValue |= BSN_MIRROR_DEST_VAL;
94 break;
95 default:
96 throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.1: " + e);
97 }
98 }
99 return wireValue;
100 }
101
102}