Mass replace CRLF->LF
[openflowjava.git] / openflow-protocol-impl / src / main / java / org / opendaylight / openflowjava / protocol / impl / deserialization / match / AbstractOxmIpv6AddressDeserializer.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.openflowjava.protocol.api.extensibility.OFDeserializer;
13 import org.opendaylight.openflowjava.util.ByteBufUtils;
14 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntry;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.augments.rev131002.Ipv6AddressMatchEntryBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntries;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev130731.oxm.fields.grouping.MatchEntriesBuilder;
20
21 /**
22  * @author michal.polkorab
23  *
24  */
25 public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer
26         implements OFDeserializer<MatchEntries> {
27
28     @Override
29     public MatchEntries deserialize(final ByteBuf input) {
30         MatchEntriesBuilder builder = processHeader(getOxmClass(), getOxmField(), input);
31         addIpv6AddressAugmentation(builder, input);
32         if (builder.isHasMask()) {
33             OxmMaskDeserializer.addMaskAugmentation(builder, input,
34                     EncodeConstants.SIZE_OF_IPV6_ADDRESS_IN_BYTES);
35         }
36         return builder.build();
37     }
38
39     private static void addIpv6AddressAugmentation(final MatchEntriesBuilder builder, final ByteBuf input) {
40         Ipv6AddressMatchEntryBuilder ipv6AddressBuilder = new Ipv6AddressMatchEntryBuilder();
41         ipv6AddressBuilder.setIpv6Address(new Ipv6Address(ByteBufUtils.readIpv6Address(input)));
42         builder.addAugmentation(Ipv6AddressMatchEntry.class, ipv6AddressBuilder.build());
43     }
44 }