728d42fa7cc86474e664cf2b01c07c97eeffd164
[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 final class OxmMaskDeserializer {\r
21 \r
22     private OxmMaskDeserializer() {\r
23         throw new UnsupportedOperationException("Utility class shouldn't be instantiated");\r
24     }\r
25 \r
26     /**\r
27      * Appends mask to match entry (match entry builder)\r
28      * @param builder builder which the mask will append to\r
29      * @param input input ByteBuf\r
30      * @param matchEntryLength mask length\r
31      */\r
32     public static void addMaskAugmentation(MatchEntriesBuilder builder, ByteBuf input,\r
33             int matchEntryLength) {\r
34         MaskMatchEntryBuilder maskBuilder = new MaskMatchEntryBuilder();\r
35         byte[] mask = new byte[matchEntryLength];\r
36         input.readBytes(mask);\r
37         maskBuilder.setMask(mask);\r
38         builder.addAugmentation(MaskMatchEntry.class, maskBuilder.build());\r
39     }\r
40 }\r