Bump versions to 0.21.6-SNAPSHOT
[bgpcep.git] / pcep / base-parser / src / main / java / org / opendaylight / protocol / pcep / parser / object / PCEPPccIdReqIPv6ObjectParser.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. 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.protocol.pcep.parser.object;
9
10 import static com.google.common.base.Preconditions.checkArgument;
11
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
14 import org.opendaylight.protocol.util.Ipv6Util;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddressNoZone;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Object;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.ObjectHeader;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReqBuilder;
19
20 /**
21  * Parser for {@link
22  *     org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcc.id.req.object.PccIdReq
23  * } with IPv6 address.
24  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.2">PCC-ID-REQ Object</a>
25  */
26 public final class PCEPPccIdReqIPv6ObjectParser extends AbstractPccIdReqObjectParser {
27     private static final int IPV6_TYPE = 2;
28
29     public PCEPPccIdReqIPv6ObjectParser() {
30         super(IPV6_TYPE);
31     }
32
33     @Override
34     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
35         checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
36         return new PccIdReqBuilder().setIpAddress(new IpAddressNoZone(Ipv6Util.addressForByteBuf(buffer))).build();
37     }
38 }