Extensibility support (deserialization part)
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / OxmMaskDeserializer.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.deserialization.match;\r
9 \r
10 import io.netty.buffer.ByteBuf;\r
11 \r
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntry;\r
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.MaskMatchEntryBuilder;\r
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;\r
15 \r
16 /**\r
17  * @author michal.polkorab\r
18  *\r
19  */\r
20 public class OxmMaskDeserializer {\r
21 \r
22     /**\r
23      * Appends mask to match entry (match entry builder)\r
24      * @param builder builder which the mask will append to\r
25      * @param input input ByteBuf\r
26      * @param matchEntryLength mask length\r
27      */\r
28     public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input,\r
29             int matchEntryLength) {\r
30         MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();\r
31         byte[] mask = new byte[matchEntryLength];\r
32         input.readBytes(mask);\r
33         maskBuilder.setMask(mask);\r
34         builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
35     }\r
36 }\r