alshabib | 86ac11c | 2014-08-14 16:14:41 -0700 | [diff] [blame^] | 1 | // 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 | |
| 10 | package org.projectfloodlight.openflow.protocol.ver12; |
| 11 | |
| 12 | import org.projectfloodlight.openflow.protocol.*; |
| 13 | import org.projectfloodlight.openflow.protocol.action.*; |
| 14 | import org.projectfloodlight.openflow.protocol.actionid.*; |
| 15 | import org.projectfloodlight.openflow.protocol.bsntlv.*; |
| 16 | import org.projectfloodlight.openflow.protocol.errormsg.*; |
| 17 | import org.projectfloodlight.openflow.protocol.meterband.*; |
| 18 | import org.projectfloodlight.openflow.protocol.instruction.*; |
| 19 | import org.projectfloodlight.openflow.protocol.instructionid.*; |
| 20 | import org.projectfloodlight.openflow.protocol.match.*; |
| 21 | import org.projectfloodlight.openflow.protocol.oxm.*; |
| 22 | import org.projectfloodlight.openflow.protocol.queueprop.*; |
| 23 | import org.projectfloodlight.openflow.types.*; |
| 24 | import org.projectfloodlight.openflow.util.*; |
| 25 | import org.projectfloodlight.openflow.exceptions.*; |
| 26 | import org.projectfloodlight.openflow.protocol.OFBsnVportL2GreFlags; |
| 27 | import java.util.Set; |
| 28 | import org.jboss.netty.buffer.ChannelBuffer; |
| 29 | import com.google.common.hash.PrimitiveSink; |
| 30 | import java.util.EnumSet; |
| 31 | import java.util.Collections; |
| 32 | |
| 33 | |
| 34 | public class OFBsnVportL2GreFlagsSerializerVer12 { |
| 35 | |
| 36 | public final static int BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL = 0x1; |
| 37 | public final static int BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL = 0x2; |
| 38 | public final static int BSN_VPORT_L2GRE_DSCP_COPY_VAL = 0x4; |
| 39 | public final static int BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL = 0x8; |
| 40 | public final static int BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL = 0x10; |
| 41 | |
| 42 | public static Set<OFBsnVportL2GreFlags> 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<OFBsnVportL2GreFlags> set) { |
| 51 | bb.writeInt(toWireValue(set)); |
| 52 | } |
| 53 | |
| 54 | public static void putTo(Set<OFBsnVportL2GreFlags> set, PrimitiveSink sink) { |
| 55 | sink.putInt(toWireValue(set)); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | public static Set<OFBsnVportL2GreFlags> ofWireValue(int val) { |
| 60 | EnumSet<OFBsnVportL2GreFlags> set = EnumSet.noneOf(OFBsnVportL2GreFlags.class); |
| 61 | |
| 62 | if((val & BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL) != 0) |
| 63 | set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID); |
| 64 | if((val & BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL) != 0) |
| 65 | set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_ASSIGN); |
| 66 | if((val & BSN_VPORT_L2GRE_DSCP_COPY_VAL) != 0) |
| 67 | set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_DSCP_COPY); |
| 68 | if((val & BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL) != 0) |
| 69 | set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_LOOPBACK_IS_VALID); |
| 70 | if((val & BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL) != 0) |
| 71 | set.add(OFBsnVportL2GreFlags.BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID); |
| 72 | return Collections.unmodifiableSet(set); |
| 73 | } |
| 74 | |
| 75 | public static int toWireValue(Set<OFBsnVportL2GreFlags> set) { |
| 76 | int wireValue = 0; |
| 77 | |
| 78 | for(OFBsnVportL2GreFlags e: set) { |
| 79 | switch(e) { |
| 80 | case BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID: |
| 81 | wireValue |= BSN_VPORT_L2GRE_LOCAL_MAC_IS_VALID_VAL; |
| 82 | break; |
| 83 | case BSN_VPORT_L2GRE_DSCP_ASSIGN: |
| 84 | wireValue |= BSN_VPORT_L2GRE_DSCP_ASSIGN_VAL; |
| 85 | break; |
| 86 | case BSN_VPORT_L2GRE_DSCP_COPY: |
| 87 | wireValue |= BSN_VPORT_L2GRE_DSCP_COPY_VAL; |
| 88 | break; |
| 89 | case BSN_VPORT_L2GRE_LOOPBACK_IS_VALID: |
| 90 | wireValue |= BSN_VPORT_L2GRE_LOOPBACK_IS_VALID_VAL; |
| 91 | break; |
| 92 | case BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID: |
| 93 | wireValue |= BSN_VPORT_L2GRE_RATE_LIMIT_IS_VALID_VAL; |
| 94 | break; |
| 95 | default: |
| 96 | throw new IllegalArgumentException("Illegal enum value for type OFBsnVportL2GreFlags in version 1.2: " + e); |
| 97 | } |
| 98 | } |
| 99 | return wireValue; |
| 100 | } |
| 101 | |
| 102 | } |