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.ver13; |
| 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.OFBsnPktinFlag; |
| 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 OFBsnPktinFlagSerializerVer13 { |
| 35 | |
| 36 | public final static long BSN_PKTIN_FLAG_PDU_VAL = 0x1L; |
| 37 | public final static long BSN_PKTIN_FLAG_NEW_HOST_VAL = 0x2L; |
| 38 | public final static long BSN_PKTIN_FLAG_STATION_MOVE_VAL = 0x4L; |
| 39 | public final static long BSN_PKTIN_FLAG_ARP_VAL = 0x8L; |
| 40 | public final static long BSN_PKTIN_FLAG_DHCP_VAL = 0x10L; |
| 41 | public final static long BSN_PKTIN_FLAG_L2_CPU_VAL = 0x20L; |
| 42 | public final static long BSN_PKTIN_FLAG_DEBUG_VAL = 0x40L; |
| 43 | public final static long BSN_PKTIN_FLAG_TTL_EXPIRED_VAL = 0x80L; |
| 44 | public final static long BSN_PKTIN_FLAG_L3_MISS_VAL = 0x100L; |
| 45 | public final static long BSN_PKTIN_FLAG_L3_CPU_VAL = 0x200L; |
| 46 | public final static long BSN_PKTIN_FLAG_INGRESS_ACL_VAL = 0x400L; |
| 47 | |
| 48 | public static Set<OFBsnPktinFlag> readFrom(ChannelBuffer bb) throws OFParseError { |
| 49 | try { |
| 50 | return ofWireValue(bb.readLong()); |
| 51 | } catch (IllegalArgumentException e) { |
| 52 | throw new OFParseError(e); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public static void writeTo(ChannelBuffer bb, Set<OFBsnPktinFlag> set) { |
| 57 | bb.writeLong(toWireValue(set)); |
| 58 | } |
| 59 | |
| 60 | public static void putTo(Set<OFBsnPktinFlag> set, PrimitiveSink sink) { |
| 61 | sink.putLong(toWireValue(set)); |
| 62 | } |
| 63 | |
| 64 | |
| 65 | public static Set<OFBsnPktinFlag> ofWireValue(long val) { |
| 66 | EnumSet<OFBsnPktinFlag> set = EnumSet.noneOf(OFBsnPktinFlag.class); |
| 67 | |
| 68 | if((val & BSN_PKTIN_FLAG_PDU_VAL) != 0) |
| 69 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_PDU); |
| 70 | if((val & BSN_PKTIN_FLAG_NEW_HOST_VAL) != 0) |
| 71 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_NEW_HOST); |
| 72 | if((val & BSN_PKTIN_FLAG_STATION_MOVE_VAL) != 0) |
| 73 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_STATION_MOVE); |
| 74 | if((val & BSN_PKTIN_FLAG_ARP_VAL) != 0) |
| 75 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_ARP); |
| 76 | if((val & BSN_PKTIN_FLAG_DHCP_VAL) != 0) |
| 77 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_DHCP); |
| 78 | if((val & BSN_PKTIN_FLAG_L2_CPU_VAL) != 0) |
| 79 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_L2_CPU); |
| 80 | if((val & BSN_PKTIN_FLAG_DEBUG_VAL) != 0) |
| 81 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_DEBUG); |
| 82 | if((val & BSN_PKTIN_FLAG_TTL_EXPIRED_VAL) != 0) |
| 83 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_TTL_EXPIRED); |
| 84 | if((val & BSN_PKTIN_FLAG_L3_MISS_VAL) != 0) |
| 85 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_L3_MISS); |
| 86 | if((val & BSN_PKTIN_FLAG_L3_CPU_VAL) != 0) |
| 87 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_L3_CPU); |
| 88 | if((val & BSN_PKTIN_FLAG_INGRESS_ACL_VAL) != 0) |
| 89 | set.add(OFBsnPktinFlag.BSN_PKTIN_FLAG_INGRESS_ACL); |
| 90 | return Collections.unmodifiableSet(set); |
| 91 | } |
| 92 | |
| 93 | public static long toWireValue(Set<OFBsnPktinFlag> set) { |
| 94 | long wireValue = 0; |
| 95 | |
| 96 | for(OFBsnPktinFlag e: set) { |
| 97 | switch(e) { |
| 98 | case BSN_PKTIN_FLAG_PDU: |
| 99 | wireValue |= BSN_PKTIN_FLAG_PDU_VAL; |
| 100 | break; |
| 101 | case BSN_PKTIN_FLAG_NEW_HOST: |
| 102 | wireValue |= BSN_PKTIN_FLAG_NEW_HOST_VAL; |
| 103 | break; |
| 104 | case BSN_PKTIN_FLAG_STATION_MOVE: |
| 105 | wireValue |= BSN_PKTIN_FLAG_STATION_MOVE_VAL; |
| 106 | break; |
| 107 | case BSN_PKTIN_FLAG_ARP: |
| 108 | wireValue |= BSN_PKTIN_FLAG_ARP_VAL; |
| 109 | break; |
| 110 | case BSN_PKTIN_FLAG_DHCP: |
| 111 | wireValue |= BSN_PKTIN_FLAG_DHCP_VAL; |
| 112 | break; |
| 113 | case BSN_PKTIN_FLAG_L2_CPU: |
| 114 | wireValue |= BSN_PKTIN_FLAG_L2_CPU_VAL; |
| 115 | break; |
| 116 | case BSN_PKTIN_FLAG_DEBUG: |
| 117 | wireValue |= BSN_PKTIN_FLAG_DEBUG_VAL; |
| 118 | break; |
| 119 | case BSN_PKTIN_FLAG_TTL_EXPIRED: |
| 120 | wireValue |= BSN_PKTIN_FLAG_TTL_EXPIRED_VAL; |
| 121 | break; |
| 122 | case BSN_PKTIN_FLAG_L3_MISS: |
| 123 | wireValue |= BSN_PKTIN_FLAG_L3_MISS_VAL; |
| 124 | break; |
| 125 | case BSN_PKTIN_FLAG_L3_CPU: |
| 126 | wireValue |= BSN_PKTIN_FLAG_L3_CPU_VAL; |
| 127 | break; |
| 128 | case BSN_PKTIN_FLAG_INGRESS_ACL: |
| 129 | wireValue |= BSN_PKTIN_FLAG_INGRESS_ACL_VAL; |
| 130 | break; |
| 131 | default: |
| 132 | throw new IllegalArgumentException("Illegal enum value for type OFBsnPktinFlag in version 1.3: " + e); |
| 133 | } |
| 134 | } |
| 135 | return wireValue; |
| 136 | } |
| 137 | |
| 138 | } |