use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project bgpcep by opendaylight.
the class PrefixAttributesParser method parseAttribute.
private static void parseAttribute(final int key, final ByteBuf value, final ProtocolId protocolId, final PrefixAttributesBuilder builder, final List<RouteTag> routeTags, final List<ExtendedRouteTag> exRouteTags) {
switch(key) {
case IGP_FLAGS:
parseIgpFags(builder, value);
break;
case ROUTE_TAG:
parseRouteTags(routeTags, value);
break;
case EXTENDED_ROUTE_TAG:
parseExtendedRouteTags(exRouteTags, value);
break;
case PREFIX_METRIC:
final IgpMetric metric = new IgpMetric(value.readUnsignedInt());
builder.setPrefixMetric(metric);
LOG.debug("Parsed Metric: {}", metric);
break;
case FORWARDING_ADDRESS:
final IpAddress fwdAddress = parseForwardingAddress(value);
builder.setOspfForwardingAddress(fwdAddress);
LOG.debug("Parsed FWD Address: {}", fwdAddress);
break;
case PREFIX_OPAQUE:
if (LOG.isDebugEnabled()) {
LOG.debug("Parsed Opaque value: {}, not preserving it", ByteBufUtil.hexDump(value));
}
break;
case PREFIX_SID:
final SrPrefix prefix = SrPrefixAttributesParser.parseSrPrefix(value, protocolId);
builder.setSrPrefix(prefix);
LOG.debug("Parsed SR Prefix: {}", prefix);
break;
case IPV6_PREFIX_SID:
final Ipv6SrPrefix ipv6Prefix = Ipv6SrPrefixAttributesParser.parseSrIpv6Prefix(value);
builder.setIpv6SrPrefix(ipv6Prefix);
LOG.debug("Parsed Ipv6 SR Prefix: {}", ipv6Prefix);
break;
case RANGE:
final SrRange range = RangeTlvParser.parseSrRange(value, protocolId);
builder.setSrRange(range);
LOG.debug("Parsed SR Range: {}", range);
break;
case BINDING_SID:
parseBindingSid(builder, value, protocolId);
break;
default:
LOG.warn("TLV {} is not a valid prefix attribute, ignoring it", key);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project bgpcep by opendaylight.
the class VpnIpv6NextHopTest method testSerializeIpv6NextHopCase.
@Test
public void testSerializeIpv6NextHopCase() throws Exception {
// put some random valid IPv6 address here
final String TEST_IPV6 = "2001::1234:5678:90ab:cdef";
final ByteBuf buffer = Unpooled.buffer();
final byte[] nextHop = new byte[Ipv6Util.IPV6_LENGTH + RouteDistinguisherUtil.RD_LENGTH];
// now copy the IPv6 address to the byte array
System.arraycopy(Inet6Address.getByName(TEST_IPV6).getAddress(), 0, nextHop, RouteDistinguisherUtil.RD_LENGTH, Ipv6Util.IPV6_LENGTH);
final CNextHop hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(new Ipv6Address(TEST_IPV6)).build()).build();
HANDLER.serializeNextHop(hop, buffer);
assertArrayEquals(nextHop, ByteArray.readAllBytes(buffer));
final CNextHop parsedHop = HANDLER.parseNextHop(Unpooled.wrappedBuffer(nextHop));
assertTrue(hop instanceof Ipv6NextHopCase);
assertEquals(hop, parsedHop);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project bgpcep by opendaylight.
the class StrictBGPPeerRegistry method getPeer.
@Override
public synchronized BGPSessionListener getPeer(final IpAddress ip, final Ipv4Address sourceId, final Ipv4Address remoteId, final Open openObj) throws BGPDocumentedException {
requireNonNull(ip);
requireNonNull(sourceId);
requireNonNull(remoteId);
final AsNumber remoteAsNumber = AsNumberUtil.advertizedAsNumber(openObj);
requireNonNull(remoteAsNumber);
final BGPSessionPreferences prefs = getPeerPreferences(ip);
checkPeerConfigured(ip);
final BGPSessionId currentConnection = new BGPSessionId(sourceId, remoteId, remoteAsNumber);
final BGPSessionListener p = this.peers.get(ip);
final BGPSessionId previousConnection = this.sessionIds.get(ip);
if (previousConnection != null) {
LOG.warn("Duplicate BGP session established with {}", ip);
// Session reestablished with different ids
if (!previousConnection.equals(currentConnection)) {
LOG.warn("BGP session with {} {} has to be dropped. Same session already present {}", ip, currentConnection, previousConnection);
throw new BGPDocumentedException(String.format("BGP session with %s %s has to be dropped. Same session already present %s", ip, currentConnection, previousConnection), BGPError.CEASE);
// Session reestablished with lower source bgp id, dropping current
} else if (previousConnection.isHigherDirection(currentConnection) || previousConnection.hasHigherAsNumber(currentConnection)) {
LOG.warn("BGP session with {} {} has to be dropped. Opposite session already present", ip, currentConnection);
throw new BGPDocumentedException(String.format("BGP session with %s initiated %s has to be dropped. " + "Opposite session already present", ip, currentConnection), BGPError.CEASE);
// Session reestablished with higher source bgp id, dropping previous
} else if (currentConnection.isHigherDirection(previousConnection) || currentConnection.hasHigherAsNumber(previousConnection)) {
LOG.warn("BGP session with {} {} released. Replaced by opposite session", ip, previousConnection);
this.peers.get(ip).releaseConnection();
return this.peers.get(ip);
// Session reestablished with same source bgp id, dropping current as duplicate
} else {
LOG.warn("BGP session with %s initiated from %s to %s has to be dropped. Same session already present", ip, sourceId, remoteId);
throw new BGPDocumentedException(String.format("BGP session with %s initiated %s has to be dropped. " + "Same session already present", ip, currentConnection), BGPError.CEASE);
}
}
validateAs(remoteAsNumber, openObj, prefs);
// Map session id to peer IP address
this.sessionIds.put(ip, currentConnection);
for (final PeerRegistrySessionListener peerRegistrySessionListener : this.sessionListeners) {
peerRegistrySessionListener.onSessionCreated(ip);
}
return p;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address in project bgpcep by opendaylight.
the class NodeChangedListener method getIpTerminationPoint.
private InstanceIdentifier<TerminationPoint> getIpTerminationPoint(final ReadWriteTransaction trans, final IpAddress addr, final InstanceIdentifier<Node> sni, final Boolean inControl) throws ReadFailedException {
final Topology topo = trans.read(LogicalDatastoreType.OPERATIONAL, this.target).checkedGet().get();
if (topo.getNode() != null) {
for (final Node n : topo.getNode()) {
if (n.getTerminationPoint() != null) {
for (final TerminationPoint tp : n.getTerminationPoint()) {
final TerminationPoint1 tpa = tp.getAugmentation(TerminationPoint1.class);
if (tpa != null) {
final TerminationPointType tpt = tpa.getIgpTerminationPointAttributes().getTerminationPointType();
if (tpt instanceof Ip) {
for (final IpAddress address : ((Ip) tpt).getIpAddress()) {
if (addr.equals(address)) {
handleSni(sni, n, inControl, trans);
return this.target.builder().child(Node.class, n.getKey()).child(TerminationPoint.class, tp.getKey()).build();
}
}
} else {
LOG.debug("Ignoring termination point type {}", tpt);
}
}
}
}
}
}
LOG.debug("Termination point for {} not found, creating a new one", addr);
return createTP(addr, sni, inControl, trans);
}
Aggregations