Merge "OPNFLWPLUG-1062 Include additional LLDP fields in liblldp"
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / serialization / match / IpEcnEntrySerializer.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 package org.opendaylight.openflowplugin.impl.protocol.serialization.match;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
12 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.Match;
14
15 public class IpEcnEntrySerializer extends AbstractMatchEntrySerializer {
16
17     @Override
18     public void serialize(Match match, ByteBuf outBuffer) {
19         super.serialize(match, outBuffer);
20         outBuffer.writeByte(match.getIpMatch().getIpEcn());
21     }
22
23     @Override
24     public boolean matchTypeCheck(Match match) {
25         return match.getIpMatch() != null && match.getIpMatch().getIpEcn() != null;
26     }
27
28     @Override
29     protected boolean getHasMask(Match match) {
30         return false;
31     }
32
33     @Override
34     protected int getOxmFieldCode() {
35         return OxmMatchConstants.IP_ECN;
36     }
37
38     @Override
39     protected int getOxmClassCode() {
40         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;
41     }
42
43     @Override
44     protected int getValueLength() {
45         return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;
46     }
47
48 }