Search in sources :

Example 1 with BgpEvpnEsi

use of org.onosproject.bgpio.types.BgpEvpnEsi in project onos by opennetworkinglab.

the class BgpEvpnRouteType2Nlri method read.

/**
 * Reads the Evpn type 2 attributes.
 *
 * @param cb channel buffer
 * @return type2 route
 * @throws BgpParseException parse exception
 */
public static BgpEvpnRouteType2Nlri read(ChannelBuffer cb) throws BgpParseException {
    if (cb.readableBytes() == 0) {
        return null;
    }
    RouteDistinguisher rd = RouteDistinguisher.read(cb);
    BgpEvpnEsi esi = BgpEvpnEsi.read(cb);
    int ethernetTagID = cb.readInt();
    byte macAddressLength = cb.readByte();
    MacAddress macAddress = Validation.toMacAddress(macAddressLength / 8, cb);
    byte ipAddressLength = cb.readByte();
    InetAddress ipAddress = null;
    if (ipAddressLength > 0) {
        ipAddress = Validation.toInetAddress(ipAddressLength / 8, cb);
    }
    BgpEvpnLabel mplsLabel1 = BgpEvpnLabel.read(cb);
    BgpEvpnLabel mplsLabel2 = null;
    if (cb.readableBytes() > 0) {
        mplsLabel2 = BgpEvpnLabel.read(cb);
    }
    return new BgpEvpnRouteType2Nlri(rd, esi, ethernetTagID, macAddress, ipAddress, mplsLabel1, mplsLabel2);
}
Also used : BgpEvpnLabel(org.onosproject.bgpio.types.BgpEvpnLabel) BgpEvpnEsi(org.onosproject.bgpio.types.BgpEvpnEsi) RouteDistinguisher(org.onosproject.bgpio.types.RouteDistinguisher) MacAddress(org.onlab.packet.MacAddress) InetAddress(java.net.InetAddress)

Aggregations

InetAddress (java.net.InetAddress)1 MacAddress (org.onlab.packet.MacAddress)1 BgpEvpnEsi (org.onosproject.bgpio.types.BgpEvpnEsi)1 BgpEvpnLabel (org.onosproject.bgpio.types.BgpEvpnLabel)1 RouteDistinguisher (org.onosproject.bgpio.types.RouteDistinguisher)1