return regs;
}
- private static void registerCapabilityParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
+ private static void registerCapabilityParsers(final List<AutoCloseable> regs,
+ final BGPExtensionProviderContext context) {
final AddressFamilyRegistry afiReg = context.getAddressFamilyRegistry();
final SubsequentAddressFamilyRegistry safiReg = context.getSubsequentAddressFamilyRegistry();
regs.add(context.registerCapabilitySerializer(BgpExtendedMessageCapability.class, bgpextmessage));
}
- private static void registerAttributeParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
- final BgpPrefixSidAttributeParser prefixSidAttributeParser = new BgpPrefixSidAttributeParser(context.getBgpPrefixSidTlvRegistry());
+ private static void registerAttributeParsers(final List<AutoCloseable> regs,
+ final BGPExtensionProviderContext context) {
+ final BgpPrefixSidAttributeParser prefixSidAttributeParser
+ = new BgpPrefixSidAttributeParser(context.getBgpPrefixSidTlvRegistry());
regs.add(context.registerAttributeSerializer(BgpPrefixSid.class, prefixSidAttributeParser));
regs.add(context.registerAttributeParser(BgpPrefixSidAttributeParser.TYPE, prefixSidAttributeParser));
regs.add(context.registerAttributeSerializer(NextHop.class, nextHopAttributeParser));
regs.add(context.registerAttributeParser(NextHopAttributeParser.TYPE, nextHopAttributeParser));
- final MultiExitDiscriminatorAttributeParser multiExitDiscriminatorAttributeParser = new MultiExitDiscriminatorAttributeParser();
+ final MultiExitDiscriminatorAttributeParser multiExitDiscriminatorAttributeParser
+ = new MultiExitDiscriminatorAttributeParser();
regs.add(context.registerAttributeSerializer(MultiExitDisc.class, multiExitDiscriminatorAttributeParser));
- regs.add(context.registerAttributeParser(MultiExitDiscriminatorAttributeParser.TYPE, multiExitDiscriminatorAttributeParser));
+ regs.add(context.registerAttributeParser(MultiExitDiscriminatorAttributeParser.TYPE,
+ multiExitDiscriminatorAttributeParser));
final LocalPreferenceAttributeParser localPreferenceAttributeParser = new LocalPreferenceAttributeParser();
regs.add(context.registerAttributeSerializer(LocalPref.class, localPreferenceAttributeParser));
regs.add(context.registerAttributeSerializer(AtomicAggregate.class, atomicAggregateAttributeParser));
regs.add(context.registerAttributeParser(AtomicAggregateAttributeParser.TYPE, atomicAggregateAttributeParser));
- final AggregatorAttributeParser as4AggregatorAttributeParser = new AggregatorAttributeParser(context.getReferenceCache());
+ final AggregatorAttributeParser as4AggregatorAttributeParser
+ = new AggregatorAttributeParser(context.getReferenceCache());
regs.add(context.registerAttributeSerializer(Aggregator.class, as4AggregatorAttributeParser));
regs.add(context.registerAttributeParser(AggregatorAttributeParser.TYPE, as4AggregatorAttributeParser));
- final CommunitiesAttributeParser communitiesAttributeParser = new CommunitiesAttributeParser(context.getReferenceCache());
+ final CommunitiesAttributeParser communitiesAttributeParser
+ = new CommunitiesAttributeParser(context.getReferenceCache());
regs.add(context.registerAttributeSerializer(Communities.class, communitiesAttributeParser));
regs.add(context.registerAttributeParser(CommunitiesAttributeParser.TYPE, communitiesAttributeParser));
regs.add(context.registerAttributeSerializer(MpUnreachNlri.class, mpUnreachAttributeParser));
regs.add(context.registerAttributeParser(MPUnreachAttributeParser.TYPE, mpUnreachAttributeParser));
- final ExtendedCommunitiesAttributeParser extendedCommunitiesAttributeParser = new ExtendedCommunitiesAttributeParser(context.getExtendedCommunityRegistry());
+ final ExtendedCommunitiesAttributeParser extendedCommunitiesAttributeParser
+ = new ExtendedCommunitiesAttributeParser(context.getExtendedCommunityRegistry());
regs.add(context.registerAttributeSerializer(ExtendedCommunities.class, extendedCommunitiesAttributeParser));
- regs.add(context.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE, extendedCommunitiesAttributeParser));
+ regs.add(context.registerAttributeParser(ExtendedCommunitiesAttributeParser.TYPE,
+ extendedCommunitiesAttributeParser));
- regs.add(context.registerAttributeParser(AS4AggregatorAttributeParser.TYPE, new AS4AggregatorAttributeParser()));
+ regs.add(context.registerAttributeParser(AS4AggregatorAttributeParser.TYPE,
+ new AS4AggregatorAttributeParser()));
regs.add(context.registerAttributeParser(AS4PathAttributeParser.TYPE, new AS4PathAttributeParser()));
- regs.add(context.registerAttributeSerializer(UnrecognizedAttributes.class, new UnrecognizedAttributesSerializer()));
+ regs.add(context.registerAttributeSerializer(UnrecognizedAttributes.class,
+ new UnrecognizedAttributesSerializer()));
}
- private static void registerMessageParsers(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
+ private static void registerMessageParsers(final List<AutoCloseable> regs,
+ final BGPExtensionProviderContext context) {
final BGPOpenMessageParser omp = new BGPOpenMessageParser(context.getParameterRegistry());
regs.add(context.registerMessageParser(BGPOpenMessageParser.TYPE, omp));
regs.add(context.registerMessageSerializer(Open.class, omp));
regs.add(context.registerMessageSerializer(RouteRefresh.class, rrmp));
}
- private static void registerExtendedCommunities(final List<AutoCloseable> regs, final BGPExtensionProviderContext context) {
+ private static void registerExtendedCommunities(final List<AutoCloseable> regs,
+ final BGPExtensionProviderContext context) {
final AsTwoOctetSpecificEcHandler twoOctetSpecificEcHandler = new AsTwoOctetSpecificEcHandler();
- regs.add(context.registerExtendedCommunityParser(twoOctetSpecificEcHandler.getType(true), twoOctetSpecificEcHandler.getSubType(),
- twoOctetSpecificEcHandler));
- regs.add(context.registerExtendedCommunityParser(twoOctetSpecificEcHandler.getType(false), twoOctetSpecificEcHandler.getSubType(),
- twoOctetSpecificEcHandler));
+ regs.add(context.registerExtendedCommunityParser(twoOctetSpecificEcHandler.getType(true),
+ twoOctetSpecificEcHandler.getSubType(), twoOctetSpecificEcHandler));
+ regs.add(context.registerExtendedCommunityParser(twoOctetSpecificEcHandler.getType(false),
+ twoOctetSpecificEcHandler.getSubType(), twoOctetSpecificEcHandler));
regs.add(context.registerExtendedCommunitySerializer(AsSpecificExtendedCommunityCase.class, twoOctetSpecificEcHandler));
final Ipv4SpecificEcHandler ipv4SpecificEcHandler = new Ipv4SpecificEcHandler();
- regs.add(context.registerExtendedCommunityParser(ipv4SpecificEcHandler.getType(true), ipv4SpecificEcHandler.getSubType(),
+ regs.add(context.registerExtendedCommunityParser(ipv4SpecificEcHandler.getType(true),
+ ipv4SpecificEcHandler.getSubType(), ipv4SpecificEcHandler));
+ regs.add(context.registerExtendedCommunityParser(ipv4SpecificEcHandler.getType(false),
+ ipv4SpecificEcHandler.getSubType(), ipv4SpecificEcHandler));
+ regs.add(context.registerExtendedCommunitySerializer(Inet4SpecificExtendedCommunityCase.class,
ipv4SpecificEcHandler));
- regs.add(context.registerExtendedCommunityParser(ipv4SpecificEcHandler.getType(false), ipv4SpecificEcHandler.getSubType(),
- ipv4SpecificEcHandler));
- regs.add(context.registerExtendedCommunitySerializer(Inet4SpecificExtendedCommunityCase.class, ipv4SpecificEcHandler));
final OpaqueEcHandler opaqueEcHandler = new OpaqueEcHandler();
- regs.add(context.registerExtendedCommunityParser(opaqueEcHandler.getType(true), opaqueEcHandler.getSubType(),
- opaqueEcHandler));
- regs.add(context.registerExtendedCommunityParser(opaqueEcHandler.getType(false), opaqueEcHandler.getSubType(),
- opaqueEcHandler));
+ regs.add(context.registerExtendedCommunityParser(opaqueEcHandler.getType(true),
+ opaqueEcHandler.getSubType(), opaqueEcHandler));
+ regs.add(context.registerExtendedCommunityParser(opaqueEcHandler.getType(false),
+ opaqueEcHandler.getSubType(), opaqueEcHandler));
regs.add(context.registerExtendedCommunitySerializer(OpaqueExtendedCommunityCase.class, opaqueEcHandler));
final RouteOriginAsTwoOctetEcHandler routeOriginAS2bEcHandler = new RouteOriginAsTwoOctetEcHandler();
- regs.add(context.registerExtendedCommunityParser(routeOriginAS2bEcHandler.getType(true), routeOriginAS2bEcHandler.getSubType(),
- routeOriginAS2bEcHandler));
- regs.add(context.registerExtendedCommunityParser(routeOriginAS2bEcHandler.getType(false), routeOriginAS2bEcHandler.getSubType(),
+ regs.add(context.registerExtendedCommunityParser(routeOriginAS2bEcHandler.getType(true),
+ routeOriginAS2bEcHandler.getSubType(), routeOriginAS2bEcHandler));
+ regs.add(context.registerExtendedCommunityParser(routeOriginAS2bEcHandler.getType(false),
+ routeOriginAS2bEcHandler.getSubType(), routeOriginAS2bEcHandler));
+ regs.add(context.registerExtendedCommunitySerializer(RouteOriginExtendedCommunityCase.class,
routeOriginAS2bEcHandler));
- regs.add(context.registerExtendedCommunitySerializer(RouteOriginExtendedCommunityCase.class, routeOriginAS2bEcHandler));
final RouteTargetAsTwoOctetEcHandler routeTargetAS2bEcHandler = new RouteTargetAsTwoOctetEcHandler();
- regs.add(context.registerExtendedCommunityParser(routeTargetAS2bEcHandler.getType(true), routeTargetAS2bEcHandler.getSubType(),
- routeTargetAS2bEcHandler));
- regs.add(context.registerExtendedCommunityParser(routeTargetAS2bEcHandler.getType(false), routeTargetAS2bEcHandler.getSubType(),
+ regs.add(context.registerExtendedCommunityParser(routeTargetAS2bEcHandler.getType(true),
+ routeTargetAS2bEcHandler.getSubType(), routeTargetAS2bEcHandler));
+ regs.add(context.registerExtendedCommunityParser(routeTargetAS2bEcHandler.getType(false),
+ routeTargetAS2bEcHandler.getSubType(), routeTargetAS2bEcHandler));
+ regs.add(context.registerExtendedCommunitySerializer(RouteTargetExtendedCommunityCase.class,
routeTargetAS2bEcHandler));
- regs.add(context.registerExtendedCommunitySerializer(RouteTargetExtendedCommunityCase.class, routeTargetAS2bEcHandler));
final RouteOriginIpv4EcHandler routeOriginIpv4EcHandler = new RouteOriginIpv4EcHandler();
- regs.add(context.registerExtendedCommunityParser(routeOriginIpv4EcHandler.getType(true), routeOriginIpv4EcHandler.getSubType(),
- routeOriginIpv4EcHandler));
- regs.add(context.registerExtendedCommunityParser(routeOriginIpv4EcHandler.getType(false), routeOriginIpv4EcHandler.getSubType(),
- routeOriginIpv4EcHandler));
+ regs.add(context.registerExtendedCommunityParser(routeOriginIpv4EcHandler.getType(true),
+ routeOriginIpv4EcHandler.getSubType(), routeOriginIpv4EcHandler));
+ regs.add(context.registerExtendedCommunityParser(routeOriginIpv4EcHandler.getType(false),
+ routeOriginIpv4EcHandler.getSubType(), routeOriginIpv4EcHandler));
regs.add(context.registerExtendedCommunitySerializer(RouteOriginIpv4Case.class, routeOriginIpv4EcHandler));
final RouteTargetIpv4EcHandler routeTargetIpv4EcHandler = new RouteTargetIpv4EcHandler();
- regs.add(context.registerExtendedCommunityParser(routeTargetIpv4EcHandler.getType(true), routeTargetIpv4EcHandler.getSubType(),
- routeTargetIpv4EcHandler));
- regs.add(context.registerExtendedCommunityParser(routeTargetIpv4EcHandler.getType(false), routeTargetIpv4EcHandler.getSubType(),
- routeTargetIpv4EcHandler));
+ regs.add(context.registerExtendedCommunityParser(routeTargetIpv4EcHandler.getType(true),
+ routeTargetIpv4EcHandler.getSubType(), routeTargetIpv4EcHandler));
+ regs.add(context.registerExtendedCommunityParser(routeTargetIpv4EcHandler.getType(false),
+ routeTargetIpv4EcHandler.getSubType(), routeTargetIpv4EcHandler));
regs.add(context.registerExtendedCommunitySerializer(RouteTargetIpv4Case.class, routeTargetIpv4EcHandler));
final LinkBandwidthEC linkBandwidthECHandler = new LinkBandwidthEC();
- regs.add(context.registerExtendedCommunityParser(linkBandwidthECHandler.getType(false), linkBandwidthECHandler.getSubType(),
- linkBandwidthECHandler));
+ regs.add(context.registerExtendedCommunityParser(linkBandwidthECHandler.getType(false),
+ linkBandwidthECHandler.getSubType(), linkBandwidthECHandler));
regs.add(context.registerExtendedCommunitySerializer(LinkBandwidthCase.class, linkBandwidthECHandler));
final Generic4OctASEcHandler gen4OctASEcHandler = new Generic4OctASEcHandler();
- regs.add(context.registerExtendedCommunityParser(gen4OctASEcHandler.getType(true), gen4OctASEcHandler.getSubType(), gen4OctASEcHandler));
- regs.add(context.registerExtendedCommunityParser(gen4OctASEcHandler.getType(false), gen4OctASEcHandler.getSubType(), gen4OctASEcHandler));
- regs.add(context.registerExtendedCommunitySerializer(As4GenericSpecExtendedCommunityCase.class, gen4OctASEcHandler));
+ regs.add(context.registerExtendedCommunityParser(gen4OctASEcHandler.getType(true),
+ gen4OctASEcHandler.getSubType(), gen4OctASEcHandler));
+ regs.add(context.registerExtendedCommunityParser(gen4OctASEcHandler.getType(false),
+ gen4OctASEcHandler.getSubType(), gen4OctASEcHandler));
+ regs.add(context.registerExtendedCommunitySerializer(As4GenericSpecExtendedCommunityCase.class,
+ gen4OctASEcHandler));
final RouteTarget4OctectASEcHandler rt4ASHandler = new RouteTarget4OctectASEcHandler();
- regs.add(context.registerExtendedCommunityParser(rt4ASHandler.getType(true), rt4ASHandler.getSubType(), rt4ASHandler));
+ regs.add(context.registerExtendedCommunityParser(rt4ASHandler.getType(true),
+ rt4ASHandler.getSubType(), rt4ASHandler));
regs.add(context.registerExtendedCommunitySerializer(As4RouteTargetExtendedCommunityCase.class, rt4ASHandler));
final RouteOrigin4OctectASEcHandler rOrig4Oct = new RouteOrigin4OctectASEcHandler();
- regs.add(context.registerExtendedCommunityParser(rOrig4Oct.getType(true), rOrig4Oct.getSubType(), rOrig4Oct));
+ regs.add(context.registerExtendedCommunityParser(rOrig4Oct.getType(true)
+ , rOrig4Oct.getSubType(), rOrig4Oct));
regs.add(context.registerExtendedCommunitySerializer(As4RouteOriginExtendedCommunityCase.class, rOrig4Oct));
final EncapsulationEC encapsulationECHandler = new EncapsulationEC();
- regs.add(context.registerExtendedCommunityParser(encapsulationECHandler.getType(true), encapsulationECHandler.getSubType(),
- encapsulationECHandler));
+ regs.add(context.registerExtendedCommunityParser(encapsulationECHandler.getType(true),
+ encapsulationECHandler.getSubType(), encapsulationECHandler));
regs.add(context.registerExtendedCommunitySerializer(EncapsulationCase.class, encapsulationECHandler));
final VrfRouteImportHandler vrfRouteImportHandler = new VrfRouteImportHandler();
@Override
public Keepalive parseMessageBody(final ByteBuf body, final int messageLength) throws BGPDocumentedException {
if (body.isReadable()) {
- throw BGPDocumentedException.badMessageLength("Message length field not within valid range.", messageLength);
+ throw BGPDocumentedException.badMessageLength("Message length field not within valid range.",
+ messageLength);
}
return KEEPALIVE_MSG;
}
}
final int errorCode = body.readUnsignedByte();
final int errorSubcode = body.readUnsignedByte();
- final NotifyBuilder builder = new NotifyBuilder().setErrorCode((short) errorCode).setErrorSubcode((short) errorSubcode);
+ final NotifyBuilder builder = new NotifyBuilder()
+ .setErrorCode((short) errorCode).setErrorSubcode((short) errorSubcode);
if (body.isReadable()) {
builder.setData(ByteArray.readAllBytes(body));
}
- LOG.debug("BGP Notification message was parsed: err = {}, data = {}.", BGPError.forValue(errorCode, errorSubcode),
- Arrays.toString(builder.getData()));
+ LOG.debug("BGP Notification message was parsed: err = {}, data = {}.",
+ BGPError.forValue(errorCode, errorSubcode), Arrays.toString(builder.getData()));
return builder.build();
}
}
private static final int BGP_ID_SIZE = 4;
private static final int OPT_PARAM_LENGTH_SIZE = 1;
- private static final int MIN_MSG_LENGTH = VERSION_SIZE + AS_SIZE + HOLD_TIME_SIZE + BGP_ID_SIZE + OPT_PARAM_LENGTH_SIZE;
+ private static final int MIN_MSG_LENGTH = VERSION_SIZE + AS_SIZE
+ + HOLD_TIME_SIZE + BGP_ID_SIZE + OPT_PARAM_LENGTH_SIZE;
private static final int BGP_VERSION = 4;
}
final int version = body.readUnsignedByte();
if (version != BGP_VERSION) {
- throw new BGPDocumentedException("BGP Protocol version " + version + " not supported.", BGPError.VERSION_NOT_SUPPORTED);
+ throw new BGPDocumentedException("BGP Protocol version " + version + " not supported.",
+ BGPError.VERSION_NOT_SUPPORTED);
}
final AsNumber as = new AsNumber((long) body.readUnsignedShort());
final int holdTime = body.readUnsignedShort();
if (holdTime == 1 || holdTime == 2) {
throw new BGPDocumentedException("Hold time value not acceptable.", BGPError.HOLD_TIME_NOT_ACC);
}
- Ipv4Address bgpId = null;
+ Ipv4Address bgpId;
try {
bgpId = Ipv4Util.addressForByteBuf(body);
} catch (final IllegalArgumentException e) {
if (optLength > 0) {
fillParams(body.slice(), optParams);
}
- LOG.debug("BGP Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as, holdTime, bgpId, optParams);
- return new OpenBuilder().setMyAsNumber(as.getValue().intValue()).setHoldTimer(holdTime).setBgpIdentifier(bgpId).setBgpParameters(
- optParams).build();
+ LOG.debug("BGP Open message was parsed: AS = {}, holdTimer = {}, bgpId = {}, optParams = {}", as,
+ holdTime, bgpId, optParams);
+ return new OpenBuilder().setMyAsNumber(as.getValue().intValue()).setHoldTimer(holdTime)
+ .setBgpIdentifier(bgpId).setBgpParameters(optParams).build();
}
private void fillParams(final ByteBuf buffer, final List<BgpParameters> params) throws BGPDocumentedException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(), "BUffer cannot be null or empty.");
+ Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ "Buffer cannot be null or empty.");
if (LOG.isTraceEnabled()) {
LOG.trace("Started parsing of BGP parameter: {}", ByteBufUtil.hexDump(buffer));
}
while (buffer.isReadable()) {
if (buffer.readableBytes() <= 2) {
- throw new BGPDocumentedException("Malformed parameter encountered (" + buffer.readableBytes() + " bytes left)", BGPError.OPT_PARAM_NOT_SUPPORTED);
+ throw new BGPDocumentedException("Malformed parameter encountered (" + buffer.readableBytes()
+ + " bytes left)", BGPError.OPT_PARAM_NOT_SUPPORTED);
}
final int paramType = buffer.readUnsignedByte();
final int paramLength = buffer.readUnsignedByte();
public static final int TYPE = 5;
private static final int TRIPLET_BYTE_SIZE = 4;
+ private static final String ARGUMENT_ERROR = "Message is not of type RouteRefresh.";
private final AddressFamilyRegistry afiReg;
private final SubsequentAddressFamilyRegistry safiReg;
- public BGPRouteRefreshMessageParser(final AddressFamilyRegistry afiReg, final SubsequentAddressFamilyRegistry safiReg) {
+ public BGPRouteRefreshMessageParser(final AddressFamilyRegistry afiReg,
+ final SubsequentAddressFamilyRegistry safiReg) {
this.afiReg = requireNonNull(afiReg);
this.safiReg = requireNonNull(safiReg);
}
*/
@Override
public void serializeMessage(final Notification message, final ByteBuf bytes) {
- Preconditions.checkArgument(message instanceof RouteRefresh, "Message is not of type RouteRefresh.");
+ Preconditions.checkArgument(message instanceof RouteRefresh, ARGUMENT_ERROR);
final RouteRefresh msg = (RouteRefresh) message;
final ByteBuf msgBuf = Unpooled.buffer(TRIPLET_BYTE_SIZE);
- MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg, msg.getAfi(), msg.getSafi(), msgBuf);
+ MultiprotocolCapabilitiesUtil.serializeMPAfiSafi(this.afiReg, this.safiReg,
+ msg.getAfi(), msg.getSafi(), msgBuf);
LOG.trace("RouteRefresh message serialized to: {}", ByteBufUtil.hexDump(msgBuf));
MessageUtil.formatMessage(TYPE, msgBuf, bytes);
if (body.readableBytes() < TRIPLET_BYTE_SIZE) {
throw BGPDocumentedException.badMessageLength("RouteRefresh message is too small.", messageLength);
}
- final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(body, this.afiReg, this.safiReg);
+ final Optional<BgpTableType> parsedAfiSafi = MultiprotocolCapabilitiesUtil.parseMPAfiSafi(body, this.afiReg,
+ this.safiReg);
if (!parsedAfiSafi.isPresent()) {
- throw new BGPDocumentedException("Unsupported afi/safi in Route Refresh message.", BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
+ throw new BGPDocumentedException("Unsupported afi/safi in Route Refresh message.",
+ BGPError.WELL_KNOWN_ATTR_NOT_RECOGNIZED);
}
return new RouteRefreshBuilder(parsedAfiSafi.get()).build();
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final Aggregator aggregator = pathAttributes.getAggregator();
if (aggregator == null) {
return;
}
- Preconditions.checkArgument(aggregator.getAsNumber() != null, "Missing AS number that formed the aggregate route (encoded as 2 octets).");
+ Preconditions.checkArgument(aggregator.getAsNumber() != null,
+ "Missing AS number that formed the aggregate route (encoded as 2 octets).");
final ShortAsNumber shortAsNumber = new ShortAsNumber(aggregator.getAsNumber());
final ByteBuf buffer = Unpooled.buffer();
buffer.writeInt(shortAsNumber.getValue().intValue());
buffer.writeBytes(Ipv4Util.bytesForAddress(aggregator.getNetworkAddress()));
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, buffer, byteAggregator);
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE,
+ TYPE, buffer, byteAggregator);
}
}
* @param buffer bytes to be parsed
* @return new ASPath object
* @throws BGPDocumentedException if there is no AS_SEQUENCE present (mandatory)
- * @throws BGPParsingException
*/
- private static AsPath parseAsPath(final ReferenceCache refCache, final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ private static AsPath parseAsPath(final ReferenceCache refCache, final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
if (!buffer.isReadable()) {
return EMPTY;
}
}
final int count = buffer.readUnsignedByte();
- final List<AsNumber> asList = AsPathSegmentParser.parseAsSegment(refCache, count, buffer.readSlice(count * AsPathSegmentParser.AS_NUMBER_LENGTH));
+ final List<AsNumber> asList = AsPathSegmentParser.parseAsSegment(refCache, count,
+ buffer.readSlice(count * AsPathSegmentParser.AS_NUMBER_LENGTH));
if (segmentType == SegmentType.AS_SEQUENCE) {
ases.add(new SegmentsBuilder().setAsSequence(asList).build());
isSequence = true;
}
}
if (!isSequence) {
- throw new BGPDocumentedException("AS_SEQUENCE must be present in AS_PATH attribute.", BGPError.AS_PATH_MALFORMED);
+ throw new BGPDocumentedException("AS_SEQUENCE must be present in AS_PATH attribute.",
+ BGPError.AS_PATH_MALFORMED);
}
ases.trimToSize();
}
@Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
+ public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder)
+ throws BGPDocumentedException, BGPParsingException {
builder.setAsPath(parseAsPath(this.refCache, buffer));
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final AsPath asPath = pathAttributes.getAsPath();
if (asPath == null) {
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
if (pathAttributes.getAtomicAggregate() == null) {
return;
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Attributes pathAttributes = (Attributes) attribute;
final BgpPrefixSid prefixSid = pathAttributes.getBgpPrefixSid();
if (prefixSid == null) {
}
@Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
+ public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder)
+ throws BGPDocumentedException, BGPParsingException {
final BgpPrefixSidBuilder sid = new BgpPrefixSidBuilder();
final List<BgpPrefixSidTlvs> tlvList = new ArrayList<>();
while (buffer.isReadable()) {
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final ClusterId cid = ((Attributes) attribute).getClusterId();
if (cid == null) {
return;
* @throws BGPDocumentedException
*/
@VisibleForTesting
- public static Community parseCommunity(final ReferenceCache refCache, final ByteBuf buffer) throws BGPDocumentedException {
+ public static Community parseCommunity(final ReferenceCache refCache, final ByteBuf buffer)
+ throws BGPDocumentedException {
if (buffer.readableBytes() != COMMUNITY_LENGTH) {
- throw new BGPDocumentedException("Community with wrong length: " + buffer.readableBytes(), BGPError.OPT_ATTR_ERROR);
+ throw new BGPDocumentedException("Community with wrong length: "
+ + buffer.readableBytes(), BGPError.OPT_ATTR_ERROR);
}
final byte[] body = ByteArray.getBytes(buffer, COMMUNITY_LENGTH);
if (Arrays.equals(body, NO_EXPORT)) {
communitiesBuffer.writeShort(community.getAsNumber().getValue().shortValue());
communitiesBuffer.writeShort(community.getSemantics().shortValue());
}
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, communitiesBuffer, byteAggregator);
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE,
+ TYPE, communitiesBuffer, byteAggregator);
}
}
* advertised outside a BGP confederation boundary (a stand-alone autonomous system that is not part of a
* confederation should be considered a confederation itself).
*/
- public static final Community NO_EXPORT = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF01);
+ public static final Community NO_EXPORT
+ = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF01);
/**
* NO_ADVERTISE community. All routes received carrying a communities attribute containing this value MUST NOT be
* advertised to other BGP peers.
*/
- public static final Community NO_ADVERTISE = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF02);
+ public static final Community NO_ADVERTISE
+ = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF02);
/**
* NO_EXPORT_SUBCONFED community. All routes received carrying a communities attribute containing this value MUST
* NOT be advertised to external BGP peers (this includes peers in other members autonomous systems inside a BGP
* confederation).
*/
- public static final Community NO_EXPORT_SUBCONFED = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF03);
+ public static final Community NO_EXPORT_SUBCONFED
+ = CommunityUtil.create(NoopReferenceCache.getInstance(), 0xFFFF, 0xFF03);
private final ReferenceCache refCache;
}
@Override
- public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
+ public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder)
+ throws BGPDocumentedException, BGPParsingException {
final List<ExtendedCommunities> set = new ArrayList<>();
while (buffer.isReadable()) {
final ExtendedCommunities exComm = this.ecReg.parseExtendedCommunity(buffer);
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final List<ExtendedCommunities> communitiesList = ((Attributes) attribute).getExtendedCommunities();
if (communitiesList == null || communitiesList.isEmpty()) {
return;
this.ecReg.serializeExtendedCommunity(extendedCommunities, extendedCommunitiesBuffer);
}
if (extendedCommunitiesBuffer.readableBytes() > 0) {
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE, extendedCommunitiesBuffer, byteAggregator);
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL | AttributeUtil.TRANSITIVE, TYPE,
+ extendedCommunitiesBuffer, byteAggregator);
}
}
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final LocalPref lp = ((Attributes) attribute).getLocalPref();
if (lp == null) {
return;
}
- AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, Unpooled.copyInt(lp.getPref().intValue()), byteAggregator);
+ AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE,
+ Unpooled.copyInt(lp.getPref().intValue()), byteAggregator);
}
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final MultiExitDisc multiExitDisc = ((Attributes) attribute).getMultiExitDisc();
if (multiExitDisc == null) {
return;
}
- AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE, Unpooled.copyInt(multiExitDisc.getMed().intValue()), byteAggregator);
+ AttributeUtil.formatAttribute(AttributeUtil.OPTIONAL, TYPE,
+ Unpooled.copyInt(multiExitDisc.getMed().intValue()), byteAggregator);
}
}
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) {
- Preconditions.checkArgument(buffer.readableBytes() == Ipv4Util.IP4_LENGTH, "Length of byte array for NEXT_HOP should be %s, but is %s", buffer.readableBytes(), Ipv4Util.IP4_LENGTH);
+ Preconditions.checkArgument(buffer.readableBytes() == Ipv4Util.IP4_LENGTH,
+ "Length of byte array for NEXT_HOP should be %s, but is %s",
+ buffer.readableBytes(), Ipv4Util.IP4_LENGTH);
builder.setCNextHop(NextHopUtil.parseNextHop(buffer));
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final CNextHop cNextHop = ((Attributes) attribute).getCNextHop();
if (cNextHop == null) {
return;
final byte rawOrigin = buffer.readByte();
final BgpOrigin borigin = BgpOrigin.forValue(UnsignedBytes.toInt(rawOrigin));
if (borigin == null) {
- throw new BGPDocumentedException("Unknown Origin type.", BGPError.ORIGIN_ATTR_NOT_VALID, new byte[] { (byte) 0x01, (byte) 0x01, rawOrigin} );
+ throw new BGPDocumentedException("Unknown Origin type.", BGPError.ORIGIN_ATTR_NOT_VALID,
+ new byte[] { (byte) 0x01, (byte) 0x01, rawOrigin} );
}
switch (borigin) {
case Egp:
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final Origin origin = ((Attributes) attribute).getOrigin();
if (origin == null) {
return;
}
- AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE, Unpooled.wrappedBuffer(new byte[] {UnsignedBytes.checkedCast(origin.getValue().getIntValue())}), byteAggregator);
+ AttributeUtil.formatAttribute(AttributeUtil.TRANSITIVE, TYPE,
+ Unpooled.wrappedBuffer(new byte[] {UnsignedBytes.checkedCast(origin.getValue().getIntValue())}),
+ byteAggregator);
}
}
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) {
- Preconditions.checkArgument(buffer.readableBytes() == Ipv4Util.IP4_LENGTH, "Length of byte array for ORIGINATOR_ID should be %s, but is %s", Ipv4Util.IP4_LENGTH, buffer.readableBytes());
+ Preconditions.checkArgument(buffer.readableBytes() == Ipv4Util.IP4_LENGTH,
+ "Length of byte array for ORIGINATOR_ID should be %s, but is %s",
+ Ipv4Util.IP4_LENGTH, buffer.readableBytes());
builder.setOriginatorId(new OriginatorIdBuilder().setOriginator(Ipv4Util.addressForByteBuf(buffer)).build());
}
@Override
public void serializeAttribute(final DataObject attribute, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attribute instanceof Attributes, "Attribute parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attribute instanceof Attributes,
+ "Attribute parameter is not a PathAttribute object.");
final OriginatorId originator = ((Attributes) attribute).getOriginatorId();
if (originator == null) {
return;
import org.opendaylight.protocol.bgp.parser.spi.AttributeSerializer;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.AttributesBuilder;
-/**
- * @author Claudio D. Gasparini
- */
public abstract class ReachAttributeParser implements AttributeParser, AttributeSerializer {
@Override
@Override
public void serializeAttribute(final DataObject attributes, final ByteBuf byteAggregator) {
- Preconditions.checkArgument(attributes instanceof Attributes, "Attributes parameter is not a PathAttribute object.");
+ Preconditions.checkArgument(attributes instanceof Attributes,
+ "Attributes parameter is not a PathAttribute object.");
final List<UnrecognizedAttributes> unrecognizedAttrs = ((Attributes) attributes).getUnrecognizedAttributes();
if (unrecognizedAttrs == null) {
return;
if (unrecognizedAttr.isTransitive()) {
flags |= AttributeUtil.TRANSITIVE;
}
- AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType(), Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
+ AttributeUtil.formatAttribute(flags, unrecognizedAttr.getType(),
+ Unpooled.wrappedBuffer(unrecognizedAttr.getValue()), byteAggregator);
}
}
private static final int SUBTYPE = 0;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
final AsSpecificExtendedCommunity asSpecific = new AsSpecificExtendedCommunityBuilder()
.setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
.setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof AsSpecificExtendedCommunityCase,
- "The extended community %s is not AsSpecificExtendedCommunity type.", extendedCommunity);
- final AsSpecificExtendedCommunity asSpecific = ((AsSpecificExtendedCommunityCase) extendedCommunity).getAsSpecificExtendedCommunity();
- ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(asSpecific.getGlobalAdministrator().getValue()), byteAggregator);
+ "The extended community %s is not AsSpecificExtendedCommunity type.",
+ extendedCommunity);
+ final AsSpecificExtendedCommunity asSpecific = ((AsSpecificExtendedCommunityCase) extendedCommunity)
+ .getAsSpecificExtendedCommunity();
+ ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(asSpecific.getGlobalAdministrator().getValue()),
+ byteAggregator);
byteAggregator.writeBytes(asSpecific.getLocalAdministrator());
}
private static final int CONTENT_SIZE = 6;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
- Preconditions.checkArgument(buffer != null && buffer.isReadable(), "Array of bytes is mandatory. Can't be null or empty.");
- Preconditions.checkArgument(buffer.readableBytes() == CONTENT_SIZE, "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ".");
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
+ Preconditions.checkArgument(buffer != null && buffer.isReadable(),
+ "Array of bytes is mandatory. Can't be null or empty.");
+ Preconditions.checkArgument(buffer.readableBytes() == CONTENT_SIZE,
+ "Wrong length of array of bytes. Passed: " + buffer.readableBytes() + ".");
buffer.skipBytes(RESERVED_SIZE);
final EncapsulationExtendedCommunity encap = new EncapsulationExtendedCommunityBuilder()
.setTunnelType(EncapsulationTunnelType.forValue(buffer.readUnsignedShort()))
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof EncapsulationCase,
"The extended community %s is not EncapsulationCase type.", extendedCommunity);
- final EncapsulationExtendedCommunity encap = ((EncapsulationCase) extendedCommunity).getEncapsulationExtendedCommunity();
+ final EncapsulationExtendedCommunity encap
+ = ((EncapsulationCase) extendedCommunity).getEncapsulationExtendedCommunity();
body.writeZero(RESERVED_SIZE);
body.writeShort(encap.getTunnelType().getIntValue());
}
private static final int AS_TRANS_LENGTH = 2;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
buffer.skipBytes(AS_TRANS_LENGTH);
final LinkBandwidthExtendedCommunity lb = new LinkBandwidthExtendedCommunityBuilder()
.setBandwidth(new Bandwidth(ByteArray.readBytes(buffer, BANDWIDTH_SIZE)))
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof LinkBandwidthCase,
"The extended community %s is not LinkBandwidthCase type.", extendedCommunity);
- final LinkBandwidthExtendedCommunity lb = ((LinkBandwidthCase) extendedCommunity).getLinkBandwidthExtendedCommunity();
+ final LinkBandwidthExtendedCommunity lb
+ = ((LinkBandwidthCase) extendedCommunity).getLinkBandwidthExtendedCommunity();
body.writeShort(AS_TRANS);
ByteBufWriteUtil.writeFloat32(lb.getBandwidth(), body);
}
private static final int SUBTYPE = 0;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
return new OpaqueExtendedCommunityCaseBuilder().setOpaqueExtendedCommunity(
new OpaqueExtendedCommunityBuilder()
.setValue(ByteArray.readAllBytes(buffer))
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof OpaqueExtendedCommunityCase,
- "The extended community %s is not OpaqueExtendedCommunityCase type.", extendedCommunity);
- final OpaqueExtendedCommunity opaqueExtendedCommunity = ((OpaqueExtendedCommunityCase) extendedCommunity).getOpaqueExtendedCommunity();
+ "The extended community %s is not OpaqueExtendedCommunityCase type.",
+ extendedCommunity);
+ final OpaqueExtendedCommunity opaqueExtendedCommunity
+ = ((OpaqueExtendedCommunityCase) extendedCommunity).getOpaqueExtendedCommunity();
byteAggregator.writeBytes(opaqueExtendedCommunity.getValue());
}
private static final int SUBTYPE = 3;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
final RouteOriginExtendedCommunity targetOrigin = new RouteOriginExtendedCommunityBuilder()
.setGlobalAdministrator(new ShortAsNumber((long) buffer.readUnsignedShort()))
.setLocalAdministrator(ByteArray.readBytes(buffer, AS_LOCAL_ADMIN_LENGTH))
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf byteAggregator) {
Preconditions.checkArgument(extendedCommunity instanceof RouteOriginExtendedCommunityCase,
- "The extended community %s is not RouteOriginExtendedCommunity type.", extendedCommunity);
- final RouteOriginExtendedCommunity routeOrigin = ((RouteOriginExtendedCommunityCase) extendedCommunity).getRouteOriginExtendedCommunity();
- ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeOrigin.getGlobalAdministrator().getValue()), byteAggregator);
+ "The extended community %s is not RouteOriginExtendedCommunity type.",
+ extendedCommunity);
+ final RouteOriginExtendedCommunity routeOrigin
+ = ((RouteOriginExtendedCommunityCase) extendedCommunity).getRouteOriginExtendedCommunity();
+ ByteBufWriteUtil.writeUnsignedShort(Ints.checkedCast(routeOrigin.getGlobalAdministrator().getValue()),
+ byteAggregator);
byteAggregator.writeBytes(routeOrigin.getLocalAdministrator());
}
}
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf buffer)
+ throws BGPDocumentedException, BGPParsingException {
final RouteOriginIpv4 routeTarget = new RouteOriginIpv4Builder()
.setGlobalAdministrator(Ipv4Util.addressForByteBuf(buffer))
.setLocalAdministrator(buffer.readUnsignedShort())
private static final int SUBTYPE = 4;
@Override
- public ExtendedCommunity parseExtendedCommunity(final ByteBuf body) throws BGPDocumentedException, BGPParsingException {
- return new As4GenericSpecExtendedCommunityCaseBuilder().setAs4GenericSpecExtendedCommunity(new As4GenericSpecExtendedCommunityBuilder()
- .setAs4SpecificCommon(FourOctAsCommonECUtil.parseCommon(body)).build()).build();
+ public ExtendedCommunity parseExtendedCommunity(final ByteBuf body)
+ throws BGPDocumentedException, BGPParsingException {
+ return new As4GenericSpecExtendedCommunityCaseBuilder()
+ .setAs4GenericSpecExtendedCommunity(new As4GenericSpecExtendedCommunityBuilder()
+ .setAs4SpecificCommon(FourOctAsCommonECUtil.parseCommon(body)).build()).build();
}
@Override
public void serializeExtendedCommunity(final ExtendedCommunity extendedCommunity, final ByteBuf body) {
Preconditions.checkArgument(extendedCommunity instanceof As4GenericSpecExtendedCommunityCase,
- "The extended community %s is not As4GenericSpecExtendedCommunityCase type.", extendedCommunity);
- FourOctAsCommonECUtil.serializeCommon(((As4GenericSpecExtendedCommunityCase) extendedCommunity).getAs4GenericSpecExtendedCommunity()
- .getAs4SpecificCommon(), body);
+ "The extended community %s is not As4GenericSpecExtendedCommunityCase type.",
+ extendedCommunity);
+ FourOctAsCommonECUtil.serializeCommon(((As4GenericSpecExtendedCommunityCase) extendedCommunity)
+ .getAs4GenericSpecExtendedCommunity()
+ .getAs4SpecificCommon(), body);
}
@Override
final ByteBuf buffer = Unpooled.buffer(bgpExeBytes.length);
handler.serializeCapability(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY, buffer);
Assert.assertArrayEquals(bgpExeBytes, buffer.array());
- Assert.assertEquals(handler.parseCapability(Unpooled.wrappedBuffer(bgpExeBytes)), BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY);
+ Assert.assertEquals(handler.parseCapability(Unpooled.wrappedBuffer(bgpExeBytes)),
+ BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY);
final byte[] bgpExeBytes2 = {(byte) 0x40, (byte) 0x06};
buffer.clear();
@Test
public void testRRCapHandler() throws BGPDocumentedException, BGPParsingException {
- final CParameters expectedParams = new CParametersBuilder().addAugmentation(CParameters1.class,new CParameters1Builder().setRouteRefreshCapability(
+ final CParameters expectedParams = new CParametersBuilder().addAugmentation(CParameters1.class,
+ new CParameters1Builder().setRouteRefreshCapability(
new RouteRefreshCapabilityBuilder().build()).build()).build();
assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(OK_BYTES)));
assertEquals(expectedParams, HANDLER.parseCapability(Unpooled.copiedBuffer(WRONG_BYTES)));
HANDLER.serializeCapability(expectedParams, byteAggregator);
assertEquals(Unpooled.copiedBuffer(CAP_BYTES), byteAggregator);
- final CParameters missingCap = new CParametersBuilder().addAugmentation(CParameters1.class,new CParameters1Builder().setRouteRefreshCapability(
+ final CParameters missingCap = new CParametersBuilder().addAugmentation(CParameters1.class,
+ new CParameters1Builder().setRouteRefreshCapability(
null).build()).build();
final ByteBuf byteAggregator2 = Unpooled.buffer(0);
HANDLER.serializeCapability(missingCap, byteAggregator2);