MVPN RFC6514 Extendend communities
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / extended / community / FourOctAsCommonECUtil.java
1 /*
2  * Copyright (c) 2016 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.bgp.parser.spi.extended.community;
10
11 import io.netty.buffer.ByteBuf;
12 import org.opendaylight.protocol.util.ByteBufWriteUtil;
13 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.spec.common.As4SpecificCommon;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.as._4.spec.common.As4SpecificCommonBuilder;
16
17 public final class FourOctAsCommonECUtil {
18     private FourOctAsCommonECUtil() {
19         throw new UnsupportedOperationException();
20     }
21
22     public static As4SpecificCommon parseCommon(final ByteBuf body) {
23         return new As4SpecificCommonBuilder().setAsNumber(new AsNumber(body.readUnsignedInt()))
24             .setLocalAdministrator(body.readUnsignedShort()).build();
25     }
26
27     public static void serializeCommon(final As4SpecificCommon extComm, final ByteBuf body) {
28         body.writeInt(extComm.getAsNumber().getValue().intValue());
29         ByteBufWriteUtil.writeUnsignedShort(extComm.getLocalAdministrator(), body);
30     }
31 }