* terms of the Eclipse Public License v1.0 which accompanies this distribution,
* and is available at http://www.eclipse.org/legal/epl-v10.html
*/
-
package org.opendaylight.openflowjava.protocol.impl.deserialization.factories;
-import io.netty.buffer.ByteBuf;
+import static org.opendaylight.yangtools.yang.common.netty.ByteBufUtils.readUint32;
+import com.google.common.collect.ImmutableSet;
+import io.netty.buffer.ByteBuf;
import java.util.ArrayList;
import java.util.List;
-
+import java.util.Set;
import org.opendaylight.openflowjava.protocol.api.extensibility.OFDeserializer;
import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowRemovedReason;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.async.body.grouping.PortStatusMaskBuilder;
/**
- * Translates GetAsyncReply messages
+ * Translates GetAsyncReply messages.
+ *
* @author timotej.kubas
* @author michal.polkorab
*/
public class GetAsyncReplyMessageFactory implements OFDeserializer<GetAsyncOutput> {
-
private static final byte SEPARATE_ROLES = 2;
@Override
public GetAsyncOutput deserialize(ByteBuf rawMessage) {
- GetAsyncOutputBuilder builder = new GetAsyncOutputBuilder();
- builder.setVersion((short) EncodeConstants.OF13_VERSION_ID);
- builder.setXid(rawMessage.readUnsignedInt());
- builder.setPacketInMask(decodePacketInMask(rawMessage));
- builder.setPortStatusMask(decodePortStatusMask(rawMessage));
- builder.setFlowRemovedMask(decodeFlowRemovedMask(rawMessage));
- return builder.build();
+ return new GetAsyncOutputBuilder()
+ .setVersion(EncodeConstants.OF_VERSION_1_3)
+ .setXid(readUint32(rawMessage))
+ .setPacketInMask(decodePacketInMask(rawMessage))
+ .setPortStatusMask(decodePortStatusMask(rawMessage))
+ .setFlowRemovedMask(decodeFlowRemovedMask(rawMessage))
+ .build();
}
private static List<PacketInMask> decodePacketInMask(ByteBuf input) {
return inMasks;
}
- private static List<PacketInReason> decodePacketInReasons(long input) {
- List<PacketInReason> reasons = new ArrayList<>();
- if ((input & (1 << 0)) != 0) {
- reasons.add(PacketInReason.OFPRNOMATCH);
+ private static Set<PacketInReason> decodePacketInReasons(long input) {
+ final var builder = ImmutableSet.<PacketInReason>builder();
+ if ((input & 1 << 0) != 0) {
+ builder.add(PacketInReason.OFPRNOMATCH);
}
- if ((input & (1 << 1)) != 0) {
- reasons.add(PacketInReason.OFPRACTION);
+ if ((input & 1 << 1) != 0) {
+ builder.add(PacketInReason.OFPRACTION);
}
- if ((input & (1 << 2)) != 0) {
- reasons.add(PacketInReason.OFPRINVALIDTTL);
+ if ((input & 1 << 2) != 0) {
+ builder.add(PacketInReason.OFPRINVALIDTTL);
}
- return reasons;
+ return builder.build();
}
- private static List<PortReason> decodePortReasons(long input) {
- List<PortReason> reasons = new ArrayList<>();
- if ((input & (1 << 0)) != 0) {
- reasons.add(PortReason.OFPPRADD);
+ private static Set<PortReason> decodePortReasons(long input) {
+ final var builder = ImmutableSet.<PortReason>builder();
+ if ((input & 1 << 0) != 0) {
+ builder.add(PortReason.OFPPRADD);
}
- if ((input & (1 << 1)) != 0) {
- reasons.add(PortReason.OFPPRDELETE);
+ if ((input & 1 << 1) != 0) {
+ builder.add(PortReason.OFPPRDELETE);
}
- if ((input & (1 << 2)) != 0) {
- reasons.add(PortReason.OFPPRMODIFY);
+ if ((input & 1 << 2) != 0) {
+ builder.add(PortReason.OFPPRMODIFY);
}
- return reasons;
+ return builder.build();
}
- private static List<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
- List<FlowRemovedReason> reasons = new ArrayList<>();
- if ((input & (1 << 0)) != 0) {
- reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+ private static Set<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
+ final var builder = ImmutableSet.<FlowRemovedReason>builder();
+ if ((input & 1 << 0) != 0) {
+ builder.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
}
- if ((input & (1 << 1)) != 0) {
- reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+ if ((input & 1 << 1) != 0) {
+ builder.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
}
- if ((input & (1 << 2)) != 0) {
- reasons.add(FlowRemovedReason.OFPRRDELETE);
+ if ((input & 1 << 2) != 0) {
+ builder.add(FlowRemovedReason.OFPRRDELETE);
}
- if ((input & (1 << 3)) != 0) {
- reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
+ if ((input & 1 << 3) != 0) {
+ builder.add(FlowRemovedReason.OFPRRGROUPDELETE);
}
- return reasons;
+ return builder.build();
}
}