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
9 package org.opendaylight.protocol.rsvp.parser.spi.subobjects;
11 import com.google.common.base.Preconditions;
13 import io.netty.buffer.ByteBuf;
14 import org.opendaylight.protocol.util.ByteBufWriteUtil;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCase;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.UnnumberedCaseBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.Unnumbered;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev150820.basic.explicit.route.subobjects.subobject.type.unnumbered._case.UnnumberedBuilder;
20 public class CommonUnnumberedInterfaceSubobjectParser {
21 protected static UnnumberedCase parseUnnumeredInterface(final ByteBuf buffer) {
22 final UnnumberedBuilder ubuilder = new UnnumberedBuilder();
23 ubuilder.setRouterId(buffer.readUnsignedInt());
24 ubuilder.setInterfaceId(buffer.readUnsignedInt());
25 return new UnnumberedCaseBuilder().setUnnumbered(ubuilder.build()).build();
28 protected static void serializeUnnumeredInterface(final Unnumbered unnumbered, final ByteBuf body) {
29 Preconditions.checkArgument(unnumbered.getRouterId() != null, "RouterId is mandatory.");
30 ByteBufWriteUtil.writeUnsignedInt(unnumbered.getRouterId(), body);
31 Preconditions.checkArgument(unnumbered.getInterfaceId() != null, "InterfaceId is mandatory.");
32 ByteBufWriteUtil.writeUnsignedInt(unnumbered.getInterfaceId(), body);