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