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 of_factories.java |
| 8 | // Do not modify |
| 9 | |
| 10 | package org.projectfloodlight.openflow.protocol; |
| 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.jboss.netty.buffer.ChannelBuffer; |
| 27 | |
| 28 | public final class OFFactories { |
| 29 | |
| 30 | private static final GenericReader GENERIC_READER = new GenericReader(); |
| 31 | |
| 32 | public static OFFactory getFactory(OFVersion version) { |
| 33 | switch(version) { |
| 34 | case OF_10: |
| 35 | return org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10.INSTANCE; |
| 36 | case OF_11: |
| 37 | return org.projectfloodlight.openflow.protocol.ver11.OFFactoryVer11.INSTANCE; |
| 38 | case OF_12: |
| 39 | return org.projectfloodlight.openflow.protocol.ver12.OFFactoryVer12.INSTANCE; |
| 40 | case OF_13: |
| 41 | return org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13.INSTANCE; |
| 42 | default: |
| 43 | throw new IllegalArgumentException("Unknown version: "+version); |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | private static class GenericReader implements OFMessageReader<OFMessage> { |
| 48 | public OFMessage readFrom(ChannelBuffer bb) throws OFParseError { |
| 49 | short wireVersion = U8.f(bb.getByte(0)); |
| 50 | OFFactory factory; |
| 51 | switch (wireVersion) { |
| 52 | case 1: |
| 53 | factory = org.projectfloodlight.openflow.protocol.ver10.OFFactoryVer10.INSTANCE; |
| 54 | break; |
| 55 | case 2: |
| 56 | factory = org.projectfloodlight.openflow.protocol.ver11.OFFactoryVer11.INSTANCE; |
| 57 | break; |
| 58 | case 3: |
| 59 | factory = org.projectfloodlight.openflow.protocol.ver12.OFFactoryVer12.INSTANCE; |
| 60 | break; |
| 61 | case 4: |
| 62 | factory = org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13.INSTANCE; |
| 63 | break; |
| 64 | default: |
| 65 | throw new IllegalArgumentException("Unknown wire version: " + wireVersion); |
| 66 | } |
| 67 | return factory.getReader().readFrom(bb); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | public static OFMessageReader<OFMessage> getGenericReader() { |
| 72 | return GENERIC_READER; |
| 73 | } |
| 74 | } |