2 * Copyright (c) 2016 Pantheon Technologies s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.openflowplugin.impl.protocol.deserialization.match;
11 import io.netty.buffer.ByteBuf;
12 import java.util.Objects;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.PortNumber;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
18 public class TcpDestinationPortEntryDeserializer extends AbstractMatchEntryDeserializer {
21 public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
22 processHeader(message);
23 final int port = message.readUnsignedShort();
25 if (Objects.isNull(builder.getLayer4Match())) {
26 builder.setLayer4Match(new TcpMatchBuilder()
27 .setTcpDestinationPort(new PortNumber(port))
29 } else if (TcpMatch.class.isInstance(builder.getLayer4Match())
30 && Objects.isNull(TcpMatch.class.cast(builder.getLayer4Match()).getTcpDestinationPort())) {
31 builder.setLayer4Match(new TcpMatchBuilder(TcpMatch.class.cast(builder.getLayer4Match()))
32 .setTcpDestinationPort(new PortNumber(port))
35 throwErrorOnMalformed(builder, "layer4Match", "tcpDestinationPort");