use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1 in project bgpcep by opendaylight.
the class SynchronizationTest method setUp.
@Before
public void setUp() {
this.listener = new SimpleSessionListener();
this.ipv4m = new UpdateBuilder().setNlri(Collections.singletonList(new NlriBuilder().setPrefix(new Ipv4Prefix("1.1.1.1/32")).build())).build();
MpReachNlriBuilder mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(Ipv6AddressFamily.class);
mpBuilder.setSafi(UnicastSubsequentAddressFamily.class);
AttributesBuilder paBuilder = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpBuilder.build()).build());
this.ipv6m = new UpdateBuilder().setAttributes(paBuilder.build()).build();
mpBuilder = new MpReachNlriBuilder();
mpBuilder.setAfi(LinkstateAddressFamily.class);
mpBuilder.setSafi(LinkstateSubsequentAddressFamily.class);
paBuilder = new AttributesBuilder().addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mpBuilder.build()).build());
this.lsm = new UpdateBuilder().setAttributes(paBuilder.build()).build();
this.eorm = new UpdateBuilder().build();
this.bs = new BGPSynchronization(this.listener, Sets.newHashSet(this.ipv4, this.linkstate));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1 in project bgpcep by opendaylight.
the class BGPSynchronization method updReceived.
/**
* For each received Update message, the upd sync variable needs to be updated to true, for particular AFI/SAFI
* combination. Currently we only assume Unicast SAFI. From the Update message we have to extract the AFI. Each
* Update message can contain BGP Object with one type of AFI. If the object is BGP Link, BGP Node or a BGPPrefix
* the AFI is Linkstate. In case of BGPRoute, the AFI depends on the IP Address of the prefix.
*
* @param msg received Update message
*/
public void updReceived(final Update msg) {
TablesKey type = new TablesKey(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class);
boolean isEOR = false;
if (msg.getNlri() == null && msg.getWithdrawnRoutes() == null) {
if (msg.getAttributes() != null) {
if (msg.getAttributes().getAugmentation(Attributes1.class) != null) {
final Attributes1 pa = msg.getAttributes().getAugmentation(Attributes1.class);
if (pa.getMpReachNlri() != null) {
type = new TablesKey(pa.getMpReachNlri().getAfi(), pa.getMpReachNlri().getSafi());
}
} else if (msg.getAttributes().getAugmentation(Attributes2.class) != null) {
final Attributes2 pa = msg.getAttributes().getAugmentation(Attributes2.class);
if (pa.getMpUnreachNlri() != null) {
type = new TablesKey(pa.getMpUnreachNlri().getAfi(), pa.getMpUnreachNlri().getSafi());
}
if (pa.getMpUnreachNlri().getWithdrawnRoutes() == null) {
// EOR message contains only MPUnreach attribute and no NLRI
isEOR = true;
}
}
} else {
// true for empty Update Message
isEOR = true;
}
}
syncType(type, isEOR);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1 in project bgpcep by opendaylight.
the class CodecsImpl method serializeAttributes.
@Override
public ContainerNode serializeAttributes(final Attributes pathAttr) {
Preconditions.checkState(this.attributesCodec != null, "Attributes codec not available");
final AttributesBuilder a = new AttributesBuilder(pathAttr);
a.addAugmentation(Attributes1.class, null);
a.addAugmentation(Attributes2.class, null);
return (ContainerNode) this.attributesCodec.serialize(a.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1 in project bgpcep by opendaylight.
the class AbstractRIBSupport method buildUpdate.
@Nonnull
@Override
public final Update buildUpdate(final Collection<MapEntryNode> advertised, final Collection<MapEntryNode> withdrawn, final Attributes attr) {
final UpdateBuilder ub = new UpdateBuilder();
final AttributesBuilder ab = new AttributesBuilder(attr);
final CNextHop hop = ab.getCNextHop();
LOG.debug("cnextHop before={}", hop);
// do not preserve next hop in attributes if we are using MpReach
ab.setCNextHop(null);
if (!advertised.isEmpty()) {
final MpReachNlri mb = buildReach(advertised, hop);
ab.addAugmentation(Attributes1.class, new Attributes1Builder().setMpReachNlri(mb).build());
LOG.debug("mpreach nexthop={}", mb);
}
if (!withdrawn.isEmpty()) {
final MpUnreachNlri mb = buildUnreach(withdrawn);
ab.addAugmentation(Attributes2.class, new Attributes2Builder().setMpUnreachNlri(mb).build());
LOG.debug("mpunrach mb={}", mb);
}
ub.setAttributes(ab.build());
LOG.debug("update {}", ub.build());
return ub.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.Attributes1 in project bgpcep by opendaylight.
the class LinkstateAttributeParserTest method testGetNlriType.
@Test
public void testGetNlriType() throws BGPParsingException {
final ByteBuf b = Unpooled.buffer();
AttributesBuilder builder = new AttributesBuilder();
this.parser.parseAttribute(b, builder);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
final Attributes1Builder builder1 = new Attributes1Builder();
builder.addAugmentation(Attributes1.class, builder1.build());
this.parser.parseAttribute(b, builder);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
builder.addAugmentation(Attributes1.class, builder1.setMpReachNlri(new MpReachNlriBuilder().setAdvertizedRoutes(new AdvertizedRoutesBuilder().setDestinationType(new DestinationIpv4CaseBuilder().build()).build()).build()).build());
this.parser.parseAttribute(b, builder);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
final Attributes2Builder builder2 = new Attributes2Builder();
builder.addAugmentation(Attributes2.class, builder2.build());
this.parser.parseAttribute(b, builder);
assertEquals(0, b.readableBytes());
builder = new AttributesBuilder();
builder.addAugmentation(Attributes2.class, builder2.setMpUnreachNlri(new MpUnreachNlriBuilder().setWithdrawnRoutes(new WithdrawnRoutesBuilder().setDestinationType(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationIpv6CaseBuilder().build()).build()).build()).build());
this.parser.parseAttribute(b, builder);
assertEquals(0, b.readableBytes());
}
Aggregations