blob: 128609b8983024e0170d9b4abb0b7038cf0c0a25 [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.ver13;
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.OFFlowModFlags;
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 OFFlowModFlagsSerializerVer13 {
35
36 public final static short SEND_FLOW_REM_VAL = (short) 0x1;
37 public final static short CHECK_OVERLAP_VAL = (short) 0x2;
38 public final static short RESET_COUNTS_VAL = (short) 0x4;
39 public final static short NO_PKT_COUNTS_VAL = (short) 0x8;
40 public final static short NO_BYT_COUNTS_VAL = (short) 0x10;
41 public final static short BSN_SEND_IDLE_VAL = (short) 0x80;
42
43 public static Set<OFFlowModFlags> readFrom(ChannelBuffer bb) throws OFParseError {
44 try {
45 return ofWireValue(bb.readShort());
46 } catch (IllegalArgumentException e) {
47 throw new OFParseError(e);
48 }
49 }
50
51 public static void writeTo(ChannelBuffer bb, Set<OFFlowModFlags> set) {
52 bb.writeShort(toWireValue(set));
53 }
54
55 public static void putTo(Set<OFFlowModFlags> set, PrimitiveSink sink) {
56 sink.putShort(toWireValue(set));
57 }
58
59
60 public static Set<OFFlowModFlags> ofWireValue(short val) {
61 EnumSet<OFFlowModFlags> set = EnumSet.noneOf(OFFlowModFlags.class);
62
63 if((val & SEND_FLOW_REM_VAL) != 0)
64 set.add(OFFlowModFlags.SEND_FLOW_REM);
65 if((val & CHECK_OVERLAP_VAL) != 0)
66 set.add(OFFlowModFlags.CHECK_OVERLAP);
67 if((val & RESET_COUNTS_VAL) != 0)
68 set.add(OFFlowModFlags.RESET_COUNTS);
69 if((val & NO_PKT_COUNTS_VAL) != 0)
70 set.add(OFFlowModFlags.NO_PKT_COUNTS);
71 if((val & NO_BYT_COUNTS_VAL) != 0)
72 set.add(OFFlowModFlags.NO_BYT_COUNTS);
73 if((val & BSN_SEND_IDLE_VAL) != 0)
74 set.add(OFFlowModFlags.BSN_SEND_IDLE);
75 return Collections.unmodifiableSet(set);
76 }
77
78 public static short toWireValue(Set<OFFlowModFlags> set) {
79 short wireValue = 0;
80
81 for(OFFlowModFlags e: set) {
82 switch(e) {
83 case SEND_FLOW_REM:
84 wireValue |= SEND_FLOW_REM_VAL;
85 break;
86 case CHECK_OVERLAP:
87 wireValue |= CHECK_OVERLAP_VAL;
88 break;
89 case RESET_COUNTS:
90 wireValue |= RESET_COUNTS_VAL;
91 break;
92 case NO_PKT_COUNTS:
93 wireValue |= NO_PKT_COUNTS_VAL;
94 break;
95 case NO_BYT_COUNTS:
96 wireValue |= NO_BYT_COUNTS_VAL;
97 break;
98 case BSN_SEND_IDLE:
99 wireValue |= BSN_SEND_IDLE_VAL;
100 break;
101 default:
102 throw new IllegalArgumentException("Illegal enum value for type OFFlowModFlags in version 1.3: " + e);
103 }
104 }
105 return wireValue;
106 }
107
108}