blob: 148dea5e0b627601b3be3f33133548e717f9e924 [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.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.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 OFPortConfigSerializerVer10 {
35
36 public final static int PORT_DOWN_VAL = 0x1;
37 public final static int NO_STP_VAL = 0x2;
38 public final static int NO_RECV_VAL = 0x4;
39 public final static int NO_RECV_STP_VAL = 0x8;
40 public final static int NO_FLOOD_VAL = 0x10;
41 public final static int NO_FWD_VAL = 0x20;
42 public final static int NO_PACKET_IN_VAL = 0x40;
43 public final static int BSN_MIRROR_DEST_VAL = (int) 0x80000000;
44
45 public static Set<OFPortConfig> readFrom(ChannelBuffer bb) throws OFParseError {
46 try {
47 return ofWireValue(bb.readInt());
48 } catch (IllegalArgumentException e) {
49 throw new OFParseError(e);
50 }
51 }
52
53 public static void writeTo(ChannelBuffer bb, Set<OFPortConfig> set) {
54 bb.writeInt(toWireValue(set));
55 }
56
57 public static void putTo(Set<OFPortConfig> set, PrimitiveSink sink) {
58 sink.putInt(toWireValue(set));
59 }
60
61
62 public static Set<OFPortConfig> ofWireValue(int val) {
63 EnumSet<OFPortConfig> set = EnumSet.noneOf(OFPortConfig.class);
64
65 if((val & PORT_DOWN_VAL) != 0)
66 set.add(OFPortConfig.PORT_DOWN);
67 if((val & NO_STP_VAL) != 0)
68 set.add(OFPortConfig.NO_STP);
69 if((val & NO_RECV_VAL) != 0)
70 set.add(OFPortConfig.NO_RECV);
71 if((val & NO_RECV_STP_VAL) != 0)
72 set.add(OFPortConfig.NO_RECV_STP);
73 if((val & NO_FLOOD_VAL) != 0)
74 set.add(OFPortConfig.NO_FLOOD);
75 if((val & NO_FWD_VAL) != 0)
76 set.add(OFPortConfig.NO_FWD);
77 if((val & NO_PACKET_IN_VAL) != 0)
78 set.add(OFPortConfig.NO_PACKET_IN);
79 if((val & BSN_MIRROR_DEST_VAL) != 0)
80 set.add(OFPortConfig.BSN_MIRROR_DEST);
81 return Collections.unmodifiableSet(set);
82 }
83
84 public static int toWireValue(Set<OFPortConfig> set) {
85 int wireValue = 0;
86
87 for(OFPortConfig e: set) {
88 switch(e) {
89 case PORT_DOWN:
90 wireValue |= PORT_DOWN_VAL;
91 break;
92 case NO_STP:
93 wireValue |= NO_STP_VAL;
94 break;
95 case NO_RECV:
96 wireValue |= NO_RECV_VAL;
97 break;
98 case NO_RECV_STP:
99 wireValue |= NO_RECV_STP_VAL;
100 break;
101 case NO_FLOOD:
102 wireValue |= NO_FLOOD_VAL;
103 break;
104 case NO_FWD:
105 wireValue |= NO_FWD_VAL;
106 break;
107 case NO_PACKET_IN:
108 wireValue |= NO_PACKET_IN_VAL;
109 break;
110 case BSN_MIRROR_DEST:
111 wireValue |= BSN_MIRROR_DEST_VAL;
112 break;
113 default:
114 throw new IllegalArgumentException("Illegal enum value for type OFPortConfig in version 1.0: " + e);
115 }
116 }
117 return wireValue;
118 }
119
120}