use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class VpnIpv4NlriParserTest method testMpReachNlri.
@Test
public void testMpReachNlri() throws BGPParsingException {
final MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv4AddressFamily.class);
mpBuilder.setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv4.rev171207.update.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv4CaseBuilder().setVpnIpv4Destination(new VpnIpv4DestinationBuilder().setVpnDestination(Collections.singletonList(IPV4_VPN)).build()).build()).build()).build();
final MpReachNlri mpReachExpected = mpBuilder.build();
final MpReachNlriBuilder testBuilder = new MpReachNlriBuilder();
testBuilder.setAfi(Ipv4AddressFamily.class);
PARSER.parseNlri(Unpooled.copiedBuffer(REACH_NLRI), testBuilder);
Assert.assertEquals(mpReachExpected, testBuilder.build());
final ByteBuf output = Unpooled.buffer();
PARSER.serializeAttribute(new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpReachExpected).build()).build(), output);
Assert.assertArrayEquals(REACH_NLRI, ByteArray.readAllBytes(output));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class AggregatorAttributeParser method parseAttribute.
/**
* Parse {@link Aggregator} from bytes
*
* @param buffer byte buffer to be parsed
* @param builder AttributesBuilder into which parsed {@link Aggregator} will be set
*/
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) {
final AsNumber asNumber = this.refCache.getSharedReference(new AsNumber(buffer.readUnsignedInt()));
final Ipv4Address address = Ipv4Util.addressForByteBuf(buffer);
builder.setAggregator(new AggregatorBuilder().setAsNumber(asNumber).setNetworkAddress(address).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class OriginAttributeParser method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException {
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 });
}
switch(borigin) {
case Egp:
builder.setOrigin(EGP);
return;
case Igp:
builder.setOrigin(IGP);
return;
case Incomplete:
builder.setOrigin(INC);
return;
default:
return;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class OriginatorIdAttributeParser method parseAttribute.
@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());
builder.setOriginatorId(new OriginatorIdBuilder().setOriginator(Ipv4Util.addressForByteBuf(buffer)).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder in project bgpcep by opendaylight.
the class BgpPrefixSidAttributeParser method parseAttribute.
@Override
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()) {
final BgpPrefixSidTlv tlv = this.reg.parseBgpPrefixSidTlv(buffer.readUnsignedByte(), buffer);
tlvList.add(new BgpPrefixSidTlvsBuilder().setBgpPrefixSidTlv(tlv).build());
}
builder.setBgpPrefixSid(sid.setBgpPrefixSidTlvs(tlvList).build());
}
Aggregations