2 * Copyright (c) 2015 Cisco Systems, Inc. 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.protocol.pcep.sync.optimizations;
10 import static com.google.common.base.Preconditions.checkArgument;
11 import static org.opendaylight.protocol.util.ByteBufUtils.readUint64;
12 import static org.opendaylight.protocol.util.ByteBufUtils.writeOrZero;
14 import io.netty.buffer.ByteBuf;
15 import io.netty.buffer.Unpooled;
16 import org.opendaylight.protocol.pcep.spi.PCEPDeserializerException;
17 import org.opendaylight.protocol.pcep.spi.TlvParser;
18 import org.opendaylight.protocol.pcep.spi.TlvSerializer;
19 import org.opendaylight.protocol.pcep.spi.TlvUtil;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.lsp.db.version.tlv.LspDbVersion;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev181109.lsp.db.version.tlv.LspDbVersionBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.Tlv;
24 public class LspDbVersionTlvParser implements TlvParser, TlvSerializer {
25 public static final int TYPE = 23;
28 public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
29 checkArgument(tlv instanceof LspDbVersion, "Tlv object is not instance of LspDbVersion.");
30 final ByteBuf body = Unpooled.buffer();
31 writeOrZero(body, ((LspDbVersion) tlv).getLspDbVersionValue());
32 TlvUtil.formatTlv(TYPE, body, buffer);
36 public Tlv parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
40 return new LspDbVersionBuilder().setLspDbVersionValue(readUint64(buffer)).build();