Search in sources :

Example 1 with BgpLSNlri

use of org.onosproject.bgpio.protocol.BgpLSNlri in project onos by opennetworkinglab.

the class MpReachNlri method read.

/**
 * Reads from ChannelBuffer and parses MpReachNlri.
 *
 * @param cb channelBuffer
 * @return object of MpReachNlri
 * @throws BgpParseException while parsing MpReachNlri
 */
public static MpReachNlri read(ChannelBuffer cb) throws BgpParseException {
    ChannelBuffer tempBuf = cb.copy();
    Validation parseFlags = Validation.parseAttributeHeader(cb);
    int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempBuf.readBytes(len);
    if (cb.readableBytes() < parseFlags.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength());
    }
    if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }
    BgpLSNlri bgpLSNlri = null;
    List<BgpLSNlri> mpReachNlri = new LinkedList<>();
    ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
    short afi = 0;
    byte safi = 0;
    IpAddress ipNextHop = null;
    while (tempCb.readableBytes() > 0) {
        afi = tempCb.readShort();
        safi = tempCb.readByte();
        // Supporting for AFI 16388 / SAFI 71 and VPN AFI 16388 / SAFI 128
        if ((afi == Constants.AFI_VALUE) && (safi == Constants.SAFI_VALUE) || (afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
            byte nextHopLen = tempCb.readByte();
            InetAddress ipAddress = Validation.toInetAddress(nextHopLen, tempCb);
            if (ipAddress.isMulticastAddress()) {
                throw new BgpParseException("Multicast not supported");
            }
            ipNextHop = IpAddress.valueOf(ipAddress);
            byte reserved = tempCb.readByte();
            while (tempCb.readableBytes() > 0) {
                short nlriType = tempCb.readShort();
                short totNlriLen = tempCb.readShort();
                if (tempCb.readableBytes() < totNlriLen) {
                    Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
                }
                tempBuf = tempCb.readBytes(totNlriLen);
                switch(nlriType) {
                    case BgpNodeLSNlriVer4.NODE_NLRITYPE:
                        bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
                        break;
                    case BgpLinkLsNlriVer4.LINK_NLRITYPE:
                        bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
                        break;
                    case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
                    case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV6_NLRITYPE:
                        // RFC 7752 : Structure of IPv4 and IPv6 is same
                        bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi, safi);
                        break;
                    default:
                        log.debug("nlriType not supported" + nlriType);
                }
                mpReachNlri.add(bgpLSNlri);
            }
        } else if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE) || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) {
            List<BgpValueType> flowSpecComponents = new LinkedList<>();
            RouteDistinguisher routeDistinguisher = null;
            if (tempCb.readableBytes() > 0) {
                BgpValueType flowSpecComponent = null;
                byte nextHopLen = tempCb.readByte();
                if (nextHopLen > 0) {
                    InetAddress ipAddress = Validation.toInetAddress(nextHopLen, tempCb);
                    if (ipAddress.isMulticastAddress()) {
                        throw new BgpParseException("Multicast not supported");
                    }
                    ipNextHop = IpAddress.valueOf(ipAddress);
                }
                byte reserved = tempCb.readByte();
                if (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE) {
                    routeDistinguisher = new RouteDistinguisher();
                    routeDistinguisher = RouteDistinguisher.read(tempCb);
                }
                while (tempCb.readableBytes() > 0) {
                    short totNlriLen = tempCb.getUnsignedByte(tempCb.readerIndex());
                    if (totNlriLen >= BgpFlowSpecNlri.FLOW_SPEC_LEN) {
                        if (tempCb.readableBytes() < 2) {
                            Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
                        }
                        totNlriLen = tempCb.readShort();
                    } else {
                        totNlriLen = tempCb.readByte();
                    }
                    if (tempCb.readableBytes() < totNlriLen) {
                        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
                    }
                    tempBuf = tempCb.readBytes(totNlriLen);
                    while (tempBuf.readableBytes() > 0) {
                        short type = tempBuf.readByte();
                        switch(type) {
                            case Constants.BGP_FLOWSPEC_DST_PREFIX:
                                flowSpecComponent = BgpFsDestinationPrefix.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_SRC_PREFIX:
                                flowSpecComponent = BgpFsSourcePrefix.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_IP_PROTO:
                                flowSpecComponent = BgpFsIpProtocol.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_PORT:
                                flowSpecComponent = BgpFsPortNum.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_DST_PORT:
                                flowSpecComponent = BgpFsDestinationPortNum.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_SRC_PORT:
                                flowSpecComponent = BgpFsSourcePortNum.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_ICMP_TP:
                                flowSpecComponent = BgpFsIcmpType.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_ICMP_CD:
                                flowSpecComponent = BgpFsIcmpCode.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_TCP_FLAGS:
                                flowSpecComponent = BgpFsTcpFlags.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_PCK_LEN:
                                flowSpecComponent = BgpFsPacketLength.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_DSCP:
                                flowSpecComponent = BgpFsDscpValue.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_FRAGMENT:
                                flowSpecComponent = BgpFsFragment.read(tempBuf);
                                break;
                            default:
                                log.debug("flow spec type not supported" + type);
                                break;
                        }
                        flowSpecComponents.add(flowSpecComponent);
                    }
                }
            }
            BgpFlowSpecNlri flowSpecDetails = new BgpFlowSpecNlri(flowSpecComponents);
            flowSpecDetails.setRouteDistinguiher(routeDistinguisher);
            return new MpReachNlri(flowSpecDetails, afi, safi);
        } else if ((afi == Constants.AFI_EVPN_VALUE) && (safi == Constants.SAFI_EVPN_VALUE)) {
            List<BgpEvpnNlri> eVpnComponents = null;
            byte nextHopLen = tempCb.readByte();
            InetAddress ipAddress = Validation.toInetAddress(nextHopLen, tempCb);
            if (ipAddress.isMulticastAddress()) {
                throw new BgpParseException("Multicast not supported");
            }
            ipNextHop = IpAddress.valueOf(ipAddress);
            byte reserved = tempCb.readByte();
            while (tempCb.readableBytes() > 0) {
                BgpEvpnNlri eVpnComponent = BgpEvpnNlriImpl.read(tempCb);
                eVpnComponents = new LinkedList<>();
                eVpnComponents.add(eVpnComponent);
                log.info("=====evpn Component is {} ======", eVpnComponent);
            }
            return new MpReachNlri(eVpnComponents, afi, safi, ipNextHop);
        } else if ((afi == Constants.AFI_IPV4_UNICAST && safi == Constants.SAFI_UNICAST) || (afi == Constants.AFI_IPV6_UNICAST && safi == Constants.SAFI_UNICAST)) {
            byte nextHopLen = tempCb.readByte();
            InetAddress ipAddress = Validation.toInetAddress(nextHopLen, tempCb);
            if (ipAddress.isMulticastAddress()) {
                throw new BgpParseException("Multicast not supported");
            }
            ipNextHop = IpAddress.valueOf(ipAddress);
            byte snpa = tempCb.readByte();
            // TODO : Use this info, if required
            if (tempCb.readableBytes() > 0) {
                // Convert bits to bytes
                int mpReachNlriPrefixLength = tempCb.readByte() / ONE_BYTE_LENGTH;
                tempCb.skipBytes(mpReachNlriPrefixLength);
            }
            return new MpReachNlri(mpReachNlri, afi, safi, ipNextHop, parseFlags.getLength());
        } else {
            throw new BgpParseException("Not Supporting afi " + afi + "safi " + safi);
        }
    }
    return new MpReachNlri(mpReachNlri, afi, safi, ipNextHop, parseFlags.getLength());
}
Also used : Validation(org.onosproject.bgpio.util.Validation) BgpParseException(org.onosproject.bgpio.exceptions.BgpParseException) BgpFlowSpecNlri(org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri) LinkedList(java.util.LinkedList) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) BgpLSNlri(org.onosproject.bgpio.protocol.BgpLSNlri) IpAddress(org.onlab.packet.IpAddress) List(java.util.List) LinkedList(java.util.LinkedList) BgpEvpnNlri(org.onosproject.bgpio.protocol.BgpEvpnNlri) InetAddress(java.net.InetAddress)

Example 2 with BgpLSNlri

use of org.onosproject.bgpio.protocol.BgpLSNlri in project onos by opennetworkinglab.

the class BgpPeerImpl method buildAdjRibIn.

@Override
public void buildAdjRibIn(List<BgpValueType> pathAttr) throws BgpParseException {
    ListIterator<BgpValueType> iterator = pathAttr.listIterator();
    while (iterator.hasNext()) {
        BgpValueType attr = iterator.next();
        if (attr instanceof MpReachNlri) {
            List<BgpLSNlri> nlri = ((MpReachNlri) attr).mpReachNlri();
            callAdd(this, nlri, pathAttr);
        }
        if (attr instanceof MpUnReachNlri) {
            List<BgpLSNlri> nlri = ((MpUnReachNlri) attr).mpUnReachNlri();
            callRemove(this, nlri);
        }
    }
}
Also used : BgpValueType(org.onosproject.bgpio.types.BgpValueType) MpUnReachNlri(org.onosproject.bgpio.types.MpUnReachNlri) BgpLSNlri(org.onosproject.bgpio.protocol.BgpLSNlri) MpReachNlri(org.onosproject.bgpio.types.MpReachNlri)

Example 3 with BgpLSNlri

use of org.onosproject.bgpio.protocol.BgpLSNlri in project onos by opennetworkinglab.

the class BgpPeerImpl method callRemove.

/**
 * Removes NLRI identifier node in a tree separately based on afi and safi.
 *
 * @param peerImpl BGP peer instance
 * @param nlri NLRI information
 * @throws BgpParseException BGP parse exception
 */
public void callRemove(BgpPeerImpl peerImpl, List<BgpLSNlri> nlri) throws BgpParseException {
    ListIterator<BgpLSNlri> listIterator = nlri.listIterator();
    while (listIterator.hasNext()) {
        BgpLSNlri nlriInfo = listIterator.next();
        if (nlriInfo instanceof BgpNodeLSNlriVer4) {
            if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) {
                adjRib.remove(nlriInfo);
                bgplocalRib.delete(nlriInfo);
            } else {
                vpnAdjRib.removeVpn(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
                bgplocalRibVpn.delete(nlriInfo, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
            }
        } else if (nlriInfo instanceof BgpLinkLsNlriVer4) {
            if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) {
                adjRib.remove(nlriInfo);
                bgplocalRib.delete(nlriInfo);
            } else {
                vpnAdjRib.removeVpn(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
                bgplocalRibVpn.delete(nlriInfo, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
            }
        } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) {
            if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) {
                adjRib.remove(nlriInfo);
                bgplocalRib.delete(nlriInfo);
            } else {
                vpnAdjRib.removeVpn(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
                bgplocalRibVpn.delete(nlriInfo, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
            }
        }
    }
}
Also used : BgpNodeLSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4) BgpPrefixIPv4LSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4) BgpLSNlri(org.onosproject.bgpio.protocol.BgpLSNlri) BgpLinkLsNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4)

Example 4 with BgpLSNlri

use of org.onosproject.bgpio.protocol.BgpLSNlri in project onos by opennetworkinglab.

the class BgpPeerImpl method callAdd.

/**
 * Updates NLRI identifier node in a tree separately based on afi and safi.
 *
 * @param peerImpl BGP peer instance
 * @param nlri MpReachNlri path attribute
 * @param pathAttr list of BGP path attributes
 * @throws BgpParseException throws exception
 */
public void callAdd(BgpPeerImpl peerImpl, List<BgpLSNlri> nlri, List<BgpValueType> pathAttr) throws BgpParseException {
    ListIterator<BgpLSNlri> listIterator = nlri.listIterator();
    while (listIterator.hasNext()) {
        BgpLSNlri nlriInfo = listIterator.next();
        if (nlriInfo instanceof BgpNodeLSNlriVer4) {
            PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr);
            if (!((BgpNodeLSNlriVer4) nlriInfo).isVpnPresent()) {
                adjRib.add(nlriInfo, details);
                bgplocalRib.add(sessionInfo(), nlriInfo, details);
            } else {
                vpnAdjRib.addVpn(nlriInfo, details, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
                bgplocalRibVpn.add(sessionInfo(), nlriInfo, details, ((BgpNodeLSNlriVer4) nlriInfo).getRouteDistinguisher());
            }
        } else if (nlriInfo instanceof BgpLinkLsNlriVer4) {
            PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr);
            if (!((BgpLinkLsNlriVer4) nlriInfo).isVpnPresent()) {
                adjRib.add(nlriInfo, details);
                bgplocalRib.add(sessionInfo(), nlriInfo, details);
            } else {
                vpnAdjRib.addVpn(nlriInfo, details, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
                bgplocalRibVpn.add(sessionInfo(), nlriInfo, details, ((BgpLinkLsNlriVer4) nlriInfo).getRouteDistinguisher());
            }
        } else if (nlriInfo instanceof BgpPrefixIPv4LSNlriVer4) {
            PathAttrNlriDetails details = setPathAttrDetails(nlriInfo, pathAttr);
            if (!((BgpPrefixIPv4LSNlriVer4) nlriInfo).isVpnPresent()) {
                adjRib.add(nlriInfo, details);
                bgplocalRib.add(sessionInfo(), nlriInfo, details);
            } else {
                vpnAdjRib.addVpn(nlriInfo, details, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
                bgplocalRibVpn.add(sessionInfo(), nlriInfo, details, ((BgpPrefixIPv4LSNlriVer4) nlriInfo).getRouteDistinguisher());
            }
        }
    }
}
Also used : BgpNodeLSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4) BgpPrefixIPv4LSNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4) PathAttrNlriDetails(org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails) BgpLSNlri(org.onosproject.bgpio.protocol.BgpLSNlri) BgpLinkLsNlriVer4(org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4)

Example 5 with BgpLSNlri

use of org.onosproject.bgpio.protocol.BgpLSNlri in project onos by opennetworkinglab.

the class MpUnReachNlri method read.

/**
 * Reads from ChannelBuffer and parses MpUnReachNlri.
 *
 * @param cb ChannelBuffer
 * @return object of MpUnReachNlri
 * @throws BgpParseException while parsing MpUnReachNlri
 */
public static MpUnReachNlri read(ChannelBuffer cb) throws BgpParseException {
    ChannelBuffer tempBuf = cb.copy();
    Validation parseFlags = Validation.parseAttributeHeader(cb);
    int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
    ChannelBuffer data = tempBuf.readBytes(len);
    if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() && parseFlags.getThirdBit()) {
        throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
    }
    if (cb.readableBytes() < parseFlags.getLength()) {
        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength());
    }
    LinkedList<BgpLSNlri> mpUnReachNlri = new LinkedList<>();
    BgpLSNlri bgpLSNlri = null;
    short afi = 0;
    byte safi = 0;
    ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
    while (tempCb.readableBytes() > 0) {
        afi = tempCb.readShort();
        safi = tempCb.readByte();
        // Supporting only for AFI 16388 / SAFI 71
        if ((afi == Constants.AFI_VALUE) && (safi == Constants.SAFI_VALUE) || (afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
            while (tempCb.readableBytes() > 0) {
                short nlriType = tempCb.readShort();
                short totNlriLen = tempCb.readShort();
                if (tempCb.readableBytes() < totNlriLen) {
                    Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
                }
                tempBuf = tempCb.readBytes(totNlriLen);
                switch(nlriType) {
                    case BgpNodeLSNlriVer4.NODE_NLRITYPE:
                        bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
                        break;
                    case BgpLinkLsNlriVer4.LINK_NLRITYPE:
                        bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
                        break;
                    case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
                    case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV6_NLRITYPE:
                        // RFC 7752 : Structure of IPv4 and IPv6 is same
                        bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi, safi);
                        break;
                    default:
                        log.debug("nlriType not supported" + nlriType);
                        break;
                }
                mpUnReachNlri.add(bgpLSNlri);
            }
        } else if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE) || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) {
            List<BgpValueType> flowSpecComponents = new LinkedList<>();
            RouteDistinguisher routeDistinguisher = null;
            if (tempCb.readableBytes() > 0) {
                BgpValueType flowSpecComponent = null;
                if (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE) {
                    routeDistinguisher = new RouteDistinguisher();
                    routeDistinguisher = RouteDistinguisher.read(tempCb);
                }
                while (tempCb.readableBytes() > 0) {
                    short totNlriLen = tempCb.getUnsignedByte(tempCb.readerIndex());
                    if (totNlriLen >= BgpFlowSpecNlri.FLOW_SPEC_LEN) {
                        if (tempCb.readableBytes() < 2) {
                            Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
                        }
                        totNlriLen = tempCb.readShort();
                    } else {
                        totNlriLen = tempCb.readByte();
                    }
                    if (tempCb.readableBytes() < totNlriLen) {
                        Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
                    }
                    tempBuf = tempCb.readBytes(totNlriLen);
                    while (tempBuf.readableBytes() > 0) {
                        short type = tempBuf.readByte();
                        switch(type) {
                            case Constants.BGP_FLOWSPEC_DST_PREFIX:
                                flowSpecComponent = BgpFsDestinationPrefix.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_SRC_PREFIX:
                                flowSpecComponent = BgpFsSourcePrefix.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_IP_PROTO:
                                flowSpecComponent = BgpFsIpProtocol.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_PORT:
                                flowSpecComponent = BgpFsPortNum.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_DST_PORT:
                                flowSpecComponent = BgpFsDestinationPortNum.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_SRC_PORT:
                                flowSpecComponent = BgpFsSourcePortNum.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_ICMP_TP:
                                flowSpecComponent = BgpFsIcmpType.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_ICMP_CD:
                                flowSpecComponent = BgpFsIcmpCode.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_TCP_FLAGS:
                                flowSpecComponent = BgpFsTcpFlags.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_PCK_LEN:
                                flowSpecComponent = BgpFsPacketLength.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_DSCP:
                                flowSpecComponent = BgpFsDscpValue.read(tempBuf);
                                break;
                            case Constants.BGP_FLOWSPEC_FRAGMENT:
                                flowSpecComponent = BgpFsFragment.read(tempBuf);
                                break;
                            default:
                                log.debug("flow spec type not supported" + type);
                                break;
                        }
                        flowSpecComponents.add(flowSpecComponent);
                    }
                }
            }
            BgpFlowSpecNlri flowSpecDetails = new BgpFlowSpecNlri(flowSpecComponents);
            flowSpecDetails.setRouteDistinguiher(routeDistinguisher);
            return new MpUnReachNlri(flowSpecDetails, afi, safi);
        } else if ((afi == Constants.AFI_EVPN_VALUE) && (safi == Constants.SAFI_EVPN_VALUE)) {
            List<BgpEvpnNlri> eVpnComponents = null;
            while (tempCb.readableBytes() > 0) {
                BgpEvpnNlri eVpnComponent = BgpEvpnNlriImpl.read(tempCb);
                eVpnComponents = new LinkedList<>();
                eVpnComponents.add(eVpnComponent);
                log.info("=====evpn Component is {} ======", eVpnComponent);
            }
            return new MpUnReachNlri(eVpnComponents, afi, safi);
        } else if ((afi == Constants.AFI_IPV4_UNICAST && safi == Constants.SAFI_UNICAST) || (afi == Constants.AFI_IPV6_UNICAST && safi == Constants.SAFI_UNICAST)) {
            // Right now, we do not know where to use these bytes so we skip them
            // If we do not skip, there are errors in reading subsequent TLVs
            // TODO : Use this info, if required
            // Short for AFI, byte for SAFI
            int remainingLen = parseFlags.getLength() - 3;
            if (remainingLen > 0) {
                tempCb.skipBytes(remainingLen);
            }
        } else {
            // TODO: check with the values got from capability
            throw new BgpParseException("Not Supporting afi " + afi + "safi " + safi);
        }
    }
    return new MpUnReachNlri(mpUnReachNlri, afi, safi, parseFlags.getLength());
}
Also used : Validation(org.onosproject.bgpio.util.Validation) BgpParseException(org.onosproject.bgpio.exceptions.BgpParseException) BgpFlowSpecNlri(org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri) LinkedList(java.util.LinkedList) ChannelBuffer(org.jboss.netty.buffer.ChannelBuffer) BgpLSNlri(org.onosproject.bgpio.protocol.BgpLSNlri) List(java.util.List) LinkedList(java.util.LinkedList) BgpEvpnNlri(org.onosproject.bgpio.protocol.BgpEvpnNlri)

Aggregations

BgpLSNlri (org.onosproject.bgpio.protocol.BgpLSNlri)5 LinkedList (java.util.LinkedList)2 List (java.util.List)2 ChannelBuffer (org.jboss.netty.buffer.ChannelBuffer)2 BgpParseException (org.onosproject.bgpio.exceptions.BgpParseException)2 BgpEvpnNlri (org.onosproject.bgpio.protocol.BgpEvpnNlri)2 BgpFlowSpecNlri (org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri)2 BgpLinkLsNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4)2 BgpNodeLSNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4)2 BgpPrefixIPv4LSNlriVer4 (org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4)2 Validation (org.onosproject.bgpio.util.Validation)2 InetAddress (java.net.InetAddress)1 IpAddress (org.onlab.packet.IpAddress)1 PathAttrNlriDetails (org.onosproject.bgpio.protocol.linkstate.PathAttrNlriDetails)1 BgpValueType (org.onosproject.bgpio.types.BgpValueType)1 MpReachNlri (org.onosproject.bgpio.types.MpReachNlri)1 MpUnReachNlri (org.onosproject.bgpio.types.MpUnReachNlri)1