82722fc540b46992617b7820ad3315d90e9935be
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / serialization / match / OxmIcmpv4CodeSerializer.java
1 /*\r
2  * Copyright (c) 2013 Pantheon Technologies s.r.o. and others.  All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 package org.opendaylight.openflowjava.protocol.impl.serialization.match;\r
9 \r
10 import io.netty.buffer.ByteBuf;\r
11 \r
12 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;\r
13 import org.opendaylight.openflowjava.protocol.api.util.OxmMatchConstants;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Icmpv4CodeMatchEntry;\r
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;\r
16 \r
17 /**\r
18  * @author michal.polkorab\r
19  *\r
20  */\r
21 public class OxmIcmpv4CodeSerializer extends AbstractOxmMatchEntrySerializer {\r
22 \r
23     @Override\r
24     public void serialize(MatchEntries entry, ByteBuf outBuffer) {\r
25         super.serialize(entry, outBuffer);\r
26         outBuffer.writeByte(entry.getAugmentation(Icmpv4CodeMatchEntry.class).getIcmpv4Code());\r
27     }\r
28 \r
29     @Override\r
30     protected int getOxmClassCode() {\r
31         return OxmMatchConstants.OPENFLOW_BASIC_CLASS;\r
32     }\r
33 \r
34     @Override\r
35     protected int getOxmFieldCode() {\r
36         return OxmMatchConstants.ICMPV4_CODE;\r
37     }\r
38 \r
39     @Override\r
40     protected int getValueLength() {\r
41         return EncodeConstants.SIZE_OF_BYTE_IN_BYTES;\r
42     }\r
43 }\r