* 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 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;
* @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<>();
+ private static Set<PacketInReason> decodePacketInReasons(long input) {
+ final var builder = ImmutableSet.<PacketInReason>builder();
if ((input & 1 << 0) != 0) {
- reasons.add(PacketInReason.OFPRNOMATCH);
+ builder.add(PacketInReason.OFPRNOMATCH);
}
if ((input & 1 << 1) != 0) {
- reasons.add(PacketInReason.OFPRACTION);
+ builder.add(PacketInReason.OFPRACTION);
}
if ((input & 1 << 2) != 0) {
- reasons.add(PacketInReason.OFPRINVALIDTTL);
+ builder.add(PacketInReason.OFPRINVALIDTTL);
}
- return reasons;
+ return builder.build();
}
- private static List<PortReason> decodePortReasons(long input) {
- List<PortReason> reasons = new ArrayList<>();
+ private static Set<PortReason> decodePortReasons(long input) {
+ final var builder = ImmutableSet.<PortReason>builder();
if ((input & 1 << 0) != 0) {
- reasons.add(PortReason.OFPPRADD);
+ builder.add(PortReason.OFPPRADD);
}
if ((input & 1 << 1) != 0) {
- reasons.add(PortReason.OFPPRDELETE);
+ builder.add(PortReason.OFPPRDELETE);
}
if ((input & 1 << 2) != 0) {
- reasons.add(PortReason.OFPPRMODIFY);
+ builder.add(PortReason.OFPPRMODIFY);
}
- return reasons;
+ return builder.build();
}
- private static List<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
- List<FlowRemovedReason> reasons = new ArrayList<>();
+ private static Set<FlowRemovedReason> decodeFlowRemovedReasons(long input) {
+ final var builder = ImmutableSet.<FlowRemovedReason>builder();
if ((input & 1 << 0) != 0) {
- reasons.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
+ builder.add(FlowRemovedReason.OFPRRIDLETIMEOUT);
}
if ((input & 1 << 1) != 0) {
- reasons.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
+ builder.add(FlowRemovedReason.OFPRRHARDTIMEOUT);
}
if ((input & 1 << 2) != 0) {
- reasons.add(FlowRemovedReason.OFPRRDELETE);
+ builder.add(FlowRemovedReason.OFPRRDELETE);
}
if ((input & 1 << 3) != 0) {
- reasons.add(FlowRemovedReason.OFPRRGROUPDELETE);
+ builder.add(FlowRemovedReason.OFPRRGROUPDELETE);
}
- return reasons;
+ return builder.build();
}
}