Use ByteBuf.readRetainedSlice()
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / match / Ipv6NdSllEntryDeserializer.java
1 /*
2  * Copyright (c) 2016 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.openflowplugin.impl.protocol.deserialization.match;
9
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.openflowjava.protocol.impl.deserialization.match.OxmDeserializerHelper;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6Match;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv6MatchBuilder;
16
17 public class Ipv6NdSllEntryDeserializer extends AbstractMatchEntryDeserializer {
18
19     @Override
20     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
21         processHeader(message);
22         final MacAddress address = OxmDeserializerHelper.convertMacAddress(message);
23
24         if (builder.getLayer3Match() == null) {
25             builder.setLayer3Match(new Ipv6MatchBuilder()
26                     .setIpv6NdSll(address)
27                     .build());
28         } else if (builder.getLayer3Match() instanceof Ipv6Match
29                 && ((Ipv6Match) builder.getLayer3Match()).getIpv6NdSll() == null) {
30             final Ipv6Match match = (Ipv6Match) builder.getLayer3Match();
31             builder.setLayer3Match(new Ipv6MatchBuilder(match)
32                     .setIpv6NdSll(address)
33                     .build());
34         } else {
35             throwErrorOnMalformed(builder, "layer3Match", "ipv6NdSll");
36         }
37     }
38 }