import io.netty.buffer.ByteBuf;
-import org.opendaylight.openflowjava.protocol.impl.deserialization.OFDeserializer;
+import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.impl.util.ByteBufUtils;
-import org.opendaylight.openflowjava.protocol.impl.util.EncodeConstants;
+import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures;
*/
public class PortStatusMessageFactory implements OFDeserializer<PortStatusMessage> {
- private static PortStatusMessageFactory instance;
private static final byte PADDING_IN_PORT_STATUS_HEADER = 7;
private static final byte PADDING_IN_OFP_PORT_HEADER_1 = 4;
private static final byte PADDING_IN_OFP_PORT_HEADER_2 = 2;
-
- private PortStatusMessageFactory() {
- // Singleton
- }
-
- /**
- * @return singleton factory
- */
- public static synchronized PortStatusMessageFactory getInstance(){
- if(instance == null){
- instance = new PortStatusMessageFactory();
- }
- return instance;
- }
-
+
@Override
- public PortStatusMessage bufferToMessage(ByteBuf rawMessage, short version) {
+ public PortStatusMessage deserialize(ByteBuf rawMessage) {
PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
- builder.setVersion(version);
+ builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
builder.setXid(rawMessage.readUnsignedInt());
builder.setReason(PortReason.forValue(rawMessage.readUnsignedByte()));
rawMessage.skipBytes(PADDING_IN_PORT_STATUS_HEADER);
}
private static PortFeatures createPortFeatures(long input){
- System.out.println("long: " + input);
final Boolean _10mbHd = ((input) & (1<<0)) != 0;
final Boolean _10mbFd = ((input) & (1<<1)) != 0;
final Boolean _100mbHd = ((input) & (1<<2)) != 0;
final Boolean _noPacketIn = ((input) & (1<<6)) != 0;
return new PortConfig(_noFwd, _noPacketIn, _noRecv, _portDown);
}
-
}