2 * Copyright (c) 2013 Pantheon Technologies s.r.o. and others. All rights reserved.
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
8 package org.opendaylight.openflowjava.protocol.impl.deserialization.match;
10 import io.netty.buffer.ByteBuf;
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;
22 * @author michal.polkorab
25 public abstract class AbstractOxmIpv6AddressDeserializer extends AbstractOxmMatchEntryDeserializer
26 implements OFDeserializer<MatchEntries> {
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);
36 return builder.build();
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());