Add multipart request message serializers
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / IpDscpEntrySerializer.java
1 /*
2  * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
10
11 import io.netty.buffer.ByteBuf;
12 import java.util.Objects;
13 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
14 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
16
17 public class IpDscpEntrySerializer extends AbstractMatchEntrySerializer {
18
19     @Override
20     public void serialize(Match match, ByteBuf outBuffer) {
21         super.serialize(match, outBuffer);
22         outBuffer.writeByte(match.getIpMatch().getIpDscp().getValue());
23     }
24
25     @Override
26     public boolean matchTypeCheck(Match match) {
27         return Objects.nonNull(match.getIpMatch()) &&
28                 Objects.nonNull(match.getIpMatch().getIpDscp());
29     }
30
31     @Override
32     protected boolean getHasMask(Match match) {
33         return false;
34     }
35
36     @Override
37     protected int getOxmFieldCode() {
38         return OxmMatchConstants.IP_DSCP;
39     }
40
41     @Override
42     protected int getOxmClassCode() {
43         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
44     }
45
46     @Override
47     protected int getValueLength() {
48         return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
49     }
50
51 }