blob: afc2f1f683748a88ceb8411e019e90bfbafd9a94 [file] [log] [blame]
alshabib86ac11c2014-08-14 16:14:41 -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 of_factories.java
8// Do not modify
9
10package org.projectfloodlight.openflow.protocol;
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.jboss.netty.buffer.ChannelBuffer;
27
28public 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}