6ba0a4183a584d1f01a8caea2a81acf969c04719
[openflowplugin.git] / openflowplugin-impl / src / main / java / org / opendaylight / openflowplugin / impl / protocol / deserialization / match / Icmpv6CodeEntryDeserializer.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.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6MatchBuilder;
13
14 public class Icmpv6CodeEntryDeserializer extends AbstractMatchEntryDeserializer {
15
16     @Override
17     public void deserializeEntry(ByteBuf message, MatchBuilder builder) {
18         processHeader(message);
19         final short code = message.readUnsignedByte();
20
21         if (builder.getIcmpv6Match() == null) {
22             builder.setIcmpv6Match(new Icmpv6MatchBuilder()
23                     .setIcmpv6Code(code)
24                     .build());
25         } else if (builder.getIcmpv6Match().getIcmpv6Code() == null) {
26             builder.setIcmpv6Match(new Icmpv6MatchBuilder(builder.getIcmpv6Match())
27                     .setIcmpv6Code(code)
28                     .build());
29         } else {
30             throwErrorOnMalformed(builder, "icmpv6Match", "icmpv6Code");
31         }
32     }
33 }