21cb18799b38eb7c612be691cc70d9a066eb3d50
[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
9 package org.opendaylight.protocol.pcep.parser.object;
10
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.protocol.pcep.spi.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.IpAddress;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReqBuilder;
19
20 /**
21  * Parser for {@link org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcc.id.req.object.PccIdReq} with IPv6 address
22  * @see <a href="https://tools.ietf.org/html/rfc5886#section-4.2">PCC-ID-REQ Object</a>
23  */
24 public class PCEPPccIdReqIPv6ObjectParser extends AbstractPccIdReqObjectParser {
25
26     @Override
27     public Object parseObject(final ObjectHeader header, final ByteBuf buffer) throws PCEPDeserializerException {
28         Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
29         final PccIdReqBuilder builder = new PccIdReqBuilder();
30         builder.setIpAddress(new IpAddress(Ipv6Util.addressForByteBuf(buffer)));
31         return builder.build();
32     }
33
34 }